:root {
    --bg-0: #0a1617;
    --bg-1: #15292b;
    --panel: rgba(247, 237, 220, 0.86);
    --panel-strong: rgba(249, 242, 229, 0.95);
    --panel-dark: rgba(18, 33, 35, 0.72);
    --line: rgba(30, 53, 55, 0.16);
    --line-strong: rgba(109, 71, 46, 0.22);
    --text: #132022;
    --muted: #4f5d5d;
    --accent: #8b5e34;
    --accent-2: #315b63;
    --accent-3: #9f2732;
    --danger: #c73d48;
    --success: #2f7a5e;
    --shadow: 0 28px 68px rgba(5, 15, 16, 0.26);
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Mono', 'SFMono-Regular', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top left, rgba(168, 120, 72, 0.24), transparent 30%),
        radial-gradient(circle at bottom right, rgba(49, 91, 99, 0.26), transparent 32%),
        linear-gradient(180deg, #091516 0%, #123033 38%, #e7dac1 38%, #f4ead7 100%);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 100%),
        linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 100%);
    background-size: 84px 84px;
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    inset: auto 0 0;
    height: 240px;
    background:
        linear-gradient(175deg, transparent 0 58%, rgba(7, 23, 23, 0.92) 58% 100%),
        linear-gradient(160deg, transparent 0 70%, rgba(34, 66, 70, 0.9) 70% 100%),
        linear-gradient(150deg, transparent 0 82%, rgba(17, 40, 43, 0.88) 82% 100%);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}

.ambient {
    position: fixed;
    inset: auto;
    width: 34rem;
    height: 34rem;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.32;
    pointer-events: none;
    z-index: 0;
}

.ambient-a {
    top: -11rem;
    left: -9rem;
    background: rgba(199, 157, 106, 0.24);
}

.ambient-b {
    right: -11rem;
    bottom: -10rem;
    background: rgba(49, 91, 99, 0.24);
}

.hidden {
    display: none !important;
}

#game-shell {
    position: relative;
    z-index: 1;
    width: min(1080px, calc(100vw - 24px));
    margin: 0 auto;
    padding: 18px 0 40px;
}

.screen {
    border: 1px solid rgba(43, 68, 70, 0.18);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero {
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 26px;
}

.hero-copy {
    display: grid;
    gap: 16px;
    max-width: 820px;
}

.eyebrow {
    font-size: 0.8rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--accent-3);
    font-weight: 800;
}

h1,
h2,
h3 {
    font-family: var(--font-heading);
    letter-spacing: -0.03em;
}

.hero h2 {
    font-size: clamp(2.2rem, 4.8vw, 4.7rem);
    line-height: 0.92;
    max-width: 13ch;
}

.hero-text {
    max-width: 70ch;
    color: var(--muted);
    font-size: 1.08rem;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 5;
    margin-bottom: 14px;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: rgba(245, 236, 221, 0.82);
    border: 1px solid rgba(36, 56, 57, 0.16);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.topbar-copy {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.topbar-title {
    font-size: clamp(1.5rem, 2.8vw, 2.4rem);
    line-height: 0.95;
}

.topbar-subtitle {
    max-width: 44ch;
    color: var(--muted);
    line-height: 1.5;
}

.progress-box {
    min-width: min(340px, 100%);
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(17, 33, 35, 0.06);
    border: 1px solid rgba(49, 91, 99, 0.14);
    display: grid;
    gap: 10px;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent-2);
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(13, 26, 28, 0.1);
    border: 1px solid rgba(13, 26, 28, 0.09);
}

.progress-fill {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #af7a43 0%, #d4b07a 55%, #4b7b86 100%);
    transition: width 0.3s ease;
}

.timer-box {
    display: grid;
    justify-items: end;
    gap: 4px;
    min-width: 130px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(139, 94, 52, 0.2);
    background: rgba(255, 255, 255, 0.34);
}

.timer-label {
    font-size: 0.74rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 800;
}

.timer-display {
    font-family: var(--font-mono);
    font-size: clamp(1.45rem, 2.6vw, 2rem);
    font-weight: 800;
    letter-spacing: 0.06em;
}

.timer-danger {
    color: var(--danger);
}

.hint-panel {
    margin-top: 14px;
    padding: 14px 18px;
    display: grid;
    gap: 12px;
}

.hint-panel p {
    color: var(--success);
    font-style: italic;
    line-height: 1.6;
}

.room-stack {
    margin-top: 14px;
    display: grid;
    gap: 18px;
}

.room {
    border-radius: 28px;
}

.room-card,
.ending-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
    display: grid;
    gap: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.06) 100%),
        var(--panel-strong);
    border: 1px solid rgba(81, 61, 36, 0.12);
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.room-card::before,
.ending-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(159, 39, 50, 0.08), transparent 28%),
        linear-gradient(315deg, rgba(49, 91, 99, 0.08), transparent 32%);
    opacity: 0.75;
}

.room-card > *,
.ending-card > * {
    position: relative;
    z-index: 1;
}

.room-card {
    border-top: 4px solid rgba(159, 39, 50, 0.45);
}

.ending-card {
    justify-items: center;
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
}

.room-solved .room-card {
    border-top-color: rgba(47, 122, 94, 0.72);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.08) 100%),
        rgba(238, 248, 239, 0.96);
}

.room-title {
    font-size: clamp(1.4rem, 2.4vw, 2.2rem);
    line-height: 1.02;
}

.ending-title {
    font-size: clamp(2.3rem, 4.8vw, 4.3rem);
    line-height: 0.96;
    max-width: 14ch;
}

