/* ============================================================
   Moneydial 2026 — Matchday Retro
   Palette: cream #F5F0E4 · pitch #0E3B2E · gold #D9A441 · red #C8402F
   Fonts: Secular One (display) · Rubik (body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Secular+One&family=Rubik:wght@400;500;600;700&display=swap');

:root {
  --cream:       #F5F0E4;
  --cream-dark:  #EAE4D2;
  --pitch:       #0E3B2E;
  --pitch-mid:   #1A5C40;
  --pitch-light: #2C7A58;
  --gold:        #D9A441;
  --gold-dark:   #B8882E;
  --red:         #C8402F;
  --dark:        #1A1A1A;
  --muted:       #6B6355;
  --border:      #1A1A1A;
  --radius:      6px;
  --sticker-shadow: 3px 3px 0 var(--dark);
  --font-display: 'Secular One', 'Arial Hebrew', sans-serif;
  --font-body:    'Rubik', 'Arial Hebrew', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--cream);
  color: var(--dark);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  direction: rtl;
}

/* ---- Layout ---- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px 80px;
  min-height: 100dvh;
}

/* ---- Header ---- */
.app-header {
  background: var(--pitch);
  color: var(--cream);
  text-align: center;
  padding: 20px 16px 16px;
  margin: 0 -12px 16px;
  border-bottom: 3px solid var(--dark);
}
.app-header h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: -0.5px;
  color: var(--cream);
  line-height: 1.1;
}
.app-header h1 .gold { color: var(--gold); }
.app-header .tagline {
  font-size: 0.78rem;
  color: rgba(245,240,228,.6);
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  background: var(--pitch);
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--sticker-shadow);
  position: sticky;
  top: 8px;
  z-index: 50;
}
.nav button {
  flex: 1;
  background: transparent;
  color: rgba(245,240,228,.65);
  border: none;
  border-left: 1px solid rgba(255,255,255,.1);
  padding: 11px 4px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav button:last-child { border-left: none; }
.nav button.active {
  background: var(--gold);
  color: var(--dark);
}
.nav button:not(.active):hover {
  background: var(--pitch-mid);
  color: var(--cream);
}

/* ---- Screen transitions ---- */
.screen { display: none; }
.screen.active { display: block; }

/* ---- Login ---- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 120px);
  padding: 20px 0;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--cream);
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  box-shadow: var(--sticker-shadow);
  overflow: hidden;
}
.login-card-head {
  background: var(--pitch);
  color: var(--cream);
  padding: 20px 20px 16px;
  text-align: center;
}
.login-card-head h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
}
.login-card-head p {
  font-size: 0.8rem;
  opacity: .7;
  margin-top: 4px;
}
.login-card-body { padding: 20px; }
.login-field {
  margin-bottom: 12px;
}
.login-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-error {
  background: rgba(200,64,47,.08);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.82rem;
  margin-top: 10px;
  display: none;
}
.login-error.visible { display: block; }

/* ---- Inputs ---- */
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  background: white;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  color: var(--dark);
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: rtl;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(217,164,65,.2);
}
input::placeholder { color: var(--muted); font-weight: 400; }

/* Score inputs: narrower */
input.score-input {
  width: 52px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 8px 4px;
  font-variant-numeric: tabular-nums;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: translate(1px, 1px); }
.btn-primary {
  background: var(--pitch);
  color: var(--cream);
  box-shadow: var(--sticker-shadow);
  width: 100%;
  margin-top: 4px;
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-gold {
  background: var(--gold);
  color: var(--dark);
  box-shadow: var(--sticker-shadow);
}
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  color: var(--dark);
  border-color: var(--dark);
}
.btn-outline:hover { background: var(--cream-dark); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; }

/* Outcome/bet toggle buttons */
.bet-group {
  display: flex;
  gap: 6px;
}
.bet-btn {
  flex: 1;
  padding: 9px 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  background: white;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
}
.bet-btn:hover { background: var(--cream-dark); }
.bet-btn.selected {
  background: var(--pitch);
  color: var(--cream);
  border-color: var(--pitch);
  box-shadow: 2px 2px 0 var(--dark);
}
.bet-btn.selected.gold-pick {
  background: var(--gold);
  color: var(--dark);
  border-color: var(--gold-dark);
}

