/* ELECT Bingo — election-night styling */
:root {
  --navy: #0a1633;
  --navy-2: #122457;
  --navy-3: #1b3272;
  --red: #c8102e;
  --red-2: #e52a47;
  --blue: #2b5bd8;
  --blue-2: #4f7cf0;
  --white: #f6f4ee;
  --cream: #efe9da;
  --gold: #f5c542;
  --ink: #0a1633;
  --muted: #9aa7c7;
  --cell-bg: #f6f4ee;
  --cell-ink: #0f1d45;
  --font-head: 'Oswald', 'Arial Narrow', 'Roboto Condensed', Impact, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--white);
  background: var(--navy);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(79,124,240,.22), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(200,16,46,.22), transparent 45%);
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}
body::before { /* faint stars */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 22%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 70%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 48%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 25% 88%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 60% 35%, rgba(255,255,255,.3) 50%, transparent 51%);
}
.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 10px 12px 28px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 8px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .box { width: 34px; height: 34px; flex: none; }
.brand h1 { font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: .03em; margin: 0; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.iconbtn {
  appearance: none; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: var(--white);
  width: 40px; height: 40px; border-radius: 12px; font-size: 20px; line-height: 1; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:active { transform: scale(.94); }
.topbar .actions { display: flex; gap: 8px; }

/* ---------- card ---------- */
.card {
  background: var(--navy-2);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08);
  position: relative;
}
.card-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--muted);
  padding: 2px 4px 8px;
}
.card-title .id { color: var(--gold); font-weight: 600; letter-spacing: .12em; }

.letters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 5px; }
.letters span {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(26px, 8vw, 40px); line-height: 1;
  text-align: center; padding: 6px 0 4px; border-radius: 10px 10px 4px 4px;
  color: var(--white); text-shadow: 0 2px 0 rgba(0,0,0,.35);
  background: linear-gradient(180deg, var(--red-2), var(--red));
}
.letters span:nth-child(even) { background: linear-gradient(180deg, var(--blue-2), var(--blue)); }

