:root {
    --bg: #0d0c0f;
    --bg-deep: #08070a;
    --panel: rgba(24, 21, 27, 0.94);
    --panel-2: rgba(34, 30, 37, 0.94);
    --ink: #f7f1e6;
    --muted: #a9a1a8;
    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.21);
    --red: #ff3158;
    --red-dark: #d91840;
    --gold: #e9b949;
    --gold-pale: #ffd980;
    --success: #82db9a;
    --danger: #ff7891;
    --shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    color-scheme: dark;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100dvh;
    color: var(--ink);
    background:
        radial-gradient(circle at 13% 14%, rgba(255, 49, 88, 0.15), transparent 31rem),
        radial-gradient(circle at 89% 84%, rgba(233, 185, 73, 0.12), transparent 28rem),
        linear-gradient(135deg, var(--bg-deep), var(--bg) 44%, #121015);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(233, 185, 73, 0.58);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.22;
    z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: linear-gradient(to bottom, black, rgba(0,0,0,.42));
}

.game-page::before,
.game-page::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: 0;
    border-radius: 999px;
    filter: blur(2px);
}

.game-page::before {
    width: 44vw;
    height: 8px;
    top: 12%;
    left: -8vw;
    background: rgba(255, 49, 88, 0.16);
    transform: rotate(-8deg);
}

.game-page::after {
    width: 38vw;
    height: 5px;
    right: -9vw;
    bottom: 14%;
    background: rgba(233, 185, 73, 0.16);
    transform: rotate(7deg);
}

.auth-shell,
.menu-shell,
.page-loading {
    position: relative;
    z-index: 1;
}

.auth-shell {
    width: min(1180px, calc(100% - 40px));
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(28px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.72fr);
    gap: clamp(42px, 7vw, 100px);
    align-items: center;
}

.auth-brand {
    min-width: 0;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    place-items: center;
    border: 2px solid var(--ink);
    border-radius: 12px;
    color: #fff;
    background: var(--red);
    box-shadow: 6px 6px 0 var(--gold);
    font-size: 18px;
    font-weight: 950;
    letter-spacing: -0.08em;
    transform: rotate(-4deg);
}

.brand-copy {
    display: grid;
    line-height: 0.88;
    text-transform: uppercase;
}

.brand-copy strong {
    font-size: 22px;
    font-weight: 950;
    letter-spacing: -0.055em;
}

.brand-copy .brand-accent {
    color: var(--red);
}

.brand-copy small {
    margin-top: 8px;
    color: var(--gold-pale);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.22em;
}

.auth-intro {
    max-width: 680px;
    margin-top: clamp(72px, 10vh, 130px);
}

.eyebrow,
.panel-kicker {
    color: var(--gold-pale);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow {
    display: inline-flex;
    padding: 7px 10px;
    border: 1px solid rgba(233, 185, 73, 0.38);
    border-radius: 7px;
    background: rgba(233, 185, 73, 0.06);
    transform: rotate(-1deg);
}

.auth-intro h1,
.menu-copy h1 {
    margin: 18px 0 18px;
    max-width: 760px;
    font-size: clamp(3.4rem, 8vw, 7.2rem);
    line-height: 0.83;
    letter-spacing: -0.075em;
    text-transform: uppercase;
}

.auth-intro p,
.menu-copy > p {
    max-width: 650px;
    margin: 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.4vw, 1.18rem);
    line-height: 1.65;
}

.auth-card {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: clamp(28px, 4vw, 44px);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background:
        linear-gradient(160deg, rgba(255,255,255,.045), transparent 42%),
        var(--panel);
    box-shadow: var(--shadow);
}

.auth-card::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    top: -95px;
    right: -85px;
    border: 24px solid rgba(255, 49, 88, 0.07);
    transform: rotate(18deg);
}

.card-topline {
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: linear-gradient(90deg, var(--red), var(--gold));
}

.panel-heading {
    position: relative;
    z-index: 1;
}

