/* ============================================================
GLOBAL FONT SETUP — Merriweather (headings/buttons/labels) + Inter (body/tables/forms)
============================================================ */

/* Google Fonts import */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,400&family=Inter:wght@300..700&display=swap');

/* ── Font Variables ─────────────────────────────────────── */
:root {
  --font-display: 'Merriweather', Georgia, serif;
  --font-body:    'Inter', 'Helvetica Neue', system-ui, sans-serif;
}

/* ── Body / Paragraphs / Tables / Form controls — Inter ── */
body,
p,
td, th,
input, select, textarea,
.stat-row,
.game-detail-item,
.leaderboard-stats,
.form-rating-breakdown,
.history-player-stats,
.history-accordion-meta,
.form-rating-explainer > p,
.form-factor-desc,
.no-data,
.error,
.success {
  font-family: var(--font-body);
}

/* ── Headings — Merriweather ────────────────────────────── */
h1, h2, h3, h4, h5, h6,
header h1,
.section h2,
.chart-container h3,
.stat-card h3,
.player-input-card h4,
.leaderboard-name,
.game-title,
.summary-value,
#playerDetailName,
.history-accordion-date,
.form-factor-name,
.form-rating-name {
  font-family: var(--font-display);
}

/* ── Buttons — Merriweather ─────────────────────────────── */
button,
.tab {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

/* ── Key Labels / Badges / Uppercase tags — Merriweather ── */
label,
.summary-label,
.stat-card h3,
.stats-table th,
.player-input-card h4,
.form-score-badge,
.history-unlock-indicator {
  font-family: var(--font-display);
}

/* ── Player tags / chips — Merriweather ─────────────────── */
.player-tag,
.leaderboard-rank,
.form-rating-rank,
.form-score-number,
.form-factor-weight {
  font-family: var(--font-display);
}

/* ============================================================
PLAYER DETAIL VIEW
============================================================ */

#player-detail .section {
  padding: 24px;
}

#player-detail .chart-container {
  margin-top: 24px;
}

/* ============================================================
GAME STATS TAB — Summary Cards
============================================================ */

.game-stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.summary-card:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-2px);
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.summary-label {
  font-size: 0.72rem;
  color: rgba(205, 204, 202, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* ============================================================
GAME STATS TAB — Buy-ins Table
============================================================ */

.stats-table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 600px;
}

.stats-table thead tr {
  background: rgba(255, 255, 255, 0.06);
}

.stats-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(205, 204, 202, 0.5);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.stats-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: rgba(205, 204, 202, 0.85);
  vertical-align: middle;
}

.stats-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.stats-table tbody tr:last-child td {
  border-bottom: none;
}

.total-row {
  background: rgba(255, 255, 255, 0.05) !important;
  font-weight: 700;
}

.total-row td {
  color: rgba(205, 204, 202, 0.95) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* ============================================================
CHART CONTAINERS
============================================================ */

.chart-container {
  background: #000000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
}

.chart-container h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #ffffff;
  font-weight: 600;
  margin-bottom: 18px;
}

.chart-container canvas {
  max-height: 340px;
}

/* ============================================================
RESPONSIVE OVERRIDES
============================================================ */

@media (max-width: 640px) {
  .game-stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-value {
    font-size: 1.3rem;
  }

  .chart-container {
    padding: 16px;
  }

  .chart-container canvas {
    height: 350px !important;
  }

  .stats-table th,
  .stats-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}

