:root {
  --ink: #211a3a;
  --muted: #786f8c;
  --paper: #faf8f3;
  --panel: #ffffff;
  --purple: #6c4cf5;
  --purple-dark: #5438d9;
  --orange: #ff8a4c;
  --gold: #ffc857;
  --teal: #34c6a0;
  --line: #e9e4f0;
  --shadow: 0 22px 60px rgba(50, 35, 88, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

.ambient { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; z-index: -1; }
.ambient-one { width: 440px; height: 440px; right: -180px; top: 90px; background: rgba(255, 200, 87, 0.19); }
.ambient-two { width: 380px; height: 380px; left: -210px; bottom: -100px; background: rgba(108, 76, 245, 0.09); }

.app-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 64px; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(33, 26, 58, 0.09); }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; font: 700 24px/1 "Fredoka", sans-serif; }
.brand em { color: var(--purple); font-style: normal; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: white; border-radius: 12px 12px 12px 4px; background: var(--purple); transform: rotate(-4deg); box-shadow: 0 7px 15px rgba(108,76,245,.25); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.button, .icon-button { border: 0; cursor: pointer; transition: .2s ease; }
.button { min-height: 46px; padding: 0 21px; border-radius: 14px; font-weight: 700; }
.button-ghost { background: white; border: 1px solid var(--line); }
.button-ghost:hover { border-color: var(--purple); color: var(--purple); }
.icon-button { width: 44px; height: 44px; border-radius: 50%; background: transparent; border: 1px solid var(--line); font-weight: 800; }
.icon-button:hover { background: white; }
.sound-off { display: none; }
.icon-button.muted .sound-on { display: none; }
.icon-button.muted .sound-off { display: inline; }

.hero { padding: 50px 4px 38px; display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.eyebrow, .kicker { text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 800; margin: 0 0 10px; color: var(--purple); }
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow span { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(52,198,160,.15); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font: 700 clamp(48px, 7vw, 76px)/.92 "Fredoka", sans-serif; letter-spacing: -.035em; }
h1 span { color: var(--purple); }
.hero-copy { margin: 0; color: var(--muted); font-size: 16px; }
.stats { display: flex; background: rgba(255,255,255,.7); padding: 12px 10px; border: 1px solid rgba(233,228,240,.9); border-radius: 20px; backdrop-filter: blur(12px); }
.stat { min-width: 115px; padding: 5px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border: 0; }
.stat strong { display: block; font: 700 27px/1.2 "Fredoka", sans-serif; }
.stat span { color: var(--muted); font-size: 11px; font-weight: 600; }
.stat.accent strong { color: var(--orange); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .8fr); gap: 24px; align-items: stretch; }
.card-panel, .caller-panel { background: var(--panel); border: 1px solid rgba(233,228,240,.8); border-radius: 28px; box-shadow: var(--shadow); }
.card-panel { padding: 30px; }
.caller-panel { padding: 30px; background: var(--ink); color: white; overflow: hidden; position: relative; }
.caller-panel::before { content: ""; position: absolute; width: 280px; height: 280px; border-radius: 50%; background: rgba(108,76,245,.23); top: 70px; right: -150px; }
.panel-heading, .caller-heading, .recent-heading, .modal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading h2, .caller-heading h2, .modal-header h2 { margin: 0; font: 700 24px/1.1 "Fredoka", sans-serif; }
.panel-heading h2 span { color: #aea6bf; font: 600 12px/1 "DM Sans", sans-serif; }
.auto-toggle { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.auto-toggle input { position: absolute; opacity: 0; }
.toggle-track { width: 42px; height: 24px; padding: 3px; background: #ded9e7; border-radius: 20px; transition: .2s; }
.toggle-track span { display: block; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.14); transition: .2s; }
.auto-toggle input:checked + .toggle-track { background: var(--purple); }
.auto-toggle input:checked + .toggle-track span { transform: translateX(18px); }
.auto-toggle input:focus-visible + .toggle-track { outline: 3px solid rgba(108,76,245,.25); }

.bingo-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin-top: 27px; }
.card-header { height: 38px; display: grid; place-items: center; font: 700 24px/1 "Fredoka", sans-serif; color: var(--purple); }
.card-header:nth-child(2) { color: var(--orange); }
.card-header:nth-child(3) { color: var(--teal); }
.card-header:nth-child(4) { color: #efb52f; }
.card-header:nth-child(5) { color: #ea5f89; }
.number-cell { aspect-ratio: 1; display: grid; place-items: center; position: relative; border-radius: 16px; border: 1px solid var(--line); background: #fbfafc; color: var(--ink); font: 700 clamp(18px, 2.3vw, 25px)/1 "Fredoka", sans-serif; cursor: pointer; transition: transform .16s, border-color .16s, background .16s; }
.number-cell:hover { transform: translateY(-2px); border-color: #cfc5ff; }
.number-cell:focus-visible { outline: 3px solid rgba(108,76,245,.3); outline-offset: 2px; }
.number-cell.marked { color: white; background: var(--purple); border-color: var(--purple); box-shadow: inset 0 -4px 0 rgba(0,0,0,.09), 0 7px 14px rgba(108,76,245,.18); }
.number-cell.marked::after { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,.25); border-radius: 11px; }
.number-cell.free { background: #fff4de; color: #d49000; border-color: #ffe1a4; font-size: 13px; text-align: center; line-height: 1.05; }
.number-cell.free span { font-size: 19px; display: block; }
.number-cell.winning { animation: winnerPulse .75s ease-in-out infinite alternate; background: var(--orange); border-color: var(--orange); }
.card-tip { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.caller-heading { position: relative; }
.caller-panel .kicker { color: #a994ff; }
.remaining { color: #bdb6ce; font-size: 12px; }
.remaining strong { color: white; }
.ball-stage { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.ball { width: 126px; height: 126px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 1; color: var(--ink); background: radial-gradient(circle at 34% 28%, #fff 0 13%, #fffbf2 40%, #e8dfce 100%); box-shadow: inset -9px -12px 20px rgba(93,67,35,.12), 0 14px 30px rgba(0,0,0,.22); }
.ball::before { content: ""; position: absolute; inset: 13px; border: 2px solid var(--purple); border-radius: 50%; opacity: .18; }
.ball-letter { color: var(--purple); font-size: 13px; font-weight: 800; letter-spacing: .13em; }
.ball strong { font: 700 50px/.9 "Fredoka", sans-serif; }
.ball.empty strong { color: #b7afc3; }
.ball.called { animation: ballDrop .45s cubic-bezier(.2,.8,.25,1.25); }
.ball-shadow { position: absolute; width: 95px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.28); top: 170px; filter: blur(5px); }
.ball-stage p { color: #bdb6ce; margin: 22px 0 0; font-size: 12px; }
.draw-button { width: 100%; display: flex; justify-content: space-between; align-items: center; background: var(--purple); color: white; min-height: 57px; padding-inline: 23px; position: relative; }
.draw-button:hover { background: var(--purple-dark); transform: translateY(-2px); box-shadow: 0 10px 22px rgba(108,76,245,.25); }
.draw-button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.recent-section { margin-top: 27px; position: relative; }
.recent-heading h3 { font-size: 12px; margin: 0; }
.recent-heading button, .text-button { border: 0; background: none; color: #a994ff; font-size: 11px; font-weight: 700; cursor: pointer; }
.recent-balls { display: flex; gap: 8px; margin-top: 14px; min-height: 38px; }
.recent-ball { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.12); font-size: 11px; font-weight: 800; }
.recent-ball:first-child { background: var(--orange); border-color: var(--orange); }
.empty-message { color: #776f8d; font-size: 12px; align-self: center; margin: 0; }

.modal { padding: 0; border: 0; background: transparent; overflow: visible; }
.modal::backdrop { background: rgba(21,16,39,.7); backdrop-filter: blur(6px); }
.modal-card { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 26px; padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.close-button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: white; cursor: pointer; font-size: 22px; }
.number-board { display: grid; grid-template-columns: repeat(15, 1fr); gap: 6px; margin-top: 26px; }
.board-number { aspect-ratio: 1; min-width: 0; display: grid; place-items: center; border-radius: 8px; background: #f2eff5; color: #a19aaa; font-size: 10px; font-weight: 700; }
.board-number.called { background: var(--purple); color: white; }
.win-card { text-align: center; width: min(460px, calc(100vw - 32px)); position: relative; overflow: hidden; padding: 42px 35px 30px; }
.win-star { width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 20px 20px 20px 7px; display: grid; place-items: center; background: var(--gold); color: white; font-size: 30px; transform: rotate(-5deg); }
.win-card h2 { color: var(--purple); font: 700 58px/.9 "Fredoka", sans-serif; margin-bottom: 18px; }
.win-card p:not(.kicker) { color: var(--muted); line-height: 1.6; }
.win-card .button { display: block; background: var(--purple); color: white; width: 100%; margin-top: 25px; }
.win-card .text-button { margin-top: 15px; color: var(--muted); }

@keyframes ballDrop { from { transform: translateY(-35px) rotate(-10deg) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes winnerPulse { to { transform: scale(1.06); box-shadow: 0 8px 20px rgba(255,138,76,.34); } }

@media (max-width: 860px) {
  .hero { align-items: flex-start; }
  .stats { display: none; }
  .game-layout { grid-template-columns: 1fr; }
  .caller-panel { order: -1; }
  .ball-stage { min-height: 210px; }
  .number-board { grid-template-columns: repeat(10, 1fr); }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 24px, 1180px); padding-bottom: 30px; }
  .topbar { height: 74px; }
  .brand { font-size: 20px; }
  .brand-mark { width: 32px; height: 32px; }
  .button-ghost { padding: 0 14px; min-height: 42px; }
  .hero { padding: 35px 3px 27px; }
  h1 { font-size: 50px; }
  .hero-copy { font-size: 14px; }
  .card-panel, .caller-panel { padding: 21px; border-radius: 22px; }
  .bingo-card { gap: 5px; }
  .number-cell { border-radius: 10px; font-size: 18px; }
  .number-cell.marked::after { inset: 4px; border-radius: 7px; }
  .number-cell.free { font-size: 9px; }
  .number-cell.free span { font-size: 14px; }
  .card-header { font-size: 20px; }
  .number-board { grid-template-columns: repeat(5, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
