:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(12, 28, 49, 0.88);
  --panel-strong: rgba(16, 36, 62, 0.96);
  --line: rgba(152, 199, 255, 0.18);
  --text: #ecf6ff;
  --muted: #9cb6d0;
  --accent: #7dd3fc;
  --accent-2: #c084fc;
  --gold: #ffd166;
  --success: #7ef0a9;
  --danger: #ff8e8e;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(125, 211, 252, 0.18), transparent 30%),
    linear-gradient(180deg, #07111f 0%, #081a2f 45%, #06111e 100%);
  color: var(--text);
}

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

.shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.topnav, .eyebrow, .mini, .small, .hint, .hud span { color: var(--muted); }
.topnav {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  font-size: 0.95rem;
}
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 26px;
  text-align: center;
  margin-bottom: 18px;
}
.hero h1 { margin: 8px 0 10px; font-size: clamp(2rem, 5vw, 3.4rem); }
.subtitle {
  margin: 0 auto;
  width: min(720px, 100%);
  color: #d8e8f8;
  line-height: 1.55;
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.hud .panel {
  padding: 14px 16px;
  text-align: center;
}
.hud span {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hud strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.9fr);
  gap: 18px;
}

.board-panel { padding: 20px; }
.board-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.board-head h2 { margin: 4px 0 0; font-size: clamp(1.15rem, 2.6vw, 1.55rem); }

.board-wrap {
  position: relative;
  overflow: hidden;
  padding: 22px 16px 18px;
  min-height: 560px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.06);
  background:
    radial-gradient(circle at top, rgba(192, 132, 252, 0.14), transparent 28%),
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}

.start-slot {
  margin: 0 auto 12px;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(125,211,252,0.35);
  background: rgba(125,211,252,0.12);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.row {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.peg {
  position: relative;
  width: clamp(42px, 8vw, 58px);
  height: clamp(42px, 8vw, 58px);
  border-radius: 18px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(180deg, rgba(13, 31, 52, 0.98), rgba(8, 19, 34, 0.98));
  color: var(--text);
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.peg:hover, .peg:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(125, 211, 252, 0.6);
  box-shadow: 0 8px 20px rgba(125, 211, 252, 0.18);
  outline: none;
}
.peg.locked {
  cursor: default;
  border-color: rgba(255, 209, 102, 0.35);
  background: linear-gradient(180deg, rgba(58, 47, 17, 0.92), rgba(37, 29, 10, 0.94));
}
.peg.active {
  border-color: rgba(126, 240, 169, 0.8);
  box-shadow: 0 0 0 2px rgba(126, 240, 169, 0.2), 0 12px 22px rgba(126, 240, 169, 0.22);
}
.peg.starred::after {
  content: '✦';
  position: absolute;
  top: -8px;
  right: -2px;
  font-size: 0.9rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.65);
}
.peg.hit-star {
  background: linear-gradient(180deg, rgba(59, 43, 9, 0.98), rgba(32, 26, 7, 0.98));
}

.ball {
  position: absolute;
  left: 50%;
  top: 42px;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #dbeafe 55%, #7dd3fc 100%);
  box-shadow: 0 0 16px rgba(125, 211, 252, 0.45);
  opacity: 0;
  z-index: 2;
  transition: transform 240ms ease-in-out, opacity 120ms ease;
  pointer-events: none;
}
.ball.show { opacity: 1; }

.buckets {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.bucket-row {
  display: grid;
  gap: 10px;
}
.bucket {
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid rgba(156, 182, 208, 0.22);
  background: rgba(7, 17, 31, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}
.bucket.target {
  border-color: rgba(192, 132, 252, 0.55);
  color: #f4ddff;
  box-shadow: inset 0 0 0 1px rgba(192,132,252,0.24);
}
.bucket.hit {
  border-color: rgba(126,240,169,0.82);
  color: var(--success);
  box-shadow: 0 0 0 2px rgba(126,240,169,0.16);
}
.bucket.miss {
  border-color: rgba(255,142,142,0.7);
  color: var(--danger);
}

.side {
  display: grid;
  gap: 18px;
}
.side .panel { padding: 18px; }
.side h2 { margin: 0 0 10px; }
.rules ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.55;
}
.button-stack {
  display: grid;
  gap: 10px;
}
button {
  border: 0;
  border-radius: 16px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07111f;
}
button.ghost {
  border: 1px solid rgba(125, 211, 252, 0.28);
  background: transparent;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.hint {
  margin: 12px 0 0;
  line-height: 1.5;
}
.level-dots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.level-dots li {
  border-radius: 16px;
  border: 1px solid rgba(156, 182, 208, 0.18);
  padding: 10px 12px;
  color: var(--muted);
}
.level-dots li.done { color: var(--success); border-color: rgba(126,240,169,0.28); }
.level-dots li.current { color: var(--text); border-color: rgba(125,211,252,0.36); }

@media (max-width: 920px) {
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  .board-head { flex-direction: column; align-items: stretch; }
  .board-wrap { min-height: 520px; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 16px, 1120px); padding-top: 14px; }
  .hero, .board-panel, .side .panel { border-radius: 20px; }
  .board-wrap { padding-left: 10px; padding-right: 10px; min-height: 500px; }
  .row { gap: 8px; }
  .bucket { min-height: 46px; font-size: 0.82rem; }
}
