* { box-sizing: border-box; }

:root {
    --bg: #080506;
    --bg-soft: #12080b;
    --card: #16090d;
    --card-deep: #0e0709;
    --gold: #d7b56d;
    --gold-soft: #b89351;
    --cream: #e3d2a5;
    --muted: #9d8d78;
    --line: rgba(215, 181, 109, .34);
    --danger: #d9a7a7;
}

html {
    background: var(--bg);
    color-scheme: dark;
}

body {
    margin: 0;
    min-width: 320px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 50% 0%, rgba(76, 20, 31, .16), transparent 38rem),
        var(--bg);
    color: var(--cream);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.site-shell {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 18px 16px 42px;
}

.quiet-nav {
    width: min(100%, 610px);
    margin-left: auto;
    margin-right: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .04em;
}

.quiet-nav a {
    text-decoration: none;
}

.quiet-nav > div {
    display: flex;
    gap: 18px;
}

.player-flash {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--cream);
    background: rgba(255,255,255,.03);
    font-size: 14px;
}

.player-flash.error {
    border-color: rgba(217, 167, 167, .45);
    color: var(--danger);
}

.player-flash.success {
    border-color: rgba(180, 207, 168, .4);
}

.brand {
    text-align: center;
    margin: 34px auto 22px;
}

.brand-kicker,
.level-kicker,
.card-meta,
.card-section-label,
.layer-label {
    color: var(--gold);
    letter-spacing: .28em;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
}

.brand h1 {
    margin: 10px 0 4px;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    letter-spacing: .05em;
    font-size: clamp(34px, 10vw, 56px);
    color: var(--cream);
}

.brand p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.panel {
    width: min(100%, 520px);
    margin: 0 auto 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(19, 9, 12, .78);
}

.field { margin-bottom: 16px; }

label {
    display: block;
    margin-bottom: 7px;
    color: var(--gold);
    font-size: 13px;
    letter-spacing: .08em;
}

input[type="email"],
input[type="password"] {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0,0,0,.2);
    color: var(--cream);
    padding: 11px 13px;
    font: inherit;
    font-size: 16px;
}

button,
.button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid var(--gold-soft);
    background: var(--gold);
    color: #1b0d0c;
    text-decoration: none;
    padding: 10px 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button.secondary,
.button.secondary {
    background: transparent;
    color: var(--cream);
    border-color: var(--line);
}

button.quiet,
.button.quiet {
    min-height: 40px;
    padding: 8px 12px;
    background: transparent;
    color: var(--muted);
    border-color: transparent;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 4px;
}