.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.cell {
  position: relative; aspect-ratio: 1 / 1.12; border-radius: 8px; overflow: hidden;
  background: var(--cell-bg); color: var(--cell-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4px 3px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s ease, box-shadow .2s ease;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
}
.cell:active { transform: scale(.96); }
.cell svg { position: absolute; inset: 6% ; width: 88%; height: 88%; opacity: .11; pointer-events: none; }
.cell .name { position: relative; font-family: var(--font-head); font-weight: 600; font-size: clamp(10px, 2.9vw, 15px); line-height: 1.05; letter-spacing: .01em; word-break: break-word; }
.cell .st { position: relative; margin-top: 3px; font-size: clamp(8px, 2.3vw, 11px); font-weight: 700; letter-spacing: .14em; color: var(--red); }
.cell.free { background: linear-gradient(160deg, #fff3f4, #e9eeff); border: 2px dashed rgba(200,16,46,.45); cursor: default; }
.cell.free .name { color: var(--red); font-size: clamp(12px, 3.5vw, 18px); }
.cell.free .vote { position: relative; width: 44%; margin-bottom: 2px; }
.cell.overflow .st { color: var(--blue); }

/* best-line highlight */
.cell.best { box-shadow: 0 0 0 2px var(--gold), inset 0 -2px 0 rgba(0,0,0,.08); }
.cell.best.won { box-shadow: 0 0 0 2px var(--gold); }
.grid.one-away .cell.best { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 2px var(--gold); } 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 16px 2px rgba(245,197,66,.6); } }

/* stamp */
.cell.won { background: #dfe6fb; }
.cell.won .name, .cell.won .st { opacity: .55; }
.stamp {
  position: absolute; inset: 0; display: none; align-items: flex-end; justify-content: center; pointer-events: none; padding-bottom: 9%;
}
.cell.won .stamp { display: flex; }
.stamp span {
  font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  font-size: clamp(12px, 3.6vw, 19px); line-height: 1; color: var(--blue);
  border: 3px solid var(--blue); border-radius: 6px; padding: 3px 5px;
  transform: rotate(-14deg);
  mix-blend-mode: multiply; opacity: .92;
  text-shadow: 0 0 1px rgba(43,91,216,.5);
  mask-image: radial-gradient(circle at 30% 40%, #000 60%, rgba(0,0,0,.6) 80%, #000 100%);
}
.cell.won.just .stamp span { animation: slam .32s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes slam {
  0% { transform: rotate(-14deg) scale(2.6); opacity: 0; }
  60% { transform: rotate(-14deg) scale(.92); opacity: 1; }
  100% { transform: rotate(-14deg) scale(1); opacity: .92; }
}
.cell.won.just { animation: shake .3s ease-out; }
@keyframes shake { 0% { transform: translate(0,0);} 30% { transform: translate(-1px,2px);} 60% { transform: translate(1px,-1px);} 100% { transform: translate(0,0);} }
.cell.won.lined { background: #fff1c2; }
.cell.won.lined .stamp span { color: var(--red); border-color: var(--red); }

/* ---------- status strip ---------- */
.status {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;
  margin-top: 12px; padding: 10px 12px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
}
.status .count { font-family: var(--font-head); font-size: 28px; font-weight: 700; line-height: 1; color: var(--gold); }
.status .count small { font-size: 12px; color: var(--muted); font-weight: 500; display: block; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.status .best { font-size: 13px; line-height: 1.35; color: #d8def0; }
.status .best b { color: var(--white); }
.status .best .away { font-family: var(--font-head); color: var(--gold); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.status .best.hot .away { color: #ffd86a; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .55; } }

.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; line-height: 1.5; }
.hint b { color: #d8def0; font-weight: 600; }

/* ---------- lines won list ---------- */
.lines { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lines span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; background: var(--gold); color: var(--ink); }

/* ---------- menu sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(4,9,24,.6); backdrop-filter: blur(3px); z-index: 50; display: none; }
.sheet-bg.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 560px; margin: 0 auto;
  background: var(--navy-2); border-radius: 20px 20px 0 0; padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .22s ease; border-top: 1px solid rgba(255,255,255,.14);
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); margin: 2px auto 12px; }
.sheet button, .sheet a.btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; text-decoration: none;
  appearance: none; border: 0; background: rgba(255,255,255,.06); color: var(--white); font: inherit; font-size: 16px;
  padding: 14px 14px; border-radius: 12px; margin-bottom: 8px; cursor: pointer;
}
.sheet button:active, .sheet a.btn:active { background: rgba(255,255,255,.12); }
.sheet .ico { width: 26px; text-align: center; font-size: 18px; }
.sheet .danger { color: #ffb3bd; }
.sheet .sub { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 70;
  background: var(--white); color: var(--ink); font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: all .2s ease; pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- winner overlay ---------- */
.winner {
  position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, rgba(27,50,114,.92), rgba(10,22,51,.96));
}
.winner.open { display: flex; }
.winner .panel { text-align: center; animation: pop .5s cubic-bezier(.2,1.5,.4,1) both; max-width: 420px; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.winner .bingo {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(56px, 20vw, 110px); line-height: .95; letter-spacing: .04em;
  background: linear-gradient(180deg, #fff 0%, var(--gold) 55%, #d49a0a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,.35));
}
.winner .ribbon {
  display: inline-block; margin: 10px 0 14px; padding: 8px 22px; font-family: var(--font-head); font-weight: 700; letter-spacing: .2em; text-transform: uppercase;
  color: var(--white); background: linear-gradient(90deg, var(--red), var(--red-2)); border-radius: 6px;
  box-shadow: 0 6px 0 #8a0a1e;
}
.winner .meta { color: #d8def0; font-size: 15px; line-height: 1.5; }
.winner .meta b { color: var(--gold); letter-spacing: .12em; }
.winner .dismiss {
  margin-top: 22px; appearance: none; border: 2px solid rgba(255,255,255,.5); background: transparent; color: var(--white);
  font: inherit; font-weight: 600; padding: 12px 22px; border-radius: 999px; cursor: pointer;
}
.winner .stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.winner .stars i {
  position: absolute; width: 22px; height: 22px; background: var(--gold); opacity: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: twinkle 1.8s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: 0; transform: scale(.4) rotate(0deg);} 50% { opacity: 1; transform: scale(1.1) rotate(25deg);} }

/* ---------- confirm dialog ---------- */
.confirm { position: fixed; inset: 0; z-index: 65; display: none; align-items: center; justify-content: center; background: rgba(4,9,24,.7); padding: 24px; }
.confirm.open { display: flex; }
.confirm .box { background: var(--white); color: var(--ink); border-radius: 16px; padding: 20px; max-width: 360px; width: 100%; }
.confirm h3 { margin: 0 0 6px; font-family: var(--font-head); font-size: 22px; }
.confirm p { margin: 0 0 16px; color: #3a4668; font-size: 14px; line-height: 1.5; }
.confirm .row { display: flex; gap: 8px; justify-content: flex-end; }
.confirm button { appearance: none; border: 0; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer; background: #e7eaf3; color: var(--ink); }
.confirm button.go { background: var(--red); color: #fff; }

@media (min-width: 480px) {
  .brand h1 { font-size: 20px; }
}
