/* play.css — the game screen. Colours come from theme.js custom properties. */
:root {
  --primary: #b08d3e; --on-primary: #fff; --accent: #d9b8a6; --bg: #faf7ef; --text: #4a4137;
  --ball: #b08d3e; --on-ball: #fff;
  --font-display: 'Pinyon Script', cursive; --font-body: 'Jost', system-ui, sans-serif;
  --card: color-mix(in srgb, var(--bg) 86%, white);
  --line: color-mix(in srgb, var(--primary) 26%, transparent);
  /* 80% keeps secondary text at 4.5:1 or better on the background and cards for every preset (worst: sage, 77%) */
  --muted: color-mix(in srgb, var(--text) 80%, var(--bg));
  --soft: color-mix(in srgb, var(--primary) 12%, var(--bg));
  --b: #f2a3a3; --i: #f4cf86; --n: #a6d39f; --g: #98c3e8; --o: #c6a6e0;
}
:root[data-dark="1"] { --card: color-mix(in srgb, var(--bg) 88%, white); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font-body);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- backgrounds ---------- */
.backdrop { position: fixed; inset: 0; z-index: -2; background: var(--bg); }
[data-bg="gradient"] .backdrop {
  background:
    radial-gradient(900px 480px at 10% -5%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 62%),
    radial-gradient(900px 520px at 92% 6%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 62%),
    radial-gradient(1200px 700px at 50% 112%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 62%),
    var(--bg);
}
[data-bg="photo"] .backdrop { background: var(--bg-photo) center / cover no-repeat; }
[data-bg="photo"] .backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(2px);
}
.slides { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.slides img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%;
  opacity: 0; transition: opacity 1.6s ease;
}
.slides img.on { opacity: .16; }
[data-dark="1"] .slides img.on { opacity: .22; }

/* ---------- layout ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; padding: clamp(14px, 2.4vw, 32px) clamp(14px, 3vw, 44px) 18px; gap: clamp(10px, 1.6vw, 22px); }
.head { text-align: center; }
.names { font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 6.4vw, 92px); line-height: 1.05; margin: 0; color: var(--text); }
[data-font="serif"] .names, [data-font="modern"] .names, [data-font="playful"] .names, [data-font="elegant"] .names { font-weight: 600; letter-spacing: .01em; font-size: clamp(34px, 5vw, 72px); }
.names .amp { color: var(--primary); font-size: .72em; }
.logo { display: block; margin: 0 auto 8px; max-height: clamp(44px, 7vh, 84px); max-width: min(60vw, 320px); width: auto; object-fit: contain; }
.sub { margin: 6px 0 0; color: var(--muted); letter-spacing: .22em; text-transform: uppercase; font-size: clamp(11px, 1vw, 14px); }
.sub:empty { display: none; }

.main { flex: 1; display: grid; grid-template-columns: minmax(300px, 0.8fr) 1.6fr; gap: clamp(14px, 2vw, 28px); align-items: start; width: 100%; max-width: 1600px; margin: 0 auto; }
@media (max-width: 960px) { .main { grid-template-columns: 1fr; } }

.side { display: flex; flex-direction: column; gap: clamp(14px, 2vw, 28px); min-width: 0; }
.stage, .board, .panel {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 24px 60px color-mix(in srgb, var(--text) 10%, transparent);
  backdrop-filter: blur(6px);
}
.stage { padding: clamp(16px, 2vw, 28px); display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ---------- prize ---------- */
.prize { display: inline-flex; align-items: center; gap: 6px; justify-content: center; text-align: center; color: var(--text); }
.prize b::before { content: "🏆 "; }
.prize .icon-btn { width: 26px; height: 26px; font-size: 15px; opacity: .55; }
.prize .icon-btn:disabled { visibility: hidden; }
.prize b { font-size: clamp(16px, 1.5vw, 22px); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 20px; line-height: 1; flex: none; }

/* ---------- ball ---------- */
.ball-wrap { --size: clamp(170px, min(22vw, 36vh), 360px); width: var(--size); height: var(--size); margin: 8px 0 2px; position: relative; display: grid; place-items: center; }
.ball-wrap::before { content: ""; position: absolute; inset: -14%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--primary) 30%, transparent), transparent 66%); opacity: 0; transition: opacity .4s; }
.ball-wrap.glow::before { opacity: 1; }
.ball {
  width: 100%; height: 100%; border-radius: 50%; position: relative; display: grid; place-items: center;
  background: radial-gradient(circle at 34% 26%, #fff 0%, #fbfaf7 30%, #e9e5dc 70%, #c9c3b6 100%);
  box-shadow: 0 26px 60px color-mix(in srgb, var(--text) 26%, transparent), inset 0 -18px 36px rgba(0,0,0,.18), inset 0 12px 24px rgba(255,255,255,.9);
  user-select: none; transform: translateZ(0);
}
.ball::after { content: ""; position: absolute; top: 7%; left: 17%; width: 38%; height: 24%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255,255,255,.95), rgba(255,255,255,.35) 45%, transparent 72%); transform: rotate(-24deg); pointer-events: none; z-index: 2; }
/* shading over the face so the number sits on a curved surface, not a flat sticker */
.ball::before { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 1;
  background: radial-gradient(circle at 36% 30%, transparent 48%, rgba(0,0,0,.10) 72%, rgba(0,0,0,.32) 100%); }
