:root {
    --bg-0: #f5efe3;
    --bg-1: #e9dcc8;
    --panel: rgba(255, 252, 246, 0.78);
    --panel-strong: rgba(255, 255, 252, 0.95);
    --line: rgba(53, 41, 30, 0.12);
    --text: #241c15;
    --muted: #625549;
    --accent: #9f3f2f;
    --accent-2: #1f4e79;
    --success: #2e7d52;
    --danger: #a63a2a;
    --shadow: 0 22px 55px rgba(40, 26, 12, 0.16);
    --font-heading: 'Cormorant Garamond', serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Sans', sans-serif;
}

* {
    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 10% 10%, rgba(159, 63, 47, 0.16), transparent 24%),
        radial-gradient(circle at 90% 16%, rgba(31, 78, 121, 0.14), transparent 26%),
        radial-gradient(circle at 50% 100%, rgba(120, 99, 56, 0.12), transparent 28%),
        linear-gradient(150deg, rgba(246, 240, 228, 0.88) 0%, rgba(234, 223, 207, 0.84) 48%, rgba(221, 207, 188, 0.9) 100%),
        url('assets/sprakstriden-bg.png');
    background-attachment: fixed, fixed, fixed, fixed, fixed;
    background-position: center, center, center, center, center;
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    background-size: cover, cover, cover, cover, cover;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        linear-gradient(135deg, rgba(52, 37, 23, 0.035) 0 1px, transparent 1px 100%),
        linear-gradient(45deg, rgba(52, 37, 23, 0.025) 0 1px, transparent 1px 100%);
    background-size: 72px 72px;
    opacity: 0.34;
}

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

.ambient-a {
    top: -8rem;
    left: -10rem;
    background: rgba(159, 63, 47, 0.18);
}

.ambient-b {
    right: -10rem;
    bottom: -10rem;
    background: rgba(31, 78, 121, 0.16);
}

.hidden {
    display: none !important;
}

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

.screen {
    border: 1px solid var(--line);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.56));
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.hero {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 22px;
    padding: 28px;
}

.hero::before {
    content: 'SPRÅKSTRIDEN';
    position: absolute;
    right: -0.08em;
    top: -0.15em;
    font-family: var(--font-heading);
    font-size: clamp(3.2rem, 12vw, 9rem);
    line-height: 0.85;
    letter-spacing: 0.08em;
    color: rgba(36, 28, 21, 0.04);
    pointer-events: none;
}

.hero-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 18px;
    align-items: stretch;
}

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

.hero-visual {
    display: grid;
    gap: 12px;
    align-content: start;
}

.poster-card {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 10px;
    padding: 18px;
    min-height: 100%;
    border-radius: 22px;
    border: 1px solid rgba(53, 41, 30, 0.12);
    background:
        linear-gradient(145deg, rgba(159, 63, 47, 0.14), rgba(31, 78, 121, 0.08)),
        rgba(255, 255, 255, 0.52);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.poster-card::after {
    content: '';
    position: absolute;
    inset: auto -18% -30% auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(159, 63, 47, 0.22), transparent 68%);
    pointer-events: none;
}

.poster-label {
    display: inline-flex;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(53, 41, 30, 0.12);
    background: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--accent);
}

.poster-card h3 {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 0.95;
}

.poster-card p {
    color: var(--muted);
    max-width: 30ch;
    line-height: 1.55;
}

.poster-seal {
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(36, 28, 21, 0.06);
    border: 1px solid rgba(53, 41, 30, 0.08);
    font-family: var(--font-heading);
    letter-spacing: 0.04em;
    font-weight: 700;
}

.poster-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.poster-mini {
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(53, 41, 30, 0.1);
    background: rgba(255, 255, 255, 0.5);
    display: grid;
    gap: 6px;
    justify-items: center;
    text-align: center;
}

.poster-mini span {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    line-height: 1;
}

.poster-mini small {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.68rem;
    font-weight: 700;
}

.hero-notes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.note-card {
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(53, 41, 30, 0.10);
    background: rgba(255, 255, 255, 0.35);
    display: grid;
    gap: 8px;
}

