:root {
    color-scheme: dark;
    --bg: #081225;
    --panel: rgba(255, 255, 255, .09);
    --panel-strong: rgba(255, 255, 255, .14);
    --line: rgba(255, 255, 255, .17);
    --text: #f8fbff;
    --muted: #bfd0e8;
    --blue: #7dd3fc;
    --green: #86efac;
    --yellow: #fde68a;
    --red: #fda4af;
    --shadow: 0 24px 80px rgba(0, 0, 0, .35);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(125, 211, 252, .28), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(134, 239, 172, .20), transparent 28rem),
        linear-gradient(135deg, #07111f, #101b3a 52%, #111827);
    color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.noscript {
    padding: 18px;
    background: #7f1d1d;
    color: white;
    text-align: center;
    font-weight: 700;
}

.app-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 56px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-icon {
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: rgba(255,255,255,.12);
    border: 1px solid var(--line);
    font-size: 34px;
    box-shadow: var(--shadow);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 4rem); letter-spacing: -.04em; }
h2 { font-size: clamp(1.55rem, 3vw, 2.8rem); margin-bottom: .4rem; }
h3 { margin-bottom: .75rem; }
.eyebrow {
    margin-bottom: .25rem;
    color: var(--blue);
    font-weight: 800;
    text-transform: uppercase;
    font-size: .76rem;
    letter-spacing: .11em;
}

.server-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: var(--muted);
    white-space: nowrap;
    font-weight: 700;
}
.server-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #fbbf24;
    display: inline-block;
    box-shadow: 0 0 18px rgba(251, 191, 36, .7);
}
.server-pill.online .server-dot { background: #22c55e; box-shadow: 0 0 18px rgba(34,197,94,.8); }
.server-pill.offline .server-dot { background: #f87171; box-shadow: 0 0 18px rgba(248,113,113,.8); }

.screen {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}
.hidden { display: none !important; }

.start-screen {
    grid-template-columns: minmax(0, 1.25fr) minmax(310px, .75fr);
    align-items: stretch;
}
.hero-card, .info-card, .leaderboard-card, .end-card {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 32px;
    padding: clamp(20px, 3vw, 34px);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}
.hero-card {
    min-height: 520px;
    display: grid;
    place-items: center;
    text-align: center;
}
.hero-route {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2vw, 20px);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.hero-message {
    display: grid;
    place-items: center;
    width: clamp(72px, 10vw, 118px);
    height: clamp(72px, 10vw, 118px);
    border-radius: 30px;
    background: rgba(255,255,255,.14);
    border: 1px solid var(--line);
    font-size: clamp(2.7rem, 6vw, 5.3rem);
}
.hero-arrow { font-size: clamp(2.3rem, 5vw, 4.2rem); color: var(--yellow); }
.big-hint { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.35rem); margin-bottom: 22px; }

.name-row {
    display: inline-grid;
    grid-template-columns: auto minmax(180px, 260px);
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,255,255,.08);
}
.name-row.compact { margin: 14px auto 18px; }
.name-row label { color: var(--muted); font-weight: 800; padding-left: 8px; }
input {
    width: 100%;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.12);
    color: white;
    border-radius: 14px;
    padding: 11px 12px;
    outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(125,211,252,.16); }

.primary-action, .secondary-action, .repeat-button, .station-button {
    border: 0;
    border-radius: 22px;
    color: #081225;
    font-weight: 900;
    transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 220px;
    padding: 18px 26px;
    background: linear-gradient(135deg, var(--green), var(--blue));
    font-size: 1.35rem;
    box-shadow: 0 16px 46px rgba(125,211,252,.25);
}
.primary-action span:first-child { font-size: 1.9rem; }
.primary-action.small { min-width: 160px; padding: 14px 18px; font-size: 1rem; }
.secondary-action {
    padding: 12px 16px;
    background: rgba(255,255,255,.92);
    color: #0f172a;
}
.primary-action:hover, .secondary-action:hover, .repeat-button:hover, .station-button:hover { transform: translateY(-2px); filter: brightness(1.04); }
.primary-action:active, .secondary-action:active, .repeat-button:active, .station-button:active { transform: translateY(1px) scale(.99); }

.picture-rules {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.picture-rules span {
    min-width: 46px;
    min-height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(255,255,255,.10);
    border: 1px solid var(--line);
    font-size: 1.85rem;
}

.info-card dl { margin: 0; display: grid; gap: 12px; }
.info-card div { padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.09); }
dt { color: var(--muted); font-weight: 900; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
dd { margin: 3px 0 0; line-height: 1.45; }
code { color: var(--yellow); }
details { margin-top: 18px; }
summary { cursor: pointer; font-weight: 900; color: var(--blue); }
.api-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; padding: 0 !important; border: 0 !important; }
.api-row button { border: 0; border-radius: 14px; padding: 10px 12px; font-weight: 900; }

.game-screen {
    grid-template-rows: auto auto auto auto;
    gap: 16px;
}
.game-hud {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.hud-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 72px;
    border-radius: 24px;
    background: rgba(255,255,255,.10);
    border: 1px solid var(--line);
    font-size: clamp(1.2rem, 3vw, 2rem);
    box-shadow: var(--shadow);
}
.hud-box span { font-size: 1.5em; }