.panel-heading h2 {
    margin: 8px 0 8px;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 0.95;
    letter-spacing: -0.055em;
    text-transform: uppercase;
}

.panel-heading p:last-child {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.session-check {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.spinner-large {
    width: 34px;
    height: 34px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.login-form {
    position: relative;
    z-index: 1;
    margin-top: 30px;
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field > span {
    display: block;
    margin-bottom: 8px;
    color: #d8d1d7;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.field input {
    width: 100%;
    min-height: 58px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    color: var(--ink);
    background: rgba(5, 5, 7, 0.58);
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.field input::placeholder {
    color: #6f6870;
}

.field input:focus {
    border-color: rgba(233, 185, 73, 0.7);
    background: rgba(10, 9, 12, 0.9);
    box-shadow: 0 0 0 4px rgba(233, 185, 73, 0.08);
    outline: none;
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 72px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    min-width: 52px;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    color: var(--gold-pale);
    background: transparent;
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
}

.form-message {
    min-height: 24px;
    margin: -2px 0 12px;
    font-size: 14px;
}

.form-message[data-type="error"] {
    color: var(--danger);
}

.menu-button {
    position: relative;
    width: 100%;
    min-height: 82px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 15px;
    align-items: center;
    padding: 14px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    color: var(--ink);
    text-align: left;
    background:
        linear-gradient(100deg, rgba(255,255,255,.035), transparent 55%),
        rgba(23, 21, 27, 0.88);
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.menu-button:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(233, 185, 73, 0.5);
    background:
        linear-gradient(100deg, rgba(233,185,73,.08), transparent 55%),
        rgba(30, 27, 33, 0.96);
    box-shadow: 0 16px 35px rgba(0,0,0,.22);
}

.menu-button:active:not(:disabled) {
    transform: translateY(0);
}

.menu-button:disabled {
    opacity: .7;
    cursor: wait;
}

.menu-button-primary {
    border-color: rgba(255, 49, 88, 0.72);
    background:
        linear-gradient(100deg, rgba(255,255,255,.08), transparent 52%),
        linear-gradient(135deg, var(--red), var(--red-dark));
    box-shadow: 5px 5px 0 rgba(233, 185, 73, 0.88);
}

.menu-button-primary:hover:not(:disabled) {
    border-color: var(--gold-pale);
    background:
        linear-gradient(100deg, rgba(255,255,255,.1), transparent 52%),
        linear-gradient(135deg, #ff3f63, #df183f);
    box-shadow: 5px 7px 0 rgba(233, 185, 73, 0.95), 0 18px 42px rgba(0,0,0,.26);
}

.menu-button-muted {
    opacity: .74;
}

.menu-button-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 11px;
    background: rgba(0,0,0,.18);
}

.menu-button-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu-button-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.menu-button-copy strong {
    font-size: 18px;
    font-weight: 950;
    letter-spacing: -0.025em;
    text-transform: uppercase;
}

.menu-button-copy small {
    color: rgba(247, 241, 230, 0.62);
    font-size: 13px;
}

.menu-button-primary .menu-button-copy small {
    color: rgba(255,255,255,.74);
}

.menu-button-arrow {
    color: var(--gold-pale);
    font-size: 28px;
    font-weight: 300;
}

.login-button {
    margin-top: 2px;
}

.auth-footer {
    position: relative;
    z-index: 1;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

.auth-footer a {
    color: var(--gold-pale);
    font-weight: 850;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.page-loading {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    color: var(--muted);
}

.menu-shell {
    width: min(1180px, calc(100% - 40px));
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand-lockup-compact .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 15px;
    box-shadow: 5px 5px 0 var(--gold);
}

.brand-lockup-compact .brand-copy strong {
    font-size: 18px;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.035);
}

.player-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #111015;
    background: var(--gold);
    font-weight: 950;
}

.player-chip-copy {
    min-width: 0;
    display: grid;
    line-height: 1.05;
}

.player-chip-copy small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.player-chip-copy strong {
    max-width: 210px;
    overflow: hidden;
    margin-top: 4px;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.menu-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
    gap: clamp(50px, 9vw, 120px);
    align-items: center;
    padding: 58px 0;
}

.menu-copy h1 {
    font-size: clamp(4rem, 8.7vw, 8rem);
}

.player-stats {
    display: flex;
    gap: 14px;
    margin-top: 34px;
}

.stat {
    min-width: 112px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
}

.stat strong,
.stat span {
    display: block;
}

.stat strong {
    color: var(--gold-pale);
    font-size: 26px;
    line-height: 1;
}

.stat span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.menu-actions {
    min-width: 0;
    display: grid;
    gap: 13px;
}

.menu-message {
    min-height: 20px;
    opacity: 0;
    transform: translateY(-3px);
    color: var(--gold-pale);
    font-size: 13px;
    line-height: 1.45;
    transition: opacity .16s ease, transform .16s ease;
}

.menu-message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.menu-footer {
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: #746e75;
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.text-button {
    padding: 7px 0;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    cursor: pointer;
}

.text-button:hover {
    color: var(--ink);
}

@media (max-width: 820px) {
    .auth-shell,
    .menu-content {
        grid-template-columns: 1fr;
    }

    .auth-shell {
        width: min(620px, calc(100% - 32px));
        align-content: center;
        gap: 34px;
        padding-top: max(24px, env(safe-area-inset-top));
    }

    .auth-intro {
        margin-top: 48px;
    }

    .auth-intro h1 {
        font-size: clamp(3.25rem, 14vw, 5.8rem);
    }

    .auth-intro p {
        max-width: 560px;
    }

    .menu-shell {
        width: min(680px, calc(100% - 32px));
    }

    .menu-content {
        gap: 38px;
        align-content: center;
        padding: 52px 0 42px;
    }

    .menu-copy h1 {
        max-width: 600px;
        font-size: clamp(3.8rem, 15vw, 6.3rem);
    }

    .menu-actions {
        width: min(100%, 560px);
    }
}

@media (max-width: 540px) {
    .game-page::before,
    .game-page::after {
        display: none;
    }

    .auth-shell,
    .menu-shell {
        width: min(100% - 24px, 580px);
    }

    .auth-shell {
        display: block;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }

    .auth-brand {
        padding-top: 4px;
    }

    .brand-mark {
        width: 48px;
        height: 48px;
        font-size: 15px;
        border-radius: 10px;
        box-shadow: 5px 5px 0 var(--gold);
    }

    .brand-copy strong {
        font-size: 18px;
    }

    .auth-intro {
        margin-top: 46px;
        margin-bottom: 34px;
    }

    .auth-intro h1 {
        margin-top: 15px;
        font-size: clamp(3.25rem, 18vw, 5rem);
    }

    .auth-intro p {
        font-size: 15px;
    }

    .auth-card {
        padding: 27px 20px 24px;
        border-radius: 16px;
    }

    .panel-heading h2 {
        font-size: 2.2rem;
    }

    .field input {
        min-height: 56px;
        font-size: 16px;
    }

    .menu-header {
        align-items: flex-start;
    }

    .brand-lockup-compact .brand-copy {
        display: none;
    }

    .player-chip-copy strong {
        max-width: 145px;
    }

    .menu-content {
        padding-top: 52px;
        gap: 32px;
    }

    .menu-copy h1 {
        margin-top: 14px;
        font-size: clamp(3.7rem, 18vw, 5.4rem);
    }

    .player-stats {
        margin-top: 25px;
    }

    .stat {
        flex: 1;
        min-width: 0;
    }

    .menu-button {
        min-height: 76px;
        grid-template-columns: 42px minmax(0, 1fr) auto;
        gap: 12px;
        padding: 12px 14px;
    }

    .menu-button-icon {
        width: 42px;
        height: 42px;
    }

    .menu-button-copy strong {
        font-size: 16px;
    }

    .menu-button-copy small {
        font-size: 12px;
    }

    .menu-footer {
        padding-bottom: 2px;
    }
}

@media (max-width: 385px) {
    .auth-intro h1,
    .menu-copy h1 {
        letter-spacing: -0.065em;
    }

    .menu-button-copy small {
        display: none;
    }

    .menu-button {
        min-height: 66px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Web game setup + lobby
   -------------------------------------------------------------------------- */

.menu-button {
    text-decoration: none;
}

.form-message.is-visible.is-error {
    color: var(--danger);
}

.form-message.is-visible.is-success {
    color: var(--success);
}

.field select,
.lobby-setting select {
    width: 100%;
    min-height: 58px;
    padding: 0 44px 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    color: var(--ink);
    background-color: rgba(5, 5, 7, 0.72);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--gold-pale) 50%),
        linear-gradient(135deg, var(--gold-pale) 50%, transparent 50%);
    background-position:
        calc(100% - 20px) 25px,
        calc(100% - 14px) 25px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    appearance: none;
    cursor: pointer;
}

.field select:focus,
.lobby-setting select:focus {
    border-color: rgba(233, 185, 73, 0.7);
    box-shadow: 0 0 0 4px rgba(233, 185, 73, 0.08);
    outline: none;
}

.field select:disabled,
.lobby-setting select:disabled {
    opacity: .72;
    cursor: default;
}

.setup-shell,
.lobby-shell,
.web-game-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 40px));
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
}

.simple-header,
.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.back-link {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-decoration: none;
    text-transform: uppercase;
}

.back-link:hover {
    color: var(--ink);
}

.setup-grid {
    min-height: calc(100dvh - 100px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, .72fr);
    gap: clamp(42px, 7vw, 100px);
    align-items: center;
    padding: 46px 0;
}

.setup-copy h1 {
    max-width: 760px;
    margin: 18px 0;
    font-size: clamp(3.8rem, 8.7vw, 7.7rem);
    line-height: .83;
    letter-spacing: -.075em;
    text-transform: uppercase;
}

.setup-copy p {
    max-width: 640px;
    margin: 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.4vw, 1.18rem);
    line-height: 1.65;
}

.setup-card .field {
    margin-top: 26px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 17px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.toggle-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.toggle-copy strong {
    font-size: 14px;
    font-weight: 950;
    letter-spacing: -.01em;
    text-transform: uppercase;
}

.toggle-copy small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.switch {
    position: relative;
    flex: 0 0 auto;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    position: relative;
    display: block;
    width: 52px;
    height: 30px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    transition: background .16s ease, border-color .16s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .16s ease, background .16s ease;
}

.switch input:checked + .switch-track {
    border-color: rgba(233, 185, 73, .7);
    background: rgba(233, 185, 73, .18);
}

.switch input:checked + .switch-track::after {
    transform: translateX(22px);
    background: var(--gold-pale);
}

.switch input:focus-visible + .switch-track {
    outline: 3px solid rgba(233, 185, 73, 0.58);
    outline-offset: 3px;
}

.switch input:disabled + .switch-track {
    opacity: .62;
}

.setup-note {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 0 18px;
    color: var(--muted);
    font-size: 12px;
}

.setup-note strong {
    color: var(--ink);
    text-transform: uppercase;
}

.join-code-field input {
    min-height: 92px;
    font-size: clamp(2.8rem, 10vw, 4.8rem);
    font-weight: 950;
    letter-spacing: .18em;
    text-align: center;
}

.lobby-shell {
    display: flex;
    flex-direction: column;
}

.lobby-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.lobby-code-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lobby-code-wrap small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.lobby-code {
    min-width: 116px;
    padding: 8px 14px;
    border: 1px solid rgba(233, 185, 73, .52);
    border-radius: 10px;
    color: var(--gold-pale);
    background: rgba(233, 185, 73, .07);
    font-size: 23px;
    font-weight: 950;
    letter-spacing: .16em;
    cursor: pointer;
}

.lobby-grid {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: clamp(30px, 5vw, 68px);
    align-items: start;
    padding: 48px 0 34px;
}

.lobby-title-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.lobby-title-row h1 {
    margin: 16px 0 0;
    max-width: 720px;
    font-size: clamp(3.2rem, 7vw, 6.2rem);
    line-height: .85;
    letter-spacing: -.07em;
    text-transform: uppercase;
}

.player-count {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 19px;
    font-weight: 900;
}

.player-count strong {
    color: var(--gold-pale);
    font-size: 34px;
}

.lobby-player-list {
    display: grid;
    gap: 11px;
    margin-top: 34px;
}

.lobby-player {
    min-height: 76px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255,255,255,.025);
}

.lobby-player.is-you {
    border-color: rgba(233, 185, 73, .34);
    background: rgba(233, 185, 73, .045);
}

.lobby-player-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 11px;
    background: rgba(255,255,255,.055);
    color: var(--gold-pale);
    font-weight: 950;
}

.lobby-player-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.lobby-player-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.lobby-player-copy strong span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.lobby-player-copy small {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.player-state {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.player-state.ready {
    border-color: rgba(130, 219, 154, .4);
    color: var(--success);
    background: rgba(130, 219, 154, .06);
}

.player-state.host {
    border-color: rgba(233, 185, 73, .45);
    color: var(--gold-pale);
    background: rgba(233, 185, 73, .07);
}

.player-state.offline {
    color: var(--danger);
}

.player-state.waiting {
    color: var(--muted);
}

.lobby-status {
    min-height: 24px;
    margin-top: 20px;
    color: var(--gold-pale);
    font-size: 13px;
}

.lobby-side {
    display: grid;
    gap: 14px;
}

.lobby-panel {
    padding: 22px;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 18px 50px rgba(0,0,0,.25);
}

.lobby-setting {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.lobby-setting > span {
    color: #d8d1d7;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.lobby-toggle {
    margin-top: 14px;
}

.settings-note {
    display: block;
    margin-top: 13px;
    color: #777079;
    line-height: 1.5;
}

.lobby-actions {
    display: grid;
    gap: 11px;
}

.resume-button {
    border-color: rgba(233, 185, 73, .42);
}

.game-shell-page {
    display: grid;
}

.web-game-shell {
    display: flex;
    flex-direction: column;
}

.game-stage-placeholder {
    flex: 1;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    padding: 50px 0;
}

.game-stage-placeholder h1 {
    max-width: 850px;
    margin: 18px auto;
    font-size: clamp(3.5rem, 8vw, 7rem);
    line-height: .84;
    letter-spacing: -.075em;
    text-transform: uppercase;
}

.game-stage-placeholder p {
    max-width: 700px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.65;
}

.countdown-number {
    margin: 22px 0 0;
    color: var(--gold-pale);
    font-size: clamp(7rem, 24vw, 14rem);
    font-weight: 950;
    line-height: .8;
    text-shadow: 7px 7px 0 rgba(255,49,88,.55);
}

.game-stage-meta {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 28px;
}

.game-stage-meta span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.game-stage-meta strong {
    color: var(--ink);
}

@media (max-width: 820px) {
    .setup-shell,
    .lobby-shell,
    .web-game-shell {
        width: min(680px, calc(100% - 32px));
    }

    .setup-grid,
    .lobby-grid {
        grid-template-columns: 1fr;
    }

    .setup-grid {
        align-content: center;
        gap: 34px;
        padding-top: 52px;
    }

    .setup-copy h1 {
        font-size: clamp(3.6rem, 15vw, 6.2rem);
    }

    .lobby-grid {
        gap: 30px;
    }

    .lobby-side {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .lobby-actions {
        align-self: stretch;
    }
}

@media (max-width: 540px) {
    .setup-shell,
    .lobby-shell,
    .web-game-shell {
        width: min(100% - 24px, 580px);
    }

    .simple-header .brand-copy,
    .lobby-header .brand-copy {
        display: none;
    }

    .setup-grid {
        min-height: auto;
        padding-top: 44px;
    }

    .setup-copy h1 {
        font-size: clamp(3.5rem, 18vw, 5rem);
    }

    .setup-card {
        padding: 27px 20px 24px;
    }

    .join-code-field input {
        min-height: 82px;
        font-size: 3.2rem;
    }

    .lobby-header {
        align-items: flex-start;
    }

    .lobby-code-wrap {
        display: grid;
        gap: 5px;
        justify-items: end;
    }

    .lobby-code {
        min-width: 104px;
        font-size: 20px;
    }

    .lobby-grid {
        padding-top: 34px;
    }

    .lobby-title-row {
        align-items: flex-start;
    }

    .lobby-title-row h1 {
        font-size: clamp(3.2rem, 16vw, 4.6rem);
    }

    .player-count {
        margin-top: 5px;
    }

    .lobby-player {
        grid-template-columns: 42px minmax(0, 1fr) auto;
        gap: 11px;
        padding: 10px 11px;
    }

    .lobby-player-avatar {
        width: 42px;
        height: 42px;
    }

    .player-state {
        max-width: 96px;
        text-align: center;
    }

    .lobby-side {
        grid-template-columns: 1fr;
    }

    .game-stage-placeholder h1 {
        font-size: clamp(3.3rem, 17vw, 5rem);
    }
}

/* ========================================================================== 
   Live web round engine
   ========================================================================== */

.live-game-page {
    overflow-x: hidden;
}

.live-game-shell {
    position: relative;
    z-index: 1;
    width: min(1320px, calc(100% - 34px));
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 0 max(22px, env(safe-area-inset-bottom));
}

.live-game-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
}

.live-game-meta {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.live-game-meta span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: rgba(0, 0, 0, .16);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.live-game-meta strong {
    color: var(--ink);
    font-size: 12px;
}

.starting-screen,
.final-screen {
    min-height: calc(100dvh - 112px);
    display: grid;
    justify-items: center;
    align-content: center;
    text-align: center;
    padding: 48px 0;
}

.starting-screen h1,
.final-screen h1 {
    margin: 18px 0 14px;
    font-size: clamp(3.5rem, 9vw, 7.6rem);
    line-height: .82;
    letter-spacing: -.075em;
    text-transform: uppercase;
}

.starting-screen p,
.final-screen > p {
    margin: 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
}

.round-screen {
    padding: 24px 0 10px;
}

.round-topline {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    align-items: center;
}

.round-topline > div:first-child {
    display: grid;
    gap: 9px;
}

.round-status-copy {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.round-timer {
    min-width: 74px;
    padding: 10px 13px;
    border: 1px solid rgba(233,185,73,.4);
    border-radius: 12px;
    color: var(--gold-pale);
    background: rgba(233,185,73,.08);
    text-align: center;
    font-size: 32px;
    font-weight: 950;
    line-height: 1;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
}

.round-timer.is-results {
    color: var(--ink);
    border-color: var(--line-strong);
    background: rgba(255,255,255,.05);
}

.scenario-card-web {
    position: relative;
    overflow: hidden;
    margin-top: 18px;
    min-height: 168px;
    padding: clamp(24px, 4vw, 42px);
    border: 1px solid rgba(233,185,73,.28);
    border-radius: 22px;
    background:
        linear-gradient(115deg, rgba(255,49,88,.10), transparent 45%),
        linear-gradient(135deg, rgba(31,27,34,.96), rgba(16,14,18,.97));
    box-shadow: var(--shadow);
}

.scenario-card-web::after {
    content: "SCENARIO";
    position: absolute;
    right: -8px;
    bottom: -20px;
    color: rgba(255,255,255,.025);
    font-size: clamp(5rem, 13vw, 10rem);
    font-weight: 950;
    letter-spacing: -.07em;
    pointer-events: none;
}

.scenario-category-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
    gap: 11px;
    flex-wrap: wrap;
}

.scenario-category-wrap span {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.scenario-category-wrap strong {
    color: var(--gold-pale);
    font-size: 15px;
    font-weight: 950;
    text-transform: uppercase;
}

.scenario-card-web p {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 17px 0 0;
    font-size: clamp(1.25rem, 2.5vw, 2.1rem);
    font-weight: 850;
    line-height: 1.22;
    letter-spacing: -.03em;
}

.active-round-panel,
.locked-panel,
.results-panel {
    margin-top: 18px;
}

.hand-heading,
.results-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 13px;
}

.hand-heading h2,
.results-heading h2,
.locked-panel h2 {
    margin: 5px 0 0;
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    line-height: 1;
    letter-spacing: -.045em;
    text-transform: uppercase;
}

.hand-count,
.results-next {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.staff-hand {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(8px, 1.3vw, 16px);
    align-items: end;
}

.staff-card-web {
    position: relative;
    min-width: 0;
    padding: 0;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 16px;
    overflow: hidden;
    color: var(--ink);
    background: #171419;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 14px 34px rgba(0,0,0,.34);
    transform: translateY(0);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.staff-card-web:hover {
    transform: translateY(-6px);
    border-color: rgba(233,185,73,.46);
}

.staff-card-web.is-selected {
    transform: translateY(-12px);
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(233,185,73,.35), 0 22px 48px rgba(0,0,0,.5);
}

.staff-card-web::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}

.staff-card-image {
    display: block;
    aspect-ratio: 80 / 33;
    overflow: hidden;
    background: #0c0a0d;
}

.staff-card-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.staff-card-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #5d565f;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: .15em;
}

.staff-card-body {
    display: grid;
    gap: 6px;
    padding: 11px 12px 12px;
}

.staff-card-rarity {
    color: var(--muted);
    font-size: 8px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.staff-card-body > strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(.9rem, 1.5vw, 1.15rem);
    letter-spacing: -.025em;
}

.staff-card-current-stat {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 8px;
    margin-top: 3px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.staff-card-current-stat small {
    overflow: hidden;
    color: var(--muted);
    font-size: 8px;
    font-weight: 850;
    line-height: 1.15;
    text-transform: uppercase;
}

.staff-card-current-stat b {
    color: var(--gold-pale);
    font-size: clamp(1.45rem, 3vw, 2.1rem);
    line-height: .9;
}

.rarity-rare .staff-card-rarity { color: #92c8ff; }
.rarity-epic .staff-card-rarity { color: #d5a3ff; }
.rarity-legendary .staff-card-rarity { color: var(--gold-pale); }

.round-action-bar {
    margin-top: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, .48fr);
    gap: 14px;
    align-items: stretch;
}

.selected-summary {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
}

.selected-summary > span {
    color: var(--muted);
    font-size: 8px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.selected-summary strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.selected-summary small {
    color: var(--gold-pale);
    font-size: 11px;
}

.lock-card-button {
    min-height: 70px;
}

.locked-panel {
    min-height: 230px;
    display: grid;
    justify-items: center;
    align-content: center;
    padding: 34px 20px;
    border: 1px solid rgba(233,185,73,.24);
    border-radius: 18px;
    background: rgba(26,23,29,.82);
    text-align: center;
}

.locked-panel p {
    margin: 15px 0 7px;
    color: var(--muted);
}

.locked-panel p strong {
    color: var(--gold-pale);
    font-size: 3.4rem;
    line-height: 1;
}

.locked-panel p span {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.locked-panel > small {
    color: var(--muted);
}

.round-results-list,
.final-leaderboard {
    display: grid;
    gap: 8px;
}

.round-result-row {
    display: grid;
    grid-template-columns: 58px 68px minmax(0, 1fr) minmax(90px, auto) 72px;
    gap: 12px;
    align-items: center;
    min-height: 78px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(25,22,28,.82);
}

.round-result-row.is-you {
    border-color: rgba(255,49,88,.34);
}

.round-result-row.is-winner {
    border-color: rgba(233,185,73,.46);
    background: linear-gradient(90deg, rgba(233,185,73,.09), rgba(25,22,28,.86) 42%);
}

.result-place {
    color: var(--gold-pale);
    font-size: 17px;
    font-weight: 950;
    text-align: center;
    text-transform: uppercase;
}

.result-card-thumb {
    width: 68px;
    aspect-ratio: 80 / 33;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: #0d0b0e;
    font-size: 8px;
    font-weight: 900;
}

.result-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-player-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.result-player-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-player-copy strong span,
.final-score-row strong span {
    color: var(--red);
    font-size: .72em;
}

.result-player-copy small {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-value {
    display: grid;
    justify-items: end;
}

.result-value span {
    font-size: 24px;
    font-weight: 950;
}

.result-value small {
    color: var(--muted);
    font-size: 8px;
    font-weight: 850;
    text-transform: uppercase;
}

.result-points {
    color: var(--muted);
    font-size: 19px;
    font-weight: 950;
    text-align: right;
}

.result-points.has-points {
    color: var(--success);
}

.final-screen {
    max-width: 820px;
    margin: 0 auto;
}

.final-leaderboard {
    width: min(700px, 100%);
    margin-top: 30px;
}

.final-score-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 13px;
    align-items: center;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(25,22,28,.84);
    text-align: left;
}

.final-score-row.is-you {
    border-color: rgba(255,49,88,.35);
}

.final-score-row.is-winner {
    border-color: rgba(233,185,73,.48);
    background: rgba(233,185,73,.08);
}

.final-position {
    color: var(--gold-pale);
    font-size: 22px;
    font-weight: 950;
    text-align: center;
}

.final-score-row > div {
    min-width: 0;
    display: grid;
}

.final-score-row > div strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.final-score-row > div small {
    color: var(--muted);
    font-size: 10px;
}

.final-score-row > b {
    font-size: 25px;
}

.final-menu-button {
    width: min(460px, 100%);
    margin-top: 24px;
    text-decoration: none;
}

.live-game-error {
    min-height: 20px;
    margin: 13px 0 0;
    text-align: center;
}

@media (max-width: 850px) {
    .live-game-shell {
        width: min(720px, calc(100% - 24px));
    }

    .staff-hand {
        grid-template-columns: repeat(5, minmax(130px, 1fr));
        overflow-x: auto;
        overflow-y: visible;
        margin-inline: -12px;
        padding: 14px 12px 20px;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    .staff-card-web {
        scroll-snap-align: center;
    }

    .round-action-bar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .live-game-header {
        min-height: 60px;
    }

    .live-game-header .brand-copy {
        display: none;
    }

    .live-game-header .brand-mark {
        width: 44px;
        height: 44px;
        font-size: 14px;
        box-shadow: 4px 4px 0 var(--gold);
    }

    .live-game-meta {
        gap: 5px;
    }

    .live-game-meta span {
        padding: 6px 7px;
        font-size: 8px;
    }

    .live-game-meta strong {
        font-size: 10px;
    }

    .round-screen {
        padding-top: 16px;
    }

    .round-status-copy {
        max-width: 220px;
        font-size: 11px;
    }

    .round-timer {
        min-width: 58px;
        font-size: 26px;
    }

    .scenario-card-web {
        min-height: 145px;
        padding: 21px 18px;
    }

    .scenario-card-web p {
        font-size: clamp(1.08rem, 5vw, 1.45rem);
    }

    .hand-heading {
        align-items: center;
    }

    .hand-heading h2,
    .results-heading h2,
    .locked-panel h2 {
        font-size: 1.55rem;
    }

    .staff-hand {
        grid-template-columns: repeat(5, minmax(145px, 68vw));
        gap: 10px;
    }

    .staff-card-body {
        padding: 10px;
    }

    .staff-card-body > strong {
        font-size: 1rem;
    }

    .round-result-row {
        grid-template-columns: 42px 54px minmax(0, 1fr) 52px;
        gap: 8px;
        min-height: 70px;
        padding: 8px;
    }

    .result-card-thumb {
        width: 54px;
    }

    .result-value {
        display: none;
    }

    .result-points {
        font-size: 16px;
    }

    .result-place {
        font-size: 14px;
    }

    .results-heading {
        align-items: center;
    }

    .results-next {
        max-width: 92px;
        text-align: right;
    }
}