.room-story,
.ending-text {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.72;
    max-width: 72ch;
}

.room-story {
    border-left: 4px solid rgba(159, 39, 50, 0.55);
    padding-left: 16px;
}

.puzzle-container {
    padding: 16px;
    border-radius: 20px;
    border: 1px dashed rgba(139, 94, 52, 0.32);
    background: rgba(255, 255, 255, 0.32);
    display: grid;
    gap: 14px;
    justify-items: start;
}

.section-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
}

.dial-lock {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.dial {
    width: 84px;
    padding: 8px 6px 10px;
    display: grid;
    justify-items: center;
    gap: 4px;
    border-radius: 18px;
    border: 1px solid rgba(36, 56, 57, 0.12);
    background: rgba(16, 29, 31, 0.15);
}

.dial span {
    width: 100%;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    padding: 6px 0;
    color: var(--text);
}

.dial button {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 0;
    border-radius: 999px;
    transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.dial button:hover {
    color: var(--text);
    background: rgba(17, 33, 35, 0.08);
    transform: translateY(-1px);
}

.input-row {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

input[type="text"],
input[type="number"],
input[type="time"] {
    min-width: 220px;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(36, 56, 57, 0.16);
    background: rgba(248, 243, 233, 0.96);
    color: var(--text);
    font: inherit;
    font-family: var(--font-mono);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
    color: rgba(19, 32, 34, 0.42);
}

input:focus {
    border-color: rgba(139, 94, 52, 0.7);
    box-shadow: 0 0 0 4px rgba(139, 94, 52, 0.12);
}

.choice-grid,
.sequence-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
    width: 100%;
}

.btn-choice-grid {
    min-height: 72px;
    justify-content: center;
}

.sequence-track {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 48px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.38);
    border: 1px solid rgba(36, 56, 57, 0.12);
}

.sequence-placeholder {
    color: rgba(19, 32, 34, 0.54);
    font-style: italic;
}

.sequence-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(139, 94, 52, 0.14);
    border: 1px solid rgba(139, 94, 52, 0.22);
    color: var(--text);
    font-weight: 700;
}

.sequence-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hidden-box {
    width: 100%;
    display: grid;
    gap: 12px;
}

.hidden-word-button {
    align-self: start;
    min-width: 180px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px dashed rgba(139, 94, 52, 0.45);
    background: rgba(139, 94, 52, 0.08);
    color: var(--text);
    font: inherit;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.hidden-word-button.revealed {
    background: rgba(47, 122, 94, 0.12);
    border-color: rgba(47, 122, 94, 0.42);
    color: var(--success);
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.ending-message {
    display: grid;
    gap: 12px;
    text-align: center;
    justify-items: center;
}

.ending-callout {
    color: var(--text);
    font-family: var(--font-heading);
    font-size: clamp(1.15rem, 2.2vw, 1.7rem);
    line-height: 1.24;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    max-width: 28ch;
}

.ending-callout a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn {
    appearance: none;
    border: none;
    border-radius: 16px;
    padding: 14px 18px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: 3px solid rgba(49, 91, 99, 0.75);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #c18c52 0%, #e1c18d 100%);
    color: #18160f;
    box-shadow: 0 12px 32px rgba(139, 94, 52, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 16px 36px rgba(139, 94, 52, 0.28);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(36, 56, 57, 0.16);
}

.btn-secondary:hover {
    border-color: rgba(139, 94, 52, 0.38);
    background: rgba(255, 255, 255, 0.24);
}

.btn-action {
    background: rgba(49, 91, 99, 0.1);
    color: var(--text);
    border: 1px solid rgba(49, 91, 99, 0.16);
}

.btn-action:hover {
    background: rgba(49, 91, 99, 0.16);
    border-color: rgba(139, 94, 52, 0.32);
}

.btn-hint {
    background: rgba(49, 91, 99, 0.12);
    color: var(--text);
    border: 1px solid rgba(49, 91, 99, 0.26);
    justify-self: start;
}

.btn-hint:hover {
    background: rgba(49, 91, 99, 0.18);
}

.btn-choice {
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(36, 56, 57, 0.12);
    color: var(--text);
    display: grid;
    gap: 8px;
    min-height: 78px;
}

.btn-choice strong {
    color: var(--accent);
    font-size: 1.02rem;
}

.btn-choice small {
    color: var(--muted);
    text-transform: none;
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.45;
}

.btn-choice:hover {
    background: rgba(255, 255, 255, 0.48);
    border-color: rgba(139, 94, 52, 0.28);
}

.feedback {
    min-height: 1.4em;
    font-weight: 700;
    color: var(--muted);
}

.feedback.success {
    color: var(--success);
}

.feedback.error {
    color: var(--danger);
}

.hero,
.hint-panel,
.topbar,
#ending-screen,
.room-card {
    animation: fadeUp 0.55s ease both;
}

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

@media (max-width: 960px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-box {
        width: 100%;
    }
}

@media (max-width: 860px) {
    .hero,
    .room-card,
    .ending-card {
        padding: 20px;
    }
}

@media (max-width: 560px) {
    #game-shell {
        width: min(100vw - 18px, 100%);
        padding-top: 10px;
    }

    .hero {
        border-radius: 22px;
    }

    .hero-actions,
    .input-row,
    .sequence-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn,
    input[type="text"],
    input[type="number"],
    input[type="time"] {
        width: 100%;
    }

    .topbar {
        top: 10px;
        padding: 12px 14px;
    }

    .timer-box {
        width: 100%;
        justify-items: start;
    }

    .progress-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .hidden-word-button {
        width: 100%;
    }
}