.track-wrap {
    position: relative;
    min-height: 86px;
    display: grid;
    align-items: center;
}
.track {
    position: relative;
    height: 64px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    overflow: hidden;
}
.rail {
    position: absolute;
    inset: 50% 18px auto 18px;
    height: 6px;
    border-radius: 999px;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,.4) 0 18px, transparent 18px 30px);
    transform: translateY(-50%);
}
.train {
    position: absolute;
    top: 50%;
    left: 3%;
    transform: translateY(-50%);
    font-size: 2.8rem;
    filter: drop-shadow(0 8px 10px rgba(0,0,0,.25));
    animation: train-bob .72s ease-in-out infinite alternate;
}
@keyframes train-bob { from { transform: translateY(-52%) rotate(-1deg); } to { transform: translateY(-48%) rotate(1deg); } }
.feedback-bubble {
    position: absolute;
    right: 18px;
    top: -10px;
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 26px;
    background: rgba(255,255,255,.16);
    border: 1px solid var(--line);
    font-size: 2.4rem;
    box-shadow: var(--shadow);
}
.feedback-bubble.pop { animation: pop .32s ease; }
@keyframes pop { 0% { transform: scale(.88); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

.signal-zone {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 14px;
    align-items: stretch;
}
.signal-card {
    min-height: clamp(220px, 34vh, 330px);
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 34px;
    background:
        radial-gradient(circle at top left, rgba(253, 230, 138, .25), transparent 34%),
        rgba(255,255,255,.12);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.signal-label {
    position: absolute;
    left: 22px;
    top: 18px;
    font-size: 2.1rem;
    opacity: .86;
}
.signal-main {
    position: relative;
    z-index: 2;
    font-size: clamp(6rem, 17vw, 12rem);
    line-height: 1;
    filter: drop-shadow(0 16px 24px rgba(0,0,0,.34));
    transition: transform .16s ease, filter .16s ease;
}
.signal-card.noise-1 .signal-main { filter: blur(.5px) drop-shadow(0 16px 24px rgba(0,0,0,.34)); }
.signal-card.noise-2 .signal-main { filter: blur(1.2px) saturate(.9) drop-shadow(0 16px 24px rgba(0,0,0,.34)); }
.signal-card.noise-3 .signal-main { filter: blur(2.3px) saturate(.75) drop-shadow(0 16px 24px rgba(0,0,0,.34)); transform: rotate(-2deg); }
.signal-ghost {
    position: absolute;
    right: 9%;
    bottom: 8%;
    z-index: 1;
    font-size: clamp(3rem, 8vw, 5rem);
    opacity: .26;
    filter: blur(.6px);
}
.noise-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.noise-particles span {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-size: var(--s);
    opacity: .55;
    animation: drift var(--d) linear infinite alternate;
}
@keyframes drift { from { transform: translate(-8px, -4px) rotate(-8deg); } to { transform: translate(10px, 9px) rotate(10deg); } }

.repeat-button {
    min-width: 114px;
    padding: 18px;
    background: linear-gradient(135deg, var(--yellow), #fdba74);
    font-size: clamp(2.7rem, 6vw, 5.5rem);
    box-shadow: var(--shadow);
}

.destination-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 12px;
}
.station-button {
    min-height: clamp(128px, 18vh, 184px);
    padding: 12px;
    border: 1px solid rgba(255,255,255,.18);
    background: linear-gradient(160deg, rgba(255,255,255,.96), rgba(255,255,255,.78));
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
    gap: 4px;
}
.station-emoji { font-size: clamp(3.6rem, 8vw, 6.3rem); line-height: 1; }
.station-label { color: #172554; font-weight: 1000; font-size: clamp(.85rem, 1.8vw, 1.15rem); }
.station-button.correct { outline: 6px solid rgba(134,239,172,.75); transform: scale(1.02); }
.station-button.wrong { outline: 6px solid rgba(253,164,175,.78); animation: shake .28s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.end-screen { place-items: center; }
.end-card { width: min(720px, 100%); text-align: center; }
.end-emoji { font-size: clamp(4rem, 12vw, 8rem); margin-bottom: 4px; }
.final-score {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    border-radius: 24px;
    background: rgba(255,255,255,.12);
    border: 1px solid var(--line);
    font-size: clamp(2rem, 5vw, 4rem);
    margin: 10px 0;
}
.final-score span { font-size: .9em; }
.action-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.sync-info { margin-top: 14px; color: var(--muted); }

.leaderboard-card { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin-bottom: 0; }
.leaderboard-source { color: var(--muted); margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.12); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; }
td { font-weight: 750; }
.rank-medal { font-size: 1.4rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

@media (max-width: 850px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .start-screen { grid-template-columns: 1fr; }
    .destination-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
    .signal-zone { grid-template-columns: 1fr; }
    .repeat-button { min-height: 88px; font-size: 3rem; }
    .game-hud { grid-template-columns: 1fr; }
    .section-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
    .app-shell { width: min(100% - 16px, 1180px); padding-top: 10px; }
    .hero-card, .info-card, .leaderboard-card, .end-card { border-radius: 22px; }
    .destination-grid { gap: 8px; }
    .station-button { min-height: 118px; border-radius: 18px; }
    .name-row { grid-template-columns: 1fr; text-align: left; width: 100%; }
}
