/* --- Base Reset & Variables --- */
:root {
    --god-gold: #D4AF37;
    --god-light: #FFF8E1;
    --sky-top: #87CEEB;
    --sky-bottom: #E0F7FA;
    --night-blue: #1A237E;
    --danger: #FF5252;
    --text-main: #424242;
    --header-height: 60px;
}

* { box-sizing: border-box; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    font-family: 'Zen Maru Gothic', sans-serif;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
    overflow: hidden; 
    color: var(--text-main);
}

h1, h2, h3 { font-family: 'Shippori Mincho', serif; font-weight: 700; }

/* --- Screens Management --- */
.screen {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column; /* For Sticky Header Layout */
    opacity: 0;
    transition: opacity 1s ease;
    background: #fff;
}
.screen.active { display: flex; opacity: 1; z-index: 10; }

/* --- Header Design --- */
.app-header {
    height: var(--header-height);
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    z-index: 100;
    flex-shrink: 0; /* Prevent shrinking */
}
.header-logo {
    font-family: 'Shippori Mincho', serif;
    font-size: 1.2rem; color: var(--god-gold);
    font-weight: bold;
    display: flex; align-items: center; gap: 8px;
}
.header-btn {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: #888; transition: color 0.2s;
}
.header-btn:hover { color: var(--god-gold); }

/* --- Scrollable Content Area --- */
.scroll-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 80px; /* Bottom spacing */
    scroll-behavior: smooth;
}

/* --- 1. LP: God Descent --- */
#screen-lp {
    justify-content: center; align-items: center;
    background: rgb(200,230,255);
    z-index: 200; /* LP is top most */
}

.clouds-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    display: flex;
}
.cloud-panel {
    width: 50%; height: 100%; background: white; position: relative;
    transition: transform 2.5s cubic-bezier(0.65, 0.05, 0.36, 1); z-index: 20;
}
.cloud-panel::after {
    content: ""; position: absolute; top: 0; bottom: 0;
    width: 100px; background: inherit; border-radius: 50%; filter: blur(20px);
}
.cloud-left { transform: translateX(0); } .cloud-left::after { right: -50px; }
.cloud-right { transform: translateX(0); } .cloud-right::after { left: -50px; }

#screen-lp.open .cloud-left { transform: translateX(-100%); }
#screen-lp.open .cloud-right { transform: translateX(100%); }

.god-rays {
    position: absolute; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0; transition: opacity 2s ease 1s;
}
.lp-content {
    z-index: 30; text-align: center;
    opacity: 0; transform: translateY(-50px);
    transition: all 1.5s ease 1.5s;
}
#screen-lp.open .god-rays { opacity: 1; }
#screen-lp.open .lp-content { opacity: 1; transform: translateY(0); }

.btn-start {
    background: var(--god-gold); color: white;
    border: none; padding: 15px 40px; font-size: 1.2rem;
    border-radius: 50px; cursor: pointer;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.6);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* --- 2. Input UI --- */
.god-avatar { text-align: center; margin-bottom: 20px; }
.god-msg {
    background: white; padding: 10px 20px; border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: inline-block; position: relative; border: 1px solid #eee;
}
.god-msg::after {
    content: ''; position: absolute; bottom: -10px; left: 50%;
    border-width: 10px 10px 0; border-style: solid;
    border-color: white transparent; transform: translateX(-50%);
}

.section-title { font-size: 1.1rem; color: #888; margin: 30px 0 10px; padding-left: 10px; border-left: 4px solid var(--god-gold); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;}
.tag {
    background: #fff; border: 1px solid #ddd; padding: 8px 16px;
    border-radius: 20px; cursor: pointer; transition: all 0.2s; user-select: none;
}
.tag.selected {
    background: var(--god-gold); color: white; border-color: var(--god-gold);
    transform: scale(1.1); box-shadow: 0 4px 10px rgba(212, 175, 55, 0.4);
}

.timeline-container {
    position: relative; width: 100%; max-width: 400px; margin: 10px auto;
    background: white; border-radius: 15px; padding: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05); border: 1px solid #f0f0f0;
}

/* Sleep Control */
.sleep-control { text-align: center; }
.sleep-visual-bar {
    height: 20px; width: 100%; background: #eee;
    border-radius: 10px; position: relative; margin: 15px 0; overflow: hidden;
}
.sleep-segment {
    position: absolute; height: 100%; top: 0;
    background: var(--night-blue); opacity: 0.6; transition: width 0.1s, left 0.1s;
}
.slider-group { display: flex; justify-content: space-between; gap: 10px; }
.range-wrapper { flex: 1; display: flex; flex-direction: column; align-items: center; }
input[type=range] { width: 100%; accent-color: var(--night-blue); }

/* Meal Stamper */
.meal-area {
    position: relative; height: 300px; width: 60px;
    background: linear-gradient(180deg, #FFE0B2 0%, #FFF3E0 50%, #E8EAF6 100%);
    border-radius: 30px; margin: 0 auto;
    border: 2px dashed #ccc; cursor: pointer; overflow: visible;
}
.time-marker {
    position: absolute; left: -40px; font-size: 10px; color: #999;
    width: 30px; text-align: right;
}
.meal-stamp {
    position: absolute; left: 50%; transform: translate(-50%, -50%) scale(0);
    width: 40px; height: 40px; background: white;
    border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex; justify-content: center; align-items: center;
    font-size: 20px;
    animation: popIn 0.4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { to { transform: translate(-50%, -50%) scale(1); } }

.btn-submit {
    margin-top: 40px; width: 100%; background: linear-gradient(45deg, #1A237E, #87CEEB);
    color: white; border: none; padding: 20px; font-size: 1.2rem;
    border-radius: 15px; cursor: pointer;
    box-shadow: 0 10px 20px rgba(26, 35, 126, 0.3);
    transition: transform 0.1s;
}
.btn-submit:active { transform: scale(0.98); }

/* --- 3. Result UI --- */
.verdict-title { font-size: 2rem; color: var(--god-gold); text-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-top: 10px;}
.verdict-text { font-size: 1.1rem; text-align: center; margin: 10px 0 30px; line-height: 1.6; }
.mandala-container { position: relative; width: 300px; height: 300px; margin: 20px auto; }
canvas { transform: rotate(-90deg); border-radius: 50%; box-shadow: 0 0 30px rgba(212, 175, 55, 0.2); }
.score-box {
    background: white; padding: 20px; border-radius: 15px; width: 100%; max-width: 400px;
    text-align: center; margin: 20px auto; border: 2px solid var(--god-gold);
}
.score-val { font-size: 2.5rem; font-weight: bold; color: var(--god-gold); }

.shake { animation: shake 0.5s; }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } 100% { transform: translateX(0); } }