/* ── Reset & Variables ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0a1a0f;
  --bg2:       #112216;
  --bg3:       #1a3020;
  --surface:   #1e3828;
  --surface2:  #253f2d;
  --border:    rgba(45,153,85,0.22);
  --green:     #1a6b3c;
  --green-l:   #2d9955;
  --green-d:   #0f4526;
  --gold:      #d4a017;
  --gold-l:    #f0c040;
  --red:       #c0392b;
  --text:      #e8f5ee;
  --text2:     #9abba6;
  --text3:     #6b8f76;
  --fh:        'Barlow Condensed', sans-serif;
  --fb:        'Barlow', sans-serif;
  --radius:    10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--fb); font-size: 16px; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; height: 58px; position: sticky; top: 0; z-index: 100; }
.nav-logo { font-family: var(--fh); font-size: 22px; font-weight: 800; color: var(--gold-l); text-decoration: none; letter-spacing: 0.5px; }
.nav-logo span { color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 14px; font-weight: 500; padding: 7px 13px; border-radius: 8px; transition: all .15s; }
.nav-links a:hover, .nav-links a.active { background: var(--surface); color: var(--text); }
.nav-links .admin-link { color: #b090f0; }
.nav-links .btn-outline { border: 1px solid var(--border); }
.logout-btn { background: none; border: 1px solid var(--border); color: var(--text2); font-family: var(--fb); font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: all .15s; }
.logout-btn:hover { border-color: var(--red); color: #e87060; }
.theme-toggle-btn { background: none; border: 1px solid var(--border); font-size: 16px; padding: 4px 9px; border-radius: 8px; cursor: pointer; transition: border-color .15s; line-height: 1.3; }
.theme-toggle-btn:hover { border-color: var(--green-l); }

/* ── Container & Layout ───────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0; padding: 2rem 1.5rem; flex: 1; }
footer { text-align: left; padding: 1.5rem; color: var(--text3); font-size: 13px; border-top: 1px solid var(--border); margin-top: auto; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1 { font-family: var(--fh); font-size: 36px; font-weight: 800; color: var(--text); margin-bottom: .25rem; }
h2 { font-family: var(--fh); font-size: 22px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin: 1.75rem 0 .75rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
h3 { font-family: var(--fh); font-size: 18px; font-weight: 700; color: var(--text); }
p { color: var(--text2); margin-bottom: .75rem; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 14px; }
.alert-success { background: rgba(45,153,85,.18); border: 1px solid rgba(45,153,85,.4); color: #7de0a0; }
.alert-error   { background: rgba(192,57,43,.18); border: 1px solid rgba(192,57,43,.4); color: #e87060; }
.alert-info    { background: rgba(52,152,219,.15); border: 1px solid rgba(52,152,219,.4); color: #7bcff0; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .6px; }
.form-input, .form-select { width: 100%; background: var(--bg3); border: 1px solid var(--border); color: var(--text); font-family: var(--fb); font-size: 15px; padding: 10px 13px; border-radius: 8px; outline: none; transition: border-color .15s; appearance: none; }
.form-input:focus, .form-select:focus { border-color: var(--green-l); }
.form-input::placeholder { color: var(--text3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; color: var(--text2); }
.check-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--green-l); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-block; font-family: var(--fh); font-size: 16px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 10px 22px; border-radius: 8px; border: none; cursor: pointer; text-decoration: none; transition: all .15s; text-align: center; }
.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-l); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text2); }
.btn-secondary:hover { border-color: var(--green-l); color: var(--text); }
.btn-danger    { background: rgba(192,57,43,.2); border: 1px solid rgba(192,57,43,.4); color: #e87060; }
.btn-danger:hover { background: rgba(192,57,43,.35); }
.btn-gold      { background: var(--gold); color: #1a0f00; }
.btn-gold:hover { background: var(--gold-l); }
.btn-sm { font-size: 13px; padding: 6px 13px; border-radius: 7px; }
.btn-block { width: 100%; display: block; }

/* ── Auth cards ───────────────────────────────────────────────────────────── */
.auth-wrap { max-width: 420px; margin: 3rem auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2.25rem; }
.auth-title { font-family: var(--fh); font-size: 30px; font-weight: 800; color: var(--gold-l); margin-bottom: 4px; }
.auth-sub { color: var(--text2); font-size: 14px; margin-bottom: 1.75rem; }
.auth-switch { text-align: center; margin-top: 1.25rem; font-size: 13px; color: var(--text2); }
.auth-switch a { color: var(--gold-l); text-decoration: none; }
.qr-wrap { text-align: center; margin: 1rem 0; }
.qr-wrap img { border: 4px solid #fff; border-radius: 8px; width: 180px; height: 180px; }
.otp-hint { background: var(--bg3); border: 1px dashed var(--border); border-radius: 8px; padding: 1rem; margin: 1rem 0; font-size: 13px; color: var(--text2); line-height: 1.6; }
.otp-hint code { color: var(--gold-l); font-family: monospace; font-size: 14px; word-break: break-all; }

/* ── Stats row ────────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.75rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); margin-bottom: 3px; }
.stat-value { font-family: var(--fh); font-size: 30px; font-weight: 800; color: var(--text); }
.stat-value.gold  { color: var(--gold-l); }
.stat-value.green { color: #7de0a0; }

/* ── Match cards ──────────────────────────────────────────────────────────── */
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; transition: border-color .15s; }
.match-card:hover { border-color: rgba(45,153,85,.45); }
.match-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.match-meta { font-size: 12px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.match-body { display: flex; align-items: center; gap: 12px; }
.team-name { font-family: var(--fh); font-size: 21px; font-weight: 700; flex: 1; }
.team-name.home { text-align: right; }
.score-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.score-box { width: 46px; height: 46px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: var(--fh); font-size: 24px; font-weight: 800; color: var(--text); }
.score-sep { font-family: var(--fh); font-size: 22px; color: var(--text3); font-weight: 700; }
.score-input { width: 46px; height: 46px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; text-align: center; font-family: var(--fh); font-size: 24px; font-weight: 800; color: var(--text); outline: none; padding: 0; -moz-appearance: textfield; }
.score-input::-webkit-outer-spin-button, .score-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.score-input:focus { border-color: var(--green-l); background: var(--bg2); }
.match-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text3); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: .5px; }
.badge-open    { background: rgba(45,153,85,.2);  color: #7de0a0; border: 1px solid rgba(45,153,85,.4); }
.badge-closed  { background: rgba(100,100,100,.2); color: var(--text3); border: 1px solid rgba(100,100,100,.3); }
.badge-tipped  { background: rgba(212,160,23,.2); color: var(--gold-l); border: 1px solid rgba(212,160,23,.4); }
.badge-pts     { background: rgba(212,160,23,.25); color: var(--gold-l); border: 1px solid rgba(212,160,23,.5); }
.badge-exact   { background: rgba(45,153,85,.3);  color: #5ef5a0; border: 1px solid rgba(45,153,85,.6); }
.badge-blocked { background: rgba(192,57,43,.2); color: #e87060; border: 1px solid rgba(192,57,43,.4); }

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
.leaderboard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.lb-thead { display: grid; grid-template-columns: 32px 1fr 60px 60px 60px; padding: 5px .75rem; background: var(--bg3); font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; }
.lb-row { display: grid; grid-template-columns: 32px 1fr 60px 60px 60px; padding: 4px .75rem; border-top: 1px solid var(--border); align-items: center; transition: background .1s; line-height: 1.3; }
.lb-row:hover { background: var(--surface2); }
.lb-row.me { background: rgba(45,153,85,.1); border-left: 3px solid var(--green-l); }
.lb-rank { font-family: var(--fh); font-size: 14px; font-weight: 800; color: var(--text3); }
.lb-rank.gold { color: var(--gold-l); }
.lb-name { font-weight: 500; font-size: 13px; }
.lb-num  { font-family: var(--fh); font-size: 14px; font-weight: 700; text-align: center; color: var(--text2); }
.lb-pts  { color: var(--gold-l) !important; }
.lb-exact { color: #7de0a0 !important; }

/* ── Admin ────────────────────────────────────────────────────────────────── */
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text3); padding: 4px 8px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 4px 8px; border-bottom: 1px solid rgba(45,153,85,.1); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(45,153,85,.04); }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Tips table (compact) ─────────────────────────────────────────────────── */
.table-scroll { overflow-x: visible; }
.tips-table { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tips-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text2); padding: 6px 8px; background: var(--bg3); text-align: left; white-space: nowrap; }
.tips-table th.team-col.home { text-align: right; }
.tips-table td { padding: 5px 8px; border-top: 1px solid rgba(45,153,85,.1); vertical-align: middle; line-height: 1.4; color: var(--text); }
.tips-table .meta-col { font-size: 13px; color: var(--text2); white-space: nowrap; }
.tips-table .meta-col small { font-size: 12px; color: var(--text2); }
.tips-table .team-col { font-family: var(--fh); font-size: 16px; font-weight: 700; white-space: nowrap; color: var(--text); }
.tips-table .team-col.home { text-align: right; }
.tips-table .score-col { text-align: center; width: 40px; }
.tips-table .sep-col { text-align: center; width: 12px; color: var(--text2); font-weight: 700; }
.tips-table .tip-val { font-family: var(--fh); font-size: 16px; font-weight: 800; color: var(--text); }
.tips-table .tip-val.empty { color: var(--text2); }
.tips-table .status-col { white-space: nowrap; }
.tips-table .result-display { display: block; font-size: 12px; color: var(--text2); margin-top: 2px; }
.tips-table .tips-link { display: block; font-size: 12px; color: var(--green-l); text-decoration: none; margin-top: 2px; }
.tips-table .tips-link:hover { text-decoration: underline; }
/* ── Compact table (shared for match-tips, etc.) ─────────────────────────── */
.compact-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.compact-table th { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--text3); padding: 4px 8px; background: var(--bg3); text-align: left; }
.compact-table td { padding: 3px 8px; border-top: 1px solid rgba(45,153,85,.1); vertical-align: middle; line-height: 1.3; }
.compact-table tr:hover td { background: rgba(45,153,85,.04); }
.compact-table tr.me td { background: rgba(45,153,85,.1); }
.compact-table tr.me td:first-child { border-left: 3px solid var(--green-l); padding-left: 5px; }
.you-tag { font-size: 10px; color: var(--green-l); }

