.keno-board {
  --pick: #8f6bff;
  --pick-deep: #6a45e0;
  --pick-edge: #36217f;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  height: 100%;
  min-height: 560px;
  padding: 22px clamp(14px, 3vw, 32px) 24px;
  background:
    radial-gradient(640px 380px at 50% 46%, rgb(143 107 255 / 0.09), transparent 70%),
    var(--bg-0);
}

/* ---------- Drawn balls tray ---------- */

.keno-tray {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(4px, 0.8vw, 8px);
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 7px;
  border-radius: 999px;
  background: var(--bg-2);
  box-shadow: inset 0 2px 0 rgb(0 0 0 / 0.28), 0 0 0 1px var(--line);
}
.keno-slot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  max-height: 44px;
  justify-self: center;
  width: 100%;
  max-width: 44px;
  border-radius: 50%;
  background: var(--bg-0);
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.45);
  font-family: var(--font-display);
  font-size: clamp(10px, 1.3vw, 14px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.keno-slot.is-filled {
  color: #1a1f2b;
  background: radial-gradient(circle at 34% 30%, #ffffff, #d9deea 48%, #9aa3b8);
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.4), inset 0 -3px 5px rgb(0 0 0 / 0.18);
  animation: ball-drop 420ms var(--ease-spring);
}
.keno-slot.is-hit {
  color: var(--win-ink);
  background: radial-gradient(circle at 34% 30%, #d9ffee, #45eea4 45%, #0f9b5f);
  box-shadow: 0 3px 10px rgb(34 224 143 / 0.45), inset 0 -3px 5px rgb(0 0 0 / 0.2);
}
@keyframes ball-drop {
  0% { transform: translateY(-26px) scale(0.6); opacity: 0; }
  60% { transform: translateY(3px) scale(1.06); opacity: 1; }
}

/* ---------- Number grid ---------- */

.keno-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(5px, 1vw, 10px);
  width: min(100%, 640px);
  margin: 0 auto;
  align-self: center;
  user-select: none;
  -webkit-user-select: none;
}

.keno-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.keno-tile:disabled { cursor: default; }
.keno-tile__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #2c3d63, #253554);
  box-shadow: 0 4px 0 #131d33, inset 0 1px 0 rgb(255 255 255 / 0.09);
  transition: transform 140ms var(--ease-out), background 140ms, box-shadow 140ms, opacity 200ms;
}
.keno-tile__num {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--font-display);
  font-size: clamp(11px, 1.55vw, 17px);
  font-weight: 800;
  transition: transform 140ms var(--ease-out), color 140ms;
  pointer-events: none;
}
@media (hover: hover) {
  .keno-tile:not(:disabled):hover .keno-tile__face {
    transform: translateY(-3px);
    background: linear-gradient(180deg, #37507f, #2f446d);
    box-shadow: 0 7px 0 #131d33, 0 10px 20px rgb(0 0 0 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.13);
  }
  .keno-tile:not(:disabled):hover .keno-tile__num { transform: translateY(-3px); }
}
.keno-tile:not(:disabled):active .keno-tile__face { transform: translateY(2px); box-shadow: 0 2px 0 #131d33; }
.keno-tile:not(:disabled):active .keno-tile__num { transform: translateY(2px); }

/* Picked */
.keno-tile.is-picked .keno-tile__face,
.keno-tile.is-picked:not(:disabled):hover .keno-tile__face {
  background: linear-gradient(180deg, var(--pick), var(--pick-deep));
  box-shadow: 0 4px 0 var(--pick-edge), 0 0 18px rgb(143 107 255 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.28);
}
.keno-tile.is-picked .keno-tile__num { color: #fff; }
.keno-tile.is-popping .keno-tile__face { animation: keno-pop 380ms var(--ease-spring) var(--pop-delay, 0ms) backwards; }
.keno-tile.is-popping .keno-tile__num { animation: keno-pop 380ms var(--ease-spring) var(--pop-delay, 0ms) backwards; }
@keyframes keno-pop { 0% { transform: scale(0.72); } }
.keno-tile.is-refused { animation: fx-shake 320ms; --shake: 3px; }

/* After the draw: tiles that were neither picked nor drawn step back. */
.keno-grid.is-drawn .keno-tile:not(.is-picked):not(.is-miss) .keno-tile__face { opacity: 0.55; }
.keno-grid.is-drawn .keno-tile:not(.is-picked):not(.is-miss) .keno-tile__num { color: var(--text-3); }
.keno-grid.is-drawn .keno-tile.is-picked:not(.is-hit) .keno-tile__face { opacity: 0.7; }

/* Drawn but not picked */
.keno-tile.is-miss .keno-tile__face {
  background: #0d1424;
  box-shadow: inset 0 0 0 2px #2a1a2a;
  transform: none;
}
.keno-tile.is-miss .keno-tile__num { color: var(--loss); transform: none; }

/* Drawn and picked: a hit */
.keno-tile.is-hit .keno-tile__face {
  background: radial-gradient(circle at 50% 40%, rgb(34 224 143 / 0.5), #0c3a29 78%);
  box-shadow: inset 0 0 0 2px var(--win), 0 0 24px rgb(34 224 143 / 0.45);
  transform: none;
}
.keno-tile.is-hit .keno-tile__num { color: #eafff5; transform: none; text-shadow: 0 0 12px rgb(34 224 143 / 0.8); }
.keno-tile.is-hit::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 13px;
  border: 2px solid var(--win);
  opacity: 0;
  pointer-events: none;
}
.keno-tile.is-hit.is-landed::after { animation: keno-ring 520ms var(--ease-out); }
.keno-tile.is-landed .keno-tile__face { animation: keno-land 300ms var(--ease-spring); }
.keno-tile.is-landed .keno-tile__num { animation: keno-land 300ms var(--ease-spring); }
@keyframes keno-land { 0% { transform: scale(0.8); } }
@keyframes keno-ring { 0% { opacity: 1; transform: scale(0.9); } 100% { opacity: 0; transform: scale(1.35); } }

/* ---------- Paytable ---------- */

.keno-pays-wrap { width: min(100%, 640px); margin: 0 auto; }
.keno-pays {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--line);
}
.keno-pay {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  padding: 8px 2px 7px;
  border-radius: 8px;
  background: var(--bg-1);
  transition: background 160ms, box-shadow 160ms, transform 200ms var(--ease-spring);
}
.keno-pay strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 800;
  white-space: nowrap;
}
.keno-pay.is-paying strong { color: var(--text); }
.keno-pay > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.keno-pay__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--win);
  box-shadow: 0 0 6px rgb(34 224 143 / 0.6);
}
.keno-pay.is-current {
  background: var(--bg-4);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transform: translateY(-2px);
}
.keno-pay.is-current strong { color: var(--text); }
.keno-pay.is-final.is-paid {
  background: var(--win);
  box-shadow: 0 0 18px rgb(34 224 143 / 0.45);
  animation: keno-paid 480ms var(--ease-spring);
}
.keno-pay.is-final.is-paid strong,
.keno-pay.is-final.is-paid > span { color: var(--win-ink); }
.keno-pay.is-final.is-paid .keno-pay__dot { background: var(--win-ink); box-shadow: none; }
.keno-pay.is-final.is-unpaid { background: color-mix(in srgb, var(--loss) 16%, var(--bg-1)); }
@keyframes keno-paid { 0% { transform: scale(0.9); } }

.keno-hint {
  display: grid;
  place-items: center;
  height: 52px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 600;
}

@media (max-width: 600px) {
  .keno-board { min-height: 0; gap: 12px; padding: 14px 10px 16px; }
  .keno-tray { padding: 5px; }
  .keno-tile { border-radius: 8px; }
  .keno-pay { padding: 6px 1px 5px; }
  .keno-pay > span { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .keno-slot.is-filled, .keno-tile.is-landed .keno-tile__face, .keno-tile.is-landed .keno-tile__num,
  .keno-tile.is-popping .keno-tile__face, .keno-tile.is-popping .keno-tile__num,
  .keno-tile.is-hit.is-landed::after, .keno-pay.is-final.is-paid { animation: none; }
}
