:root {
  color-scheme: dark;
  --bg: #090d19;
  --panel: #11182a;
  --panel-2: #171f34;
  --line: #28324d;
  --ink: #f5f7ff;
  --muted: #98a3bd;
  --lime: #b6ff3b;
  --lime-soft: #d8ff96;
  --coral: #ff6b57;
  --cyan: #51d7ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% -10%, rgba(81, 215, 255, .13), transparent 32rem),
    radial-gradient(circle at 100% 35%, rgba(182, 255, 59, .08), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

.app-shell {
  width: min(100%, 52rem);
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}

.topbar,
.arena-head,
.result-top,
.feedback,
.history-card,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar > div:first-child,
.arena-head > div:first-child,
.feedback p,
.start-panel { min-width: 0; }

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--cyan);
  font-size: .75rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: .14em;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  letter-spacing: -.04em;
}

h2 { margin-bottom: 0; font-size: clamp(1.1rem, 4vw, 1.45rem); }

.state-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.5rem;
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 24, 42, .82);
  color: var(--muted);
  font-size: .8rem;
}

.state-chip span,
.feedback-dot {
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 .22rem rgba(152, 163, 189, .12);
}

.state-chip.live { color: var(--lime-soft); border-color: rgba(182, 255, 59, .28); }
.state-chip.live span,
.feedback.ready .feedback-dot { background: var(--lime); box-shadow: 0 0 0 .22rem rgba(182, 255, 59, .14), 0 0 1rem rgba(182, 255, 59, .45); }
.feedback.warning .feedback-dot { background: var(--coral); box-shadow: 0 0 0 .22rem rgba(255, 107, 87, .15); }

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  margin: 1.25rem 0 .8rem;
}

.scoreboard article {
  min-width: 0;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(23, 31, 52, .94), rgba(14, 20, 35, .94));
}

.scoreboard article > span,
.result-grid span,
.result-score > span {
  display: block;
  margin-bottom: .4rem;
  color: var(--muted);
  font-size: .75rem;
}

.scoreboard strong,
.result-score strong {
  display: flex;
  align-items: baseline;
  gap: .22rem;
  white-space: nowrap;
}

.scoreboard strong b { overflow: hidden; text-overflow: ellipsis; font-size: clamp(1.25rem, 6vw, 2rem); }
.scoreboard strong small,
.result-score strong small { color: var(--muted); font-size: .72rem; font-weight: 700; }
.scoreboard .average-card { border-color: rgba(182, 255, 59, .26); }
.average-card strong b { color: var(--lime); }

.meter { margin-bottom: 1rem; padding: 0 .25rem; }
.meter-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .68rem; }
.meter-track {
  display: block;
  width: 100%;
  height: .45rem;
  margin-top: .35rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: #26314b;
}
.meter-track::-webkit-progress-bar { border-radius: 999px; background: #26314b; }
.meter-track::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--cyan) 58%, var(--coral)); transition: width .25s ease; }
.meter-track::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--cyan) 58%, var(--coral)); }

.arena-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: rgba(17, 24, 42, .93);
  box-shadow: var(--shadow);
}

.arena-head { padding: 1rem 1rem .85rem; }
.round-label { display: inline-block; margin-bottom: .35rem; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }

.info-button {
  flex: 0 0 auto;
  width: 2.7rem;
  height: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--panel-2);
  cursor: pointer;
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(.45rem, 2.5vw, .85rem);
  min-height: min(100vw, 30rem);
  padding: clamp(.8rem, 3vw, 1.4rem);
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #0c1221;
  background-size: 2rem 2rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.hole {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid #27314a;
  border-radius: 50%;
  color: transparent;
  background: radial-gradient(ellipse at center, #03050a 0 47%, #121a2c 49% 67%, #1b263e 69% 100%);
  box-shadow: inset 0 -.55rem 1.3rem rgba(0, 0, 0, .48), 0 .65rem 1.5rem rgba(0, 0, 0, .18);
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.hole::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px dashed rgba(152, 163, 189, .12);
  border-radius: 50%;
}

.hole span {
  position: relative;
  z-index: 2;
  font-size: clamp(2.5rem, 14vw, 5rem);
  line-height: 1;
  transform: translateY(125%) scale(.74);
  filter: drop-shadow(0 .5rem .45rem rgba(0,0,0,.55));
  opacity: 0;
}

.hole.active {
  border-color: rgba(182, 255, 59, .8);
  background: radial-gradient(ellipse at center, #060a0d 0 42%, #213121 44% 68%, #334d28 70% 100%);
  box-shadow: inset 0 -.55rem 1.3rem rgba(0, 0, 0, .46), 0 0 0 .24rem rgba(182, 255, 59, .12), 0 0 2.2rem rgba(182, 255, 59, .18);
  cursor: pointer;
}

.hole.active span {
  color: initial;
  opacity: 1;
  transform: translateY(6%) scale(1);
  animation: pop-up .15s cubic-bezier(.2,.9,.3,1.35);
}

.hole.hit { animation: hit-flash .2s ease; }

@keyframes pop-up { from { opacity: 0; transform: translateY(125%) scale(.65); } }
@keyframes hit-flash { 50% { background: var(--lime); transform: scale(.95); } }

.start-panel,
.countdown {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(9, 13, 25, .91);
  backdrop-filter: blur(.45rem);
}

.start-panel[hidden],
.countdown[hidden] { display: none; }

.start-panel p { max-width: 27rem; margin: .8rem auto 1.15rem; color: #c7cde0; font-size: 1rem; line-height: 1.65; }
.start-panel small { margin-top: .8rem; color: var(--muted); font-size: .75rem; }
.target-demo { display: grid; place-items: center; width: 5rem; height: 5rem; border: 1px solid rgba(182,255,59,.4); border-radius: 50%; background: rgba(182,255,59,.08); font-size: 3rem; }
.countdown { color: var(--lime); font-size: clamp(5rem, 30vw, 10rem); font-weight: 900; font-variant-numeric: tabular-nums; }

.primary-button,
.secondary-button {
  min-height: 3.25rem;
  border: 0;
  border-radius: .95rem;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  width: min(100%, 18rem);
  color: #101607;
  background: var(--lime);
  box-shadow: 0 .65rem 1.8rem rgba(182, 255, 59, .18);
}

.primary-button:active { transform: translateY(1px) scale(.99); }

.secondary-button { width: 100%; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); }

.feedback {
  min-height: 4.25rem;
  padding: .85rem 1rem;
  border-top: 1px solid var(--line);
}

.feedback p { flex: 1; margin: 0; color: #c8cede; font-size: .86rem; line-height: 1.45; }
.false-starts { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.false-starts b { color: var(--coral); }

.history-card {
  align-items: flex-start;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(17, 24, 42, .76);
}
.history-card h2 { font-size: 1rem; }
.history-card ol { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.history-card li { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .75rem; color: var(--muted); font-size: .75rem; }
.history-card li b { color: var(--ink); }

footer { align-items: flex-start; padding: 1.2rem .2rem .2rem; color: var(--muted); font-size: .7rem; line-height: 1.55; }
footer span { max-width: 34rem; }
footer button { padding: 0; border: 0; color: var(--muted); background: transparent; text-decoration: underline; cursor: pointer; white-space: nowrap; }

dialog {
  width: min(calc(100% - 1.5rem), 34rem);
  max-height: min(90dvh, 48rem);
  overflow: auto;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  color: var(--ink);
  background: #101728;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(2, 4, 10, .78); backdrop-filter: blur(.35rem); }
.grade-badge { padding: .55rem .75rem; border: 1px solid rgba(182,255,59,.4); border-radius: 999px; color: var(--lime); background: rgba(182,255,59,.08); font-size: .78rem; font-weight: 850; }

.result-score { margin: 1rem 0; padding: 1.2rem; border-radius: 1.15rem; background: linear-gradient(145deg, rgba(182,255,59,.12), rgba(81,215,255,.06)); }
.result-score strong b { color: var(--lime); font-size: clamp(3rem, 17vw, 5rem); line-height: 1; letter-spacing: -.06em; }
.result-score strong small { font-size: 1rem; }
.result-score p { margin: .85rem 0 0; color: #ced4e5; line-height: 1.55; }

.result-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; }
.result-grid article { padding: .8rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel-2); }
.result-grid strong { font-size: 1rem; }

.round-chart { margin: 1.15rem 0; }
.round-chart h3 { font-size: .9rem; }
.round-chart ol { display: grid; gap: .42rem; margin: 0; padding: 0; list-style: none; }
.round-chart li { display: grid; grid-template-columns: 2.1rem 1fr 3.8rem; align-items: center; gap: .5rem; color: var(--muted); font-size: .72rem; }
.round-chart progress {
  display: block;
  width: 100%;
  height: .5rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: #26314b;
}
.round-chart progress::-webkit-progress-bar { border-radius: 999px; background: #26314b; }
.round-chart progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--cyan)); }
.round-chart progress::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--cyan)); }
.round-chart b { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

.info-content h2 { margin-bottom: 1rem; }
.info-content ol { padding-left: 1.35rem; color: #cdd3e4; line-height: 1.75; }
.info-content li + li { margin-top: .45rem; }

@media (min-width: 44rem) {
  .app-shell { padding-top: 2rem; }
  .scoreboard { gap: .8rem; }
  .scoreboard article { padding: 1rem 1.15rem; }
  .arena-head { padding: 1.2rem 1.3rem 1rem; }
  .feedback { padding-inline: 1.3rem; }
}

@media (max-width: 23rem) {
  .app-shell { padding-inline: .7rem; }
  .state-chip { padding-inline: .6rem; }
  .scoreboard article { padding: .7rem .55rem; }
  .scoreboard article > span { font-size: .68rem; }
  .arena { padding: .65rem; gap: .4rem; }
  .false-starts { display: none; }
}

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