/* ==========================================================================
   PBC Tracker App — Modern Billiards Club UI (Mobile-First)
   ========================================================================== */

:root {
    /* Brand — Tournament Baize & Warm Brass */
    --brand-950: #06221b;
    --brand-900: #0b3b2e;
    --brand-800: #0f513e;
    --brand-700: #156b53;
    --brand-100: #e3f2ed;
    --brand-50:  #f0f8f5;

    --gold-600:  #a67c1e;
    --gold-500:  #c89b3c;
    --gold-100:  #fdf6e3;

    /* Neutrals */
    --bg-canvas:   #f4f6f5;
    --bg-surface:  #ffffff;
    --bg-subtle:   #f8faf9;
    --border:      #e2e8e5;
    --border-strong: #cbd5d0;

    --text-primary:   #10201b;
    --text-secondary: #4a5c56;
    --text-muted:     #72857e;

    /* Semantic */
    --win-bg:      #dcfce7;
    --win-text:    #166534;
    --loss-bg:     #fee2e2;
    --loss-text:   #991b1b;
    --info-bg:     #e0f2fe;
    --info-text:   #075985;
    --warn-bg:     #fef3c7;
    --warn-text:   #92400e;
    --danger:      #dc2626;
    --danger-hover:#b91c1c;

    /* Radii & Shadows */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(6, 34, 27, 0.04);
    --shadow-sm: 0 1px 3px rgba(6, 34, 27, 0.06), 0 1px 2px rgba(6, 34, 27, 0.04);
    --shadow-md: 0 6px 20px rgba(6, 34, 27, 0.08);

    --header-h: 60px;
    --bottom-nav-h: 64px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

a {
    color: var(--brand-800);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--brand-900);
}

