/* BeatBrawl — neon rhythm-battle theme */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0b0713;
    --panel: #171126;
    --panel-2: #1f1733;
    --text: #ece7f7;
    --muted: #8f86a8;
    --accent: #b14dff;
    --accent-2: #4dd2ff;
    --easy: #7dff4d;
    --medium: #ffd24d;
    --hard: #ff9a4d;
    --expert: #ff4d6d;
}

html, body { height: 100%; }

body {
    background: radial-gradient(1200px 600px at 50% -10%, #241344 0%, var(--bg) 60%);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; }

h1, h2, h3 { font-weight: 700; }
h2 { margin-bottom: 12px; }
h3 { margin: 16px 0 8px; color: var(--muted); }

.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

.game-title {
    font-size: clamp(2rem, 7vw, 3.2rem);
    text-align: center;
    margin: 24px 0 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline { text-align: center; color: var(--muted); margin-bottom: 24px; }

/* ── Buttons / forms ─────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid #372a55;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: linear-gradient(90deg, var(--accent), #7a2ff0);
    border: none;
    font-weight: 700;
}
.btn-large { font-size: 18px; padding: 14px 34px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

input[type="text"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid #372a55;
    border-radius: 8px;
    color: var(--text);
    padding: 11px 12px;
    font-size: 16px; /* prevents iOS zoom */
    margin-bottom: 10px;
}
input[type="text"]:focus { outline: 2px solid var(--accent); border-color: transparent; }

.checkbox-label { display: block; margin: 8px 0 14px; color: var(--muted); font-size: 14px; }

.mode-pick { display: flex; gap: 8px; margin-bottom: 10px; }
.mode-option {
    flex: 1;
    background: var(--bg);
    border: 1px solid #372a55;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
}
.mode-option input { display: none; }
.mode-option:has(input:checked) {
    border-color: var(--accent);
    background: #241344;
}

.error-banner {
    background: #4a1220;
    border: 1px solid var(--expert);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 auto 18px;
    max-width: 640px;
    text-align: center;
}

/* ── Home ────────────────────────────────────────────────────────────────── */
.home-container, .lobby-container { max-width: 920px; margin: 0 auto; padding: 12px 16px 40px; }

.home-panels { display: flex; gap: 18px; margin-bottom: 18px; }
.home-panels .panel { flex: 1; }

.panel {
    background: var(--panel);
    border: 1px solid #241b3d;
    border-radius: 14px;
    padding: 20px;
}

.room-list { list-style: none; }
.room-list li {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid #241b3d;
    font-size: 14px;
}
.room-code { font-weight: 700; letter-spacing: 2px; color: var(--accent-2); }
.room-mode { color: var(--muted); }

.leaderboard-panel { margin-top: 0; }
.leaderboard { width: 100%; border-collapse: collapse; font-size: 14px; }
.leaderboard th, .leaderboard td { padding: 8px 10px; text-align: left; }
.leaderboard thead th { color: var(--muted); border-bottom: 1px solid #372a55; }
.leaderboard tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }

.diff-easy { color: var(--easy); }
.diff-medium { color: var(--medium); }
.diff-hard { color: var(--hard); }
.diff-expert { color: var(--expert); }

/* ── Lobby ───────────────────────────────────────────────────────────────── */
.lobby-container { text-align: center; }
.room-code-display {
    font-size: 20px;
    margin: 18px 0 6px;
}
.room-code-display .code {
    font-weight: 800;
    letter-spacing: 6px;
    color: var(--accent-2);
    margin: 0 6px;
}
.share-hint { color: var(--muted); margin-bottom: 22px; }

.player-list-section { max-width: 420px; margin: 0 auto 26px; }
.player-list { list-style: none; }
.player-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--panel);
    border: 1px solid #241b3d;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 8px;
    font-size: 16px;
}
.player-dot {
    width: 14px; height: 14px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
}
.host-badge {
    background: var(--accent);
    font-size: 11px; font-weight: 700;
    border-radius: 4px;
    padding: 2px 6px;
    margin-left: auto;
}
.waiting-msg { color: var(--muted); font-size: 17px; margin-top: 10px; }
.start-hint { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ── Game ────────────────────────────────────────────────────────────────── */
#game-wrap {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}

#top-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px;
    background: rgba(11,7,19,0.85);
    border-bottom: 1px solid #241b3d;
    z-index: 5;
}
.song-label { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.room-chip {
    font-size: 12px; letter-spacing: 2px; font-weight: 700;
    color: var(--accent-2);
    border: 1px solid #372a55; border-radius: 6px;
    padding: 3px 8px;
}
#progress-track {
    flex: 1; height: 6px;
    background: var(--panel-2);
    border-radius: 3px;
    overflow: hidden;
}
#progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .2s linear;
}

