:root {
    color-scheme: dark;
    --bg-deep: #11151c;
    --bg-mid: #2a1820;
    --brand-red: #8e1027;
    --brand-red-dark: #5e0b1b;
    --gold: #f2c94c;
    --gold-dark: #c99b23;
    --surface: rgba(44, 47, 53, 0.94);
    --surface-border: rgba(255, 255, 255, 0.12);
    --input: #494b50;
    --input-border: #777a80;
    --text: #f7f7f5;
    --muted: #c1c2c5;
    --danger: #ff9c9c;
    --success: #9be3bd;
    --focus: #8fcfff;
    --shadow: 0 22px 55px rgba(0, 0, 0, 0.34);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-deep);
}

body {
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

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

button {
    color: inherit;
}

.auth-page {
    overflow-x: hidden;
    background:
        radial-gradient(circle at 50% -18%, rgba(181, 28, 54, 0.84) 0, rgba(126, 13, 35, 0.83) 29%, rgba(53, 23, 31, 0.9) 57%, transparent 78%),
        linear-gradient(180deg, #52101f 0%, #23191f 50%, #11151c 78%);
    background-attachment: fixed;
}

.auth-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: min(100%, 540px);
    min-height: calc(100svh - 38px);
    margin: 0 auto;
    padding: 22px 18px 30px;
}

.brand {
    display: grid;
    place-items: center;
    width: 100%;
    margin-bottom: 14px;
    filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.35));
    animation: brand-arrival 620ms cubic-bezier(.2, .85, .25, 1) both;
}

.brand img {
    display: block;
    width: clamp(138px, 29vw, 205px);
    height: auto;
    max-height: 250px;
    object-fit: contain;
}

.auth-card {
    width: min(100%, 430px);
    padding: 26px 30px 22px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    animation: card-arrival 500ms 80ms cubic-bezier(.2, .85, .25, 1) both;
}

.card-header {
    margin-bottom: 22px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--gold);
    font-size: .71rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(1.45rem, 5vw, 1.82rem);
    line-height: 1.2;
}