/* ---- Section header ---- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--dark);
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--pitch);
}
.section-head .count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

/* ---- Stage badge ---- */
.stage-badge {
  display: inline-block;
  background: var(--pitch);
  color: var(--cream);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.stage-badge.group  { background: var(--pitch); }
.stage-badge.r32    { background: #1a4a6b; }
.stage-badge.r16    { background: #6b3a1a; }
.stage-badge.qf     { background: #4a1a6b; }
.stage-badge.sf     { background: #6b1a1a; }
.stage-badge.final  { background: var(--gold); color: var(--dark); }
.stage-badge.x3rd   { background: var(--muted); }

/* ---- Match card ---- */
.match-card {
  background: white;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  box-shadow: var(--sticker-shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.match-card-head {
  background: var(--cream-dark);
  border-bottom: 1px solid var(--cream-dark);
  padding: 7px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.match-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  direction: ltr;
  unicode-bidi: isolate;
}
.match-time.locked { color: var(--red); font-weight: 700; }

.match-teams {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 10px;
}
.team-name {
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.team-name.home { justify-content: flex-start; }
.team-name.away { justify-content: flex-end; flex-direction: row-reverse; }
.team-flag { font-size: 1.3rem; line-height: 1; }
.vs-sep {
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Score display (after result) */
.match-result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 0 8px;
}
.result-score {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--dark);
}

/* ---- Bets section ---- */
.match-bets {
  border-top: 1px solid var(--cream-dark);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bet-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bet-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  min-width: 70px;
  flex-shrink: 0;
}
.exact-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  direction: ltr;
  unicode-bidi: isolate;
}
.exact-sep {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--muted);
  padding: 0 1px;
}

.match-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px;
  justify-content: flex-end;
}
.save-msg {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
  margin-right: 0;
  font-variant-numeric: tabular-nums;
}
.save-msg.ok    { color: var(--pitch-mid); font-weight: 600; }
.save-msg.error { color: var(--red); font-weight: 600; }

/* Locked overlay */
.locked-banner {
  background: var(--red);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 12px;
  text-align: center;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Points earned (after result) */
.points-earned {
  background: var(--pitch);
  color: var(--cream);
  padding: 6px 12px;
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.points-earned .pts {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ---- Who bar ---- */
.who-bar {
  background: var(--cream-dark);
  border: 1px solid var(--cream-dark);
  border-bottom: 2px solid var(--dark);
  padding: 6px 12px;
  margin: 0 -12px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}
.who-bar .player-name {
  font-weight: 700;
  color: var(--pitch);
}
.who-bar .logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: underline;
  padding: 0;
}
.who-bar .logout-btn:hover { color: var(--red); }

/* ---- Avatar ---- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--dark);
  background: var(--pitch-mid);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar.lg { width: 42px; height: 42px; font-size: 1.1rem; }

/* Avatar colors by id */
.avatar[data-av="1"]  { background: #1A5C40; }
.avatar[data-av="2"]  { background: #6b3a1a; }
.avatar[data-av="3"]  { background: #1a4a6b; }
.avatar[data-av="4"]  { background: #4a1a6b; }
.avatar[data-av="5"]  { background: #6b1a1a; }
.avatar[data-av="6"]  { background: #4a6b1a; }
.avatar[data-av="7"]  { background: #6b1a4a; }
.avatar[data-av="8"]  { background: #1a6b6b; }
.avatar[data-av="9"]  { background: #3a1a6b; }
.avatar[data-av="10"] { background: #1a3a6b; }
.avatar[data-av="11"] { background: #6b4a1a; }
.avatar[data-av="12"] { background: #1a6b3a; }

/* ---- Leaderboard ---- */
.leaderboard-wrap {
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  box-shadow: var(--sticker-shadow);
  overflow: hidden;
}
table.lb {
  width: 100%;
  border-collapse: collapse;
  background: white;
}
table.lb thead th {
  background: var(--pitch);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 8px;
  text-align: center;
}
table.lb thead th.name-col { text-align: right; }
table.lb tbody tr {
  border-bottom: 1px solid var(--cream-dark);
  transition: background 0.12s;
}
table.lb tbody tr:last-child { border-bottom: none; }
table.lb tbody tr:hover { background: var(--cream); }
table.lb tbody tr.me { background: rgba(14,59,46,.06); }
table.lb td {
  padding: 11px 8px;
  font-size: 0.88rem;
  text-align: center;
  vertical-align: middle;
}
table.lb td.rank {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  width: 36px;
}
table.lb td.name-col {
  text-align: right;
  font-weight: 700;
}
table.lb td.name-col .player-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
table.lb td.pts-col {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--pitch);
  font-weight: 700;
  direction: ltr;
  unicode-bidi: isolate;
}
table.lb td.sub-col {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
table.lb tbody tr.me td.pts-col { color: var(--gold-dark); }
.medal { font-size: 1rem; }
.move-arrow { font-size: 0.7rem; }
.move-up   { color: var(--pitch-mid); }
.move-down { color: var(--red); }
.move-same { color: var(--muted); }

/* ---- Tournament picks ---- */
.tournament-card {
  background: white;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  box-shadow: var(--sticker-shadow);
  overflow: hidden;
  margin-bottom: 12px;
}
.tournament-card-head {
  background: var(--pitch);
  color: var(--cream);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tournament-card-head h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--gold);
}
.tournament-card-head .pts-badge {
  background: var(--gold);
  color: var(--dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
}
.tournament-card-body { padding: 12px 14px; }
.tournament-locked {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 0 4px;
}
.tournament-pick-val {
  font-weight: 700;
  font-size: 1rem;
  color: var(--pitch);
  margin-top: 4px;
}

/* ---- Admin ---- */
.admin-section {
  background: white;
  border: 2px solid var(--dark);
  border-radius: var(--radius);
  box-shadow: var(--sticker-shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.admin-section h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--pitch);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cream-dark);
}
.admin-match {
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--cream);
}
.admin-match-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.admin-teams {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.admin-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.locked-tag {
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.finished-tag {
  background: var(--pitch);
  color: var(--cream);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
}
.back-link {
  display: inline-block;
  color: var(--pitch);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--pitch);
}
.back-link:hover { opacity: .75; }

/* ---- Misc ---- */
.empty, .loading {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 0.88rem;
}
.error-text {
  color: var(--red);
  font-size: 0.82rem;
  margin-top: 6px;
}
.inline-err {
  display: inline-block;
  background: rgba(200,64,47,.08);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.8rem;
  margin-top: 6px;
}
.save-status {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.save-status.ok    { color: var(--pitch-mid); }
.save-status.error { color: var(--red); }

/* Group header inside match list */
.group-header {
  background: var(--cream-dark);
  border: 1px solid var(--dark);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--pitch);
  margin: 14px 0 6px;
  display: inline-block;
  letter-spacing: 0.3px;
}

/* Admin form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Avatar picker grid */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 8px 0;
}
.avatar-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.12s;
}
.avatar-opt:hover { background: var(--cream-dark); }
.avatar-opt.selected {
  background: var(--pitch);
  outline: 2px solid var(--gold);
  border-radius: 4px;
}
.avatar-opt.selected .avatar { border-color: var(--gold); }

/* ---- Responsive ---- */
@media (max-width: 400px) {
  .app-header h1 { font-size: 1.5rem; }
  .team-name { font-size: 0.82rem; }
  .team-flag { font-size: 1.1rem; }
  .nav button { font-size: 0.75rem; padding: 9px 2px; }
  table.lb td { padding: 9px 5px; font-size: 0.8rem; }
  .form-grid { grid-template-columns: 1fr; }
}
