:root {
  color-scheme: dark;
  --ink: #08182f;
  --ink-2: #0d2344;
  --panel: #10294f;
  --panel-soft: #17365f;
  --cream: #f6f0e2;
  --muted: #99abc2;
  --aqua: #5ee1cf;
  --coral: #ff655a;
  --yellow: #ffc857;
  --line: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 70px rgba(2, 8, 20, 0.42);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(circle at 12% 12%, rgba(94, 225, 207, 0.13), transparent 27rem),
    radial-gradient(circle at 88% 78%, rgba(255, 101, 90, 0.12), transparent 28rem),
    var(--ink);
}

button { font: inherit; }

.app-shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px clamp(18px, 3vw, 48px) 20px;
}

.topbar,
.section-heading,
.history-header,
.progress-copy,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-dot {
  width: 14px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(var(--coral), var(--yellow));
  box-shadow: 0 0 24px rgba(255, 101, 90, 0.42);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--aqua);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.19em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -0.04em; }
h1 span { color: var(--coral); }
h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.35rem); letter-spacing: -0.045em; }
h3 { margin: 0; font-size: 0.96rem; }

.game-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c8d3e1;
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.04);
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 12px var(--aqua);
}

.game-status.paused .status-light { background: var(--yellow); box-shadow: 0 0 12px var(--yellow); }
.game-status.finished .status-light { background: var(--coral); box-shadow: 0 0 12px var(--coral); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(400px, 0.92fr) minmax(500px, 1.08fr);
  gap: 18px;
  padding: 18px 0;
}

.tombola-panel,
.numbers-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(19, 49, 91, 0.96), rgba(10, 31, 61, 0.96));
  box-shadow: var(--shadow);
}

.tombola-panel { padding: clamp(22px, 3vw, 36px); }
.numbers-panel { padding: clamp(22px, 3vw, 34px); }

.counter-chip {
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(94, 225, 207, 0.1);
  color: #bcece5;
  font-size: 0.78rem;
}
.counter-chip strong { color: var(--aqua); font-size: 1.05rem; }

.tombola-stage {
  position: relative;
  width: min(100%, 430px);
  height: 335px;
  margin: 8px auto 0;
}

.drum {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 250px;
  height: 250px;
  transform: translate(-50%, -50%);
  border: 12px solid #55708e;
  border-radius: 50%;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255,255,255,.22), transparent 32%),
    rgba(113, 154, 188, 0.14);
  box-shadow: inset 0 0 30px rgba(255,255,255,.08), 0 22px 36px rgba(0,0,0,.25);
}

.drum::before,
.drum::after {
  content: "";
  position: absolute;
  inset: 11%;
  border: 2px solid rgba(255,255,255,.13);
  border-radius: 50%;
}
.drum::after { inset: 28%; }

.drum-glass {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: linear-gradient(120deg, rgba(255,255,255,.14), transparent 36%, rgba(255,255,255,.04));
  pointer-events: none;
}

.drum-ring {
  position: absolute;
  left: 50%; top: 50%;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  border: 7px solid var(--yellow);
  border-radius: 50%;
  background: var(--ink-2);
  box-shadow: 0 0 0 7px rgba(255,200,87,.13);
}

.mini-ball {
  position: absolute;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  font-weight: 900;
  font-size: .78rem;
  box-shadow: inset -5px -7px 10px rgba(8,24,47,.2), 0 5px 9px rgba(0,0,0,.28);
}
.b1 { left: 34px; top: 45px; background: var(--yellow); }
.b2 { left: 126px; top: 28px; }
.b3 { right: 30px; top: 95px; background: var(--aqua); }
.b4 { left: 60px; bottom: 35px; background: var(--coral); color: white; }
.b5 { right: 65px; bottom: 32px; }
.b6 { left: 107px; top: 98px; background: #9eb5ff; }

.drum.spinning { animation: drumWobble .32s linear infinite; }
.drum.spinning .mini-ball { animation: ballBounce .42s ease-in-out infinite alternate; }
.drum.spinning .b2, .drum.spinning .b5 { animation-delay: -.18s; }
.drum.spinning .b3, .drum.spinning .b6 { animation-delay: -.31s; }

.drum-shadow {
  position: absolute;
  left: 50%; bottom: 72px;
  width: 280px; height: 40px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0,0,0,.28);
  filter: blur(12px);
}

