:root {
  --bg1: #3b1f14;
  --bg2: #6a2c16;
  --card: #fdf6e9;
  --cell: #fffaf1;
  --ink: #3b2416;
  --muted: #8a6a55;
  --rust: #c4561f;
  --cranberry: #9e1b32;
  --gold: #e2a829;
  --sage: #7d8b5a;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg1) 70%) fixed;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- picker ---------- */
.picker {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--card);
}
.picker .turkey { font-size: 64px; line-height: 1; }
.picker h1 { font-family: var(--display); font-weight: 800; font-size: clamp(32px, 9vw, 52px); margin: 12px 0 4px; }
.picker .sub { color: #f1d9bf; margin: 0 0 24px; }
.picker .note { color: var(--gold); margin: 0 0 8px; }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 360px); }
.players a {
  display: block; padding: 18px 12px; border-radius: 14px;
  background: var(--card); color: var(--ink); text-decoration: none;
  font-family: var(--display); font-weight: 600; font-size: 22px;
  box-shadow: 0 4px 0 #00000040;
}
.players a:active { transform: translateY(2px); box-shadow: 0 2px 0 #00000040; }

/* ---------- card page ---------- */
.cardpage {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 8px max(16px, env(safe-area-inset-bottom));
}
header { color: var(--card); text-align: center; margin: 4px 0 10px; }
header h1 { font-family: var(--display); font-weight: 800; font-size: clamp(24px, 7vw, 36px); margin: 0; }
.who { display: flex; justify-content: center; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.who strong { font-size: 17px; }
.progress { font-size: 14px; color: #f1d9bf; }

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  padding: 6px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 10px 30px #00000055;
}

.colhead {
  position: relative;
  height: 40px;
  border-radius: 9px;
  background: var(--rust);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 2px 4px; text-align: center; overflow: hidden;
  font-family: var(--display); font-weight: 800; line-height: 1.05;
}
.colhead:nth-child(2) { background: var(--cranberry); }
.colhead:nth-child(3) { background: #8a5a2b; }
.colhead:nth-child(4) { background: var(--sage); }
.colhead:nth-child(5) { background: #b8742a; }
.colhead .fit { display: block; width: 100%; }

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1.5px solid #e8d6bd;
  border-radius: 10px;
  background: var(--cell);
  color: var(--ink);
  padding: 0;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s ease, background 0.2s ease;
}
.cell:active { transform: scale(0.95); }
.cell .label {
  position: absolute; inset: 5px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; z-index: 2;
}
.cell .fit {
  display: block; width: 100%;
  font-weight: 600; line-height: 1.12;
  word-break: normal; hyphens: manual;
}

/* bingo dauber: ink splat that spreads to fill the square */
.cell::after {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 150%; height: 150%;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 40%, #c42a45, #9e1b32 45%, #7e1428 70%);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.22s cubic-bezier(.3, 1.3, .5, 1);
  z-index: 1;
}
.cell.marked { border-color: #7e1428; }
.cell.marked::after { transform: translate(-50%, -50%) scale(1); }
.cell::before {
  content: '\2713';
  position: absolute; right: 4px; bottom: 1px; z-index: 3;
  font-size: 12px; font-weight: 800; color: #ffd9a0; opacity: 0;
}
.cell.marked::before { opacity: 1; }
.cell.marked .fit { color: #fff; text-shadow: 0 1px 2px #00000080; }

.cell.free {
  cursor: default;
  background: linear-gradient(160deg, #f6d27a, var(--gold));
  border-color: #c98f15;
}
.cell.free::after, .cell.free::before { display: none; }
.cell.free .label { inset: 15px 4px 4px; }
.cell.free .fit { color: var(--ink); text-shadow: none; }
.freetag {
  position: absolute; top: 3px; left: 0; right: 0; z-index: 2;
  font-family: var(--display); font-weight: 800; font-size: 10px; letter-spacing: 0.12em;
  color: #6a3d06;
}

.cell.win { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 14px #e2a829aa; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 22px #e2a829; } }

.hint { color: #f1d9bf; text-align: center; font-size: 14px; margin: 12px 0 6px; }
footer { display: flex; justify-content: center; gap: 22px; margin-top: 4px; }
.linkbtn {
  background: none; border: none; color: #f1d9bf; font: inherit; font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 14px;
  background: #1f120b; color: #fff; padding: 10px 10px 10px 16px;
  border-radius: 999px; box-shadow: 0 6px 20px #00000066;
  font-size: 14px; z-index: 50; animation: up 0.2s ease-out;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  flex: none; background: var(--gold); color: var(--ink); border: none; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; cursor: pointer;
}
@keyframes up { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.dialog { background: var(--card); border-radius: 16px; padding: 20px; width: min(100%, 340px); }
.dialog p { margin: 0 0 18px; font-size: 17px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.actions button { border: none; border-radius: 10px; padding: 10px 16px; font-size: 15px; font-weight: 600; cursor: pointer; }
.ghost { background: #eadbc6; color: var(--ink); }
.danger { background: var(--cranberry); color: #fff; }

/* ---------- BINGO overlay ---------- */
.bingo { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: #2a120acc; overflow: hidden; }
.bingo-card {
  position: relative; z-index: 2; text-align: center; color: var(--card);
  animation: pop 0.45s cubic-bezier(.3, 1.6, .5, 1);
}
.bingo-word { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 22vw, 140px); color: var(--gold); text-shadow: 0 4px 0 var(--cranberry), 0 10px 30px #000a; line-height: 1; }
.bingo-sub { font-size: 20px; margin-top: 10px; font-weight: 600; }
.bingo-tap { font-size: 13px; margin-top: 18px; opacity: 0.7; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px;
  animation-name: fall; animation-timing-function: cubic-bezier(.25, .6, .5, 1); animation-fill-mode: forwards;
}
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); } }

@media (prefers-reduced-motion: reduce) {
  .cell.win { animation: none; }
  .confetti { display: none; }
}
