:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #11141b;
  --text: #f7f8fb;
  --muted: #8e94a3;
  --line: rgba(255, 255, 255, 0.1);
  --green: #22df88;
  --red: #ff4e68;
  --yellow: #ffcf45;
  --blue: #4285ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); }

body {
  min-height: 100svh;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(66, 133, 255, 0.08), transparent 36%),
    linear-gradient(180deg, #0b0e14 0%, #080a0e 100%);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.game-shell {
  width: min(100%, 470px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 22px max(20px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  position: relative;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 24px;
  height: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  transform: rotate(45deg);
}
.brand-mark i { display: block; border-radius: 2px; }
.brand-mark i:nth-child(1) { background: var(--green); }
.brand-mark i:nth-child(2) { background: var(--red); }
.brand-mark i:nth-child(3) { background: var(--yellow); }
.brand-mark i:nth-child(4) { background: var(--blue); }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: #cdd1db;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
}
.icon-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-off { display: none; }
.icon-button[aria-pressed="false"] .sound-on { display: none; }
.icon-button[aria-pressed="false"] .sound-off { display: block; }

.status {
  min-height: 120px;
  display: grid;
  grid-template-columns: 62px 1fr 62px;
  align-items: end;
  padding: 24px 2px 16px;
  text-align: center;
}

.status > div { display: grid; gap: 1px; text-align: left; }
.status .score-block { text-align: right; }
.eyebrow { color: #7e8492; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; }
.status strong { font-size: 1.65rem; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.status p { margin: 0 6px 2px; color: #d3d6de; font-size: 0.94rem; line-height: 1.35; }

.board-wrap { min-height: 0; display: grid; place-items: center; position: relative; }
.ambient { position: absolute; width: 38%; aspect-ratio: 1; border-radius: 50%; filter: blur(75px); opacity: 0.11; pointer-events: none; }
.ambient-a { background: var(--green); left: 2%; top: 23%; }
.ambient-b { background: var(--blue); right: 0; bottom: 20%; }

.board {
  width: min(82vw, 378px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  padding: 11px;
  position: relative;
  border-radius: 50%;
  background: #07090d;
  box-shadow: 0 25px 70px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(255,255,255,0.05);
}

.pad {
  border: 0;
  cursor: pointer;
  opacity: 0.84;
  transition: transform 100ms ease, filter 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}
.pad::after { content: ""; position: absolute; inset: 0; background: linear-gradient(145deg, rgba(255,255,255,0.24), transparent 38%, rgba(0,0,0,0.18)); }
.pad-green { background: var(--green); border-radius: 100% 16px 16px 16px; transform-origin: bottom right; }
.pad-red { background: var(--red); border-radius: 16px 100% 16px 16px; transform-origin: bottom left; }
.pad-yellow { background: var(--yellow); border-radius: 16px 16px 16px 100%; transform-origin: top right; }
.pad-blue { background: var(--blue); border-radius: 16px 16px 100% 16px; transform-origin: top left; }
.pad.active { opacity: 1; filter: brightness(1.45) saturate(1.15); transform: scale(0.975); box-shadow: 0 0 32px currentColor; }
.pad:focus-visible, .core:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid white; outline-offset: 4px; }

.core {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 35%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 8px solid #080a0e;
  color: var(--text);
  background: linear-gradient(145deg, #242934, #11141b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 12px 28px rgba(0,0,0,0.6);
  display: grid;
  place-content: center;
  gap: 6px;
  cursor: pointer;
  z-index: 2;
  transition: transform 130ms ease, background 180ms ease;
}
.core:active { transform: translate(-50%, -50%) scale(0.96); }
.core-icon { font-size: 1.3rem; margin-left: 3px; }
.core-label { font-size: 0.67rem; font-weight: 900; letter-spacing: 0.14em; }
.core.playing .core-icon { display: none; }
.core.playing .core-label { font-size: 1.7rem; letter-spacing: 0.02em; }

footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 2px 0; }
footer p { display: flex; align-items: center; gap: 9px; margin: 0; color: #898f9d; font-size: 0.76rem; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #626876; box-shadow: 0 0 0 4px rgba(255,255,255,0.035); }
.pulse-dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(34,223,136,0.12), 0 0 12px var(--green); }
.how-button { border: 0; color: #a8adba; background: transparent; font-size: 0.78rem; cursor: pointer; padding: 10px 0 10px 10px; }
.how-button span { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 5px; border: 1px solid #555b68; border-radius: 50%; }

dialog { width: min(calc(100% - 32px), 420px); border: 0; padding: 0; border-radius: 26px; color: var(--text); background: transparent; }
dialog::backdrop { background: rgba(2,4,7,0.78); backdrop-filter: blur(8px); }
.dialog-card { position: relative; padding: 30px 26px 24px; background: #151922; border: 1px solid var(--line); border-radius: 26px; }
.dialog-card h2 { margin: 7px 0 22px; font-size: 1.9rem; }
.dialog-card ol { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 17px; }
.dialog-card li { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 12px; color: #bec3ce; line-height: 1.4; }
.dialog-card li span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #242936; color: white; font-weight: 800; }
.dialog-close { position: absolute; right: 18px; top: 16px; border: 0; background: transparent; color: #9298a6; font-size: 1.8rem; cursor: pointer; }
.dialog-start { width: 100%; min-height: 52px; border: 0; border-radius: 15px; background: var(--text); color: #0a0c11; font-weight: 900; cursor: pointer; }

.shake { animation: shake 280ms ease; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

@media (max-height: 690px) {
  .game-shell { padding-top: 14px; padding-bottom: 12px; }
  .status { min-height: 92px; padding: 14px 2px 10px; }
  .board { width: min(67vh, 82vw, 350px); }
  footer { padding-top: 10px; }
}

@media (min-width: 760px) {
  body { display: grid; place-items: center; }
  .game-shell { min-height: min(900px, 94vh); border: 1px solid rgba(255,255,255,0.07); border-radius: 34px; box-shadow: 0 30px 100px rgba(0,0,0,0.5); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