.score-input-sm { width: 34px; height: 26px; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; text-align: center; font-family: var(--fh); font-size: 15px; font-weight: 800; color: var(--text); outline: none; padding: 0; -moz-appearance: textfield; }
.score-input-sm::-webkit-outer-spin-button, .score-input-sm::-webkit-inner-spin-button { -webkit-appearance: none; }
.score-input-sm:focus { border-color: var(--green-l); background: var(--bg2); }
.badge-zero { background: rgba(100,100,100,.2); color: var(--text3); border: 1px solid rgba(100,100,100,.3); }

/* Untipped rows */
.row-untipped { opacity: 0.45; }
.row-untipped:hover { opacity: 0.7; }
/* Finished rows */
.row-finished { border-left: 3px solid var(--green-d); }
.row-finished td:first-child { padding-left: 7px; }

/* ── Tips layout (sidebar + table) ────────────────────────────────────────── */
.tips-layout { display: grid; grid-template-columns: 1fr 3fr; gap: 12px; align-items: flex-start; }
.user-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-height: 70vh; overflow-y: auto; position: sticky; top: 68px; }
.sidebar-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); padding: 6px 10px; background: var(--bg3); }
.user-item { display: block; padding: 3px 10px; font-size: 13px; color: var(--text2); text-decoration: none; border-bottom: 1px solid rgba(45,153,85,.08); transition: all .1s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-item:hover { background: var(--surface2); color: var(--text); }
.user-item.active { background: var(--green); color: #fff; font-weight: 600; }
.tips-col { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.tips-col .table-scroll { overflow-x: visible; width: 100%; }
.tips-table { width: 100%; }
.save-row { text-align: left; }
/* ── Hamburger menu ──────────────────────────────────────────────────────── */
.nav-hamburger { display: none; background: none; border: 1px solid var(--border); color: var(--text2); font-size: 20px; padding: 4px 10px; border-radius: 6px; cursor: pointer; line-height: 1; }

/* ── Group tabs ──────────────────────────────────────────────────────────── */
.group-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.group-tab { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; text-decoration: none; background: var(--surface); border: 1px solid var(--border); color: var(--text2); transition: all .15s; cursor: pointer; }
.group-tab:hover { border-color: var(--green-l); color: var(--text); }
.group-tab.active { background: var(--green); border-color: var(--green-l); color: #fff; }

/* ── Admin group details ─────────────────────────────────────────────────── */
.group-details { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .5rem; }
.group-details summary { cursor: pointer; list-style: none; }
.group-details summary::-webkit-details-marker { display: none; }
.group-details[open] { background: var(--bg3); }

/* ── Leaderboard tips panel ──────────────────────────────────────────────── */
.lb-layout { display: flex; gap: 12px; align-items: flex-start; margin-top: 1rem; }
.lb-sidebar-col { width: 150px; flex-shrink: 0; }
.lb-main-col { width: 450px; flex-shrink: 0; }
.lb-row { cursor: pointer; }
.lb-row.selected { background: rgba(45,153,85,.18) !important; border-left: 3px solid var(--green-l); }
.lb-tips-panel { width: 400px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; position: sticky; top: 68px; max-height: calc(100vh - 90px); overflow-y: auto; }
.lb-tips-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg3); border-bottom: 1px solid var(--border); }
.lb-tips-header strong { font-family: var(--fh); font-size: 16px; font-weight: 700; }
.lb-tips-close { background: none; border: none; color: var(--text3); font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; }
.lb-tips-close:hover { color: var(--text); }

/* ── Light mode ───────────────────────────────────────────────────────────── */
html.light {
  --bg:        #cdd9cd;
  --bg2:       #ffffff;
  --bg3:       #e8efe8;
  --surface:   #ffffff;
  --surface2:  #edf3ed;
  --border:    rgba(0,100,40,0.15);
  --green:     #1a7a42;
  --green-l:   #1a8a45;
  --green-d:   #c8ecd5;
  --gold:      #b07800;
  --gold-l:    #8a5e00;
  --red:       #c0392b;
  --text:      #0f1f14;
  --text2:     #2d5c3a;
  --text3:     #5a7d63;
}
html.light .alert-success { background: rgba(26,138,69,.1); color: #0d5c2a; }
html.light .alert-error   { background: rgba(192,57,43,.1); color: #8b1a0f; }
html.light .alert-info    { background: rgba(52,152,219,.1); color: #1a5c8a; }
html.light .badge-open    { background: rgba(26,138,69,.15); color: #0d5c2a; border-color: rgba(26,138,69,.3); }
html.light .badge-tipped  { background: rgba(176,120,0,.15); color: #7a5200; border-color: rgba(176,120,0,.3); }
html.light .badge-pts     { background: rgba(176,120,0,.15); color: #7a5200; border-color: rgba(176,120,0,.3); }
html.light .badge-exact   { background: rgba(26,138,69,.2); color: #0a4520; border-color: rgba(26,138,69,.5); }
html.light .badge-blocked { background: rgba(192,57,43,.1); color: #8b1a0f; border-color: rgba(192,57,43,.3); }
html.light .lb-row.me     { background: rgba(26,138,69,.08); }
html.light .logout-btn:hover { color: #c0392b; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .lb-thead, .lb-row { grid-template-columns: 28px 1fr 50px 50px; }
  .lb-thead > :last-child, .lb-row > :last-child { display: none; }
  .nav-hamburger { display: block; }
  .nav-links { display: none; position: absolute; top: 58px; left: 0; right: 0; flex-direction: column; background: var(--bg2); border-bottom: 1px solid var(--border); padding: .5rem 1rem; gap: 2px; z-index: 99; }
  .nav-links.nav-open { display: flex; }
  .nav-links a, .nav-links .logout-btn, .nav-links form { width: 100%; }
  .nav-links .logout-btn { text-align: left; padding: 7px 13px; width: 100%; }
  .tips-table { font-size: 11px; }
  .tips-table .team-col { font-size: 12px; }
  .score-input-sm { width: 30px; height: 24px; font-size: 13px; }
  .tips-layout { grid-template-columns: 1fr; }
  .lb-layout { flex-direction: column; overflow-x: visible; }
  .lb-sidebar-col, .lb-main-col, .lb-tips-panel { width: 100%; flex-shrink: 1; }
  .lb-tips-panel { position: static; max-height: none; }
  .user-sidebar { width: 100%; max-height: 120px; position: static; flex-direction: row; display: flex; flex-wrap: wrap; gap: 0; border-radius: 8px; }
  .sidebar-title { padding: 4px 8px; width: 100%; }
  .user-item { display: inline-block; border-bottom: none; padding: 2px 8px; font-size: 12px; }
  .tips-col { width: 100%; }
}