.tabular {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Top Navigation Header
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(135deg, var(--brand-950) 0%, var(--brand-900) 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 10px rgba(6, 34, 27, 0.16);
}

.header-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 12px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand-word-extra {
    display: none;
}

.brand:hover {
    color: #ffffff;
}

.brand-ball {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #3a3f42 0%, #111416 62%, #000000 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 0 0 1.5px rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
}

.brand-ball span {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ffffff;
    color: #111416;
    font-size: 0.68rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.brand-sub {
    display: none;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Desktop Nav Links */
.desktop-nav {
    display: none;
    align-items: center;
    gap: 4px;
}

.desktop-nav a {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.desktop-nav a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.desktop-nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    font-weight: 600;
}

/* Header Right Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px 3px 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gold-500);
    color: var(--brand-950);
    font-size: 0.72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    flex-shrink: 0;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* ==========================================================================
   Mobile Bottom Navigation Bar
   ========================================================================== */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(6, 34, 27, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: var(--bottom-nav-h);
    max-width: 600px;
    margin: 0 auto;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 6px 4px;
    position: relative;
    transition: color 0.15s ease;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.bottom-nav-item.active {
    color: var(--brand-800);
}

.bottom-nav-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 3px;
    background: var(--brand-800);
    border-radius: 0 0 3px 3px;
}

.bottom-nav-item.primary-action svg {
    color: var(--brand-800);
}

/* ==========================================================================
   Main Container & Page Headers
   ========================================================================== */

.page-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px 14px 32px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.page-title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-subtitle {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 18px;
}

.card-my-group {
    border-color: var(--brand-700);
    box-shadow: 0 2px 10px rgba(15, 81, 62, 0.1);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ==========================================================================
   Flash Messages / Alerts
   ========================================================================== */

.messages {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    box-shadow: var(--shadow-xs);
}

.alert a {
    text-decoration: underline;
    font-weight: 700;
    color: inherit;
}

.alert.success { background: var(--win-bg);  color: var(--win-text);  border-color: #bbf7d0; }
.alert.error   { background: var(--loss-bg); color: var(--loss-text); border-color: #fecaca; }
.alert.info    { background: var(--info-bg); color: var(--info-text); border-color: #bae6fd; }
.alert.warning { background: var(--warn-bg); color: var(--warn-text); border-color: #fde68a; }

.alert-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.65;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 2px 4px;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    background: var(--brand-800);
    color: #ffffff;
    box-shadow: var(--shadow-xs);
}

.btn:hover {
    background: var(--brand-900);
    color: #ffffff;
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger-outline {
    background: var(--bg-surface);
    color: var(--danger);
    border-color: #fecaca;
}

.btn-danger-outline:hover {
    background: var(--loss-bg);
    color: var(--danger-hover);
}

.btn-sm {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.84rem;
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   Badges & Pills
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.badge-game {
    background: var(--brand-50);
    color: var(--brand-800);
    border: 1px solid var(--brand-100);
}

.badge-win {
    background: var(--win-bg);
    color: var(--win-text);
}

.badge-loss {
    background: var(--loss-bg);
    color: var(--loss-text);
}

.badge-neutral {
    background: #eef2f0;
    color: var(--text-secondary);
}

.badge-gold {
    background: var(--gold-100);
    color: var(--gold-600);
    border: 1px solid #f0ddb0;
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
}

.badge-you {
    background: var(--brand-800);
    color: #ffffff;
    font-size: 0.68rem;
    padding: 2px 7px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-tournament {
    background: var(--gold-100);
    color: var(--gold-600);
    border: 1px solid #f0ddb0;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

a.badge-tournament:hover {
    background: #faecc4;
    border-color: var(--gold-500);
    color: #856114;
}

/* ==========================================================================
   Dashboard KPI Grid
   ========================================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
}

.kpi-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kpi-value.accent-win { color: var(--win-text); }
.kpi-value.accent-loss { color: var(--loss-text); }

.kpi-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.kpi-card.span-2-mobile {
    grid-column: span 2;
}

/* ==========================================================================
   Tables (Clean, Modern, Responsive)
   ========================================================================== */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 9px 8px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 11px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--bg-subtle);
}

.data-table tbody tr.row-highlight {
    background: var(--brand-50);
}

.data-table tbody tr.row-highlight:hover {
    background: var(--brand-100);
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

/* Score Pill */
.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Chart Container & Filters */
.range-switch {
    display: inline-flex;
    align-items: center;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.range-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 5px 9px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.range-btn:hover {
    color: var(--text-primary);
}

.range-btn.active {
    background: var(--bg-surface);
    color: var(--brand-900);
    box-shadow: var(--shadow-xs);
}

.chart-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.chart-filters::-webkit-scrollbar {
    display: none;
}

.chart-filter-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    min-height: 32px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.chart-filter-btn:hover {
    border-color: var(--brand-800);
    color: var(--brand-800);
}

.chart-filter-btn.active {
    background: var(--brand-900);
    border-color: var(--brand-900);
    color: #ffffff;
}

.chart-filter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-filter-btn.active .chart-filter-dot {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.75);
}

.chart-container {
    position: relative;
    width: 100%;
    height: 240px;
}

/* ==========================================================================
   Mobile Match Cards (Dashboard History)
   ========================================================================== */

.match-cards-mobile {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    background: var(--bg-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-card.is-win {
    border-left: 4px solid #16a34a;
}

.match-card.is-loss {
    border-left: 4px solid #dc2626;
}

.match-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.match-card-body {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
}

.match-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.match-player {
    font-size: 0.94rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-player.is-winner {
    font-weight: 700;
    color: var(--text-primary);
}

.match-player.right {
    text-align: right;
}

.match-table-desktop {
    display: none;
}

/* ==========================================================================
   Rankings Tabs & Medals
   ========================================================================== */

.tab-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    margin-bottom: 16px;
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    border-color: var(--brand-800);
    color: var(--brand-800);
}

.tab-btn.active {
    background: var(--brand-800);
    border-color: var(--brand-800);
    color: #ffffff;
    box-shadow: var(--shadow-xs);
}

.tab-count {
    font-size: 0.74rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(16, 32, 27, 0.08);
    color: inherit;
}

.tab-btn.active .tab-count {
    background: rgba(255, 255, 255, 0.22);
}

.rank-panel {
    display: none;
}

.rank-panel.active {
    display: block;
}

.rank-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.rank-badge.rank-1 {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.rank-badge.rank-2 {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.rank-badge.rank-3 {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fdba74;
}

/* ==========================================================================
   Tournaments List & Detail
   ========================================================================== */

.section-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 22px 0 10px;
}

.section-label:first-of-type {
    margin-top: 0;
}

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

.tournament-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tournament-card:hover {
    border-color: var(--brand-700);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    color: inherit;
}

.tournament-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.tournament-name {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tournament-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.tournament-result-bar {
    margin-top: 2px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.84rem;
}

.tournament-result-bar.medal-gold {
    background: #fffbeb;
    border-color: #fde68a;
}

.tournament-result-bar.medal-silver {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.tournament-result-bar.medal-bronze {
    background: #fff7ed;
    border-color: #fed7aa;
}

.tournament-result-bar.not-played {
    background: transparent;
    border: 1px dashed var(--border);
    padding: 7px 12px;
}

.tournament-result-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.medal-pill {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.medal-pill.medal-gold {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #f59e0b;
}

.medal-pill.medal-silver {
    background: #e2e8f0;
    color: #334155;
    border: 1px solid #94a3b8;
}

.medal-pill.medal-bronze {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fb923c;
}

.medal-pill.medal-other {
    background: #e8eeeb;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}

.tournament-result-text {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-sep {
    color: var(--text-muted);
    margin: 0 3px;
}

.result-place {
    font-weight: 600;
}

.tournament-result-bar.medal-gold .result-place { color: #92400e; }
.tournament-result-bar.medal-silver .result-place { color: #334155; }
.tournament-result-bar.medal-bronze .result-place { color: #9a3412; }

.tournament-result-record {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.tournament-result-muted {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.back-link:hover {
    color: var(--brand-800);
}

.registration-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    margin-bottom: 18px;
}

.registration-banner.closed {
    background: var(--bg-subtle);
    border-color: var(--border);
}

.group-matches-list {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-match-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    font-size: 0.88rem;
}

.group-match-p1 {
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-match-p2 {
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn-remove {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn-remove:hover {
    background: var(--loss-bg);
    color: var(--danger);
    border-color: #fecaca;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.chip {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    font-size: 0.86rem;
    font-weight: 500;
}

/* ==========================================================================
   Forms & Auth Cards & Score Steppers
   ========================================================================== */

.auth-wrap {
    max-width: 420px;
    margin: 28px auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 22px;
}

.auth-header .brand-ball {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
}

.auth-header .brand-ball span {
    width: 22px;
    height: 22px;
    font-size: 0.95rem;
}

.form-card {
    max-width: 580px;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 16px; /* Prevents iOS zoom on focus */
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: auto;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-800);
    box-shadow: 0 0 0 3px rgba(15, 81, 62, 0.14);
}

.helptext {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.errorlist {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 500;
}

/* Side-by-side Score Entry with Touch Steppers */
.score-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.score-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.score-box label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.stepper-btn {
    width: 42px;
    height: 46px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.12s ease, border-color 0.12s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.stepper-btn:hover {
    background: var(--brand-50);
    border-color: var(--brand-800);
    color: var(--brand-800);
}

.stepper-btn:active {
    background: var(--brand-100);
}

.score-box input[type="number"] {
    width: 64px;
    min-height: 46px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    padding: 6px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    -moz-appearance: textfield;
}

.score-box input[type="number"]::-webkit-inner-spin-button,
.score-box input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 0.84rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pagination-actions {
    display: flex;
    gap: 8px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary);
}

.empty-state p {
    margin: 0 0 12px;
}

/* ==========================================================================
   Responsive Breakpoints (Tablet & Desktop)
   ========================================================================== */

@media (min-width: 480px) {
    .brand-word-extra {
        display: inline;
    }

    .header-inner {
        padding: 0 16px;
        gap: 12px;
    }

    .header-actions {
        gap: 8px;
    }

    .header-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .user-pill {
        max-width: none;
        font-size: 0.82rem;
    }

    .score-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .score-box {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding: 14px 12px;
        gap: 10px;
    }
}

@media (min-width: 640px) {
    .page-container {
        padding: 24px 20px 40px;
    }

    .card {
        padding: 22px 24px;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 12px;
    }

    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .kpi-card.span-2-mobile {
        grid-column: span 1;
    }

    .match-cards-mobile {
        display: none;
    }

    .match-table-desktop {
        display: block;
    }

    .tournament-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 330px;
    }
}

@media (min-width: 768px) {
    body.has-bottom-nav {
        padding-bottom: 0;
    }

    .bottom-nav {
        display: none;
    }

    .desktop-nav {
        display: flex;
    }

    .brand-sub {
        display: inline;
    }

    .page-title {
        font-size: 1.7rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
