@font-face {
    font-family: 'Brunson';
    src: url('fonts/Brunson.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #111a11; --orange: #f5a000; --red: #e8442a; --green: #27ae60;
    --text: #ffffff; --text-muted: rgba(255,255,255,0.35);
    --border: rgba(255,255,255,0.08); --card-bg: #1c261c;
}

html, body { height: 100%; background: linear-gradient(120deg, #050705 0%, #0a0e0a 15%, #111a11 45%, #162416 80%, #1a2a1a 100%); color: var(--text); font-family: 'Squada One', sans-serif; overflow: hidden; }

/* ── Screens ── */
.screen { display: none; flex-direction: column; height: 100dvh; max-width: 820px; margin: 0 auto; position: relative; }
.screen.active { display: flex; }

/* ── Login ── */
.login-container { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; gap: 24px; }
.login-box { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; }
.login-input { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-family: 'Squada One', sans-serif; font-size: 16px; padding: 16px; outline: none; text-align: center; letter-spacing: 2px; }
.login-input:focus { border-color: rgba(255,255,255,0.25); }
.login-input::placeholder { color: var(--text-muted); letter-spacing: 0; }
.btn-login { background: var(--red); color: white; border: none; border-radius: 10px; padding: 16px; font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 18px; letter-spacing: 2px; cursor: pointer; }
.btn-login:active { filter: brightness(0.85); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

/* ── Home ── */
.admin-corner { position: absolute; top: 20px; right: 20px; z-index: 10; }
.admin-btn { width: 38px; height: 38px; background: none; border: 1px solid var(--border); border-radius: 50%; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.home-top { padding: 52px 20px 0; }
.home-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.app-title { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 18px; letter-spacing: 6px; color: var(--text-muted); }
.home-card { display: flex; flex-direction: column; align-items: flex-start; padding: 20px 16px; border-radius: 14px; border: none; cursor: pointer; text-align: left; transition: transform 0.12s, filter 0.12s; min-height: 160px; }
.home-card:active { transform: scale(0.97); filter: brightness(0.9); }
.card-new-match { background: var(--red); color: white; box-shadow: 0 6px 30px rgba(232,68,42,0.35); }
.card-active { background: var(--orange); color: white; box-shadow: 0 6px 30px rgba(245,160,0,0.25); }
.card-history { background: var(--card-bg); color: white; border: 1px solid var(--border); }
.home-card-icon { opacity: 0.85; margin-bottom: auto; padding-bottom: 16px; }
.card-history .home-card-icon { opacity: 0.4; }
.home-card-title { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 24px; letter-spacing: 1px; line-height: 1.05; margin-bottom: 8px; }
.card-history .home-card-title { color: rgba(255,255,255,0.85); }
.home-card-sub { font-size: 12px; opacity: 0.65; }

/* ── Nav ── */
.nav-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.nav-title { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: 2px; }
.back-btn { width: 40px; height: 40px; background: none; border: none; color: var(--text); font-size: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.header-spacer { width: 40px; }
.header-action-btn { width: 40px; height: 40px; background: none; border: none; color: var(--text-muted); cursor: pointer; align-items: center; justify-content: center; padding: 0; }
.header-action-btn:active { color: var(--red); }

/* ── New Match ── */
.new-match-body { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 24px 20px; }
.mode-card { display: flex; align-items: center; gap: 20px; padding: 24px 20px; border-radius: 14px; border: none; cursor: pointer; text-align: left; transition: transform 0.12s, filter 0.12s; width: 100%; }
.mode-card:active { transform: scale(0.98); filter: brightness(0.9); }
.mode-tournament { background: var(--red); color: white; box-shadow: 0 6px 30px rgba(232,68,42,0.35); min-height: 110px; }
.mode-quick { background: var(--card-bg); color: white; border: 1px solid var(--border); min-height: 90px; }
.mode-icon { flex-shrink: 0; opacity: 0.9; }
.mode-quick .mode-icon { opacity: 0.4; }
.mode-text { display: flex; flex-direction: column; gap: 6px; }
.mode-title { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 26px; letter-spacing: 1px; line-height: 1; }
.mode-sub { font-size: 13px; opacity: 0.65; }

/* ── Tournament Setup ── */
.tournament-setup-body { flex: 1; display: flex; flex-direction: column; padding: 20px; gap: 16px; overflow-y: auto; }
.player-input-row { display: flex; gap: 10px; }
.player-input { flex: 1; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-family: 'Squada One', sans-serif; font-size: 16px; padding: 14px 16px; outline: none; }
.player-input:focus { border-color: rgba(255,255,255,0.25); }
.player-input::placeholder { color: var(--text-muted); }
.btn-add-player { background: var(--red); color: white; border: none; border-radius: 10px; padding: 14px 20px; font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 1px; cursor: pointer; }
.btn-add-player:active { filter: brightness(0.85); }
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-item { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.player-item-left { display: flex; align-items: center; gap: 12px; }
.player-seed { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 16px; color: var(--text-muted); width: 20px; }
.player-name { font-size: 16px; font-weight: 600; }
.btn-remove-player { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; padding: 0 4px; }
.btn-remove-player:hover { color: var(--red); }
.player-count-hint { font-size: 13px; color: var(--text-muted); text-align: center; }
.tournament-setup-footer { padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.btn-generate { width: 100%; padding: 20px; background: var(--red); color: white; border: none; border-radius: 10px; font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 22px; letter-spacing: 2px; cursor: pointer; }
.btn-generate:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-generate:not(:disabled):active { filter: brightness(0.88); }

/* ── Scoring Screen ── */
#screen-scoring { touch-action: manipulation; }
.scoring-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.scoring-left { display: contents; }
.scoring-right { display: contents; }

/* Player cards — both side by side in one container */
.scoring-players {
    display: flex; margin: 6px 10px 0; border-radius: 16px; overflow: visible;
    flex-shrink: 0;
    position: relative;
}
.scoring-card {
    flex: 1; padding: 18px 16px 22px; color: white;
    background: #c48a1a; transition: background 0.3s, filter 0.3s, transform 0.4s ease, box-shadow 0.4s ease;
    display: flex; flex-direction: column;
    filter: brightness(0.5);
    position: relative; z-index: 1;
    border-radius: 16px;
}
.scoring-card.active {
    background: #cc3318;
    filter: brightness(1);
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 2;
}

/* Top row: dot + avatar + name */
.scoring-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.scoring-active-dot { display: none; }
.scoring-card-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(0,0,0,0.2); display: flex; align-items: center;
    justify-content: center; font-family: 'Squada One', sans-serif;
    font-weight: 800; font-size: 15px; flex-shrink: 0;
    color: white;
}
.scoring-card-name {
    font-family: 'Squada One', sans-serif; font-weight: 700;
    font-size: 22px; letter-spacing: 0.5px;
}

/* Middle: huge score + legs badge */
.scoring-card-middle {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0 0 12px;
}
.scoring-card-score {
    font-family: 'League Gothic', sans-serif; font-weight: 400;
    font-size: 76px; line-height: 1; letter-spacing: -1px;
}
.scoring-card-legs {
    background: #1a1a1a; border-radius: 8px;
    padding: 6px 12px; min-width: 40px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 18px;
    flex-shrink: 0;
}

/* Stats rows */
.scoring-card-stats {
    display: flex; flex-direction: column; gap: 0; font-size: 18px;
    font-weight: 800; margin-top: auto; line-height: 1.4;
    color: rgba(0,0,0,0.55);
}
.scoring-card-stat-row { display: flex; justify-content: space-between; }
.scoring-card-stat-row strong { font-weight: 800; font-size: 20px; color: #ffffff; }

.scoring-card-checkout {
    background: #000000; border-radius: 8px;
    padding: 2px 0; font-family: 'League Gothic', sans-serif;
    font-weight: 800; font-size: 18px; letter-spacing: 4px; word-spacing: 14px;
    color: white; text-align: center; display: none;
    margin: 6px -8px; width: calc(100% + 16px);
}
.scoring-card-checkout.visible { display: block; }

/* Pointer triangle */
.scoring-pointer {
    position: absolute; bottom: -8px; left: 25%;
    width: 0; height: 0; transform: translateX(-50%);
    border-left: 9px solid transparent; border-right: 9px solid transparent;
    border-top: 9px solid #cc3318; transition: left 0.3s ease, border-top-color 0.3s ease;
}
.scoring-pointer.right { left: 75%; border-top-color: #c48a1a; }

.turn-indicator {
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 15px; letter-spacing: 2px; color: var(--red);
    text-align: center; padding: 10px 0 4px; flex-shrink: 0;
    width: 100%;
}

/* Dart bar — white pill */
.dart-bar {
    display: flex; align-items: center;
    margin: 0 10px 4px; background: #f0f0f0; border-radius: 30px;
    padding: 4px; flex-shrink: 0;
}
.dart-slots { display: flex; flex: 1; }
.dart-slot {
    flex: 1; text-align: center; height: 42px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-right: 1px solid rgba(0,0,0,0.1);
    background: none; border-radius: 0;
}
.dart-slot:last-child { border-right: none; }
.dart-slot-empty { color: rgba(0,0,0,0.2); font-size: 16px; }
.dart-slot-value {
    font-family: 'League Gothic', sans-serif; font-weight: 400;
    font-size: 26px; line-height: 1; color: #1a1a1a;
}
.dart-slot-label { font-size: 9px; color: rgba(0,0,0,0.4); letter-spacing: 0.5px; }
.btn-submit-darts {
    background: var(--green); color: white; border: none; border-radius: 24px;
    padding: 12px 22px; font-family: 'Squada One', sans-serif;
    font-weight: 800; font-size: 15px; letter-spacing: 1px; cursor: pointer;
    height: 42px; white-space: nowrap;
}
.btn-submit-darts:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-submit-darts:not(:disabled):active { filter: brightness(0.88); }

/* Number pad */
.numpad { flex: 1; display: flex; flex-direction: column; padding: 0 10px; min-height: 0; }
.numpad-tabs {
    display: flex; gap: 0; flex-shrink: 0;
    border-bottom: 2px solid var(--border);
}
.numpad-tab {
    flex: 1; padding: 8px 2px; background: none; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    color: var(--text-muted); font-family: 'Squada One', sans-serif;
    font-weight: 700; font-size: 13px; letter-spacing: 0.5px; cursor: pointer;
    text-align: center; transition: color 0.15s, border-color 0.15s;
    line-height: 1.2;
}
.numpad-tab.active { color: var(--text); border-bottom-color: var(--red); }
.numpad-tab-sub { display: block; font-size: 10px; opacity: 0.5; font-weight: 400; }
.numpad-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0;
    flex: 1; min-height: 0; max-height: 220px; padding: 4px 0;
}
.numpad-btn {
    background: none; border: none; border-radius: 10px;
    color: var(--text); font-family: 'Squada One', sans-serif;
    font-weight: 800; font-size: 7vw; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.1s;
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.numpad-btn:active { background: rgba(255,255,255,0.06); }
.numpad-actions {
    display: flex; gap: 0;
    padding: 2px 0 calc(6px + env(safe-area-inset-bottom));
    flex-shrink: 0; justify-content: space-around;
}
.numpad-actions.hidden { display: none; }
.numpad-action {
    padding: 14px 30px; background: none; border: none;
    color: var(--text-muted); font-family: 'Squada One', sans-serif;
    font-weight: 800; font-size: 36px; letter-spacing: 2px; cursor: pointer;
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.numpad-action.miss { color: var(--red); }
.numpad-action:active { opacity: 0.6; }

/* Input view toggle */
.input-view { display: none; flex: 1; min-height: 0; }
.input-view.active { display: flex; flex-direction: column; }
.dart-bar-toggle {
    width: 48px; height: 42px; background: none; border: none;
    color: rgba(0,0,0,0.35); cursor: pointer; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.dart-bar-toggle.board-active { color: var(--red); }

.voice-input {
    display: none; background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text); font-family: 'Squada One', sans-serif;
    font-size: 16px; padding: 10px 14px; margin: 4px 10px; outline: none;
    text-align: center; letter-spacing: 1px;
}
.voice-input.visible { display: block; }
.voice-input:focus { border-color: var(--red); }

.dart-bar-mic {
    width: 42px; height: 42px; background: none; border: none;
    color: rgba(0,0,0,0.35); cursor: pointer; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 50%; transition: color 0.2s, background 0.2s;
}
.dart-bar-mic.active {
    color: white; background: var(--red);
    animation: micPulse 1.5s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232,68,42,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(232,68,42,0); }
}

/* Board area — dartboard with undo/miss at top */
.board-area {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    padding: 0 0 calc(6px + env(safe-area-inset-bottom));
}
.board-top-actions {
    display: flex; justify-content: space-between; padding: 4px 8px;
    flex-shrink: 0;
}
.board-top-btn {
    background: none; border: none;
    color: var(--text-muted); font-family: 'Squada One', sans-serif;
    font-weight: 800; font-size: 36px; letter-spacing: 1.5px; cursor: pointer;
    padding: 10px 14px;
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.board-top-btn.miss { color: var(--red); }
.board-top-btn:active { opacity: 0.6; }

/* Dartboard */
.dartboard-container {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden; touch-action: none;
    -webkit-user-select: none; user-select: none;
}
.board-inner {
    position: relative; display: inline-block;
    transform-origin: 0 0;
    transition: transform 0.3s ease;
}
.dartboard-container.zoomed .board-inner {
    transition: none;
}
.dart-dots { position: absolute; inset: 0; pointer-events: none; }
.dart-dot {
    position: absolute; width: 10px; height: 10px;
    background: #4a9eff; border: 2px solid white;
    border-radius: 50%; transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.touch-dot {
    position: absolute; width: 20px; height: 20px;
    background: #4a9eff; border: 3px solid white;
    border-radius: 50%; transform: translate(-50%, -50%);
    pointer-events: none; display: none; z-index: 5;
    box-shadow: 0 0 8px rgba(74,158,255,0.6), 0 2px 6px rgba(0,0,0,0.4);
}
.touch-dot.visible { display: block; }

/* Bust overlay */
.bust-flash {
    position: absolute; inset: 0; background: rgba(232,68,42,0.9);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 48px; letter-spacing: 4px; z-index: 10;
    border-radius: 14px; animation: bustFade 1s ease-out forwards;
}
@keyframes bustFade { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* ── Config ── */
.config-scroll { flex: 1; overflow-y: auto; padding: 0 28px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.config-section { display: flex; flex-direction: column; gap: 0; }
.config-card {
    background: rgba(255,255,255,0.06); border-radius: 16px;
    padding: 16px; border: 1px solid rgba(255,255,255,0.05);
    display: flex; flex-direction: column; gap: 16px;
}
.config-label { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 11px; letter-spacing: 2px; color: var(--text-muted); }
.config-toggle-row { display: flex; gap: 0; }
.config-toggle {
    flex: 1; padding: 18px 12px; background: #101310; border: none;
    border-radius: 0; color: rgba(255,255,255,0.3); font-family: 'League Gothic', sans-serif;
    font-weight: 700; font-size: 20px; letter-spacing: 0.5px; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s; text-align: center;
}
.config-toggle.active {
    background: #2a4038; color: white; border: none;
    border-radius: 14px !important;
    z-index: 2; position: relative;
}
.config-toggle:first-child { border-radius: 14px 0 0 14px; }
.config-toggle:last-child { border-radius: 0 14px 14px 0; }
.config-toggle:only-child { border-radius: 14px; }
.config-format-grid .config-toggle { border-radius: 14px !important; }
.config-toggle:active { filter: brightness(0.9); }

.config-format-grid {
    display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto;
    gap: 4px; align-items: center;
}
.config-format-grid .config-toggle-row:nth-child(1) { grid-column: 1; grid-row: 1; }
.config-format-grid .config-toggle-row:nth-child(3) { grid-column: 3; grid-row: 1; }
.config-format-grid .config-toggle-row:nth-child(1) .config-toggle,
.config-format-grid .config-toggle-row:nth-child(3) .config-toggle { flex: none; width: 100%; }
.config-format-grid .config-toggle-row { flex-direction: column; gap: 6px; }
.config-spinner {
    grid-column: 2; grid-row: 1 / 3;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    background: var(--orange); border: none; border-radius: 14px;
    overflow: hidden; padding: 8px 0;
    z-index: 5; position: relative;
}
.spinner-btn {
    width: 56px; height: 38px; background: none; border: none; color: white;
    font-size: 24px; cursor: pointer; line-height: 1;
}
.spinner-btn:active { opacity: 0.6; }
.spinner-value {
    font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 34px;
    min-width: 56px; text-align: center; color: white;
}

.config-custom-row { display: flex; gap: 6px; }
.config-input {
    flex: 1; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: 'Squada One', sans-serif; font-size: 14px; padding: 10px 14px; outline: none;
}
.config-input:focus { border-color: rgba(255,255,255,0.25); }

/* Quick match players */
.config-card-header {
    display: flex; align-items: center; gap: 8px;
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 16px; letter-spacing: 2px; color: var(--text);
}
.quick-players-avatars {
    display: flex; align-items: center; justify-content: center; gap: 20px;
    padding: 12px 0;
}
.quick-player-avatar {
    display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
}
.avatar-circle {
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 18px;
    color: white;
}
.avatar-name {
    font-family: 'Squada One', sans-serif; font-size: 14px; color: var(--text);
}
.avatar-remove {
    background: none; border: none; color: rgba(255,255,255,0.3);
    font-size: 16px; cursor: pointer; padding: 0; line-height: 1;
}
.avatar-remove:active { color: var(--red); }
.add-circle {
    border-style: dashed; background: none; font-size: 28px; color: rgba(255,255,255,0.3);
}
.quick-player-edit {
    width: 100%; background: #101310; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; color: var(--text); font-family: 'Squada One', sans-serif;
    font-size: 16px; padding: 12px; outline: none; text-align: center;
}
.quick-player-edit:focus { border-color: rgba(255,255,255,0.3); }

/* ── Tabs ── */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab { flex: 1; padding: 12px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: 2px; cursor: pointer; transition: color 0.2s, border-color 0.2s; }
.tab.active { color: var(--text); border-bottom-color: var(--red); }
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-content.active { display: flex; }

.btn-test-fill { background: none; border: 1px solid var(--border); border-radius: 10px; padding: 10px; color: var(--text-muted); font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 1px; cursor: pointer; margin-top: 8px; }
.btn-test-fill:active { background: rgba(255,255,255,0.04); }

/* ── Tournament Scroll ── */
.tournament-scroll { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }

/* Next match card */
.next-match { background: var(--red); border-radius: 14px; padding: 20px; cursor: pointer; transition: transform 0.12s, filter 0.12s; box-shadow: 0 6px 30px rgba(232,68,42,0.35); }
.next-match:active { transform: scale(0.98); filter: brightness(0.9); }
.next-match-label { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 12px; letter-spacing: 2px; opacity: 0.7; margin-bottom: 12px; }
.next-match-players { display: flex; align-items: center; justify-content: center; gap: 16px; }
.next-match-name { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 26px; letter-spacing: 1px; flex: 1; }
.next-match-name:first-child { text-align: right; }
.next-match-name:last-child { text-align: left; }
.next-match-vs { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 18px; opacity: 0.6; }
.next-match-group { font-size: 12px; opacity: 0.6; text-align: center; margin-top: 10px; }
.next-match-count { font-size: 11px; opacity: 0.5; text-align: center; margin-top: 4px; }

.coming-up {
    font-family: 'Squada One', sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-align: center;
    padding: 8px 0 0;
}

.section-label { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 14px; letter-spacing: 2px; color: var(--text-muted); margin-top: 4px; }

/* Groups */
.groups-grid { display: flex; flex-direction: column; gap: 12px; }
.group-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.group-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border); }
.group-name { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 15px; letter-spacing: 2px; color: var(--red); }
.group-progress { font-size: 11px; color: var(--text-muted); }

.standings-table { width: 100%; border-collapse: collapse; }
.standings-table th { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 10px; letter-spacing: 1px; color: var(--text-muted); padding: 6px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.standings-table th:not(:first-child) { text-align: center; }
.standings-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.standings-table td:not(:first-child) { text-align: center; }
.standings-table tr:last-child td { border-bottom: none; }
.standings-table tr.qualified td:first-child { border-left: 3px solid var(--green); padding-left: 9px; }
.standings-table tr.bye-row td { color: var(--text-muted); font-style: italic; }
.standing-pos { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 13px; color: var(--text-muted); margin-right: 6px; }
.standing-name { font-weight: 600; font-size: 13px; }
.standing-stat { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 14px; }
.stat-highlight { color: var(--text); }

.group-body { overflow: hidden; height: 0; transition: height 0.3s ease; }
.group-matches-toggle { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; cursor: pointer; font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 11px; letter-spacing: 1.5px; color: var(--text-muted); border-top: 1px solid var(--border); }
.group-matches-toggle:active { background: rgba(255,255,255,0.04); }

.match-row { display: flex; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); cursor: pointer; transition: background 0.15s; gap: 8px; }
.match-row:active { background: rgba(255,255,255,0.04); }
.match-row.bye-match { cursor: default; opacity: 0.5; }
.match-p1, .match-p2 { flex: 1; font-size: 13px; font-weight: 600; }
.match-p1 { text-align: right; }
.match-p2 { text-align: left; }
.match-score { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 16px; min-width: 48px; text-align: center; color: var(--text-muted); }
.match-score.played { color: var(--text); }
.match-p1.winner, .match-p2.winner { color: var(--green); }
.match-p1.loser, .match-p2.loser { color: var(--text-muted); }
.match-play-icon { font-size: 16px; color: var(--text-muted); min-width: 48px; text-align: center; }
.match-edit-hint { font-size: 10px; color: var(--text-muted); min-width: 16px; text-align: center; }

/* ── Bracket ── */
.bracket-scroll { flex: 1; overflow-x: auto; overflow-y: auto; padding: 20px; display: flex; align-items: center; }
.bracket-container { display: flex; align-items: stretch; min-width: max-content; gap: 0; min-height: 60vh; flex: 1; }
.bracket-round { display: flex; flex-direction: column; min-width: 200px; }
.bracket-round.has-connectors { padding-right: 32px; }
.round-label { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 14px; letter-spacing: 2px; color: var(--text-muted); text-align: center; margin-bottom: 12px; flex-shrink: 0; }
.round-matches { display: flex; flex-direction: column; flex: 1; }
.bracket-pair { flex: 1; display: flex; flex-direction: column; position: relative; }
.bracket-match-wrapper { flex: 1; display: flex; align-items: center; padding: 6px 0; position: relative; }
.bracket-match { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; width: 100%; }
.bracket-player { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--border); }
.bracket-player:last-child { border-bottom: none; }
.bracket-player:active { background: rgba(255,255,255,0.06); }
.bracket-player.bye { color: var(--text-muted); font-style: italic; cursor: default; font-weight: 400; }
.bracket-player.winner { background: rgba(39,174,96,0.15); color: var(--green); }
.bracket-player.loser { color: var(--text-muted); text-decoration: line-through; }
.winner-badge { font-size: 12px; opacity: 0.7; }

/* Bracket connector lines */
.has-connectors .bracket-pair::after {
    content: '';
    position: absolute;
    right: -13px;
    top: 25%;
    bottom: 25%;
    border-right: 2px solid rgba(255,255,255,0.15);
}
.has-connectors .bracket-match-wrapper::after {
    content: '';
    position: absolute;
    right: -13px;
    top: 50%;
    width: 13px;
    border-top: 2px solid rgba(255,255,255,0.15);
}
.has-connectors .bracket-pair::before {
    content: '';
    position: absolute;
    right: -24px;
    top: 50%;
    width: 11px;
    border-top: 2px solid rgba(255,255,255,0.15);
}

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; align-items: flex-end; justify-content: center; max-width: 480px; margin: 0 auto; }
.modal-overlay.open { display: flex; }
.modal-sheet { background: #2a2a2a; border-radius: 20px 20px 0 0; padding: 12px 24px calc(32px + env(safe-area-inset-bottom)); width: 100%; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.modal-top-row { display: flex; align-items: center; justify-content: center; width: 100%; position: relative; }
.modal-handle { width: 40px; height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; }
.modal-close-btn { position: absolute; right: 0; top: -4px; background: none; border: none; color: var(--text-muted); font-size: 28px; cursor: pointer; padding: 0 4px; line-height: 1; }
.modal-close-btn:active { color: var(--text); }
.modal-label { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 14px; letter-spacing: 2px; color: var(--text-muted); }
.modal-players { display: flex; align-items: center; gap: 16px; width: 100%; }
.modal-player-block { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.modal-player-name { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 20px; text-align: center; line-height: 1.1; }
.modal-player-sublabel { font-size: 11px; letter-spacing: 1px; color: var(--text-muted); }
.modal-vs { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 16px; color: var(--text-muted); flex-shrink: 0; }
.leg-counter { display: flex; align-items: center; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.leg-btn { width: 44px; height: 52px; background: none; border: none; color: var(--text); font-size: 26px; cursor: pointer; line-height: 1; }
.leg-btn:active { background: rgba(255,255,255,0.08); }
.leg-value { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 32px; min-width: 44px; text-align: center; line-height: 1; }
.modal-winner-hint { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 1px; color: var(--green); min-height: 22px; }
.btn-confirm-result { width: 100%; padding: 18px; background: var(--green); color: white; border: none; border-radius: 10px; font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 20px; letter-spacing: 2px; cursor: pointer; }
.btn-confirm-result:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-confirm-result:not(:disabled):active { filter: brightness(0.88); }

.placeholder-content { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 15px; }

/* Tournament History */
.history-body { flex: 1; overflow-y: auto; padding: 16px 20px calc(20px + env(safe-area-inset-bottom)); }
.history-loading, .history-empty {
    text-align: center; color: var(--text-muted); padding: 40px 20px;
    font-size: 14px;
}
.history-item {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.history-item-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
    font-family: 'Squada One', sans-serif; font-size: 12px; letter-spacing: 1px;
    color: var(--text-muted);
}
.history-winner {
    display: flex; align-items: center; gap: 10px;
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 22px; color: var(--text);
}
.history-trophy { font-size: 24px; }
.history-runner-up {
    margin-top: 6px; font-size: 13px; color: var(--text-muted);
    padding-left: 34px;
}

/* Current user badge */
.current-user-badge {
    display: none; flex-direction: column; align-items: flex-start; gap: 2px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 10px 14px; margin-top: 12px;
    cursor: pointer; align-self: flex-start;
    transition: background 0.15s;
}
.current-user-badge:active { background: rgba(255,255,255,0.1); }
.current-user-label {
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 10px; letter-spacing: 2px; color: var(--text-muted);
}
.current-user-name {
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 18px; letter-spacing: 1px; color: var(--text);
}

/* ── Resume Tournament Card ── */
.resume-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px 20px; margin-bottom: 16px; cursor: pointer;
    transition: transform 0.12s, filter 0.12s;
}
.resume-card:active { transform: scale(0.98); filter: brightness(0.9); }
.resume-label {
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 18px; letter-spacing: 1px; color: var(--orange); margin-bottom: 4px;
}
.resume-info { font-size: 13px; color: var(--text-muted); }

/* ── Soundboard Mini Button ── */
.soundboard-mini-btn {
    width: 40px; height: 40px; background: none; border: none;
    color: var(--text-muted); cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}
.soundboard-mini-btn:active { color: var(--text); }

/* ── Soundboard ── */
.soundboard-body { flex: 1; overflow-y: auto; padding: 16px; }
.soundboard-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
    max-width: 500px; margin: 0 auto;
}
.soundboard-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 24px 12px; border: none; border-radius: 16px;
    cursor: pointer; transition: transform 0.1s, filter 0.1s;
    min-height: 100px;
}
.soundboard-btn:active { transform: scale(0.95); filter: brightness(0.85); }
.soundboard-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.soundboard-btn:disabled:active { transform: none; filter: none; }
.soundboard-icon { font-size: 32px; }
.soundboard-name {
    font-family: 'Squada One', sans-serif; font-weight: 800;
    font-size: 16px; letter-spacing: 1px; color: white;
}

/* ── Card Soundboard (home) ── */
.card-soundboard { background: var(--card-bg); color: white; border: 1px solid var(--border); }
.card-soundboard .home-card-icon { opacity: 0.4; }
.card-soundboard .home-card-title { color: rgba(255,255,255,0.85); }

/* ── Lobby ── */
.lobby-body { flex: 1; display: flex; flex-direction: column; padding: 20px; gap: 18px; overflow-y: auto; }
.lobby-info { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.lobby-host { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 14px; letter-spacing: 2px; color: var(--orange); }
.lobby-format { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 1px; color: var(--text); }
.lobby-section { display: flex; flex-direction: column; gap: 10px; }
.lobby-section-label { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 12px; letter-spacing: 2px; color: var(--text-muted); }
.lobby-add-row { display: flex; gap: 10px; }
#lobby-players-list { display: flex; flex-direction: column; gap: 8px; }
.host-badge { display: inline-block; background: var(--orange); color: #1a1a1a; font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 9px; letter-spacing: 1.5px; padding: 2px 6px; border-radius: 4px; vertical-align: middle; margin-left: 6px; }

/* ── Active Tournaments ── */
.active-item { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; margin-bottom: 12px; cursor: pointer; transition: transform 0.12s, filter 0.12s; }
.active-item:active { transform: scale(0.98); filter: brightness(0.9); }
.active-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.active-state { font-family: 'Squada One', sans-serif; font-weight: 800; font-size: 11px; letter-spacing: 2px; padding: 4px 10px; border-radius: 6px; }
.active-lobby .active-state { background: rgba(245,160,0,0.15); color: var(--orange); }
.active-active .active-state { background: rgba(39,174,96,0.15); color: var(--green); }
.active-players { font-family: 'Squada One', sans-serif; font-weight: 700; font-size: 12px; letter-spacing: 1px; color: var(--text-muted); }
.active-host { font-size: 14px; color: var(--text); }

/* ── Landscape ── */
@media (min-width: 768px) and (min-aspect-ratio: 1/1) {
    .screen { max-width: 100%; }
    .soundboard-grid { grid-template-columns: repeat(4, 1fr); max-width: 700px; }
}