.note-label {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
}

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

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

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

.hero-text {
    max-width: 68ch;
    color: var(--muted);
    font-size: 1.03rem;
    line-height: 1.75;
}

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

.topbar {
    position: sticky;
    top: 12px;
    z-index: 5;
    margin-bottom: 14px;
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: rgba(255, 252, 246, 0.86);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

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

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

.topbar-subtitle {
    max-width: 60ch;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.timer-box {
    display: grid;
    justify-items: end;
    gap: 4px;
    min-width: 140px;
    padding: 9px 12px;
    border-radius: 16px;
    border: 1px solid rgba(159, 63, 47, 0.2);
    background: rgba(255, 255, 255, 0.36);
}

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

.timer-display {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 2.3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.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;
    font-weight: 600;
}

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

.room {
    border-radius: 28px;
}

.room-card,
.ending-card,
.transition-frame {
    position: relative;
    overflow: hidden;
    padding: 24px;
    display: grid;
    gap: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
    border: 1px solid rgba(53, 41, 30, 0.11);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.room-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: linear-gradient(180deg, var(--room-accent), rgba(255, 255, 255, 0));
}

.room-card::after {
    content: attr(data-room-number);
    position: absolute;
    right: 18px;
    bottom: 10px;
    font-family: var(--font-heading);
    font-size: clamp(3rem, 8vw, 6rem);
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: rgba(36, 28, 21, 0.04);
    pointer-events: none;
}

.room-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.room-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--room-accent-wash);
    border: 1px solid var(--room-accent-soft);
    color: var(--room-accent);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
}

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

.transition {
    margin-top: 14px;
}

.transition-frame {
    min-height: 320px;
    align-content: center;
    justify-items: start;
    border: 1px solid var(--transition-accent-soft, rgba(159, 63, 47, 0.16));
    background:
        linear-gradient(135deg, var(--transition-accent-wash, rgba(159, 63, 47, 0.06)), rgba(255, 255, 255, 0.78) 48%, rgba(255, 255, 255, 0.9)),
        rgba(255, 255, 255, 0.88);
}

.transition-frame::before {
    content: '';
    position: absolute;
    inset: auto -12% -28% auto;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--transition-accent-soft), transparent 70%);
    pointer-events: none;
}

.transition-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(53, 41, 30, 0.08);
}

.transition-stage-label {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--transition-accent, var(--accent));
}

.transition-stage-number {
    font-family: var(--font-heading);
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    line-height: 0.9;
    font-weight: 700;
    color: rgba(36, 28, 21, 0.12);
}

.transition-title {
    font-size: clamp(2rem, 4vw, 3.7rem);
    line-height: 0.95;
    max-width: 12ch;
}

.transition-text {
    max-width: 68ch;
    color: var(--muted);
    font-size: 1.02rem;
    line-height: 1.7;
}

.transition-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

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

.ending-title {
    font-size: clamp(2.2rem, 4.6vw, 4.5rem);
    line-height: 0.94;
    max-width: 12ch;
}

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

.room-story {
    border-left: 3px solid rgba(159, 63, 47, 0.72);
    padding-left: 16px;
}

.puzzle-container {
    padding: 16px;
    border-radius: 18px;
    border: 1px dashed var(--room-accent-soft);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.44)),
        rgba(255, 255, 255, 0.42);
    display: grid;
    gap: 14px;
    justify-items: start;
}

.puzzle-instruction {
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.55;
    max-width: 64ch;
}

.section-label {
    font-family: var(--font-heading);
    font-size: 1.08rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--room-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: 16px;
    border: 1px solid rgba(53, 41, 30, 0.12);
    background: rgba(255, 255, 255, 0.45);
}

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

.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(159, 63, 47, 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: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(53, 41, 30, 0.16);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
    color: rgba(36, 28, 21, 0.45);
}

input:focus {
    border-color: rgba(159, 63, 47, 0.82);
    box-shadow: 0 0 0 4px rgba(159, 63, 47, 0.12);
}

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

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

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

