/**
 * Last War: Survival Game — Train Driver Lottery
 * Game-style UI (lastwar.com): hero cards, military palette, train theme
 */

:root {
    /* Last War–style: dark slate/blue-grey base */
    --bg-page: #0a0d14;
    --bg-header: #0d1119;
    --bg-panel: #141a24;
    --bg-card: #1a2230;
    --bg-card-elevated: #1e2836;
    /* Borders & surfaces */
    --border: #2d3748;
    --border-light: #3d4a5c;
    /* Gold for winner / premium (game rarity style) */
    --gold: #d4a84b;
    --gold-bright: #f0c14b;
    --gold-dim: #9a7b3a;
    /* Accent: action/CTA (game button style) */
    --accent: #c93c2a;
    --accent-hover: #e04a36;
    /* Text */
    --text: #e2e8f0;
    --text-dim: #8b9bb4;
    --text-muted: #5c6b82;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Share Tech', sans-serif;
    background: var(--bg-page);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 100% 60% at 50% -10%, rgba(26, 34, 48, 0.9), transparent 50%),
        linear-gradient(180deg, var(--bg-page) 0%, #0e121a 30%, #0a0d14 100%);
}

/* ----- Header (lastwar.com style) ----- */
.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-block {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.logo-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-item {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.nav-item--active {
    color: var(--text);
    font-weight: 700;
}

/* ----- Main content ----- */
.main {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    position: relative;
}

/* Rail tracks (train theme) */
.rail {
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        var(--border) 0,
        var(--border) 8px,
        transparent 8px,
        transparent 16px
    );
    margin: 1.5rem 0;
    opacity: 0.6;
}

.rail--top { margin-top: 0; }
.rail--bottom { margin-bottom: 0; }

/* ----- Hero section ----- */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
}

.page-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    color: var(--text);
    letter-spacing: 0.03em;
    margin-bottom: 0.35rem;
}

.page-tagline {
    font-size: 1rem;
    color: var(--text-dim);
}

