/* ============================================================
   PassGrid 10×10 — mobile-first redesign
   ============================================================ */

:root {
  /* Page */
  --bg:        #F4F4F5;
  --bg-2:      #FAFAFA;
  /* Cards */
  --card:      #FFFFFF;
  --card-line: #E6E6E8;
  --shadow:    0 2px 8px rgba(0,0,0,.07);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.05);
  /* Ink */
  --ink:       #1A1A1E;
  --ink-soft:  #4A4A52;
  --muted:     #8A8A92;
  /* Cell states */
  --open-bg:   #ECECEC;
  --open-bd:   #D8D8D8;
  --held-bg:   #C4C4C4;
  --held-bd:   #AEAEAE;
  --taken-bg:  #FF6A00;
  --taken-bd:  #C24F00;
  --yours-bg:  #f5b400;
  --yours-bd:  #8a6a14;
  --live-bg:   #F2B705;
  --live-bd:   #E0A200;
  /* Accents */
  --gold:      #F2B705;
  --win:       #19a463;
  --loss:      #E23B3B;
  --blue:      #3D7BF0;
  --red:       #E23B3B;
  /* Misc */
  --radius:    0.1875rem;
  --radius-sm: 0.1875rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ── */
.app {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 14px 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Shared card ── */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Header ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo-tile {
  width: 36px;
  height: 36px;
  border-radius: 0.1875rem;
  background: var(--card);
  border: 1px solid var(--card-line);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--blue);
  box-shadow: var(--shadow-sm);
}
.brand-wordmark {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
  color: var(--ink);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yours-bg);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: .03em;
}

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 0;
}
.back-link:hover { color: var(--ink); }

/* ── Fixture strip ── */
.fixture-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 8px;
}
.fixture-team {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fixture-team-b { flex-direction: row-reverse; }
.jersey {
  width: 32px;
  height: 36px;
  border-radius: 6px 6px 4px 4px;
  position: relative;
}
.jersey-a { background: linear-gradient(180deg, #1f5cc5 0%, #163fa3 100%); }
.jersey-b { background: linear-gradient(180deg, #fde047 0%, #eab308 100%); }
/* Shirt collar notch */
.jersey::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 8px;
  background: rgba(255,255,255,.25);
  border-radius: 0 0 6px 6px;
}
.team-code {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--ink);
}
.fixture-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
}
.fixture-datetime {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .03em;
  text-align: center;
}
.fixture-sport {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Stat bar ── */
.stat-bar {
  display: flex;
  align-items: stretch;
  padding: 10px 0;
  overflow: hidden;
}
.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
}
.stat-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
}
#closesValue { color: var(--ink); }
#closesValue.live { color: var(--red); }
.stat-divider {
  width: 1px;
  background: var(--card-line);
  align-self: stretch;
  margin: 4px 0;
}

/* ── Grid section ── */
.grid-section {
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grid-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.grid-label-team {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}
.grid-label-range {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
}
.grid-label-bottom { margin-top: 2px; }

/* match info row (clock + totals) */
.match-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.team-total-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  flex: 1;
}
.pill-b { flex-direction: row-reverse; }
.tpill-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
}
.tpill-val {
  font-family: 'Roboto Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.clock-pill {
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  text-align: center;
}
.clock-val {
  font-family: 'Roboto Mono', monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

/* progress */
.progress {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--open-bg);
  border: 1px solid var(--open-bd);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), #7ba8ff);
  transition: width .25s ease;
}
.progress-marker {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--blue);
  transform: translate(-50%,-50%);
  transition: left .25s ease;
  box-shadow: var(--shadow-sm);
  overflow: visible;
}
.progress .cp {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 10px;
  background: var(--gold);
  transform: translate(-50%,-50%);
  border-radius: 1px;
  opacity: .7;
  z-index: 1;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
  margin-top: -2px;
}

/* grid board */
.grid-wrap {
  width: 100%;
}
.board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.axis-x {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  margin-left: 18px;
}
.axis-x span {
  text-align: center;
  font-family: 'Roboto Mono', monospace;
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 600;
}
.grid-with-yaxis {
  display: flex;
  gap: 4px;
  align-items: stretch;
  width: 100%;
}
.axis-y {
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  gap: 3px;
  width: 14px;
}
.axis-y span {
  display: grid;
  place-items: center;
  font-family: 'Roboto Mono', monospace;
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 600;
}

