:root {
  color-scheme: dark;
  --ink: #f5f8ff;
  --muted: #92a1b7;
  --surface: rgba(15, 29, 48, .9);
  --surface-2: #142640;
  --line: rgba(167, 194, 226, .14);
  --accent: #38bdf8;
  --b: #2f8cff;
  --i: #ff5d75;
  --n: #ffffff;
  --g: #2fca78;
  --o: #ffc53d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(47, 140, 255, .17), transparent 28rem),
    radial-gradient(circle at 92% 80%, rgba(47, 202, 120, .1), transparent 26rem),
    #07111f;
}
button, select, input { font: inherit; }
button, select { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }

.app-shell { width: min(1460px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.topbar, .topbar-statuses, .section-heading, .primary-controls, .secondary-controls, .two-fields { display: flex; align-items: center; }
.topbar { justify-content: space-between; margin-bottom: 18px; }
.topbar-statuses { gap: 10px; }
.game-type-pill { color: #9fb0c4; border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; font-size: .88rem; }
.game-type-pill strong { color: var(--ink); }
.brand { display: flex; align-items: baseline; gap: 3px; font-weight: 900; font-size: 1.45rem; letter-spacing: .08em; }
.brand span:nth-child(1) { color: var(--b); }.brand span:nth-child(2) { color: var(--i); }
.brand span:nth-child(3) { color: var(--n); }.brand span:nth-child(4) { color: var(--g); }.brand span:nth-child(5) { color: var(--o); }
.brand strong { color: var(--muted); font-size: .72rem; margin-left: 8px; letter-spacing: .18em; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; background: rgba(255,255,255,.04); }
.status-pill { display: flex; align-items: center; gap: 8px; color: #c5d1df; background: rgba(13,25,42,.8); border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; font-size: .88rem; }
.status-pill span { width: 8px; height: 8px; border-radius: 50%; background: #7d8da1; box-shadow: 0 0 0 4px rgba(125,141,161,.1); }
.status-pill.running span { background: var(--g); box-shadow: 0 0 0 4px rgba(47,202,120,.14); }
.status-pill.paused span { background: var(--o); box-shadow: 0 0 0 4px rgba(255,197,61,.14); }

.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 18px 60px rgba(0,0,0,.2); backdrop-filter: blur(12px); }
.game-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .48fr); gap: 14px; }
.stage { display: grid; grid-template-columns: minmax(300px, 1fr) 310px; height: 410px; overflow: hidden; }
.current-wrap { display: grid; align-content: start; justify-items: center; padding: 15px 24px 10px; background: linear-gradient(145deg, rgba(31,58,91,.65), rgba(10,23,39,.2)); border-right: 1px solid var(--line); }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; color: #7890aa; font-size: .76rem; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; } h1 { font-size: 1.55rem; margin-bottom: 0; } h2 { font-size: 1.25rem; margin-bottom: 0; }
.ball { --ball-color: var(--n); position: relative; display: grid; place-items: center; width: clamp(210px, 22vw, 280px); aspect-ratio: 1; border-radius: 50%; margin: 3px 0 7px; color: #091322; background: radial-gradient(circle at 35% 27%, color-mix(in srgb, var(--ball-color), white 34%) 0 18%, var(--ball-color) 52%, color-mix(in srgb, var(--ball-color), black 30%) 100%); box-shadow: inset -18px -22px 28px rgba(0,0,0,.23), 0 14px 34px rgba(0,0,0,.38), 0 0 40px color-mix(in srgb, var(--ball-color), transparent 75%); transition: transform .28s ease, filter .3s ease; }
.ball::before { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: #f9fbff; box-shadow: inset 0 2px 9px rgba(8,18,32,.18); }
.ball-letter, .ball-number { position: absolute; z-index: 1; font-weight: 950; line-height: 1; }
.ball-letter { top: 23%; font-size: clamp(2rem, 4vw, 3.3rem); }.ball-number { top: 45%; font-size: clamp(2.35rem, 5vw, 4.1rem); }
.ball-empty { filter: grayscale(1); opacity: .62; }
.ball-pop { animation: ball-pop .55s cubic-bezier(.2,.85,.25,1.2); }
@keyframes ball-pop { 0% { transform: scale(.65) rotate(-18deg); opacity: .2; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.call-count { color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }
.history-wrap { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; padding: 14px 22px; }
.history-wrap h2 { font-size: 1.05rem; text-align: center; }
.section-heading { justify-content: space-between; gap: 16px; }
.history { display: grid; grid-template-columns: 94px; justify-content: center; margin-top: 8px; }
.history-ball { --ball-color: var(--n); width: 94px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid color-mix(in srgb, var(--ball-color), transparent 45%); border-radius: 50%; color: var(--ink); background: color-mix(in srgb, var(--ball-color), transparent 78%); font-weight: 850; line-height: 1; animation: history-in .3s ease both; }
.history-letter { font-size: 1.05rem; }
.history-number { font-size: 1.7rem; }
@keyframes history-in { from { opacity: 0; transform: scale(.7); } }
.empty-copy { grid-column: 1/-1; margin: 16px 0 10px; color: var(--muted); text-align: center; font-size: .78rem; }
.active-pattern { width: 100%; align-self: start; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.active-pattern label { display: block; margin-bottom: 6px; color: #8194aa; font-size: .74rem; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .1em; }

.control-panel { padding: 30px; }
.control-panel label { display: flex; justify-content: space-between; margin: 22px 0 8px; color: #bdc9d7; font-size: .88rem; font-weight: 700; }
select { width: 100%; appearance: none; color: var(--ink); border: 1px solid var(--line); border-radius: 11px; padding: 0 38px 0 13px; background: #0b192b url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238fa2b9' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
.field-note { margin: 7px 0 0; color: #71849a; font-size: .77rem; }
.error-note { color: #ff899c; }
.two-fields { align-items: flex-end; gap: 12px; }.two-fields > div { flex: 1; min-width: 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.primary-controls, .secondary-controls { gap: 10px; margin-top: 24px; }.secondary-controls { margin-top: 10px; }
.settings-button { width: 100%; margin-top: 14px; color: #b9c8d8; border-color: var(--line); background: transparent; }
.settings-content { padding: 4px 0 18px; }
.settings-dialog label { display: flex; justify-content: space-between; margin: 20px 0 8px; color: #bdc9d7; font-size: .88rem; font-weight: 700; }
.dialog-done { width: 100%; }
.button { flex: 1; border: 1px solid transparent; border-radius: 11px; padding: 0 14px; color: var(--ink); font-weight: 800; }
.button-primary { background: var(--accent); color: #06111e; }.button-primary:hover { background: #68cdf7; }
.button-secondary { background: #203653; border-color: rgba(255,255,255,.09); }.button-secondary:hover { background: #2a4465; }
.button-quiet { background: transparent; border-color: var(--line); }.button-quiet:hover { background: rgba(255,255,255,.05); }
.button-bingo { background: #e63755; box-shadow: 0 9px 24px rgba(230,55,85,.2); }.button-bingo:hover { background: #fa4e6b; }
.icon-button { width: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-weight: 800; }
.text-button { min-height: 34px; padding: 0; border: 0; color: var(--accent); background: transparent; font-weight: 750; }.text-button:hover { color: #8bdcff; }
.danger-text { color: #ff7188; }

.board-panel { margin-top: 14px; padding: 22px 24px 24px; }
.board-heading { margin-bottom: 20px; }
.number-board { display: grid; gap: 8px; }
.number-row { display: grid; grid-template-columns: 58px repeat(15, minmax(40px, 1fr)); gap: 9px; }
.board-letter, .board-number { min-height: 68px; display: grid; place-items: center; border-radius: 10px; font-size: clamp(1.2rem, 1.8vw, 1.65rem); font-weight: 900; font-variant-numeric: tabular-nums; }
.board-letter { color: #06111e; }.board-number { color: #60758d; border: 1px solid var(--line); background: rgba(6,16,29,.58); transition: .22s ease; }
.board-number.called { color: white; border-color: color-mix(in srgb, var(--ball-color), transparent 25%); background: color-mix(in srgb, var(--ball-color), transparent 62%); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ball-color), transparent 68%); }
.letter-b { --ball-color: var(--b); }.letter-i { --ball-color: var(--i); }.letter-n { --ball-color: var(--n); }.letter-g { --ball-color: var(--g); }.letter-o { --ball-color: var(--o); }
.board-letter.letter-b { background: var(--b); }.board-letter.letter-i { background: var(--i); }.board-letter.letter-n { background: var(--n); }.board-letter.letter-g { background: var(--g); }.board-letter.letter-o { background: var(--o); }

.compact-select { width: 100%; min-height: 36px; height: 36px; padding-left: 9px; font-size: .72rem; }
.pattern-display { display: grid; grid-template-columns: 154px; justify-content: center; margin-top: 6px; }
.pattern-card { width: 154px; border: 0; padding: 0; background: transparent; }
.pattern-card h3 { margin: 0 0 5px; color: #c9d6e5; font-size: .78rem; line-height: 1.1; text-align: center; }
.pattern-grid { width: 146px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7,17,31,.72); }
.pattern-cell { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.09); border-radius: 4px; background: #0b192b; color: #7d90a7; font-size: .55rem; }
.pattern-cell.marked { border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.72); color: #06111e; }

.dialog { width: min(520px, calc(100% - 28px)); color: var(--ink); border: 1px solid var(--line); border-radius: 20px; padding: 28px; background: #102039; box-shadow: 0 28px 80px #000; }
.dialog::backdrop { background: rgba(1,7,14,.78); backdrop-filter: blur(4px); }
.dialog p:not(.eyebrow), .dialog li { color: #aebed0; line-height: 1.6; }.dialog ol { padding-left: 22px; }.dialog-actions { display: flex; gap: 10px; margin-top: 24px; }.dialog-close { float: right; width: 38px; min-height: 38px; border: 0; color: var(--muted); background: transparent; font-size: 1.5rem; }

@media (max-width: 950px) { .game-layout { grid-template-columns: 1fr; } .stage { height: 330px; } }
@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 620px); padding-top: 14px; }
  .stage { grid-template-columns: 1fr; height: auto; }.current-wrap { min-height: 330px; border-right: 0; border-bottom: 1px solid var(--line); }
  .history { grid-template-columns: 94px; }.number-board { overflow-x: auto; padding-bottom: 8px; }
  .number-row { min-width: 950px; }.brand strong { display: none; }.game-type-pill { display: none; }
  .board-panel, .history-wrap { padding: 20px; }.control-panel { padding: 32px 38px; }
}
@media (max-width: 470px) { .two-fields, .dialog-actions { align-items: stretch; flex-direction: column; }.compact-select { width: 100%; }.status-pill { font-size: 0; }.status-pill span { margin: 4px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