.btn-choice.selected {
    background: rgba(159, 63, 47, 0.10);
    border-color: rgba(159, 63, 47, 0.34);
    box-shadow: inset 0 0 0 1px rgba(159, 63, 47, 0.12);
}

.selection-summary {
    font-weight: 600;
    color: var(--muted);
}

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

.bucket-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.54);
    border: 1px solid rgba(53, 41, 30, 0.12);
    display: grid;
    gap: 10px;
}

.bucket-card strong {
    font-size: 1.05rem;
}

.bucket-card small {
    color: var(--muted);
    line-height: 1.45;
}

.bucket-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bucket-toggle {
    padding: 10px 12px;
    font-size: 0.86rem;
}

.bucket-toggle.selected {
    background: rgba(31, 78, 121, 0.10);
    border-color: rgba(31, 78, 121, 0.36);
}

.bucket-status {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.bucket-card.assigned-landsmaal {
    border-color: rgba(46, 125, 82, 0.32);
}

.bucket-card.assigned-riksmal {
    border-color: rgba(159, 63, 47, 0.32);
}

.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.58);
    border: 1px solid rgba(53, 41, 30, 0.12);
}

.sequence-placeholder {
    color: rgba(36, 28, 21, 0.54);
    font-style: italic;
}

.sequence-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(159, 63, 47, 0.11);
    border: 1px solid rgba(159, 63, 47, 0.24);
    color: var(--text);
    font-weight: 600;
}

.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(31, 78, 121, 0.5);
    background: rgba(31, 78, 121, 0.07);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
}

.hidden-word-button.revealed {
    background: rgba(46, 125, 82, 0.14);
    border-color: rgba(46, 125, 82, 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(1rem, 1.9vw, 1.45rem);
    line-height: 1.28;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    max-width: 30ch;
}

.btn {
    appearance: none;
    border: none;
    border-radius: 16px;
    padding: 14px 18px;
    font-family: var(--font-heading);
    font-size: 1.02rem;
    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(31, 78, 121, 0.8);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #b75b49 100%);
    color: #fff8f3;
    box-shadow: 0 12px 28px rgba(159, 63, 47, 0.22);
}

.btn-primary:hover {
    box-shadow: 0 16px 34px rgba(159, 63, 47, 0.28);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(53, 41, 30, 0.16);
}

.btn-secondary:hover {
    border-color: rgba(159, 63, 47, 0.44);
    background: rgba(255, 255, 255, 0.28);
}

.btn-action {
    background: rgba(31, 78, 121, 0.08);
    color: var(--text);
    border: 1px solid rgba(31, 78, 121, 0.16);
}

.btn-action:hover {
    background: rgba(31, 78, 121, 0.12);
    border-color: rgba(31, 78, 121, 0.34);
}

.btn-hint {
    background: rgba(46, 125, 82, 0.13);
    color: var(--text);
    border: 1px solid rgba(46, 125, 82, 0.36);
    justify-self: start;
}

.btn-hint:hover {
    background: rgba(46, 125, 82, 0.19);
}

.btn-choice {
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.44);
    border: 1px solid rgba(53, 41, 30, 0.10);
    color: var(--text);
    display: grid;
    gap: 8px;
}

.btn-choice strong {
    color: var(--room-accent, var(--accent-2));
    font-size: 1rem;
}

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

.btn-choice:hover {
    background: rgba(255, 255, 255, 0.62);
    border-color: rgba(31, 78, 121, 0.3);
}

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

    .hero-layout {
        grid-template-columns: 1fr;
    }

    .hero-notes,
    .choice-grid,
    .sequence-buttons,
    .multi-select-grid,
    .bucket-grid {
        grid-template-columns: 1fr;
    }

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

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

    .hero {
        border-radius: 22px;
    }

    .hero::before {
        right: 0;
        top: 0;
        font-size: clamp(2.6rem, 18vw, 5rem);
    }

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

    .poster-mini-grid {
        grid-template-columns: 1fr;
    }

    .room-card-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .room-index {
        align-self: flex-start;
    }

    .transition-stage {
        flex-direction: column;
        align-items: flex-start;
    }

    .transition-stage-number {
        font-size: 2.6rem;
    }

    .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%;
    }
}
