* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #0d0a08;
    --bg-panel: #1a1510;
    --accent: #d4a017;
    --accent-dim: #8a6b12;
    --text: #e8e0d5;
    --muted: #8a8278;
    --danger: #c42b2b;
    --unease: #7a3eb1;
}

body {
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-root {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

.vignette {
    pointer-events: none;
    position: fixed;
    inset: 0;
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.75);
    z-index: 50;
}

.game-root.flicker .vignette {
    animation: flicker 0.12s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.hud {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(13, 10, 8, 0.92);
    border-bottom: 1px solid rgba(212, 160, 23, 0.25);
}

.hud-block {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

#clockDisplay {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--accent);
    font-size: 1.25rem;
}

.hud-bars {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 11px;
    color: var(--muted);
}

.bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.25s ease, background 0.25s ease;
}

.bar-fill.hunger {
    background: linear-gradient(90deg, #2d6a4f, #95d5b2);
}

.bar-fill.fatigue {
    background: linear-gradient(90deg, #1d3557, #457b9d);
}

.bar-fill.unease {
    background: linear-gradient(90deg, #4a148c, #ce93d8);
}

.bar-fill.unease.danger {
    background: linear-gradient(90deg, var(--danger), #ff6b6b);
}

.btn-pause {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(212, 160, 23, 0.35);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-pause:active {
    transform: scale(0.96);
}

.inventory-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(26, 21, 16, 0.95);
    border-bottom: 1px solid rgba(212, 160, 23, 0.2);
    overflow-x: auto;
    z-index: 39;
}

.inv-slot {
    flex: 0 0 56px;
    height: 56px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.inv-slot.filled {
    border-style: solid;
    border-color: rgba(212, 160, 23, 0.45);
    background: rgba(212, 160, 23, 0.08);
}

.inv-slot.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.35);
}

.inv-slot .emoji {
    font-size: 1.35rem;
    line-height: 1;
}

.game-screen {
    flex: 1;
    position: relative;
    padding: 0 12px 100px;
}

.scene-stack {
    max-width: 720px;
    margin: 0 auto 8px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(212, 160, 23, 0.22);
    background: #0a0806;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.three-host {
    width: 100%;
    height: min(42vh, 340px);
    min-height: 200px;
    position: relative;
    display: block;
}

.three-host canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    vertical-align: middle;
}

.room-meta {
    padding: 12px 16px 14px;
    background: linear-gradient(180deg, rgba(26, 21, 16, 0.98), rgba(13, 10, 8, 0.99));
    border-top: 1px solid rgba(212, 160, 23, 0.15);
}

.room-meta .room-title {
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: var(--accent);
}

.room-meta .room-flavor {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.45;
    margin: 0;
}

.room {
    display: none;
    max-width: 560px;
    margin: 0 auto;
    padding-top: 8px;
    animation: fadeIn 0.35s ease;
}

.room.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.room-visual {
    border-radius: 16px;
    padding: 24px;
    min-height: 160px;
    margin-bottom: 16px;
    border: 1px solid rgba(212, 160, 23, 0.2);
    position: relative;
    overflow: hidden;
}

.corridor-bg {
    background: linear-gradient(160deg, #1a1410 0%, #2d2218 50%, #0d0a08 100%);
}

.nursery-bg {
    background: linear-gradient(165deg, #1e1a14 0%, #3d3020 40%, #15120e 100%);
}

.kitchen-bg {
    background: linear-gradient(165deg, #151e1a 0%, #24302a 50%, #0e1210 100%);
}

.living-bg {
    background: linear-gradient(165deg, #18151c 0%, #2a2430 50%, #0f0d12 100%);
}

.living-bg.lamp-on {
    background: linear-gradient(165deg, #2a2520 0%, #4a4035 50%, #221c18 100%);
    box-shadow: inset 0 0 60px rgba(212, 160, 23, 0.15);
}

.door-bg {
    background: linear-gradient(175deg, #12100e 0%, #252018 100%);
}

.room-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.room-flavor {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.45;
}

.prop-crib {
    font-size: 3rem;
    margin: 8px 0 12px;
    text-align: center;
}

.baby-tag {
    display: block;
    font-size: 11px;
    color: var(--accent-dim);
    margin-top: 6px;
    letter-spacing: 0.04em;
}

.prop-door {
    height: 40px;
    width: 4px;
    background: var(--accent-dim);
    opacity: 0.4;
    border-radius: 2px;
    margin-bottom: 12px;
}

.nav-exits {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.nav-btn {
    flex: 1 1 calc(50% - 5px);
    min-height: 48px;
    padding: 0 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    background: rgba(212, 160, 23, 0.15);
    border: 1px solid rgba(212, 160, 23, 0.35);
    border-radius: 12px;
    cursor: pointer;
}

.nav-btn:active {
    background: rgba(212, 160, 23, 0.28);
}

.hotspots {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hotspot {
    min-height: 48px;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
}

.hotspot .req,
.hotspot .hint {
    color: var(--muted);
    font-size: 0.8em;
}

.hotspot:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.event-log {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 88px;
    overflow-y: auto;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--muted);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    z-index: 45;
    pointer-events: none;
}

.event-log .log-line {
    margin-bottom: 4px;
    border-left: 2px solid var(--accent-dim);
    padding-left: 8px;
}

.event-log .log-line.warn {
    border-color: var(--danger);
    color: #e8b4b4;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.82);
}

.overlay.hidden {
    display: none;
}

.panel {
    max-width: 400px;
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid rgba(212, 160, 23, 0.35);
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.menu-panel h1 {
    font-size: 1.65rem;
    color: var(--accent);
    margin-bottom: 6px;
}

.menu-panel .sub {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    margin-top: 4px;
}

.lede {
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 16px 0;
    color: var(--muted);
}

.lede strong {
    color: var(--text);
}

.menu-bullets {
    margin: 0 0 20px 1.1rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.menu-bullets li {
    margin-bottom: 8px;
}

.btn-primary {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
    font-weight: 700;
    color: #1a1205;
    background: linear-gradient(180deg, #e8bc3a, var(--accent));
    border: none;
    border-radius: 14px;
    cursor: pointer;
    margin-bottom: 12px;
}

.btn-primary:active {
    transform: scale(0.98);
}

.fineprint {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.4;
}

.end-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    display: block;
    text-align: center;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

#endMessage {
    margin-top: 12px;
    color: var(--muted);
    line-height: 1.5;
}

@media (min-width: 720px) {
    .hud-bars {
        flex-direction: row;
        flex: 2;
    }
    .stat {
        grid-template-columns: 1fr;
        flex: 1;
    }
}
