:root {
    --bg-0: #120b0a;
    --bg-1: #211412;
    --panel: rgba(34, 20, 17, 0.88);
    --panel-strong: rgba(22, 13, 11, 0.96);
    --line: rgba(243, 226, 206, 0.14);
    --text: #f8f1e8;
    --muted: #d7c6b3;
    --accent: #e3b36c;
    --accent-2: #c96e61;
    --danger: #f16f6f;
    --success: #9fd39a;
    --shadow: 0 34px 90px rgba(0, 0, 0, 0.45);
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'IBM Plex 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:
        linear-gradient(160deg, rgba(11, 7, 6, 0.78) 0%, rgba(28, 17, 16, 0.72) 48%, rgba(16, 8, 7, 0.82) 100%),
        radial-gradient(circle at top center, rgba(227, 179, 108, 0.14), transparent 22%),
        radial-gradient(circle at bottom left, rgba(201, 110, 97, 0.12), transparent 28%),
        url('assets/realismen-background.png') center center / cover fixed;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(227, 179, 108, 0.05), transparent 12%, transparent 88%, rgba(227, 179, 108, 0.05)),
        repeating-linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.018) 0 1px,
            transparent 1px 28px
        );
    opacity: 0.22;
    pointer-events: none;
    z-index: 0;
}

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

.ambient-a {
    top: -12rem;
    left: -12rem;
    background: rgba(227, 179, 108, 0.18);
}

.ambient-b {
    right: -12rem;
    bottom: -12rem;
    background: rgba(201, 110, 97, 0.14);
}

.hidden {
    display: none !important;
}

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

.screen {
    border: 1px solid var(--line);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%),
        var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

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

.transition {
    display: grid;
    gap: 24px;
    padding: 28px;
}

.transition-copy {
    display: grid;
    gap: 14px;
    max-width: 780px;
}

.transition-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: end;
    gap: 14px;
}

.transition-meta {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.55;
    max-width: 44ch;
}

.hero-copy {
    display: grid;
    gap: 14px;
    max-width: 760px;
}

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

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

.hero h2,
.transition h2 {
    font-size: clamp(2.2rem, 5vw, 4.6rem);
    line-height: 0.95;
}

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

.how-to-play {
    display: grid;
    gap: 8px;
    max-width: 44rem;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(227, 179, 108, 0.16);
    background: rgba(0, 0, 0, 0.16);
}

.how-to-play-title {
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-size: 0.98rem;
}

.how-to-play ul {
    padding-left: 20px;
    display: grid;
    gap: 6px;
    color: var(--muted);
    line-height: 1.55;
}

.how-to-play li {
    max-width: 54ch;
}

.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:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
        rgba(27, 15, 13, 0.92);
    border: 1px solid rgba(227, 179, 108, 0.18);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.topbar-copy {
    display: grid;
    gap: 4px;
}

.topbar-title {
    font-size: clamp(1.4rem, 2.3vw, 2rem);
    line-height: 1;
}

.progress-display {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.timer-box {
    display: grid;
    justify-items: end;
    gap: 4px;
    min-width: 138px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid rgba(227, 179, 108, 0.26);
    background: rgba(8, 6, 5, 0.24);
}

.timer-label {
    font-size: 0.72rem;
    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.4vw, 2rem);
    font-weight: 800;
    letter-spacing: 0.06em;
}

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

.hint-panel {
    margin-top: 14px;
    padding: 16px 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 {
    padding: 24px;
    display: grid;
    gap: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 22%),
        var(--panel-strong);
    border: 1px solid rgba(227, 179, 108, 0.12);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.ending-card {
    justify-items: center;
    text-align: center;
}

.room-title {
    font-size: clamp(1.6rem, 2.8vw, 2.5rem);
    line-height: 1;
}

.ending-title {
    font-size: clamp(2.2rem, 4.8vw, 4.4rem);
    line-height: 0.95;
    max-width: 14ch;
}

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

.room-story {
    border-left: 3px solid rgba(227, 179, 108, 0.7);
    padding-left: 16px;
}

.puzzle-container {
    padding: 16px;
    border-radius: 20px;
    border: 1px dashed rgba(227, 179, 108, 0.4);
    background: rgba(255, 255, 255, 0.03);
    display: grid;
    gap: 14px;
    justify-items: start;
}

.section-label {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    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: 86px;
    padding: 8px 6px 10px;
    display: grid;
    justify-items: center;
    gap: 4px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.28);
}

.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: #ffffff;
}

.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(255, 255, 255, 0.06);
    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: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(9, 6, 5, 0.7);
    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(248, 241, 232, 0.42);
}

input:focus {
    border-color: rgba(227, 179, 108, 0.82);
    box-shadow: 0 0 0 4px rgba(227, 179, 108, 0.16);
}

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

.match-instruction {
    color: var(--muted);
    line-height: 1.6;
}

.matching-board {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.matching-column {
    display: grid;
    gap: 10px;
}

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

.matching-list {
    display: grid;
    gap: 10px;
}

.match-item {
    min-height: 68px;
}

.match-selected {
    border-color: rgba(227, 179, 108, 0.8) !important;
    background: rgba(227, 179, 108, 0.16) !important;
}

.match-complete {
    border-color: rgba(159, 211, 154, 0.72) !important;
    background: rgba(159, 211, 154, 0.14) !important;
}

.match-summary {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    color: var(--muted);
}

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

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

.sequence-placeholder {
    color: rgba(248, 241, 232, 0.56);
    font-style: italic;
}

.sequence-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(227, 179, 108, 0.16);
    border: 1px solid rgba(227, 179, 108, 0.3);
    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(227, 179, 108, 0.6);
    background: rgba(227, 179, 108, 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(159, 211, 154, 0.16);
    border-color: rgba(159, 211, 154, 0.48);
    color: var(--success);
}

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

.ending-message {
    display: grid;
    gap: 10px;
    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.25;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    max-width: 30ch;
}

.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.03em;
    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(227, 179, 108, 0.82);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #f1d08a 0%, #c99548 100%);
    color: #21120f;
    box-shadow: 0 12px 32px rgba(227, 179, 108, 0.24);
}

.btn-primary:hover {
    box-shadow: 0 16px 36px rgba(227, 179, 108, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-secondary:hover {
    border-color: rgba(227, 179, 108, 0.54);
    background: rgba(255, 255, 255, 0.04);
}

.btn-action {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(227, 179, 108, 0.38);
}

.btn-hint {
    background: rgba(201, 110, 97, 0.18);
    color: var(--text);
    border: 1px solid rgba(201, 110, 97, 0.44);
    justify-self: start;
}

.btn-hint:hover {
    background: rgba(201, 110, 97, 0.26);
}

.btn-choice {
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    display: grid;
    gap: 6px;
}

.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.08);
    border-color: rgba(227, 179, 108, 0.34);
}

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

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

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

.hero,
.transition,
.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: 860px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .choice-grid,
    .sequence-buttons {
        grid-template-columns: 1fr;
    }

    .matching-board {
        grid-template-columns: 1fr;
    }

    .hero,
    .transition,
    .room-card,
    .ending-card {
        padding: 20px;
    }

    .transition-actions {
        align-items: start;
    }
}

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

    .hero {
        border-radius: 22px;
    }

    .hero-actions,
    .input-row,
    .transition-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;
    }

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