:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --background: #13121e;
  --panel: #1c1a2a;
  --border: #343148;
  --text: #f7f4ff;
  --muted: #c0bbd0;
  --violet: #c3adff;
  --violet-dark: #211239;
  --drawn: #413365;
  --gap: clamp(10px, min(1.4vw, 1.8vh), 22px);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 2% 2%, #25203b 0, transparent 47%), var(--background);
  color: var(--text);
}
button, select { font: inherit; }
button:focus-visible, select:focus-visible { outline: 3px solid #e6dbff; outline-offset: 3px; }
button:disabled { opacity: .43; cursor: default; }
h1, h2, h3, p, ol { margin: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app {
  display: grid;
  align-content: center;
  gap: var(--gap);
  max-width: 1920px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(12px, 2.1vh, 30px) clamp(15px, 2.45vw, 40px);
}
.topbar, .top-actions, .brand, .board-header, .controls, .play-actions, .utility-actions, .dialog-actions {
  display: flex;
  align-items: center;
}
.topbar, .board-header, .controls { justify-content: space-between; }
.topbar, .controls { gap: 12px; }
.brand { gap: 10px; font-size: clamp(26px, 3vw, 46px); line-height: 1; letter-spacing: -.055em; font-weight: 850; }
.brand-count { color: var(--violet); }
.brand-ball {
  display: grid;
  place-items: center;
  width: .87em;
  aspect-ratio: 1;
  background: #ad91fa;
  border-radius: 50%;
  box-shadow: inset -.09em -.09em 0 #8466d2;
}
.brand-ball::before { content: ''; width: 49%; aspect-ratio: 1; border-radius: 50%; background: #eee5ff; }
.top-actions, .play-actions, .utility-actions, .dialog-actions { gap: 8px; }
.game { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.6fr); gap: var(--gap); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 19px; }

.draw {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  padding: clamp(16px, 2.5vh, 30px) clamp(13px, 2vw, 30px);
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #342653, transparent 74%), #211b32;
}
.eyebrow { color: #d7c6ff; font-size: clamp(14px, 1.15vw, 18px); font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.draw-stage {
  --diameter: clamp(132px, min(24vw, 37vh), 380px);
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: calc(var(--diameter) + 52px);
}
.orbit, .orbit::before, .orbit::after, .orbit span {
  position: absolute;
  border: 1px solid #b397f544;
  border-radius: 50%;
  aspect-ratio: 1;
}
.orbit { display: grid; place-items: center; width: calc(var(--diameter) + 24px); pointer-events: none; }
.orbit::before, .orbit::after { content: ''; }
.orbit::before { width: calc(100% + 28px); border-style: dashed; opacity: .65; }
.orbit::after { width: calc(100% + 64px); opacity: .38; }
.orbit span { width: 9px; top: 10%; right: 12%; background: #ccb7ff; box-shadow: 0 0 14px #c7a6ffa0; }
.ball {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--diameter);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 20%, #f9f0ff 0, #e0ccff 40%, #bd9cf6 72%, #7857c4 100%);
  border: 1px solid #e8d6ff;
  box-shadow: 0 17px 38px #0e081e8c, inset 0 -7px 14px #7455bb66;
  color: var(--violet-dark);
}
.ball::before {
  position: absolute;
  content: '';
  inset: 9%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 20%, #fcf8ff, #ebe0ff 82%);
  box-shadow: 0 0 0 1px #fffcff80, 0 5px 12px #4c277c25;
}
.ball span { z-index: 1; font-size: calc(var(--diameter) * .53); font-weight: 900; line-height: .96; letter-spacing: -.085em; padding-inline-end: .075em; font-variant-numeric: tabular-nums; }
.ball.reveal { animation: reveal 270ms ease-out both; }
@keyframes reveal { from { transform: translateY(8px) scale(.9); opacity: .48; } to { transform: none; opacity: 1; } }
.round-status { margin-top: 5px; font-size: clamp(15px, 1.32vw, 21px); font-weight: 650; color: #e4d8ff; }
.recent { width: 100%; margin-top: clamp(12px, 2.8vh, 27px); padding-top: clamp(10px, 1.65vh, 18px); border-top: 1px solid #a68ae448; }
.recent .eyebrow { font-size: clamp(14px, 1.03vw, 16px); }
.recent ol { display: flex; justify-content: center; gap: clamp(5px, .75vw, 12px); padding: 0; list-style: none; margin-top: 9px; }
.recent li { display: grid; place-items: center; width: clamp(29px, 3.5vw, 52px); aspect-ratio: 1; border-radius: 50%; background: #413260; border: 1px solid #735b9f; font-size: clamp(14px, 1.45vw, 22px); font-weight: 800; font-variant-numeric: tabular-nums; }
.recent .placeholder { color: #9584b4; background: transparent; border-style: dashed; border-color: #67587e; }

.board { display: grid; grid-template-rows: auto auto 1fr; gap: clamp(8px, 1.4vh, 14px); padding: clamp(12px, 2.1vh, 26px) clamp(13px, 1.8vw, 28px); }
.board-header { gap: 10px; }
.board h2 { font-size: clamp(22px, 2.45vw, 39px); line-height: 1; letter-spacing: -.045em; font-weight: 800; }
.count { font-size: clamp(14px, 1.25vw, 20px); white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.count strong { color: var(--violet); font-size: 1.52em; line-height: 1; }
.progress { height: 4px; background: #373246; border-radius: 9px; overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; background: var(--violet); transition: width 180ms ease-out; }
.numbers {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(clamp(32px, 5.3vh, 64px), 1fr));
  gap: clamp(3px, min(.62vw, .88vh), 9px);
  list-style: none;
  padding: 0;
}
.numbers li {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 8px;
  background: #272437;
  border: 1px solid #363248;
  color: #c7c1d9;
  font-size: clamp(15px, min(2.15vw, 4.1vh), 36px);
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.numbers li.drawn { background: var(--drawn); color: #f0e5ff; border-color: #8873b3; }
.numbers li.latest { background: var(--violet); color: var(--violet-dark); border-color: #eadbff; box-shadow: 0 0 14px #aa86fa60; font-weight: 900; }

.controls { padding: clamp(8px, 1vw, 15px); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 7px clamp(9px, 1vw, 17px);
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: clamp(14px, 1.08vw, 17px);
  font-weight: 720;
  line-height: 1.13;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.primary { background: var(--violet); color: var(--violet-dark); padding-inline: clamp(13px, 1.65vw, 26px); font-weight: 850; }
.primary:hover:not(:disabled) { background: #dfd0ff; }
.subtle, .secondary, .speed select { background: #292438; border-color: #48405f; }
.secondary[aria-pressed="true"], .subtle[aria-pressed="true"] { border-color: #aa8ef3; color: #f2e7ff; background: #473466; }
.quiet { color: #d9d3e6; background: transparent; }
.subtle:hover:not(:disabled), .secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #3a304f; }
.speed { position: relative; }
.speed::after { content: ''; position: absolute; width: 7px; height: 7px; right: 12px; top: calc(50% - 5px); border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.speed select { display: block; appearance: none; min-height: 43px; padding: 6px 26px 6px 10px; color: var(--text); border-style: solid; border-width: 1px; border-radius: 9px; cursor: pointer; font-size: clamp(14px, 1.08vw, 17px); font-weight: 720; }
.icon { flex: 0 0 auto; display: inline-block; width: 15px; height: 15px; position: relative; }
.play-icon::before { content: ''; position: absolute; top: 2px; left: 3px; border: solid transparent; border-width: 6px 0 6px 9px; border-left-color: currentColor; }
.auto-icon { border: 1.6px solid currentColor; border-radius: 50%; }
.auto-icon::before { content: ''; position: absolute; inset: 2px 3px 4px 5px; border-left: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; }
#auto[aria-pressed="true"] .auto-icon { border: 0; border-radius: 0; }
#auto[aria-pressed="true"] .auto-icon::before { inset: 2px 4px; border: solid currentColor; border-width: 0 2px; }
.expand-icon { background: linear-gradient(currentColor,currentColor) left top/5px 2px, linear-gradient(currentColor,currentColor) left top/2px 5px, linear-gradient(currentColor,currentColor) right top/5px 2px, linear-gradient(currentColor,currentColor) right top/2px 5px, linear-gradient(currentColor,currentColor) left bottom/5px 2px, linear-gradient(currentColor,currentColor) left bottom/2px 5px, linear-gradient(currentColor,currentColor) right bottom/5px 2px, linear-gradient(currentColor,currentColor) right bottom/2px 5px; background-repeat: no-repeat; }
.sound-icon::before { content: ''; position: absolute; inset: 1px 5px 1px 0; background: currentColor; clip-path: polygon(0 30%, 37% 30%, 100% 0, 100% 100%, 37% 70%, 0 70%); }
.sound-icon::after { content: ''; position: absolute; width: 6px; height: 2px; top: 7px; right: -2px; background: currentColor; transform: rotate(-48deg); }
#sound[aria-pressed="true"] .sound-icon::after { inset: 2px -2px 2px auto; height: auto; width: 8px; border: 1.5px solid currentColor; border-color: transparent currentColor transparent transparent; border-radius: 50%; background: none; transform: none; }
.undo-icon, .reset-icon { width: 19px; height: auto; font-size: 21px; line-height: .75; text-align: center; }

.shortcuts { display: flex; justify-content: space-between; padding-inline: 3px; gap: 10px; color: var(--muted); font-size: 14px; }
kbd { font: inherit; font-weight: 700; color: #e6dbfa; border: 1px solid #4f455f; border-radius: 5px; background: #262133; padding: 1px 6px; margin-right: 4px; }

dialog { width: min(440px, calc(100% - 28px)); padding: clamp(17px, 4vw, 28px); color: var(--text); background: var(--panel); border: 1px solid #6c5a93; border-radius: 17px; box-shadow: 0 18px 65px #0a0712a0; }
dialog::backdrop { background: #110d1bc9; }
dialog h2 { font-size: clamp(21px, 4vw, 26px); }
dialog p { color: var(--muted); line-height: 1.5; margin-top: 9px; }
.dialog-actions { justify-content: flex-end; margin-top: 23px; flex-wrap: wrap; }

@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .app { align-content: start; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .top-actions { margin-left: auto; }
  .game { grid-template-columns: minmax(0, 1fr); }
  .draw-stage { --diameter: clamp(126px, 38vw, 220px); }
  .numbers { grid-template-rows: repeat(9, minmax(31px, 1fr)); }
  .controls { grid-row: 2; flex-wrap: wrap; }
  .play-actions, .utility-actions { flex-wrap: wrap; }
  .shortcuts { display: none; }
}
@media (max-height: 620px) and (min-width: 561px) and (orientation: landscape) {
  .app { gap: 9px; padding-block: 9px; }
  .board { gap: 6px; padding-block: 10px; }
  .numbers { grid-template-rows: repeat(9, minmax(22px, 1fr)); gap: 3px; }
  .draw { padding-block: 10px; }
  .draw-stage { min-height: calc(var(--diameter) + 30px); }
  .recent { margin-top: 9px; padding-top: 8px; }
  .recent ol { margin-top: 5px; }
  .recent li { width: clamp(26px, 6vh, 39px); }
  .controls { padding-block: 6px; }
  .button, .speed select { min-height: 36px; }
  .shortcuts { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