@media (max-width: 400px) {
  .game-stats-summary {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

/* ============================================================
HISTORY TAB — Password Bar
============================================================ */

.history-password-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.history-password-bar input[type="password"] {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: rgba(205, 204, 202, 0.8);
  width: 280px;
  max-width: 100%;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.history-password-bar input[type="password"]::placeholder {
  color: rgba(205, 204, 202, 0.25);
}

.history-password-bar input[type="password"]:focus {
  outline: none;
  border-color: rgba(201, 168, 76, 0.45);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.08);
}

.history-unlock-indicator {
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  transition: color 180ms ease;
}

.history-unlock-indicator.unlocked {
  color: #6daa45;
}

.history-unlock-indicator.locked {
  color: rgba(221, 105, 116, 0.8);
}

/* ============================================================
HISTORY TAB — Player Row Layout Fix
============================================================ */

.history-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.history-player-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.history-player-name {
  font-weight: 600;
  color: rgba(205, 204, 202, 0.95);
  min-width: 80px;
  flex-shrink: 0;
}

.history-player-stats {
  color: rgba(205, 204, 202, 0.65);
  font-size: 0.82rem;
  flex: 1;
}

.history-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================
HISTORY TAB — Accordion
============================================================ */

.history-accordion-item {
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 200ms ease;
}

.history-accordion-item.is-open {
  border-color: rgba(255, 255, 255, 0.18);
}

.history-accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  gap: 12px;
}

.history-accordion-trigger:hover {
  background: rgba(255, 255, 255, 0.04);
}

.history-accordion-trigger:active {
  background: rgba(255, 255, 255, 0.07);
}

.history-accordion-date {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(205, 204, 202, 0.95);
  flex: 1;
}

.history-accordion-meta {
  font-size: 0.78rem;
  color: rgba(205, 204, 202, 0.45);
  white-space: nowrap;
}

.history-accordion-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: rgba(205, 204, 202, 0.4);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.history-accordion-item.is-open .history-accordion-chevron {
  transform: rotate(180deg);
}

.history-accordion-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.history-accordion-item.is-open .history-accordion-body {
  grid-template-rows: 1fr;
}

.history-accordion-inner {
  overflow: hidden;
}

.history-accordion-content {
  padding: 0 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 14px;
}

@media (max-width: 640px) {
  .history-accordion-trigger {
    padding: 12px 14px;
  }
  .history-accordion-content {
    padding: 12px 14px 14px;
  }
}

/* ============================================================
FORM RATING TAB
============================================================ */

.form-rating-explainer {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 28px;
}
.form-rating-explainer > p {
  margin-bottom: 16px;
  color: #ccc;
  font-size: 14px;
  line-height: 1.6;
}
.form-rating-factors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.form-factor-card {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-factor-weight {
  font-size: 22px;
  font-weight: 700;
  color: #fee140;
  line-height: 1;
}
.form-factor-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.form-factor-desc {
  font-size: 12px;
  color: #999;
  line-height: 1.4;
}

.form-rating-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  margin-bottom: 10px;
  transition: background 0.2s;
}
.form-rating-item:hover { background: rgba(255,255,255,0.06); }
.form-rating-rank {
  font-size: 18px;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: #888;
}
.form-rating-rank.rank-1 { color: #ffd700; }
.form-rating-rank.rank-2 { color: #c0c0c0; }
.form-rating-rank.rank-3 { color: #cd7f32; }
.form-rating-info { flex: 1; }
.form-rating-name {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}
.form-rating-breakdown {
  font-size: 12px;
  color: #888;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.form-rating-breakdown span { white-space: nowrap; }
.form-score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
}
.form-score-number {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.form-score-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.form-score-hot    { color: #ff6b35; }
.form-score-good   { color: #51cf66; }
.form-score-neutral { color: #ffd93d; }
.form-score-cold   { color: #74c0fc; }
.form-score-icecold { color: #a5d8ff; }

.form-score-badge-hot     { background: rgba(255,107,53,0.15);  color: #ff6b35; }
.form-score-badge-good    { background: rgba(81,207,102,0.15);  color: #51cf66; }
.form-score-badge-neutral { background: rgba(255,217,61,0.15);  color: #ffd93d; }
.form-score-badge-cold    { background: rgba(116,192,252,0.15); color: #74c0fc; }
.form-score-badge-icecold { background: rgba(165,216,255,0.15); color: #a5d8ff; }

.form-score-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.form-score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}
.form-provisional {
  font-size: 11px;
  color: #888;
  font-style: italic;
  margin-left: 6px;
}
#playerDetailName {
  font-family: var(--font-display) !important;
}
/* ══════════════════════════════════════════════════════════
   SEASON FILTER BAR
══════════════════════════════════════════════════════════ */

#seasonFilterBar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    min-height: 0;
}

#seasonFilterBar:empty {
    display: none;
}

.season-pill {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 700;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    width: auto !important;
    letter-spacing: 0.04em;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition),
                background var(--transition), box-shadow var(--transition);
    box-shadow: none !important;
}

.season-pill:hover {
    color: var(--color-text);
    border-color: var(--color-border-hover);
    background: rgba(255, 255, 255, 0.04);
    transform: none;
    box-shadow: none !important;
}

.season-pill.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 14px var(--color-primary-glow) !important;
}


/* ══════════════════════════════════════════════════════════
   SEASONS TAB — MANAGE CARDS
══════════════════════════════════════════════════════════ */

.season-manage-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-4) var(--space-5);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    transition: border-color var(--transition);
}

.season-manage-card:hover {
    border-color: var(--color-border-hover);
}

.season-manage-info {
    flex: 1;
    min-width: 160px;
}

.season-manage-name {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.season-manage-meta {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.season-manage-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.season-manage-actions button {
    width: auto !important;
    padding: var(--space-2) var(--space-4) !important;
    font-size: var(--text-xs) !important;
    min-height: 34px;
}


/* ══════════════════════════════════════════════════════════
   GAME → SEASON ASSIGNMENT MODAL
══════════════════════════════════════════════════════════ */

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.modal-close {
    background: none !important;
    border: none !important;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: var(--space-1) !important;
    width: 28px !important;
    height: 28px !important;
    min-height: unset !important;
    border-radius: var(--radius-sm) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: color var(--transition), background var(--transition);
    box-shadow: none !important;
}

.modal-close:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
    transform: none;
}

.modal-body {
    padding: var(--space-5) var(--space-6);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-shrink: 0;
}

.modal-footer button {
    width: auto !important;
    padding: var(--space-3) var(--space-5) !important;
}

/* Individual game row inside the assignment modal */
.assign-game-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: border-color var(--transition);
}

.assign-game-row:last-child {
    margin-bottom: 0;
}

.assign-game-row:hover {
    border-color: var(--color-border-hover);
}

.assign-game-info {
    flex: 1;
    min-width: 0;
}

.assign-game-date {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-game-meta {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    font-variant-numeric: tabular-nums;
}

.assign-season-select {
    flex-shrink: 0;
    min-width: 150px;
    max-width: 200px;
    font-family: var(--font-body);
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition);
    /* reset button defaults that width:100% would apply */
    width: auto !important;
    font-weight: 400 !important;
    letter-spacing: 0 !important;
}

.assign-season-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .assign-game-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .assign-season-select {
        width: 100% !important;
        max-width: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
}