.page-subtag {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ----- Winner card (hero card style like lastwar.com) ----- */
.winner-card {
    background: linear-gradient(165deg, var(--bg-card) 0%, var(--bg-panel) 100%);
    border: 2px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0;
    min-height: 180px;
}

.winner-card--has-winner {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 1px var(--gold-dim), 0 8px 24px rgba(0, 0, 0, 0.4);
}

.winner-card__badge {
    background: var(--bg-card-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    gap: 0.25rem;
}

.winner-card--has-winner .winner-card__badge {
    background: linear-gradient(180deg, rgba(212, 168, 75, 0.15) 0%, transparent 100%);
    border-right-color: var(--gold-dim);
}

.winner-card__type {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-dim);
}

.winner-card--has-winner .winner-card__type {
    color: var(--gold);
}

.winner-card__role {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.winner-card--has-winner .winner-card__role {
    color: var(--gold-bright);
}

.winner-card__portrait {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2rem;
}

.winner-card__portrait-inner {
    text-align: center;
    width: 100%;
}

.winner-card__name {
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: clamp(1.75rem, 4.5vw, 3rem);
    display: block;
    color: var(--gold-bright);
    text-shadow: 0 0 24px rgba(240, 193, 75, 0.35);
    line-height: 1.15;
    margin-bottom: 0.35rem;
}

.winner-card__name--empty {
    color: var(--text-muted);
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    text-shadow: none;
}

.winner-card__label {
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold-dim);
    display: block;
    margin-bottom: 0.25rem;
}

.winner-card:not(.winner-card--has-winner) .winner-card__label {
    color: var(--text-muted);
}

.winner-card__date {
    font-size: 0.9rem;
    color: var(--text-dim);
}

@media (max-width: 480px) {
    .winner-card {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .winner-card__badge {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        gap: 0.5rem;
    }

    .winner-card--has-winner .winner-card__badge {
        border-bottom-color: var(--gold-dim);
    }
}

/* ----- Panel (form / game UI panel) ----- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
}

.panel__title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    width: 100%;
    flex-wrap: wrap;
}

.panel__title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* UID help (? button + modal) */
.uid-help {
    position: relative;
    margin-left: auto;
}

.uid-help__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    color: var(--gold);
    background: rgba(212, 168, 75, 0.2);
    border: 1px solid var(--gold-dim);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}

.uid-help__trigger:hover {
    background: rgba(212, 168, 75, 0.4);
    color: var(--gold-bright);
    transform: scale(1.05);
}

.uid-help__backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.65);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.uid-help__backdrop[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.uid-help__popover {
    position: fixed;
    z-index: 101;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: calc(100% - 2rem);
    max-width: 420px;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.uid-help__popover[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.uid-help__inner {
    overflow-y: auto;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.uid-help__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.uid-help__title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    margin: 0;
    letter-spacing: 0.02em;
}

.uid-help__close {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-dim);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

.uid-help__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.uid-help__intro {
    font-size: 0.95rem;
    color: var(--text-dim);
    line-height: 1.45;
    margin: 0 0 1.25rem 0;
}

.uid-help__steps {
    list-style: none;
    margin: 0;
    padding: 0;
}

.uid-help__step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.uid-help__step:last-child {
    margin-bottom: 0;
}

.uid-help__step-num {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--bg-page);
    background: var(--gold);
    border-radius: 50%;
}

.uid-help__step-content {
    flex: 1;
    min-width: 0;
}

.uid-help__step-content p {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.45;
}

.uid-help__step-content p:last-child {
    margin-bottom: 0;
}

.uid-help__img-wrap {
    min-height: 120px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-page);
    overflow: hidden;
}

.uid-help__img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.uid-help__outro {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin: 1.25rem 0 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
    .panel__title-row {
        justify-content: space-between;
        gap: 0.75rem;
    }

    .uid-help {
        margin-left: 0;
    }

    .uid-help__trigger {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.15rem;
    }

    /* Full-screen modal on small screens (no clipping) */
    .uid-help__popover {
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        max-height: none;
        transform: none;
        border-radius: 0;
    }

    .uid-help__popover[aria-hidden="false"] {
        transform: none;
    }

    .uid-help__inner {
        padding: 0 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .uid-help__head {
        position: sticky;
        top: 0;
        background: var(--bg-panel);
        padding: calc(1rem + env(safe-area-inset-top, 0px)) 0 0.75rem 0;
        margin: 0 0 0.75rem 0;
        border-bottom: 1px solid var(--border);
        z-index: 1;
    }

    .uid-help__step {
        padding: 0.85rem;
        gap: 0.85rem;
    }

    .uid-help__step-num {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.85rem;
    }

    .uid-help__close {
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.6rem;
    }
}

.panel__desc {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 1.25rem;
}

.rules-note {
    margin-top: 0.85rem;
}

.rules-note__text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rules-note__toggle {
    border: none;
    background: none;
    padding: 0;
    color: var(--gold);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.rules-note__toggle:hover {
    color: var(--gold-bright);
}

.rules-note__content {
    margin-top: 0.55rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 4px;
}

.rules-note__content[aria-hidden="true"] {
    display: none;
}

.rules-note__list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-dim);
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ----- Form ----- */
.ticket-form .form-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.input {
    flex: 1;
    min-width: 180px;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
}

.input::placeholder {
    color: var(--text-muted);
}

.input:focus {
    outline: none;
    border-color: var(--border-light);
    box-shadow: 0 0 0 2px rgba(45, 55, 72, 0.5);
}

.btn {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn--primary {
    background: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* ----- Messages ----- */
.msg {
    padding: 0.65rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.msg--success {
    background: rgba(45, 72, 56, 0.4);
    border: 1px solid #2d4838;
    color: #8fbc9a;
}

.msg--error {
    background: rgba(72, 45, 45, 0.4);
    border: 1px solid #482d2d;
    color: #bc8f8f;
}

/* ----- Recent drivers ----- */
.recent-drivers.panel {
    padding: 1.5rem 1.75rem;
}

.recent-drivers .panel__title {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.04em;
}

.recent-drivers__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recent-drivers__item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    border-left: 3px solid var(--border-light);
    transition: border-color 0.15s, background 0.15s;
}

.recent-drivers__item:hover {
    background: var(--bg-card-elevated);
    border-color: var(--border-light);
}

.recent-drivers__item:first-child {
    border-left-color: var(--gold);
    background: linear-gradient(90deg, rgba(212, 168, 75, 0.08) 0%, var(--bg-card) 100%);
}

.recent-drivers__item:first-child:hover {
    background: linear-gradient(90deg, rgba(212, 168, 75, 0.12) 0%, var(--bg-card-elevated) 100%);
}

.recent-drivers__rank {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 1.5rem;
    flex-shrink: 0;
}

.recent-drivers__item:first-child .recent-drivers__rank {
    color: var(--gold);
}

.recent-drivers__name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
}

.recent-drivers__item:first-child .recent-drivers__name {
    color: var(--gold-bright);
}

.recent-drivers__date {
    font-size: 0.8rem;
    color: var(--text-dim);
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.recent-drivers__item:first-child .recent-drivers__date {
    color: var(--gold-dim);
}

/* ----- Depot stats ----- */
.depot-stats {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.depot-stats__line {
    margin: 0 0 0.35rem 0;
}

.depot-stats__hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.depot-stats__hint + .depot-stats__hint {
    margin-top: 0.35rem;
}

.depot-stats__item strong {
    color: var(--gold);
    font-weight: 700;
}

.depot-stats__hint strong {
    color: var(--gold);
    font-weight: 700;
}

.depot-stats__sep {
    margin: 0 0.5rem;
    color: var(--text-muted);
}

/* ----- Footer ----- */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-header);
}
