@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --navy:       #0f172a;
  --navy-mid:   #1e293b;
  --blue:       #2563eb;
  --blue-light: #3b82f6;
  --blue-glow:  #60a5fa;
  --teal:       #0ea5e9;
  --green:      #16a34a;
  --green-bg:   #dcfce7;
  --gold:       #d97706;
  --gold-bg:    #fef3c7;
  --red:        #dc2626;
  --red-bg:     #fee2e2;
  --white:      #ffffff;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --radius:     12px;
  --shadow:     0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.15);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--navy);
  line-height: 1.6;
  font-size: 16px;
}

a { text-decoration: none; color: inherit; }

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,23,42,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo { font-size: 1.1rem; font-weight: 700; color: var(--white); }
.nav-logo span { color: var(--blue-light); }

.nav-links { display: flex; gap: 24px; list-style: none; }
.nav-links a { color: var(--gray-400); font-size: 0.875rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover, .nav-links a.active { color: var(--white); }

.nav-admin {
  background: var(--blue);
  color: var(--white) !important;
  padding: 6px 16px;
  border-radius: 8px;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  transition: background 0.2s !important;
}
.nav-admin:hover { background: var(--blue-light) !important; }

/* ── PAGE HEADER ── */
.page-header {
  background: linear-gradient(135deg, var(--navy) 0%, #0c1f3f 60%, #0d2a4a 100%);
  padding: 48px 24px 40px;
  color: var(--white);
}

.page-header-inner { max-width: 1100px; margin: 0 auto; }

.page-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.page-header h1 span { color: var(--blue-light); }

.page-header p { color: var(--gray-400); font-size: 1rem; }

/* ── MAIN CONTAINER ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}

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

.btn-primary   { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-light); }

.btn-success   { background: var(--green); color: var(--white); }
.btn-success:hover { background: #15803d; }

.btn-danger    { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; }

.btn-full { width: 100%; justify-content: center; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--navy);
}

/* ── BADGES / STATUS CHIPS ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-open    { background: #dbeafe; color: var(--blue); }
.badge-locked  { background: #fef9c3; color: #a16207; }
.badge-complete { background: var(--green-bg); color: var(--green); }
.badge-paid    { background: var(--green-bg); color: var(--green); }
.badge-unpaid  { background: var(--red-bg); color: var(--red); }

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

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--white);
  color: var(--navy);
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); }

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

.form-hint { font-size: 0.78rem; color: var(--gray-400); margin-top: 4px; }

/* ── GAME LIST ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.game-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  display: block;
  color: inherit;
}

.game-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--blue-light);
}

.game-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.game-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}

.game-card-teams {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.game-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-200);
}

.game-card-stat { font-size: 0.8rem; color: var(--gray-600); }
.game-card-stat strong { color: var(--navy); }

.fill-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.fill-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-light) 100%);
  border-radius: 3px;
  transition: width 0.4s;
}

/* ── GAME VIEW LAYOUT ── */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

.game-info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.game-info-item { font-size: 0.875rem; color: var(--gray-600); }
.game-info-item strong { display: block; font-size: 1rem; color: var(--navy); font-weight: 700; }

/* ── PAYOUTS ── */
.payouts-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.payout-item { text-align: center; flex: 1; min-width: 60px; }
.payout-label { font-size: 0.72rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.3px; }
.payout-amount { font-size: 1.1rem; font-weight: 800; color: var(--navy); }

/* ── SCORES SECTION ── */
.scores-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.scores-section h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 14px; color: var(--navy); }

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  gap: 12px;
}

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

.score-row-label { font-weight: 600; color: var(--gray-600); min-width: 60px; }
.score-numbers { font-weight: 700; color: var(--navy); font-size: 1rem; }
.score-winner { color: var(--green); font-weight: 600; font-size: 0.8rem; }
.score-no-winner { color: var(--gray-400); font-size: 0.8rem; font-style: italic; }

/* ── SCOREBOARD ── */
.scoreboard-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow-x: auto;
}

.scoreboard {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}

.scoreboard th {
  text-align: center;
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
}

.scoreboard .sb-team-col { text-align: left; min-width: 80px; }

.scoreboard td {
  text-align: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}

.scoreboard .sb-team-name {
  text-align: left;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--navy);
}

.scoreboard .sb-score {
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
}

.scoreboard .sb-score.current {
  color: var(--blue);
}

.scoreboard tfoot td {
  border-bottom: none;
  padding-top: 4px;
}

.sb-winner-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
}

/* ── GRID ── */
.grid-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.grid-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--navy);
}

.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.squares-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  --cell: 44px;
}

.squares-table td,
.squares-table th {
  width: var(--cell);
  min-width: var(--cell);
  height: var(--cell);
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--gray-200);
  font-family: inherit;
}

.corner-cell {
  background: var(--navy);
  color: var(--gray-400);
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  width: 28px !important;
  min-width: 28px !important;
}

.home-team-vertical {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a6c 100%);
  color: rgba(255,255,255,0.9);
  font-weight: 800;
  font-size: 0.6rem;
  letter-spacing: 0;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.35;
  width: 22px !important;
  min-width: 22px !important;
  padding: 4px 0;
  border: none;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.away-team-header {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a6c 100%);
  color: var(--white);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 6px 4px;
  height: 28px;
}

.num-header {
  background: var(--navy-mid);
  color: var(--white);
  font-weight: 700;
  font-size: 0.8rem;
  width: var(--cell);
  height: 28px;
}

