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

:root {
    --bg:      #e8f4f8;
    --surface: #ffffff;
    --border:  rgba(0,0,0,0.08);
    --accent:  #2a9d5c;
    --accent2: #1a7fc4;
    --text:    #1a1f2e;
    --dim:     rgba(26,31,46,0.5);
    --card-r:  16px;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

.hidden { display: none !important; }
.dim    { color: var(--dim); }
.small  { font-size: 12px; }

/* ── Screens ── */
.screen {
    position: fixed; inset: 0;
    display: flex; justify-content: center; align-items: center;
    z-index: 50;
    background: var(--bg);
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-r);
    padding: 36px 40px;
    min-width: 340px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.card.wide { min-width: 440px; }

/* ── Lobby ── */
.logo {
    font-size: 42px; font-weight: 800;
    letter-spacing: -1px;
    color: var(--accent);
    margin-bottom: 28px;
}

#lobbyStatus { font-size: 14px; margin-bottom: 18px; }

.player-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 20px; min-height: 44px;
}
.player-item {
    padding: 9px 14px;
    background: rgba(0,0,0,0.04);
    border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px;
    text-align: left; display: flex; align-items: center; gap: 8px;
}
.player-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Fill-window bar */
.fill-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 13px; margin-bottom: 6px; color: var(--dim);
}
.fill-num { font-size: 20px; font-weight: 800; color: var(--accent); }
.fill-bar-track {
    height: 6px; background: rgba(0,0,0,0.08);
    border-radius: 99px; overflow: hidden;
}
.fill-bar {
    height: 100%; width: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width 1s linear;
}

/* ── Countdown ── */
#countdown { flex-direction: column; gap: 12px; }
.countdown-text {
    font-size: 140px; font-weight: 900;
    color: var(--accent);
    line-height: 1;
    animation: cpulse 0.85s ease-in-out infinite;
}
.countdown-maze { font-size: 18px; color: var(--dim); letter-spacing: 0.04em; }
@keyframes cpulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

/* ── Game ── */
#gameContainer { width:100vw; height:100vh; position:relative; }
#gameCanvas    { display:block; width:100%; height:100%; }

/* ── HUD ── */
#hud {
    position: absolute; top: 18px; left: 18px;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex; flex-direction: column; gap: 4px;
    min-width: 160px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.hud-round { font-size: 11px; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; }
.hud-maze  { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.hud-timer { font-size: 28px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.hud-pb    { font-size: 11px; color: var(--dim); min-height: 14px; }
.hud-keys  { font-size: 10px; color: var(--dim); margin-top: 6px; }
#tiltIndicator { margin-top: 8px; }

#placeTag {
    position: absolute; top: 18px; right: 18px;
    font-size: 22px; font-weight: 800;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 18px;
    display: none;
    color: var(--text);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ── Scoreboard ── */
.sb-round  { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.sb-result { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 20px; }

.sb-table  { width:100%; border-collapse:collapse; font-size:14px; }
.sb-table th { color:var(--dim); font-size:11px; text-transform:uppercase; letter-spacing:0.08em; padding:6px 10px; border-bottom:1px solid var(--border); }
.sb-table td { padding:10px; border-bottom:1px solid var(--border); }
.sb-table tr:last-child td { border-bottom:none; }
.sb-table .rank-1 td:first-child { color:#c8a000; font-weight:700; }
.sb-table .rank-2 td:first-child { color:#888; font-weight:700; }
.sb-table .rank-3 td:first-child { color:#a0522d; font-weight:700; }
.sb-table .is-me  { background:rgba(42,157,92,0.07); }

.final-title { font-size:32px; font-weight:800; margin-bottom:24px; color:var(--text); }

/* ── Buttons ── */
.btn-primary {
    display: inline-block; padding: 12px 28px;
    background: var(--accent); color: #fff;
    font-size: 15px; font-weight: 700;
    border: none; border-radius: 8px; cursor: pointer;
    width: 100%; margin-top: 8px;
    transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover  { background: #228a4e; }
.btn-primary:active { transform: scale(0.97); }

code {
    background: rgba(0,0,0,0.06);
    padding: 2px 7px; border-radius: 4px;
    font-family: monospace; font-size: 11px;
}