label {
    display: block;
    margin: 0 0 7px;
    color: #e6e6e4;
    font-size: .82rem;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    color: var(--text);
    background: var(--input);
    border: 1px solid var(--input-border);
    border-radius: 5px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input::placeholder {
    color: #c6c6c9;
}

input:focus,
select:focus {
    background: #51535a;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(86, 174, 232, 0.18);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #ddd 50%), linear-gradient(135deg, #ddd 50%, transparent 50%);
    background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
    background-repeat: no-repeat;
    background-size: 5px 5px, 5px 5px;
}

.phone-field,
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.phone-field > span {
    position: absolute;
    left: 12px;
    z-index: 1;
    color: #f3f3f3;
    font-size: .85rem;
    font-weight: 800;
    pointer-events: none;
}

.phone-field input {
    padding-left: 54px;
}

.password-field input {
    padding-right: 54px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    padding: 8px 5px;
    color: var(--gold);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.field-hint,
.field-error {
    min-height: 17px;
    margin: 5px 0 7px;
    font-size: .72rem;
    line-height: 1.35;
}

.field-hint {
    color: var(--muted);
}

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

.field-error--server {
    min-height: auto;
    padding: 8px 10px;
    background: rgba(179, 37, 57, 0.18);
    border-left: 3px solid #e76173;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 900;
    letter-spacing: .045em;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.button:hover {
    filter: brightness(1.06);
}

.button:active {
    transform: translateY(1px);
}

.button:focus-visible,
.back-button:focus-visible,
.auth-switch button:focus-visible,
.password-toggle:focus-visible {
    outline: 3px solid rgba(143, 207, 255, .42);
    outline-offset: 2px;
}

.button--primary {
    width: 100%;
    margin-top: 8px;
    color: #2a210c;
    background: linear-gradient(180deg, #f7d767, var(--gold-dark));
    border: 1px solid #f2d269;
    box-shadow: 0 8px 18px rgba(201, 155, 35, 0.15);
}

.button--ghost {
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255,255,255,.26);
}

.back-button {
    margin: -7px 0 14px;
    padding: 3px 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: .76rem;
    font-weight: 700;
}

.phone-summary {
    margin: 0 0 14px;
    color: var(--gold);
    font-size: .83rem;
    font-weight: 800;
}

.auth-switch {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px 8px;
    margin-top: 24px;
    padding-top: 19px;
    color: var(--muted);
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .8rem;
}

.auth-switch button {
    padding: 0;
    color: var(--gold);
    background: none;
    border: 0;
    border-bottom: 1px solid currentColor;
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-view.is-entering,
.form-step.is-entering {
    animation: panel-slide 260ms ease both;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

.form-grid__wide {
    grid-column: 1 / -1;
}

.progress {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-top: 14px;
}

.progress span {
    width: 31px;
    height: 3px;
    background: rgba(255,255,255,.16);
    transition: background 200ms ease;
}

.progress span.is-active {
    background: var(--gold);
}

.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 9px;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.45;
}

.checkbox-field input {
    flex: 0 0 17px;
    width: 17px;
    min-height: 17px;
    margin: 2px 0 0;
    accent-color: var(--gold-dark);
}

.notice {
    margin: 0 0 16px;
    padding: 9px 11px;
    border-left: 3px solid;
    font-size: .78rem;
    line-height: 1.4;
}

.notice--success {
    color: var(--success);
    background: rgba(45, 144, 92, .13);
    border-color: #47bb7e;
}

.notice--error {
    color: var(--danger);
    background: rgba(179, 37, 57, .18);
    border-color: #e76173;
}

.legal-footer {
    min-height: 38px;
    padding: 0 16px max(10px, env(safe-area-inset-bottom));
    color: rgba(255,255,255,.54);
    font-size: .68rem;
    letter-spacing: .03em;
    text-align: center;
}

.dashboard-page {
    background: linear-gradient(155deg, #751124, #17191f 58%);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 10px clamp(18px, 4vw, 50px);
    background: rgba(18, 19, 23, .74);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.topbar img {
    width: 46px;
    height: 58px;
    object-fit: contain;
}

.dashboard-shell {
    display: grid;
    place-items: center;
    min-height: calc(100svh - 72px);
    padding: 24px;
}

.welcome-card {
    width: min(100%, 560px);
    padding: clamp(25px, 6vw, 45px);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
}

.welcome-card p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.65;
}

.player-code {
    display: inline-block;
    margin-top: 12px;
    padding: 7px 12px;
    color: var(--gold);
    background: rgba(242,201,76,.09);
    border: 1px solid rgba(242,201,76,.2);
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 800;
}

.error-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(160deg, #731124, #11151c 65%);
    text-align: center;
}

.error-page main {
    width: min(100%, 440px);
    padding: 38px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
}

.error-page main > span {
    color: var(--gold);
    font-size: 3rem;
    font-weight: 900;
}

.error-page p {
    color: var(--muted);
}

.error-page pre {
    overflow: auto;
    padding: 10px;
    color: var(--danger);
    background: #191b20;
    font-size: .72rem;
    text-align: left;
}

@keyframes brand-arrival {
    from { opacity: 0; transform: translateY(-12px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes card-arrival {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes panel-slide {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 520px) {
    .auth-shell {
        justify-content: flex-start;
        padding: 12px 12px 24px;
    }

    .brand {
        margin-bottom: 8px;
    }

    .brand img {
        width: 122px;
        max-height: 190px;
    }

    .auth-card {
        padding: 22px 19px 19px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid__wide {
        grid-column: auto;
    }
}

@media (max-height: 730px) and (min-width: 521px) {
    .auth-shell {
        justify-content: flex-start;
        padding-top: 10px;
    }

    .brand img {
        width: 115px;
        max-height: 185px;
    }

    .brand {
        margin-bottom: 4px;
    }

    .auth-card {
        padding-top: 21px;
    }
}

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