/* grid cells */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 3px;
  aspect-ratio: 1 / 1;
}
.tile {
  border: 1px solid var(--open-bd);
  border-radius: 0.1875rem;
  background: var(--open-bg);
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: clamp(6px, 1.8vw, 11px);
  font-weight: 600;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
  user-select: none;
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
}
.tile:hover { opacity: .85; }

/* OPEN */
.tile.open {
  background: var(--open-bg);
  border-color: var(--open-bd);
  color: transparent; /* no coord text in open cells by default */
}

/* HELD — mid-grey with dot */
.tile.held {
  background: var(--held-bg);
  border-color: var(--held-bd);
  color: transparent;
  cursor: not-allowed;
}
.tile.held::after {
  content: '•';
  position: absolute;
  font-size: 14px;
  color: #6A6A72;
  line-height: 1;
}

/* TAKEN — red, no initials */
.tile.taken {
  background: var(--taken-bg);
  border-color: var(--taken-bd);
  color: transparent;
  cursor: not-allowed;
}

/* YOURS — blue with RM */
.tile.claimed {
  background: var(--yours-bg);
  border-color: var(--yours-bd);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(61,123,240,.30);
}
.tile.claimed .init {
  font-size: .78em;
  letter-spacing: .02em;
}

/* LIVE / winning box — steady gold, NO pulse animation */
.tile.live {
  background: var(--live-bg) !important;
  border-color: var(--live-bd) !important;
  color: #3a2700 !important;
  font-weight: 800;
  box-shadow: 0 0 0 2px #ffe9a8, 0 3px 10px rgba(242,183,5,.45) !important;
  /* NO animation — steady gold only */
}
.tile.live .init { color: #3a2700 !important; }
.tile.live::after { display: none !important; } /* suppress held dot on live */

/* gold flash on checkpoint payout */
.tile.payflash {
  animation: payflash 1.2s ease;
}
@keyframes payflash {
  0%   { box-shadow: 0 0 0 0 var(--gold); }
  30%  { box-shadow: 0 0 0 5px #ffe08a, 0 6px 18px rgba(242,183,5,.6); transform: scale(1.08); }
  100% { box-shadow: none; transform: scale(1); }
}

/* ── Legend row ── */
.legend-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.legend-chips {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.lg {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: .03em;
}
.lg-swatch {
  width: 13px;
  height: 13px;
  border-radius: 0.1875rem;
  border: 1px solid transparent;
  display: block;
}
.lg-open  .lg-swatch { background: var(--open-bg);  border-color: var(--open-bd); }
.lg-held  .lg-swatch { background: var(--held-bg);  border-color: var(--held-bd); }
.lg-taken .lg-swatch { background: var(--taken-bg); border-color: var(--taken-bd); }
.lg-yours .lg-swatch { background: var(--yours-bg); border-color: var(--yours-bd); }
.legend-hint {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Controls ── */
.controls-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .08s ease, filter .12s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #f5b400, #c98e10);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245,180,0,.30);
  font-size: 15px;
  padding: 12px;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary.running {
  background: linear-gradient(180deg, #6b7a8c, #566373);
  box-shadow: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.speed-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
}
.speed-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-right: 2px;
  white-space: nowrap;
}
.speed-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--card-line);
  color: var(--ink-soft);
  border-radius: 0.1875rem;
  padding: 7px 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: .12s;
}
.speed-btn:hover { border-color: var(--blue); }
.speed-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.action-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.btn-ghost {
  flex: 1;
  min-width: 60px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--card-line);
  font-size: 12px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover { background: var(--open-bg); }
.btn-end {
  flex: 1;
  min-width: 60px;
  background: linear-gradient(180deg, #E23B3B, #C42C2C);
  color: #fff;
  border: none;
  font-size: 12px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(226,59,59,.22);
}
.btn-end:hover { filter: brightness(1.06); }
.picks-counter {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: 999px;
  padding: 7px 14px;
  text-align: center;
}
.picks-counter.full { color: var(--blue); border-color: var(--blue); }

/* ── Your card ── */
.yourcard { padding: 12px; }
.yourcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.yourcard-head h2 {
  font-size: 14px;
  font-weight: 700;
}
.round-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: 999px;
  padding: 4px 10px;
}
.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.score {
  background: var(--bg);
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  padding: 9px;
  text-align: center;
}
.score span {
  display: block;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  margin-bottom: 3px;
}
.score strong {
  font-size: 22px;
  font-family: 'Roboto Mono', monospace;
  color: var(--ink);
}
.score.win strong { color: var(--win); }
.score.loss strong { color: var(--loss); }

/* ── Winners board ── */
.history-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.history-head h2 { font-size: 14px; font-weight: 700; }
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--ink); }
.history {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.history li {
  font-size: 11.5px;
  line-height: 1.4;
  padding: 7px 9px;
  border-radius: 0.1875rem;
  background: var(--bg);
  border: 1px solid var(--card-line);
  color: var(--ink-soft);
  display: flex;
  gap: 7px;
  align-items: flex-start;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.history li .tag {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  flex: none;
}
.history li.win-log {
  border-color: var(--win);
  background: #edfaf4;
  color: #0f6b40;
}
.history li.win-log .tag { color: var(--win); }
.history li.loss-log {
  border-color: var(--loss);
  background: #fdeaed;
  color: #a02333;
}
.history li.loss-log .tag { color: var(--loss); }
.history .empty {
  justify-content: center;
  color: var(--muted);
  font-style: italic;
  border-style: dashed;
}

/* ── Winner toast ── */
.toast-wrap {
  position: fixed;
  top: 60px;
  right: 14px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  max-width: 280px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-left: 4px solid var(--muted);
  border-radius: 0.1875rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.toast-body { font-size: 13px; color: var(--ink); line-height: 1.3; }
.toast-body b { font-weight: 800; }
.toast-win { border-left-color: var(--gold); background: linear-gradient(100deg,#fffbea,#fff); }
.toast-win .toast-tag { color: var(--gold); }
.toast-other { border-left-color: var(--blue); }
.toast-other .toast-tag { color: var(--blue); }
@media (max-width: 480px) {
  .toast-wrap { top: auto; bottom: 56px; right: 8px; left: 8px; max-width: none; }
  .toast { max-width: none; }
}

/* ── Notify bar ── */
.notify-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #edf5ff;
  border: 1px solid #c5dbff;
  border-radius: 0.1875rem;
  font-size: 12px;
  color: #1a4d8f;
  font-weight: 600;
  line-height: 1.4;
}
.notify-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  flex: none;
}

/* ── Footer ── */
.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 2px;
  font-size: 11px;
  color: var(--muted);
}
#liveCoord {
  font-family: 'Roboto Mono', monospace;
  color: var(--ink-soft);
  font-weight: 700;
}

/* ── Responsive: wider screens keep column centered ── */
@media (min-width: 540px) {
  .app { padding: 0 20px 80px; }
}

/* ── Desktop: two-column — grid left, panel rail right ──
   Mobile keeps the single-column flex stack above untouched.
   On wide screens we switch .app to CSS grid and place panels
   explicitly so the right rail reads, top-to-bottom:
     Stat bar → Your card → Winners board → Demo controls.        */
@media (min-width: 900px) {
  .app {
    max-width: 1040px;
    padding: 0 24px 80px;
    display: grid;
    grid-template-columns: minmax(420px, 1.35fr) minmax(300px, 1fr);
    grid-template-rows: auto auto auto auto auto 1fr auto auto;
    grid-template-areas:
      "head     head"
      "back     back"
      "fixture  statbar"
      "grid     yourcard"
      "grid     winners"
      "grid     controls"
      "notify   notify"
      "foot     foot";
    column-gap: 18px;
    row-gap: 12px;
    align-items: start;
  }

  .topbar        { grid-area: head; }
  .back-link     { grid-area: back; }
  .fixture-strip { grid-area: fixture; align-self: stretch; }
  .stat-bar      { grid-area: statbar; align-self: stretch; }
  .grid-section  { grid-area: grid; }
  .yourcard      { grid-area: yourcard; }
  .history-card  { grid-area: winners; }
  .controls-card { grid-area: controls; }
  .notify-bar    { grid-area: notify; margin-bottom: 0; }
  .foot          { grid-area: foot; }

  /* Stat bar sits at the top of the rail, aligned with the fixture strip.
     Let the winners board grow to fill the rail height next to the grid. */
  .history-card  { min-height: 0; }
  .history       { max-height: none; flex: 1; }
}