.ball-wrap::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -7%; height: 9%; border-radius: 50%; background: radial-gradient(ellipse, color-mix(in srgb, var(--text) 32%, transparent), transparent 70%); filter: blur(4px); z-index: -1; }
.ball-face {
  width: 60%; height: 60%; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, #fff 0%, #fff 55%, #eeebe4 100%); color: #2b241c;
  box-shadow: inset 0 0 0 calc(var(--size) * .018) var(--ball), inset 0 calc(var(--size) * -.012) calc(var(--size) * .03) rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.12);
  transform: rotate(-6deg);
}
.ball-letter { font-weight: 700; font-size: calc(var(--size) * .1); letter-spacing: .1em; line-height: 1; color: var(--ball); }
.ball-num { font-weight: 700; font-size: calc(var(--size) * .24); line-height: 1; font-variant-numeric: tabular-nums; font-family: 'Jost', system-ui, sans-serif; }

[data-ball="classic"] .ball { background: radial-gradient(circle at 34% 26%, color-mix(in srgb, var(--ball) 55%, white) 0%, var(--ball) 46%, color-mix(in srgb, var(--ball) 60%, black) 100%); }
[data-ball="gold"] .ball { background: radial-gradient(circle at 35% 22%, #fff 0%, #fffdf7 20%, #faebd0 46%, #e0c897 72%, #b89654 92%, #7d6023 100%); }
[data-ball="gold"] .ball-face { box-shadow: inset 0 0 0 calc(var(--size) * .018) #b08d3e; }
[data-ball="gold"] .ball-letter { color: #8f6f2a; }
/* a soft tint of the theme's ball colour, so the big ball matches the called balls on the board */
[data-ball="pastel"] { --pc: color-mix(in srgb, var(--ball) 45%, white); }
[data-ball="pastel"] .ball { background: radial-gradient(circle at 34% 26%, #fff 0%, var(--pc) 52%, color-mix(in srgb, var(--pc) 70%, #555) 100%); }
[data-ball="pastel"] .ball-face { box-shadow: inset 0 0 0 calc(var(--size) * .018) var(--pc); }
[data-ball="pastel"] .ball-letter { color: color-mix(in srgb, var(--pc) 60%, #333); }
[data-ball="glass"] .ball { background: radial-gradient(circle at 34% 26%, rgba(255,255,255,.95) 0%, color-mix(in srgb, var(--ball) 30%, transparent) 50%, color-mix(in srgb, var(--ball) 70%, transparent) 100%); border: 2px solid color-mix(in srgb, var(--ball) 50%, white); backdrop-filter: blur(4px); }
[data-ball="glass"] .ball-face { background: rgba(255,255,255,.75); }
/* a solid, glossy ball in the theme colour: the number sits straight on it, with the same shine and shading as the others */
[data-ball="bold"] .ball { background: radial-gradient(circle at 34% 26%, color-mix(in srgb, var(--ball) 70%, white) 0%, var(--ball) 38%, color-mix(in srgb, var(--ball) 72%, black) 88%, color-mix(in srgb, var(--ball) 55%, black) 100%);
  box-shadow: 0 26px 60px color-mix(in srgb, var(--ball) 38%, transparent), inset 0 -18px 36px rgba(0,0,0,.22), inset 0 12px 24px color-mix(in srgb, white 35%, transparent); }
[data-ball="bold"] .ball-face { background: transparent; box-shadow: none; color: var(--on-ball); position: relative; z-index: 3; text-shadow: 0 2px 6px rgba(0,0,0,.25); }
[data-ball="bold"] .ball-letter { color: var(--on-ball); opacity: .85; }
.ball[data-letter="B"] { --lc: var(--b); } .ball[data-letter="I"] { --lc: var(--i); } .ball[data-letter="N"] { --lc: var(--n); } .ball[data-letter="G"] { --lc: var(--g); } .ball[data-letter="O"] { --lc: var(--o); }

.ball.idle { animation: float 4s ease-in-out infinite; }
.ball.idle .ball-num { color: color-mix(in srgb, #2b241c 45%, transparent); }
[data-ball="bold"] .ball.idle .ball-num { color: var(--on-ball); opacity: .6; }
.ball.rolling { animation: tumble .22s ease-in-out infinite alternate; }
.ball.land { animation: land .7s cubic-bezier(.175,.885,.32,1.275); }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes tumble { from { transform: rotate(-5deg) scale(.98); } to { transform: rotate(5deg) scale(1.02); } }
@keyframes land { 0% { transform: scale(.7); } 45% { transform: scale(1.12); } 70% { transform: scale(.96); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .ball.idle, .ball.rolling, .ball.land { animation: none; } }

.call { margin: 4px 0 2px; min-height: 1.4em; font-size: clamp(15px, 1.4vw, 20px); color: var(--muted); text-align: center; }
.call b { color: var(--text); }

/* ---------- controls ---------- */
.draw {
  border: 0; cursor: pointer; border-radius: 999px; padding: 18px 54px; margin-top: 4px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: clamp(16px, 1.3vw, 19px); letter-spacing: .14em; text-transform: uppercase;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--primary) 40%, transparent); transition: transform .12s, box-shadow .12s, opacity .2s;
}
.draw:hover:not(:disabled) { transform: translateY(-2px); }
.draw:active:not(:disabled) { transform: scale(.98); }
.draw:disabled { opacity: .5; cursor: not-allowed; }
.draw:focus-visible, .ghost:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 3px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
/* Offline call lives with the other buttons: a ghost pill with a tiny number box inside */
.manual { display: inline-flex; align-items: center; gap: 6px; padding: 4px 4px 4px 14px; cursor: text; }
.manual label { cursor: pointer; white-space: nowrap; }
.manual input { width: 3.2em; height: 26px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); text-align: center; font: inherit; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 0; }
.manual input:focus { outline: none; border-color: var(--primary); }
.manual button { width: 26px; height: 26px; border: 0; border-radius: 50%; padding: 0; cursor: pointer; font-size: 13px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.manual input:not(:placeholder-shown) + button { background: var(--primary); color: var(--on-primary); }
.manual:focus-within { border-color: var(--primary); }
.link { background: none; border: 0; padding: 0; color: var(--primary); text-decoration: underline; cursor: pointer; font-size: inherit; }
.controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.ghost { border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent); border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.ghost:hover:not(:disabled) { border-color: var(--primary); }
.ghost:disabled { opacity: .4; cursor: default; }
.ghost[aria-pressed="false"] { opacity: .6; }

.recent { padding: clamp(14px, 1.6vw, 22px); }
.recent-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.counts b { color: var(--text); font-size: 15px; letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; min-height: 42px; }
.chip { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; position: relative; font-weight: 700; font-size: 17px; color: #2b241c; animation: pop .3s ease;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--ball, var(--primary)) 30%, white) 0%, var(--ball, var(--primary)) 50%, color-mix(in srgb, var(--ball, var(--primary)) 55%, black) 100%); box-shadow: 0 3px 6px color-mix(in srgb, var(--text) 22%, transparent); opacity: .8; }
.chip::before { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: #fff; }
.chip > span { position: relative; }
.chip.latest { opacity: 1; transform: scale(1.08); }
.chips .empty { color: var(--muted); font-size: 14px; align-self: center; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* ---------- board ---------- */
.main { align-items: stretch; }
.board { padding: clamp(12px, 1.6vw, 24px); display: grid; grid-template-rows: repeat(5, 1fr); gap: clamp(6px, .8vw, 12px); min-height: clamp(300px, 52vh, 640px); }
.brow { display: grid; grid-template-columns: repeat(15, 1fr); gap: clamp(4px, .5vw, 8px); }
.cell { min-height: 0; aspect-ratio: 1; max-height: 100%; margin: auto; width: 100%; max-width: clamp(28px, 4.2vw, 72px); border-radius: 50%; display: grid; place-items: center; font: inherit; font-variant-numeric: tabular-nums; font-size: clamp(12px, 1.35vw, 24px); font-weight: 600; background: transparent; cursor: pointer; padding: 0; position: relative;
  color: color-mix(in srgb, var(--text) 80%, transparent); border: 1.5px dashed color-mix(in srgb, var(--text) 16%, transparent); transition: color .3s, transform .3s; }
.cell:hover:not(.on) { border-color: color-mix(in srgb, var(--primary) 60%, transparent); color: var(--text); }
.cell:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 50%, transparent); outline-offset: 2px; }
/* a called number becomes a little bingo ball: shaded sphere, white face, number */
.cell.on { border: 0; cursor: default; font-weight: 700; color: #2b241c;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--ball, var(--primary)) 30%, white) 0%, var(--ball, var(--primary)) 50%, color-mix(in srgb, var(--ball, var(--primary)) 55%, black) 100%);
  box-shadow: 0 3px 6px color-mix(in srgb, var(--text) 25%, transparent); animation: pop .35s ease; }
.cell.on::before { content: ""; position: absolute; inset: 21%; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff 60%, #ece8e0 100%); z-index: 0; }
.cell.on::after { content: ""; position: absolute; top: 7%; left: 18%; width: 34%; height: 20%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255,255,255,.85), transparent 70%); transform: rotate(-24deg); z-index: 1; }
.cell > span { position: relative; z-index: 1; }
.cell.on > span { font-size: .82em; }
.cell.latest { transform: scale(1.16); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent), 0 8px 18px color-mix(in srgb, var(--primary) 45%, transparent); }
@media (max-width: 640px) {
  .board { grid-template-rows: none; grid-template-columns: repeat(5, 1fr); }
  .brow { grid-template-columns: 1fr; }
  .board { min-height: 0; }
  .cell { max-width: 44px; font-size: 14px; }
}

.foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); max-width: 1600px; width: 100%; margin: 0 auto; }
.foot a { color: inherit; text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ---------- trial badge ---------- */
.badge { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 20; background: #241c14; color: #fff; border-radius: 999px; padding: 9px 16px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.badge a { color: #ffd98a; font-weight: 600; }

/* ---------- winner overlay ---------- */
.winner { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); cursor: pointer; animation: fade .3s; }
.winner-inner { text-align: center; }
.winner-big { font-family: var(--font-display); font-size: clamp(90px, 16vw, 240px); color: var(--primary); line-height: 1; animation: land .8s cubic-bezier(.175,.885,.32,1.275); }
[data-font="script"] .winner-big { font-family: 'Jost', sans-serif; font-weight: 700; letter-spacing: .06em; }
.winner-sub { font-size: clamp(18px, 2vw, 30px); margin-top: 10px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- dialogs ---------- */
.modal { border: 0; border-radius: 20px; padding: 26px; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(20, 15, 10, .45); }
.modal h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; }
.modal p { color: var(--muted); line-height: 1.55; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.modal input, .modal textarea { width: 100%; font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.modal-x { position: absolute; top: 10px; right: 12px; }
.modal-x button { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: var(--primary); color: var(--on-primary); padding: 11px 20px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; margin-top: 8px; }
.row .btn { margin-top: 0; }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.tab { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.tab.on { background: var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.08); font-weight: 600; }
.result { margin-top: 14px; font-size: 17px; min-height: 1.4em; }
.result.win { color: var(--primary); font-weight: 700; }
.mini { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px; max-width: 300px; }
.mini div { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); font-weight: 600; }
.mini .h { border: 0; color: var(--primary); }
.mini .hit { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.celebrate { width: 100%; margin-top: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.keys dt { font-weight: 600; font-size: 14px; }
.keys dd { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- loading / not found ---------- */
.loading, .notfound { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 14px; padding: 24px; }
.spinner { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notfound h1 { font-family: var(--font-display); font-weight: 400; font-size: 44px; margin: 0; }

/* compact mode for the landing-page embed */
[data-embed="1"] .foot, [data-embed="1"] .hint, [data-embed="1"] .manual, [data-embed="1"] #fsBtn, [data-embed="1"] #resetBtn { display: none; }
[data-embed="1"] .app { padding: 14px; }

/* Big screens: the whole game fits on one screen, no scrolling. The board shrinks to the space left. */
@media (min-width: 961px) and (min-height: 520px) {
  .app { height: 100vh; height: 100dvh; min-height: 0; }
  .main { min-height: 0; align-items: stretch; }
  .stage { min-height: 0; justify-content: center; gap: clamp(6px, 1.2vh, 10px); }
  .side { min-height: 0; }
  .board { flex: 1; min-height: 0; }
  .ball-wrap { --size: clamp(130px, min(22vw, 30vh), 360px); }
  .names { font-size: clamp(34px, min(6.4vw, 9vh), 92px); }
  [data-font="serif"] .names, [data-font="modern"] .names, [data-font="playful"] .names, [data-font="elegant"] .names { font-size: clamp(30px, min(5vw, 7vh), 72px); }
  .brow { container-type: size; min-height: 0; }
  .cell { width: min(100%, 100cqh); font-size: clamp(11px, min(1.35vw, 2.6vh), 24px); }
  .recent .chip { width: clamp(36px, 5vh, 48px); height: clamp(36px, 5vh, 48px); font-size: clamp(13px, 1.9vh, 17px); }
}

/* phone cards QR */
.qr { width: min(260px, 70vw); margin: 14px auto 6px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-link { text-align: center; margin: 4px 0; word-break: break-all; }
.note { font-size: 13px; }
.qr-link a { color: var(--primary); }