.num-header.pending { color: var(--gray-400); }

.num-header.win-num {
  background: var(--blue) !important;
  color: white;
}

.square-cell {
  cursor: default;
  transition: opacity 0.15s;
  position: relative;
  font-weight: 600;
  font-size: 0.78rem;
}

.square-cell.empty {
  background: var(--gray-50);
  color: transparent;
}

.square-cell.claimed-unpaid {
  background: #dbeafe;
  color: #1e40af;
}

.square-cell.claimed-paid {
  background: var(--green-bg);
  color: #14532d;
}

.square-cell.winner {
  background: var(--gold-bg) !important;
  color: #78350f !important;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  font-weight: 800;
}

.square-cell:not(.empty) { cursor: pointer; }
.square-cell:not(.empty):hover { opacity: 0.8; }

/* ── GAME STATS STRIP (below grid) ── */
.game-stats-strip {
  display: flex;
  gap: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: -20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.game-stat-item {
  flex: 1;
  text-align: center;
  padding: 4px 8px;
  border-right: 1px solid var(--gray-200);
}

.game-stat-item:last-child { border-right: none; }

.game-stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy);
}

.game-stat-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.venmo-strip {
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-600);
  margin-bottom: 20px;
  padding: 4px 0;
}

.venmo-strip a {
  color: #3d95ce;
  font-weight: 700;
}

/* ── TOOLTIP ── */
.sq-tooltip {
  display: none;
  position: fixed;
  z-index: 200;
  background: var(--navy);
  color: var(--white);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.sq-tooltip.visible { display: block; }

/* ── CLAIM FORM ── */
.claim-section { }

.claim-section .card-title { color: var(--blue); }

/* ── PLAYERS LIST ── */
.players-list { }

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
  gap: 8px;
  font-size: 0.875rem;
}

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

.player-name { font-weight: 600; color: var(--navy); }
.player-meta { color: var(--gray-600); font-size: 0.8rem; margin-top: 1px; }
.player-squares { color: var(--gray-400); font-size: 0.78rem; }

/* ── ADMIN ── */
.admin-login {
  max-width: 400px;
  margin: 80px auto;
}

.admin-login h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
}

.admin-login p {
  color: var(--gray-600);
  text-align: center;
  margin-bottom: 28px;
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.admin-game-select {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 20px;
  align-items: end;
}

.admin-section {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  background: var(--white);
}

.admin-section h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.score-quarter { }
.score-quarter .quarter-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.score-inputs { display: flex; gap: 6px; }
.score-inputs input {
  width: 56px;
  padding: 8px;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  text-align: center;
  outline: none;
}
.score-inputs input:focus { border-color: var(--blue); }

.score-inputs .score-sep {
  display: flex;
  align-items: center;
  color: var(--gray-400);
  font-weight: 700;
}

.admin-players-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-players-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200);
}

.admin-players-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--navy);
  vertical-align: middle;
}

.admin-players-table tr:last-child td { border-bottom: none; }

/* ── HISTORY TABLE ── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
  background: var(--gray-50);
}

.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--navy);
}

.history-table tr:hover td { background: var(--gray-50); }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-success { background: var(--green-bg); color: #14532d; border-left: 3px solid var(--green); }
.alert-error   { background: var(--red-bg);   color: #7f1d1d; border-left: 3px solid var(--red); }
.alert-info    { background: #dbeafe;          color: #1e3a8a; border-left: 3px solid var(--blue); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ── FOOTER ── */
footer {
  background: var(--navy);
  color: var(--gray-400);
  padding: 28px 24px;
  margin-top: 40px;
  text-align: center;
  font-size: 0.8rem;
}

footer a { color: var(--blue-glow); }

/* ── SPINNER ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center { text-align: center; padding: 40px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .form-row-3, .form-row-4 { grid-template-columns: 1fr 1fr; }
  .admin-score-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .container { padding: 16px 12px; }
  .page-header { padding: 24px 12px; }
  .page-header h1 { font-size: 1.4rem; }
  .page-header p { font-size: 0.85rem; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .admin-score-grid { grid-template-columns: 1fr 1fr; }
  .payouts-row { gap: 6px; padding: 12px 16px; }
  .payout-amount { font-size: 0.95rem; }
  .tabs { flex-wrap: wrap; }
  /* fullbleed grid on mobile — break out of container padding */
  .grid-section {
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 12px 0;
  }
  .grid-section h2 { padding: 0 12px; }
  .game-stats-strip {
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .game-info-bar { gap: 12px; padding: 14px 16px; }
  .game-info-item { font-size: 0.8rem; }
  .card { padding: 16px; }
  .away-team-header { font-size: 0.65rem; }
  .squares-table { font-size: 0.6rem; }
  .corner-cell { width: 22px !important; min-width: 22px !important; font-size: 0.42rem; }
  .home-team-vertical { width: 20px !important; min-width: 20px !important; font-size: 0.5rem; }
}

.venmo-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 0;
  color: var(--gray-400);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.venmo-divider::before,
.venmo-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.venmo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #3d95ce;
  color: white !important;
  padding: 16px 20px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none !important;
  width: 100%;
  margin-top: 12px;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(61,149,206,0.4);
  border: 2px solid rgba(255,255,255,0.2);
}
.venmo-btn:hover { background: #2d7ab0; opacity: 0.95; }

.admin-secret-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.2);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.admin-secret-link:hover { color: rgba(255,255,255,0.5); }