.drum-stand span {
  position: absolute;
  bottom: 48px;
  width: 16px;
  height: 100px;
  border-radius: 8px;
  background: linear-gradient(90deg, #314b6a, #738ba5, #314b6a);
}
.drum-stand span:first-child { left: calc(50% - 104px); transform: rotate(18deg); }
.drum-stand span:last-child { right: calc(50% - 104px); transform: rotate(-18deg); }
.drum-stand::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 39px;
  width: 240px; height: 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, #243e5e, #6d88a5, #243e5e);
}

.number-ball {
  position: absolute;
  right: 6px;
  bottom: 30px;
  z-index: 10;
  display: grid;
  place-items: center;
  align-content: center;
  width: 116px;
  height: 116px;
  border: 8px solid rgba(255,255,255,.7);
  border-radius: 50%;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: inset -12px -14px 18px rgba(169,94,10,.28), 0 18px 35px rgba(0,0,0,.35);
  transform: rotate(-7deg);
}
.number-ball small { font-weight: 900; font-size: .85rem; line-height: 1; }
.number-ball strong { font-size: 3.25rem; line-height: .95; letter-spacing: -.08em; }
.number-ball.empty { color: rgba(8,24,47,.42); background: #a4b6ca; }
.number-ball.reveal { animation: ballReveal .65s cubic-bezier(.16,.9,.3,1.35); }

.draw-message {
  min-height: 24px;
  margin: -2px 0 16px;
  text-align: center;
  color: #bac8d9;
  font-size: .87rem;
}

.primary-controls,
.secondary-controls { display: grid; gap: 10px; }
.primary-controls { grid-template-columns: 1.35fr .85fr; }
.secondary-controls { grid-template-columns: 1fr 1fr; margin-top: 10px; }

.btn {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, background .18s ease, border-color .18s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(94,225,207,.45); outline-offset: 3px; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { color: white; background: linear-gradient(135deg, #ff7268, #f64d54); box-shadow: 0 10px 24px rgba(255,101,90,.24); }
.btn-auto { color: var(--aqua); background: rgba(94,225,207,.08); border-color: rgba(94,225,207,.27); }
.btn-auto[aria-pressed="true"] { color: var(--ink); background: var(--aqua); }
.auto-icon { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid currentColor; border-radius: 50%; font-size: .65rem; }
.btn-secondary { color: var(--cream); background: #203d62; border-color: rgba(255,255,255,.1); }
.btn-ghost { color: #b7c6d8; background: transparent; border-color: rgba(255,255,255,.12); }

.auto-progress {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(94,225,207,.2);
  border-radius: 14px;
  background: rgba(4,15,32,.28);
}
.progress-copy { color: #abc0d3; font-size: .78rem; }
.progress-copy strong { color: var(--aqua); font-size: .9rem; }
.progress-track { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.1); }
.progress-track span { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--aqua), #8fe7ff); transition: width .3s linear; }

.called-count { display: flex; align-items: baseline; gap: 3px; color: var(--muted); }
.called-count strong { color: var(--yellow); font-size: 2rem; line-height: 1; }
.called-count span { font-weight: 700; }

.latest-strip {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 24px 0 20px;
  padding: 13px 16px;
  border-radius: 16px;
  background: linear-gradient(100deg, rgba(255,101,90,.14), rgba(255,200,87,.06));
  border: 1px solid rgba(255,101,90,.2);
}
.latest-label { writing-mode: vertical-rl; transform: rotate(180deg); color: var(--coral); font-size: .61rem; font-weight: 900; letter-spacing: .15em; }
.latest-number { display: grid; place-items: center; align-content: center; width: 68px; height: 68px; border-radius: 50%; color: var(--ink); background: var(--yellow); box-shadow: inset -6px -8px 12px rgba(169,94,10,.25); }
.latest-number small { font-size: .68rem; font-weight: 900; line-height: 1; }
.latest-number strong { font-size: 1.7rem; line-height: 1; }
.latest-number.empty { color: #677b93; background: #bec9d5; }
.latest-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.latest-copy strong { font-size: 1rem; }
.latest-copy span { color: var(--muted); font-size: .78rem; }

.history-wrap,
.board-wrap { border-top: 1px solid var(--line); padding-top: 17px; }
.board-wrap { margin-top: 18px; }
.history-header { margin-bottom: 12px; }
.history-header span { color: var(--muted); font-size: .7rem; }

.called-list {
  min-height: 104px;
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 9px;
  scrollbar-color: #426284 transparent;
  scrollbar-width: thin;
}
.called-list.empty { display: grid; place-items: center; border: 1px dashed rgba(255,255,255,.12); border-radius: 14px; }
.empty-state { display: flex; align-items: center; gap: 9px; color: #7f94ad; }
.empty-state span { font-size: 1.45rem; }
.empty-state p { margin: 0; font-size: .8rem; }
.history-ball {
  display: grid;
  place-items: center;
  align-content: center;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--cream);
  box-shadow: inset -4px -5px 8px rgba(8,24,47,.18);
  animation: historyIn .35s ease both;
}
.history-ball:first-child { background: var(--yellow); }
.history-ball small { font-size: .55rem; font-weight: 900; line-height: 1; }
.history-ball strong { font-size: 1.15rem; line-height: 1.1; }

.number-board {
  display: grid;
  grid-template-columns: repeat(15, minmax(26px, 1fr));
  gap: 6px;
}
.board-number {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  color: #7187a2;
  background: rgba(255,255,255,.025);
  font-size: clamp(.62rem, 1.1vw, .78rem);
  font-weight: 800;
  transition: .25s ease;
}
.board-number.called { color: var(--ink); background: var(--aqua); border-color: var(--aqua); box-shadow: 0 0 15px rgba(94,225,207,.2); transform: scale(1.06); }
.board-number.latest { color: var(--ink); background: var(--yellow); border-color: var(--yellow); box-shadow: 0 0 18px rgba(255,200,87,.32); }

footer {
  padding: 2px 6px 0;
  color: #6f849e;
  font-size: .7rem;
  letter-spacing: .03em;
}
footer strong { color: #9eb1c7; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 20px);
  padding: 11px 16px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--cream);
  font-weight: 800;
  font-size: .78rem;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  box-shadow: 0 12px 30px rgba(0,0,0,.32);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes drumWobble {
  0% { transform: translate(-50%, -50%) rotate(0); }
  25% { transform: translate(-50%, -50%) rotate(5deg); }
  50% { transform: translate(-50%, -50%) rotate(0); }
  75% { transform: translate(-50%, -50%) rotate(-5deg); }
  100% { transform: translate(-50%, -50%) rotate(0); }
}
@keyframes ballBounce { from { transform: translate(-12px, -9px) rotate(-14deg); } to { transform: translate(14px, 13px) rotate(20deg); } }
@keyframes ballReveal { 0% { opacity: 0; transform: translate(90px, -110px) scale(.4) rotate(120deg); } 100% { opacity: 1; transform: rotate(-7deg) scale(1); } }
@keyframes historyIn { from { opacity: 0; transform: scale(.55) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

@media (max-width: 1000px) {
  .game-layout { grid-template-columns: 1fr; }
  .tombola-stage { height: 320px; }
  .number-board { grid-template-columns: repeat(15, minmax(23px, 1fr)); }
}

@media (max-width: 620px) {
  .app-shell { padding: 16px 12px; }
  .topbar { align-items: flex-start; }
  .game-status { padding: 8px 10px; font-size: .72rem; }
  .brand-dot { height: 38px; }
  .tombola-panel, .numbers-panel { border-radius: 20px; padding: 20px 16px; }
  .section-heading { align-items: flex-end; }
  .tombola-stage { height: 288px; transform: scale(.9); margin: -4px auto -12px; }
  .number-ball { right: 0; }
  .primary-controls { grid-template-columns: 1fr; }
  .number-board { grid-template-columns: repeat(10, 1fr); }
  .latest-strip { grid-template-columns: auto auto 1fr; padding: 11px; }
  footer { align-items: flex-start; flex-direction: column; gap: 6px; }
}

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