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

html, body {
    margin: 0; padding: 0;
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    overflow: hidden;
}

h1:focus { outline: none; }

/* ── Root: dark / light modes ───────────────────────────────────────────── */
.tv-root {
    width: 100vw; min-height: 100vh;
    position: relative;
    overflow: hidden;
    transition: background 0.4s, color 0.4s;
}
.tv-root.dark  { background: #0a0a1a; color: #f0f0f0; }
.tv-root.light { background: #f4f4f8; color: #111; }

/* ── Enter code screen ──────────────────────────────────────────────────── */
.enter-code {
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
}
.logo-area { margin-bottom: 1rem; }
.logo-emoji { font-size: 5rem; }
.enter-code h1 { font-size: 3.5rem; margin: 0; letter-spacing: -1px; }
.tagline { font-size: 1.2rem; opacity: 0.6; margin: 0; }
.enter-code input {
    font-size: 2.2rem; padding: 0.5rem 1.5rem;
    text-align: center; border-radius: 12px;
    border: 2px solid #444; background: #1a1a2e;
    color: #fff; letter-spacing: 0.3rem; text-transform: uppercase;
    outline: none; width: 320px;
}
.enter-code input:focus { border-color: #6366f1; }
.enter-code button {
    font-size: 1.4rem; padding: 0.7rem 2.5rem;
    border-radius: 12px; border: none;
    background: #6366f1; color: #fff; cursor: pointer;
    transition: background 0.2s;
}
.enter-code button:hover:not(:disabled) { background: #4f52d4; }
.enter-code button:disabled { opacity: 0.5; }
.enter-code .error { color: #f87171; font-size: 1rem; }

/* ── Lobby ──────────────────────────────────────────────────────────────── */
.lobby {
    min-height: 100vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2rem; padding: 2rem;
    text-align: center;
}
.lobby-header {
    position: absolute; top: 1.5rem; right: 1.5rem;
    display: flex; gap: 1rem; align-items: center;
}
.lobby-game-badge {
    font-size: 1.4rem; font-weight: bold;
    background: #1a1a2e; padding: 0.4rem 1.2rem;
    border-radius: 20px; border: 1px solid #333;
}
.dark-toggle {
    font-size: 1.5rem; background: none; border: none;
    cursor: pointer; line-height: 1;
}

.lobby-join-info {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.join-url { font-size: 1.6rem; opacity: 0.7; }
.join-code { display: flex; flex-direction: column; align-items: center; }
.code-label { font-size: 1rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.15rem; }
.code-value {
    font-size: 5rem; font-weight: 900;
    letter-spacing: 0.6rem; color: #ffd700;
    text-shadow: 0 0 40px rgba(255,215,0,0.4);
}

.lobby-players {
    display: flex; flex-wrap: wrap; gap: 1.5rem;
    justify-content: center; max-width: 900px;
}
.player-avatar-card {
    display: flex; flex-direction: column;
    align-items: center; gap: 0.5rem;
    animation: fadeInUp 0.4s ease;
}
.avatar-circle {
    width: 90px; height: 90px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    border: 3px solid rgba(255,255,255,0.2);
    transition: transform 0.2s;
}
.player-avatar-card:hover .avatar-circle { transform: scale(1.08); }
.avatar-circle.empty-circle {
    background: #1a1a2e; border: 2px dashed #444;
    font-size: 2rem; color: #555;
}
.avatar-name { font-size: 1.1rem; font-weight: 600; }
.avatar-badge {
    font-size: 0.65rem; font-weight: 700;
    background: #6366f1; color: #fff;
    padding: 0.15rem 0.5rem; border-radius: 6px;
    letter-spacing: 0.05rem;
}
.avatar-badge.spec { background: #0ea5e9; }
.player-avatar-card.empty .avatar-name { opacity: 0.35; font-style: italic; }

.round-wins-bar {
    display: flex; gap: 1.5rem; align-items: center;
    background: #1a1a2e; border-radius: 12px;
    padding: 0.6rem 1.5rem; font-size: 1rem;
}
.rw-label { opacity: 0.6; }

.lobby-hint { opacity: 0.45; font-size: 1rem; margin-top: 0.5rem; }

/* ── Countdown overlay ──────────────────────────────────────────────────── */
.countdown-overlay {
    position: fixed; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}
.countdown-overlay.go { background: rgba(99,102,241,0.6); }
.countdown-number {
    font-size: 20vw; font-weight: 900; color: #fff;
    text-shadow: 0 0 80px rgba(99,102,241,1);
    line-height: 1;
}
.countdown-number.pop { animation: countPop 0.4s ease-out forwards; }
@keyframes countPop {
    0% { transform: scale(2); opacity: 0; }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Match flash overlay ────────────────────────────────────────────────── */
.match-flash-overlay {
    position: fixed; inset: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--flash-color) 30%, transparent);
    animation: matchFlash 0.7s ease-out forwards;
    font-size: 15vw; pointer-events: none;
}
@keyframes matchFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ── Paused overlay ─────────────────────────────────────────────────────── */
.paused-overlay {
    position: fixed; inset: 0; z-index: 30;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.5); font-size: 5rem; color: #fff;
    backdrop-filter: blur(4px);
}

/* ── Reaction floats ────────────────────────────────────────────────────── */
.reaction-float {
    position: fixed; bottom: 10%; z-index: 60;
    display: flex; flex-direction: column; align-items: center;
    animation: floatUp var(--dur, 3s) ease-out forwards;
    pointer-events: none;
}
.r-emoji { font-size: 3rem; }
.r-name { font-size: 0.75rem; opacity: 0.7; }
@keyframes floatUp {
    0%   { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-60vh); opacity: 0; }
}

/* ── Play Again button ──────────────────────────────────────────────────── */
.play-again-btn {
    position: fixed; bottom: 2.5rem; left: 50%; transform: translateX(-50%);
    font-size: 1.5rem; padding: 0.8rem 3rem;
    border-radius: 14px; border: none;
    background: #6366f1; color: #fff; cursor: pointer;
    box-shadow: 0 4px 30px rgba(99,102,241,0.5);
    animation: fadeInUp 0.5s 1s both;
    z-index: 20;
}
.play-again-btn:hover { background: #4f52d4; }

/* ── Pictionary game board ──────────────────────────────────────────────── */
.game-board {
    width: 100vw; min-height: 100vh;
    background: #0a0a1a; color: #fff;
    display: flex; flex-direction: column;
}
.timer-bar-wrap {
    height: 6px; background: #1a1a2e; width: 100%; flex-shrink: 0;
}
.timer-bar {
    height: 100%; background: #6366f1;
    transition: width 1s linear, background 0.3s;
    border-radius: 0 3px 3px 0;
}
.timer-bar.urgent { background: #ef4444; }

.board-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.8rem 1.5rem; background: #111;
    border-bottom: 1px solid #222;
    font-size: 1.1rem;
}
.round-badge { background: #1a1a2e; padding: 0.3rem 0.8rem; border-radius: 8px; }
.drawer-info { display: flex; gap: 0.5rem; align-items: center; font-size: 1.2rem; }
.drawer-emoji { font-size: 1.8rem; }
.timer-num { font-size: 1.4rem; font-weight: bold; }
.timer-num.urgent { color: #ef4444; animation: pulse 0.5s infinite alternate; }

.word-hint {
    text-align: center; font-size: 3rem;
    letter-spacing: 0.4rem; padding: 0.5rem;
    color: #a5b4fc;
}
.word-revealed {
    text-align: center; font-size: 2rem;
    padding: 0.5rem; background: #1a1a2e;
}

.board-main {
    display: flex; flex: 1; gap: 0;
}
canvas#tv-canvas {
    flex: 1; max-width: calc(100vw - 280px);
    background: #fff;
}
.sidebar {
    width: 280px; padding: 1rem;
    display: flex; flex-direction: column; gap: 1rem;
    border-left: 1px solid #222; background: #0d0d20;
}
.scoreboard h3, .guesses h3 {
    font-size: 0.8rem; text-transform: uppercase;
    letter-spacing: 0.1rem; opacity: 0.5; margin: 0 0 0.5rem;
}
.score-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.6rem; border-radius: 8px;
    font-size: 1rem; margin-bottom: 0.3rem;
}
.score-row.is-drawer { background: #1a1a2e; border: 1px solid #6366f1; }
.sr-emoji { font-size: 1.3rem; }
.sr-name { flex: 1; font-weight: 500; }
.sr-score { font-weight: bold; color: #a5b4fc; }
.sr-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.guess {
    padding: 0.3rem 0.5rem; border-radius: 6px;
    font-size: 0.9rem; margin-bottom: 0.2rem;
    border-left: 3px solid #333;
}
.guess.correct { border-left-color: #22c55e; background: rgba(34,197,94,0.1); }

/* ── Fast Match board ───────────────────────────────────────────────────── */
.fastmatch-board {
    width: 100vw; min-height: 100vh;
    background: #0a0a1a;
    display: flex; gap: 2rem; padding: 2rem;
    box-sizing: border-box; color: #fff;
}

.fm-center-card {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.fm-card-label {
    font-size: 1.8rem; color: #aaa; margin-bottom: 1.5rem;
    text-transform: uppercase; letter-spacing: 0.15rem;
}
.fm-symbol-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1rem; max-width: 600px;
}
.fm-symbol-cell {
    background: #1a1a2e; border-radius: 16px;
    padding: 1rem; text-align: center;
    border: 2px solid #333; transition: border-color 0.2s;
}
.fm-emoji { font-size: 3.5rem; display: block; line-height: 1; }
.fm-label {
    font-size: 0.75rem; color: #888; margin-top: 0.4rem;
    display: block; text-transform: capitalize;
}

.fm-standings {
    width: 260px; display: flex; flex-direction: column;
    justify-content: center; gap: 0.8rem;
    border-left: 1px solid #333; padding-left: 2rem;
}
.fm-player-row {
    display: flex; align-items: center; gap: 0.8rem;
    background: #1a1a2e; border-radius: 14px;
    padding: 0.75rem 1rem; font-size: 1.1rem;
    border: 2px solid transparent;
    transition: border-color 0.1s, background 0.1s;
}
.fm-player-row.flash {
    border-color: var(--pc);
    background: color-mix(in srgb, var(--pc) 20%, #1a1a2e);
    animation: rowFlash 0.7s ease-out;
}
@keyframes rowFlash {
    0% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.fm-avatar {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; flex-shrink: 0;
}
.fm-player-name { flex: 1; font-weight: bold; }
.fm-card-count { color: #ffd700; font-size: 1.6rem; font-weight: bold; }

.fm-winner {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
}
.fm-winner .trophy { font-size: 8rem; animation: bounce 0.6s infinite alternate; }
.fm-winner h1 { font-size: 4rem; margin: 1rem 0; }
.fm-final-scores { margin-top: 2rem; display: flex; flex-direction: column; gap: 0.5rem; }
.fm-final-scores .score-row {
    display: flex; justify-content: space-between;
    gap: 2rem; font-size: 1.3rem;
    padding: 0.5rem 1rem; border-radius: 8px;
    align-items: center;
}
.fm-final-scores .score-row.winner { background: #ffd700; color: #000; font-weight: bold; }

@keyframes bounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-20px); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    from { opacity: 1; }
    to   { opacity: 0.5; }
}

/* ── Charades board ─────────────────────────────────────────────────────── */
.charades-board {
    width: 100vw; min-height: 100vh;
    background: #0a0a1a; color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.ch-main {
    display: flex; width: 100%; height: 100vh;
    align-items: stretch;
}
.ch-actor-area {
    flex: 0 0 40%; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-right: 1px solid #222; padding: 2rem; gap: 1rem;
}
.ch-actor-avatar {
    width: 160px; height: 160px; border-radius: 50%;
    background: #6366f1; display: flex; align-items: center; justify-content: center;
    font-size: 6rem; box-shadow: 0 0 60px rgba(99,102,241,0.4);
    animation: pulse-ring 2s infinite;
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
    70%  { box-shadow: 0 0 0 20px rgba(99,102,241,0); }
    100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}
.ch-actor-name { font-size: 2.5rem; font-weight: 800; }
.ch-acting-label { font-size: 1.2rem; color: #a5b4fc; }
.ch-timer { font-size: 5rem; font-weight: 900; color: #a5b4fc; line-height: 1; }
.ch-timer.urgent { color: #ef4444; animation: pulse 0.5s infinite alternate; }
.ch-round-tag { font-size: 0.9rem; color: #555; background: #1a1a2e; padding: 0.3rem 0.8rem; border-radius: 8px; }

.ch-right-panel {
    flex: 1; display: flex; flex-direction: column; padding: 1.5rem; gap: 1.5rem;
}
.ch-guesses-panel { flex: 1; }
.ch-guesses-panel h3, .ch-scoreboard h3 {
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1rem;
    opacity: 0.4; margin: 0 0 0.5rem;
}
.ch-guess {
    padding: 0.4rem 0.6rem; border-radius: 8px;
    font-size: 1rem; margin-bottom: 0.3rem; border-left: 3px solid #333;
}
.ch-guess.correct { border-left-color: #22c55e; background: rgba(34,197,94,0.1); color: #86efac; }

.ch-score-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.6rem; border-radius: 8px; margin-bottom: 0.3rem;
}
.ch-score-row.is-actor { background: #1a1a2e; border: 1px solid #6366f1; }
.ch-sr-emoji { font-size: 1.3rem; }
.ch-sr-name { flex: 1; }
.ch-sr-score { font-weight: bold; color: #a5b4fc; }

.ch-reveal {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 1rem; text-align: center;
    min-height: 100vh; padding: 2rem;
}
.ch-reveal-label { font-size: 1.2rem; color: #666; text-transform: uppercase; letter-spacing: 0.15rem; }
.ch-reveal-word { font-size: 6rem; font-weight: 900; color: #ffd700; letter-spacing: -2px; }
.ch-winner { font-size: 2rem; color: #86efac; }
.ch-no-winner { font-size: 1.5rem; color: #666; }
.ch-scores-reveal { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.ch-scores-reveal .ch-score-row { font-size: 1.2rem; background: #1a1a2e; border-radius: 10px; padding: 0.5rem 1rem; }

/* ── Blazor framework ───────────────────────────────────────────────────── */
.btn-primary { color: #fff; background-color: #6366f1; border-color: #4f52d4; }
a, .btn-link { color: #a5b4fc; }

#blazor-error-ui {
    color-scheme: light only; background: lightyellow;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    box-sizing: border-box; display: none; left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbmsiPjxwYXRoIGQ9Ik0yNjMuNTA2IDUxWiIgZmlsbD0iI0ZGRTUwMCIvPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem; color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

.loading-progress {
    position: relative; display: block;
    width: 8rem; height: 8rem;
    margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none; stroke: #e0e0e0; stroke-width: 0.6rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: #6366f1;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute; text-align: center; font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }
