@import url('https://fonts.googleapis.com/css2?family=Teko:wght@700&display=swap');

@font-face {
    font-family: 'LED Dot-Matrix';
    src: url('/static/fonts/LEDDotMatrix.woff2') format('woff2'),
         url('/static/fonts/LEDDotMatrix.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface2: #0f3460;
    --accent: #e94560;
    --text: #eee;
    --text-muted: #999;
    --home-color: #2196F3;
    --visitor-color: #FF9800;
    --success: #4caf50;
    --radius: 8px;
}

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

a { color: var(--accent); }

/* Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

.header {
    text-align: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface2);
    margin-bottom: 16px;
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.game-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Scoreboard */
.scoreboard {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.team-score {
    text-align: center;
}

.team-name {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.score {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-family: 'LED Dot-Matrix', monospace;
    letter-spacing: 0.15em;
}

.home-side .score { color: var(--home-color); }
.visitor-side .score { color: var(--visitor-color); }

.center-info {
    text-align: center;
    min-width: 100px;
}

.clock {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: 'LED Dot-Matrix', 'SF Mono', 'Fira Code', monospace;
    color: #ffeabc;
    letter-spacing: 0.15em;
}

.period-display {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.status-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 4px;
}

.status-pregame { background: var(--surface2); }
.status-active { background: var(--success); color: #fff; }
.status-halftime { background: var(--visitor-color); color: #000; }
.status-final { background: var(--accent); }

/* Clock Controls */
.clock-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    color: #fff;
    background: var(--surface2);
}

.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-primary { background: var(--accent); }
.btn-success { background: var(--success); }
.btn-small {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.btn-score {
    min-width: 44px;
    min-height: 44px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius);
}

.btn-score.home { background: var(--home-color); }
.btn-score.visitor { background: var(--visitor-color); }

/* Team Panels */
.team-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.team-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
}

.team-panel h3 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--surface2);
}

.player-row:last-child { border-bottom: none; }

.player-number {
    font-weight: 700;
    min-width: 36px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.player-points {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 46px;
    text-align: right;
    flex-shrink: 0;
}

.player-foul-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.player-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.team-actions {
    display: flex;
    gap: 6px;
    padding: 8px 0 0;
    flex-wrap: wrap;
}

/* Drag and drop */
.drag-handle {
    cursor: grab;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0 4px;
    user-select: none;
}

.player-row[draggable="true"] {
    transition: background 0.15s, opacity 0.15s;
}

.player-row.dragging {
    opacity: 0.4;
}

body.is-dragging .player-row * {
    pointer-events: none;
}

.player-row.drag-over {
    background: rgba(233, 69, 96, 0.25);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius);
}

/* Bench divider */
.bench-divider {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 6px 0 2px;
    border-top: 1px dashed var(--surface2);
    margin-top: 4px;
}

/* On court vs bench */
.on-bench {
    opacity: 0.55;
}

/* Fouls */
.player-fouls {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
}

.fouled-out {
    background: rgba(233, 69, 96, 0.15);
}

.fouled-out-text {
    color: var(--accent);
    font-weight: 700;
}

.btn-foul {
    background: #555;
    min-width: 28px;
    min-height: 28px;
    font-size: 0.7rem;
    padding: 2px 5px;
}

.btn-foul-off {
    background: #6d4c00;
    min-width: 28px;
    min-height: 28px;
    font-size: 0.65rem;
    padding: 2px 4px;
}

.btn-foul-undo {
    background: #333;
    min-width: 28px;
    min-height: 28px;
    font-size: 0.65rem;
    padding: 2px 4px;
}

/* Team fouls display */
.team-fouls-display {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 0;
    margin-bottom: 4px;
}

/* Bonus badge */
.bonus-badge {
    display: inline-block;
    background: var(--visitor-color);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-fouls {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-shots {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 4px;
}

.stat-minutes {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Player shot detail and minutes in scorekeeper view */
.player-shot-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.player-minutes {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
    flex-shrink: 0;
    white-space: nowrap;
}

/* No-players quick score */
.quick-score {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px 0;
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px 0;
    flex-wrap: wrap;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}

.form-group input[type="color"] {
    height: 44px;
    padding: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.form-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.setup-form {
    max-width: 500px;
    margin: 0 auto;
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
}

.setup-form h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

/* Toggle */
.toggle-group {
    display: flex;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--surface2);
}

.toggle-group button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.toggle-group button.active {
    background: var(--accent);
    color: #fff;
}

/* Modal/Dialog */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 280px;
    max-width: 90vw;
}

.modal h3 { margin-bottom: 16px; }

.modal .form-group:last-of-type { margin-bottom: 12px; }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Viewer specific */
.viewer-scoreboard .score {
    font-size: 5rem;
}

.viewer-scoreboard .clock {
    font-size: 3rem;
}

.viewer-scoreboard .team-name {
    font-size: 1.2rem;
}

.player-stats {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.player-stats h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.player-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--surface2);
}

/* Connected indicator */
.connected-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    background: var(--success);
}

.connected-indicator.disconnected {
    background: var(--accent);
}

/* Viewer count */
.viewer-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 6px;
}

/* Postgame Report */
.postgame-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.postgame-team-title {
    font-size: 1rem;
    margin-bottom: 12px;
}

.postgame-table-wrap {
    overflow-x: auto;
}

.postgame-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.postgame-table th {
    text-align: right;
    padding: 6px 10px;
    border-bottom: 2px solid var(--surface2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.postgame-table th:first-child {
    text-align: left;
}

.postgame-table td {
    text-align: right;
    padding: 8px 10px;
    border-bottom: 1px solid var(--surface2);
}

.postgame-table td:first-child {
    text-align: left;
    font-weight: 700;
}

.postgame-table .totals-row td {
    border-top: 2px solid var(--text-muted);
    border-bottom: none;
    font-weight: 700;
}

/* Timeout Display */
.timeout-display {
    font-size: 1.4rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #ff6b35;
    margin-top: 8px;
    animation: timeout-glow 1.2s ease-in-out infinite alternate;
}

@keyframes timeout-glow {
    from {
        text-shadow: 0 0 5px #ff6b35, 0 0 10px #ff6b35;
        opacity: 0.8;
    }
    to {
        text-shadow: 0 0 10px #ff6b35, 0 0 20px #ff4500, 0 0 30px #ff4500;
        opacity: 1;
    }
}

/* Timeout Button */
.btn-timeout {
    background: #ff6b35;
}

.btn-timeout.active {
    background: #ff4500;
    animation: timeout-btn-pulse 1s ease-in-out infinite alternate;
}

@keyframes timeout-btn-pulse {
    from { opacity: 0.8; }
    to { opacity: 1; box-shadow: 0 0 12px rgba(255, 69, 0, 0.5); }
}

/* Scoring Animation Overlay */
.scoring-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 75, 110, 0.88);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease-in;
    pointer-events: none;
}

.scoring-overlay.active { opacity: 1; }
.scoring-overlay.fade-out { opacity: 0; transition: opacity 0.4s ease-out; }

.scoring-canvas {
    width: min(80vw, 576px);
    height: min(66vh, 480px);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border: 3px solid #f97316;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(249, 115, 22, 0.4);
}

/* ======================== */
/* Setup Page (index.html)  */
/* ======================== */

body.setup-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.setup-page .container {
    max-width: 580px;
    padding: 32px 16px 24px;
}

.setup-page .header {
    border-bottom: none;
    padding: 0 0 24px;
    margin-bottom: 0;
}

.setup-page .header h1 {
    font-family: 'Teko', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.setup-page .header .subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px;
    font-weight: 400;
}

.setup-page .setup-form {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    max-width: 100%;
}

.setup-form-header {
    background: linear-gradient(to right, #f97316, #ef4444);
    padding: 20px 24px;
    color: #fff;
}

.setup-form-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: left;
}

.setup-form-header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.setup-form-body {
    padding: 24px;
}

.setup-page .form-group label {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.setup-page .form-group input,
.setup-page .form-group select {
    background: #f3f3f5;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    height: 48px;
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 8px;
}

.setup-page .form-group input::placeholder {
    color: #9ca3af;
}

.setup-page .form-group input:focus,
.setup-page .form-group select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.setup-page .form-group input[type="color"] {
    height: 48px;
    padding: 4px;
    background: #f3f3f5;
    border: 1px solid #e5e7eb;
}

.setup-page .toggle-group {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.setup-page .toggle-group button {
    background: #f3f3f5;
    color: #6b7280;
    padding: 10px 16px;
    font-size: 0.9rem;
}

.setup-page .toggle-group button.active {
    background: linear-gradient(to right, #f97316, #ef4444);
    color: #fff;
}

.setup-section-divider {
    border-top: 1px solid #e5e7eb;
    margin: 20px 0;
    padding-top: 16px;
}

.setup-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #1f2937;
}

.setup-section-header svg {
    width: 18px;
    height: 18px;
    color: #6b7280;
    flex-shrink: 0;
}

.btn-start {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(to right, #f97316, #ef4444);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    margin-top: 8px;
}

.btn-start:hover {
    filter: brightness(0.92);
}

.btn-start:active {
    transform: scale(0.99);
}

.setup-footer {
    text-align: center;
    padding: 20px 0 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

/* ======================== */
/* Game Page (game.html)    */
/* ======================== */

body.game-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.game-page .container {
    max-width: 900px;
    padding: 16px;
}

.game-page .header {
    border-bottom: none;
    padding: 8px 0 12px;
    margin-bottom: 12px;
}

.game-page .header .brand {
    font-family: 'Teko', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.game-page .header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin-top: 2px;
}

.game-page .game-info {
    color: rgba(255, 255, 255, 0.75);
}

/* Scoreboard card */
.game-page .scoreboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 20px 16px;
}

.game-page .team-name {
    color: #374151;
}

.game-page .center-info {
    min-width: 110px;
}

.game-page .clock {
    color: #1f2937;
}

.game-page .period-display {
    color: #6b7280;
}

/* Clock controls */
.game-page .clock-controls {
    margin-bottom: 12px;
}

.game-page .clock-controls .btn {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.game-page .clock-controls .btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.game-page .clock-controls .btn-success {
    background: var(--success);
    border-color: transparent;
}

.game-page .clock-controls .btn-primary {
    background: var(--accent);
    border-color: transparent;
}

.game-page .clock-controls .btn-timeout {
    background: #ff6b35;
    border-color: transparent;
}

.game-page .clock-controls .btn-timeout.active {
    background: #ff4500;
    border-color: transparent;
}

/* Team panels */
.game-page .team-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.game-page .team-panel h3 {
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.game-page .team-panel h3 .btn-small {
    background: #e5e7eb;
    color: #374151;
}

.game-page .team-panel h3 .btn-small:hover {
    background: #d1d5db;
}

.game-page .team-fouls-display {
    color: #6b7280;
}

.game-page .player-row {
    border-bottom-color: #e5e7eb;
}

.game-page .player-number {
    color: #1f2937;
}

.game-page .player-points {
    color: #6b7280;
}

.game-page .player-fouls {
    color: #6b7280;
}

.game-page .player-minutes {
    color: #6b7280;
}

.game-page .drag-handle {
    color: #9ca3af;
}

.game-page .bench-divider {
    color: #9ca3af;
    border-top-color: #e5e7eb;
}

.game-page .on-bench {
    opacity: 0.5;
}

.game-page .fouled-out {
    background: rgba(239, 68, 68, 0.08);
}

.game-page .player-row.drag-over {
    background: rgba(59, 130, 246, 0.15);
    outline-color: #3b82f6;
}

/* Team action buttons */
.game-page .team-actions .btn {
    background: #e5e7eb;
    color: #374151;
}

.game-page .team-actions .btn:hover {
    background: #d1d5db;
}

/* Foul buttons — keep distinct but softer */
.game-page .btn-foul {
    background: #6b7280;
}

.game-page .btn-foul-off {
    background: #d97706;
}

.game-page .btn-foul-undo {
    background: #9ca3af;
}

/* Larger tap targets for scorekeeper buttons */
.game-page .btn {
    min-height: 44px;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.game-page .btn-small {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 14px;
    font-size: 0.85rem;
}

.game-page .btn-score {
    min-width: 52px;
    min-height: 52px;
    font-size: 1.1rem;
}

.game-page .btn-foul,
.game-page .btn-foul-off,
.game-page .btn-foul-undo {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.8rem;
    padding: 6px 8px;
}

.game-page .clock-controls .btn {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 0.95rem;
}

.game-page .footer .btn,
.game-page .footer #statusBtn {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 0.95rem;
}

/* Footer */
.game-page .footer .btn {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.game-page .footer .btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.game-page .footer .btn-primary {
    background: linear-gradient(to right, #f97316, #ef4444);
    border-color: transparent;
}

.game-page .footer #statusBtn {
    background: linear-gradient(to right, #f97316, #ef4444);
    border-color: transparent;
}

/* Modals */
.game-page .modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.game-page .modal h3 {
    color: #1f2937;
}

.game-page .modal p {
    color: #374151;
}

.game-page .modal .form-group label {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.game-page .modal .form-group input,
.game-page .modal .form-group select {
    background: #f3f3f5;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    height: 48px;
    border-radius: 8px;
}

.game-page .modal .form-group input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.game-page .modal .modal-actions .btn {
    background: #e5e7eb;
    color: #374151;
    border: none;
}

.game-page .modal .modal-actions .btn-primary {
    background: linear-gradient(to right, #f97316, #ef4444);
    color: #fff;
}

/* ======================== */
/* Viewer Page (viewer.html)*/
/* ======================== */

body.viewer-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.viewer-page .container {
    max-width: 900px;
    padding: 16px;
}

.viewer-page .header {
    border-bottom: none;
    padding: 8px 0 12px;
    margin-bottom: 12px;
}

.viewer-page .header .brand {
    font-family: 'Teko', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.viewer-page .header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin-top: 2px;
}

.viewer-page .game-info {
    color: rgba(255, 255, 255, 0.75);
}

.viewer-page .connected-indicator {
    background: #4ade80;
}

.viewer-page .connected-indicator.disconnected {
    background: #f87171;
}

.viewer-page .viewer-count {
    color: rgba(255, 255, 255, 0.6);
}

/* Scoreboard card */
.viewer-page .scoreboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 24px 16px;
}

.viewer-page .team-name {
    color: #374151;
}

.viewer-page .clock {
    color: #1f2937;
}

.viewer-page .period-display {
    color: #6b7280;
}

/* Player stats card */
.viewer-page .player-stats {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.viewer-page .player-stats > h3 {
    color: #1f2937;
}

.viewer-page .player-stats-grid h3 {
    color: #374151;
}

.viewer-page .team-fouls-display {
    color: #6b7280;
}

.viewer-page .stat-row {
    color: #1f2937;
    border-bottom-color: #e5e7eb;
}

.viewer-page .stat-fouls {
    color: #6b7280;
}

.viewer-page .fouled-out {
    background: rgba(239, 68, 68, 0.08);
}

/* Viewer team stats grid */
.viewer-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.viewer-team-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
    padding: 16px;
    border: 3px solid #999;
}

.viewer-team-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.viewer-team-card .stat-row {
    color: #1f2937;
    border-bottom-color: #e5e7eb;
}

.viewer-team-card .team-fouls-display {
    color: #6b7280;
}

.viewer-team-card .stat-fouls {
    color: #6b7280;
}

.viewer-team-card .fouled-out {
    background: rgba(239, 68, 68, 0.08);
}

/* Footer */
.viewer-page .footer .btn {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.viewer-page .footer .btn-primary {
    background: linear-gradient(to right, #f97316, #ef4444);
    border-color: transparent;
}

/* ============================ */
/* Postgame Page (postgame.html)*/
/* ============================ */

body.postgame-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.postgame-page .container {
    max-width: 900px;
    padding: 16px;
}

.postgame-page .header {
    border-bottom: none;
    padding: 8px 0 12px;
    margin-bottom: 12px;
}

.postgame-page .header .brand {
    font-family: 'Teko', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.postgame-page .header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin-top: 2px;
}

.postgame-page .game-info {
    color: rgba(255, 255, 255, 0.75);
}

/* Scoreboard card */
.postgame-page .scoreboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 24px 16px;
}

.postgame-page .team-name {
    color: #374151;
}

.postgame-page .clock {
    color: #1f2937;
}

/* Postgame stat sections */
.postgame-page .postgame-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.postgame-page .postgame-team-title {
    color: #1f2937;
}

.postgame-page .postgame-table th {
    color: #6b7280;
    border-bottom-color: #e5e7eb;
}

.postgame-page .postgame-table td {
    color: #1f2937;
    border-bottom-color: #f3f4f6;
}

.postgame-page .postgame-table .totals-row td {
    border-top-color: #9ca3af;
}

/* ======================== */
/* Login Page (login.html)  */
/* ======================== */

body.login-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.login-page .container {
    max-width: 420px;
    padding: 32px 16px 24px;
}

.login-page .header {
    border-bottom: none;
    padding: 0 0 24px;
    margin-bottom: 0;
}

.login-page .header h1 {
    font-family: 'Teko', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.login-page .header .subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px;
    font-weight: 400;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.login-card-header {
    background: linear-gradient(to right, #f97316, #ef4444);
    padding: 20px 24px;
    color: #fff;
}

.login-card-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: left;
}

.login-card-header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.login-card-body {
    padding: 24px;
}

.login-page .form-group label {
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-page .form-group input[type="email"] {
    width: 100%;
    background: #f3f3f5;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    height: 48px;
    padding: 10px 14px;
    font-size: 0.95rem;
    border-radius: 8px;
    box-sizing: border-box;
}

.login-page .form-group input[type="email"]::placeholder {
    color: #9ca3af;
}

.login-page .form-group input[type="email"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.login-field-error {
    color: #b91c1c;
    font-size: 0.8rem;
    margin-top: 4px;
}

.login-success {
    text-align: center;
    padding: 8px 0 4px;
}

.login-success-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    color: #059669;
}

.login-success h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.login-success p {
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
}

/* QR Code Modal */
.qr-modal {
    text-align: center;
    max-width: 340px;
}

.qr-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

#qrCodeContainer img {
    border-radius: 8px;
}

.qr-url {
    font-size: 0.75rem;
    color: #6b7280;
    word-break: break-all;
    padding: 8px 12px;
    background: #f3f3f5;
    border-radius: 6px;
    width: 100%;
}

.qr-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ======================== */
/* Dashboard Page           */
/* ======================== */

body.dashboard-page {
    background: linear-gradient(135deg, #3b82f6, #06b6d4, #14b8a6);
    min-height: 100vh;
}

.dashboard-page .container {
    max-width: 680px;
    padding: 32px 16px 24px;
}

.dashboard-page .header {
    border-bottom: none;
    padding: 0 0 24px;
    margin-bottom: 0;
}

.dashboard-page .header h1 {
    font-family: 'Teko', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    letter-spacing: 0.02em;
}

.dashboard-page .header .subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px;
    font-weight: 400;
}

.dashboard-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.dashboard-card-header {
    background: linear-gradient(to right, #f97316, #ef4444);
    padding: 20px 24px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dashboard-card-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.dashboard-card-body {
    padding: 24px;
}

.dashboard-email {
    text-align: center;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 16px;
}

.dashboard-toggle {
    margin-bottom: 20px;
}

.dashboard-page .toggle-group {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.dashboard-page .toggle-group button {
    background: #f3f3f5;
    color: #6b7280;
    padding: 10px 16px;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.dashboard-page .toggle-group button.active {
    background: linear-gradient(to right, #f97316, #ef4444);
    color: #fff;
}

.game-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #e5e7eb;
    gap: 12px;
}

.game-card:last-child {
    border-bottom: none;
}

.game-card-main {
    flex: 1;
    min-width: 0;
}

.game-card-teams {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
}

.game-card-team {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-score {
    font-variant-numeric: tabular-nums;
    color: #374151;
    flex-shrink: 0;
}

.game-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.game-card-details {
    font-size: 0.8rem;
    color: #6b7280;
}

.game-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.game-card-actions .btn {
    background: #e5e7eb;
    color: #374151;
    font-size: 0.8rem;
    padding: 6px 10px;
    min-height: auto;
    text-decoration: none;
}

.game-card-actions .btn:hover {
    background: #d1d5db;
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: #6b7280;
    font-size: 0.95rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-top: 20px;
    font-size: 0.85rem;
    color: #6b7280;
}

.pagination .btn {
    background: #e5e7eb;
    color: #374151;
    min-height: auto;
}

/* Responsive */
@media (max-width: 600px) {
    .game-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .game-card-actions {
        width: 100%;
    }
}

/* Responsive — Setup, Login, Dashboard pages */
@media (max-width: 600px) {
    .setup-page .header h1,
    .login-page .header h1,
    .dashboard-page .header h1 {
        font-size: 2rem;
    }

    .setup-page .container {
        padding: 20px 12px 24px;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .team-panels {
        grid-template-columns: 1fr;
    }

    .scoreboard {
        grid-template-columns: 1fr 1fr;
        padding: 12px 8px;
    }

    .scoreboard .home-side {
        order: 1;
    }

    .scoreboard .visitor-side {
        order: 2;
    }

    .scoreboard .center-info {
        order: 3;
        grid-column: 1 / -1;
        padding-top: 8px;
    }

    .score {
        font-size: 2.8rem;
    }

    .clock {
        font-size: 2.2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .viewer-scoreboard .score {
        font-size: 3.5rem;
    }

    .viewer-scoreboard .clock {
        font-size: 2rem;
    }

    .viewer-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 601px) and (orientation: landscape) {
    .team-panels {
        grid-template-columns: 1fr 1fr;
    }
}