#score-strip {
    display: flex; gap: 8px;
    padding: 6px 12px;
    overflow-x: auto;
    z-index: 5;
    flex-shrink: 0;
}
.score-chip {
    border: 1px solid;
    border-radius: 10px;
    background: rgba(23,17,38,0.9);
    padding: 4px 12px;
    min-width: 110px;
    flex-shrink: 0;
}
.score-chip.me { box-shadow: 0 0 10px rgba(177,77,255,0.35); }
.score-chip.dc { opacity: 0.4; }
.chip-name { font-size: 12px; font-weight: 700; display: block; }
.chip-score { font-size: 17px; font-weight: 800; display: block; }
.chip-sub { font-size: 11px; color: var(--muted); }

#game-canvas {
    flex: 1;
    min-height: 0;
    width: 100%;
    touch-action: none;
    display: block;
}

/* ── Overlays ────────────────────────────────────────────────────────────── */
.overlay {
    position: absolute; inset: 0;
    background: rgba(11,7,19,0.88);
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
    padding: 16px;
}
.overlay.hidden, .hidden { display: none !important; }

.overlay-card {
    background: var(--panel);
    border: 1px solid #372a55;
    border-radius: 16px;
    padding: 26px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
}
.overlay-card.wide { max-width: 640px; }

.diff-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.diff-pill {
    background: var(--bg);
    border: 1px solid #372a55;
    color: var(--text);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 14px;
    cursor: pointer;
}
.diff-pill.active.diff-easy { border-color: var(--easy); color: var(--easy); }
.diff-pill.active.diff-medium { border-color: var(--medium); color: var(--medium); }
.diff-pill.active.diff-hard { border-color: var(--hard); color: var(--hard); }
.diff-pill.active.diff-expert { border-color: var(--expert); color: var(--expert); }

.song-list { list-style: none; text-align: left; }
.song-item {
    background: var(--panel-2);
    border: 1px solid #372a55;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color .15s;
}
.song-item:hover { border-color: var(--accent); }
.song-name { display: block; font-weight: 700; }
.song-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.loading-players { list-style: none; margin-top: 14px; text-align: left; }
.loading-players li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }

/* The calibration overlay lives in base.html — fixed so it centers on
   scrolling pages (home/lobby) too. */
#calib-overlay { position: fixed; }

#calib-feedback {
    min-height: 30px;
    font-size: 24px;
    font-weight: 800;
}

#calib-pulse {
    width: 110px;
    height: 110px;
    margin: 18px auto;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--accent-2), var(--accent));
    box-shadow: 0 0 30px rgba(177, 77, 255, 0.5);
    transform: scale(0.55);
    opacity: 0.35;
}

.controls-hint {
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid #372a55;
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
}

.results-table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 15px; }
.results-table th, .results-table td { padding: 8px 10px; text-align: left; }
.results-table thead th { color: var(--muted); font-size: 12px; border-bottom: 1px solid #372a55; }
.results-table .counts { font-size: 12px; color: var(--muted); }
.results-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

#toast {
    position: absolute;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--panel-2);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 10px 18px;
    opacity: 0;
    pointer-events: none;
    transition: all .25s;
    z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .home-panels { flex-direction: column; }
    .leaderboard { font-size: 12px; }
    .leaderboard th, .leaderboard td { padding: 6px; }
    .song-label { max-width: 30%; font-size: 12px; }
}

.touch-device #view-toggle { font-size: 11px; }