button:disabled,
.button.disabled {
    opacity: .42;
    cursor: not-allowed;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.actions form { margin: 0; }

.stack {
    display: grid;
    gap: 12px;
}

.stack .button,
.stack button {
    width: 100%;
}

.home-back {
    width: min(66vw, 300px);
    margin: 16px auto 24px;
}

.home-back img,
.card-back img,
.pick-back img {
    display: block;
    width: 100%;
    height: auto;
}

.home-back img {
    border-radius: 23px;
}

.home-copy {
    width: min(100%, 520px);
    margin: 0 auto 20px;
    text-align: center;
}

.home-copy h2,
.level-intro h1 {
    margin: 6px 0 10px;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    color: var(--cream);
}

.home-copy h2 { font-size: 30px; }

.home-copy p,
.level-intro p {
    color: var(--muted);
    line-height: 1.55;
}

.level-intro {
    text-align: center;
    width: min(100%, 560px);
    margin: 26px auto 20px;
}

.level-intro h1 {
    font-size: clamp(38px, 12vw, 62px);
}

.level-rule {
    margin: 10px 0 0;
    color: var(--gold);
    font-size: 14px;
    letter-spacing: .06em;
}

.card-back {
    width: min(70vw, 330px);
    margin: 16px auto 24px;
    overflow: hidden;
    border-radius: 26px;
}

.level-list {
    width: min(100%, 600px);
    margin: 0 auto;
    display: grid;
    gap: 10px;
}

.level-row {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 15px;
    background: rgba(20, 9, 12, .64);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.level-row h2 {
    margin: 2px 0 3px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 22px;
    font-weight: 400;
}

.level-row p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.card-stage {
    width: min(100%, 610px);
    margin: 4px auto 18px;
}

.game-card {
    position: relative;
    overflow: hidden;
    border-radius: 27px;
    padding: clamp(34px, 7vw, 54px) clamp(28px, 7vw, 50px);
    min-height: 72vh;
    background:
        radial-gradient(ellipse at 8% 8%, rgba(116, 31, 49, .32), transparent 30%),
        radial-gradient(ellipse at 96% 76%, rgba(108, 28, 45, .26), transparent 32%),
        linear-gradient(145deg, #16080d, #0c0709 58%, #16080d);
    box-shadow:
        inset 0 0 0 2px rgba(193, 142, 71, .78),
        inset 0 0 0 7px rgba(10, 7, 7, .86),
        inset 0 0 0 8px rgba(223, 185, 108, .28);
}

.game-card::before,
.game-card::after {
    content: "";
    position: absolute;
    width: 58%;
    height: 38%;
    border: 1px solid rgba(151, 50, 68, .34);
    border-radius: 50%;
    transform: rotate(-28deg);
    pointer-events: none;
}

.game-card::before {
    left: -30%;
    top: -11%;
    box-shadow:
        18px 14px 0 -17px rgba(185, 61, 79, .22),
        44px 30px 0 -40px rgba(214, 97, 112, .18);
}

.game-card::after {
    right: -34%;
    bottom: -7%;
    transform: rotate(-34deg);
}

.card-top {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 28px;
}

.card-meta {
    letter-spacing: .22em;
}

.card-title {
    position: relative;
    z-index: 1;
    margin: 0 0 34px;
    padding-bottom: 22px;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: clamp(30px, 8vw, 48px);
    color: var(--cream);
    line-height: 1.06;
}

.card-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 70px;
    height: 2px;
    background: var(--gold);
}

.card-copy-section {
    position: relative;
    z-index: 1;
}

.card-copy-section + .card-copy-section {
    margin-top: 34px;
}

.card-section-label {
    margin-bottom: 16px;
    padding-bottom: 13px;
    position: relative;
}

.card-section-label::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 70px;
    height: 2px;
    background: var(--gold);
}

.invitation {
    position: relative;
    z-index: 1;
    font-family: Georgia, "Times New Roman", serif;
    color: #e2d1a3;
    font-size: clamp(23px, 5.8vw, 34px);
    line-height: 1.42;
}

.invitation p,
.inspiration p,
.extra-copy p {
    margin: 0 0 1em;
}

.inspiration {
    color: #d5c18d;
    font-size: clamp(17px, 4.15vw, 21px);
    line-height: 1.62;
}

.extra-copy {
    position: relative;
    z-index: 1;
    font-family: Georgia, "Times New Roman", serif;
    color: #e2d1a3;
    font-size: clamp(22px, 5.4vw, 32px);
    line-height: 1.48;
    margin-top: 18px;
}

.game-card strong {
    color: #f0d995;
    font-weight: 700;
}

.layer-strip {
    margin: 0 auto 14px;
    width: min(100%, 610px);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: rgba(81, 33, 43, .23);
}

.layer-strip h2 {
    margin: 5px 0 7px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 22px;
    font-weight: 400;
}

.layer-strip p {
    margin: 0;
    color: var(--cream);
    line-height: 1.5;
}

.card-actions {
    width: min(100%, 610px);
    margin: 18px auto 0;
    display: grid;
    gap: 10px;
}

.card-actions .primary-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card-actions .primary-row form {
    flex: 1 1 180px;
}

.card-actions .primary-row button {
    width: 100%;
}

.pick-intro {
    text-align: center;
    width: min(100%, 600px);
    margin: 20px auto;
}

.pick-intro h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 400;
    margin: 6px 0 8px;
}

.pick-grid {
    width: min(100%, 680px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.pick-option {
    min-width: 0;
}

.pick-option > summary {
    list-style: none;
    cursor: pointer;
    text-align: center;
    color: var(--gold);
}

.pick-option > summary::-webkit-details-marker { display: none; }

.pick-back {
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 8px;
}

.pick-reveal-label {
    font-size: 13px;
    letter-spacing: .08em;
}

.pick-option[open] {
    grid-column: 1 / -1;
}

.pick-option[open] > summary {
    width: min(42%, 240px);
    margin: 0 auto 12px;
}

.pick-option[open] .pick-back {
    opacity: .32;
}

.pick-card {
    margin-top: 10px;
}

.pick-card .game-card {
    min-height: 0;
}

.pick-choose {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.pair-footer {
    width: min(100%, 680px);
    margin: 16px auto 0;
    text-align: center;
}

.muted,
.small {
    color: var(--muted);
}

.small { font-size: 13px; }

.center { text-align: center; }

code {
    color: var(--gold);
}

@media (max-width: 520px) {
    .site-shell { padding-left: 12px; padding-right: 12px; }

    .game-card {
        border-radius: 22px;
        min-height: 0;
    }

    .pick-grid {
        gap: 10px;
    }

    .level-row {
        grid-template-columns: 1fr;
    }

    .level-row .button {
        width: 100%;
    }

}


/* Dedicated pre-level screen */
.pre-level-stage {
    margin-top: 20px;
}

.pre-level-card {
    min-height: 0;
    padding-top: clamp(42px, 9vw, 68px);
    padding-bottom: clamp(38px, 8vw, 60px);
}

.pre-level-topline {
    position: relative;
    z-index: 1;
    color: var(--gold);
    letter-spacing: .28em;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}

.pre-level-name {
    position: relative;
    z-index: 1;
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(40px, 11vw, 68px);
    line-height: 1;
    font-weight: 400;
    color: var(--cream);
}

.pre-level-headline {
    position: relative;
    z-index: 1;
    margin: 24px 0 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(24px, 6vw, 34px);
    line-height: 1.18;
    font-weight: 400;
    color: var(--cream);
}

.pre-level-copy {
    position: relative;
    z-index: 1;
    line-height: 1.6;
}

.pre-level-copy p {
    margin: 0 0 1em;
}

.pre-level-copy-primary {
    margin-top: 28px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(20px, 4.8vw, 27px);
    color: #e2d1a3;
}

.pre-level-copy-secondary {
    margin-top: 20px;
    font-size: clamp(16px, 4vw, 19px);
    color: #d5c18d;
}

.pre-level-mechanics {
    position: relative;
    z-index: 1;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid rgba(215, 181, 109, .34);
}

.pre-level-mechanics-label {
    color: var(--gold);
    letter-spacing: .24em;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 7px;
}

.pre-level-mechanics-value {
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(21px, 5vw, 28px);
    color: var(--cream);
}

.pre-level-actions {
    margin-top: 16px;
}

.path-fork {
    width: min(100%, 610px);
    margin: 0 auto 16px;
    padding: 4px 8px 0;
    text-align: center;
}

.path-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 18px;
}

.path-row form {
    margin: 0;
}

.path-link {
    min-height: 40px;
    padding: 8px 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--cream);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
}

span.path-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.path-link.current {
    color: var(--gold);
    text-decoration: none;
}

.path-link.unavailable {
    color: var(--muted);
    text-decoration: none;
    opacity: .55;
}

.path-heading {
    margin: 14px 0 3px;
    color: var(--gold);
    letter-spacing: .24em;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 700;
}

.path-note {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 520px) {
    .path-row {
        gap: 0 14px;
    }

    .path-link {
        font-size: 13px;
    }
}


/* Shared player grid alignment */
.panel.pre-level-actions {
    width: min(100%, 610px);
    max-width: none;
}

/* Pick preview templates fill their local reveal area. */
.pick-card .card-stage {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Small Markdown subset used inside authored card copy. */
.md-heading {
    margin: 1.15em 0 .45em;
    font-family: Georgia, "Times New Roman", serif;
    font-size: .82em;
    line-height: 1.25;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: .04em;
}

.md-list {
    margin: .7em 0 1em 1.2em;
    padding: 0;
}

.md-list li {
    margin: .28em 0;
}

.finish-copy .md-heading,
.pre-level-copy .md-heading {
    font-size: .9em;
}


/* Runtime Visual Settings.
   Defaults match the templates immediately before this patch. */
.standard-card .card-title {
    font-size: clamp(30px, 8vw, var(--font-standard-title, 48px));
}

.standard-card .invitation {
    font-size: clamp(23px, 5.8vw, var(--font-standard-invitation, 34px));
}

.standard-card .inspiration {
    font-size: clamp(17px, 4.15vw, var(--font-standard-inspiration, 21px));
}

.layer-card .card-title {
    font-size: clamp(30px, 8vw, var(--font-layer-title, 48px));
}

.layer-card .invitation {
    font-size: clamp(23px, 5.8vw, var(--font-layer-invitation, 34px));
}

.layer-card .inspiration {
    font-size: clamp(17px, 4.15vw, var(--font-layer-inspiration, 21px));
}

.finish-card .card-title {
    font-size: clamp(30px, 8vw, var(--font-finish-title, 48px));
}

.finish-card .finish-copy {
    font-size: clamp(22px, 5.4vw, var(--font-finish-body, 32px));
}

.pre-level-card .pre-level-name {
    font-size: clamp(40px, 11vw, var(--font-pre-level-name, 68px));
}

.pre-level-card .pre-level-copy-primary {
    font-size: clamp(20px, 4.8vw, var(--font-pre-level-body, 27px));
}

.pre-level-card .pre-level-mechanics-value {
    font-size: clamp(21px, 5vw, var(--font-pre-level-mechanics, 28px));
}


/* Regression restore: section underline follows the actual heading text width. */
.card-section-label {
    display: inline-block;
    width: auto;
}

.card-section-label::after {
    width: 100%;
}

/* Later-level choices belong to the Pre card, directly under Tonight. */
.pre-level-mechanics-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 9px;
}

.pre-level-or {
    color: var(--muted);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.pre-level-paths {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 18px;
    margin-top: 9px;
}

.pre-level-paths form {
    margin: 0;
}

.pre-level-path-link {
    min-height: 32px;
    padding: 2px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--gold);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
}

.pre-level-path-link:hover,
.pre-level-path-link:focus-visible {
    color: var(--cream);
}

.pre-level-path-note {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

/* Old external path block is no longer used by the current Pre template. */
.path-fork {
    display: none;
}

/* Clean Pick 2 / Choose 1 toggle.
   Two backs stay visible; one reveal/selector is displayed at a time. */
.pick-toggle-row {
    width: min(100%, 610px);
    margin: 0 auto 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.pick-toggle {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 20px;
    background: transparent;
    color: var(--gold);
    font-weight: 600;
    overflow: hidden;
}

.pick-toggle:hover,
.pick-toggle:focus-visible,
.pick-toggle.active {
    border-color: var(--line);
    background: rgba(215, 181, 109, .05);
}

.pick-toggle-back {
    display: block;
    width: 100%;
    overflow: hidden;
}

.pick-toggle-back img {
    display: block;
    width: 100%;
    height: auto;
}

.pick-toggle-label {
    display: block;
    padding: 9px 8px 10px;
    font-size: 13px;
    letter-spacing: .06em;
}

.pick-toggle.active .pick-toggle-label::after {
    content: " · open";
    color: var(--cream);
}

.pick-reveal-stage {
    width: min(100%, 610px);
    margin: 0 auto;
}

.pick-reveal-panel[hidden] {
    display: none !important;
}

.pick-reveal-panel .card-stage {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.pick-empty-state {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
}

.pick-empty-state[hidden] {
    display: none;
}

.pick-choose {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.pick-choose form,
.pick-choose button {
    width: min(100%, 360px);
}

.pair-footer {
    width: min(100%, 610px);
    margin: 16px auto 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0 5px;
    text-align: center;
}

/* Retire the old expanding-details Pick 2 layout if cached markup appears. */
.pick-grid {
    width: min(100%, 610px);
}

@media (max-width: 520px) {
    .pre-level-mechanics-line {
        display: block;
    }

    .pre-level-or {
        margin-top: 4px;
    }

    .pre-level-paths {
        gap: 1px 14px;
    }

    .pre-level-path-link {
        font-size: 15px;
    }

    .pick-toggle-row {
        gap: 10px;
    }

    .pick-toggle-label {
        font-size: 12px;
        padding-left: 5px;
        padding-right: 5px;
    }
}


/* Normal-card title underline:
   follow the rendered title width, but cap long/wrapped titles at 95%
   of the usable card width. */
.standard-card .card-title {
    width: fit-content;
    max-width: 95%;
}

.standard-card .card-title::after {
    width: 100%;
}
