:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --ink: #18332d;
  --muted: #667b76;
  --surface: #ffffff;
  --canvas: #f3f7f5;
  --line: #dce7e3;
  --brand: #176b57;
  --brand-dark: #105344;
  --red: #e94e58;
  --red-deep: #bf303d;
  --yellow: #f2bd38;
  --yellow-deep: #8b6500;
  --green: #34a46f;
  --green-deep: #19734a;
  --move: #4d6edb;
  --shadow: 0 18px 55px rgba(30, 78, 66, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -5%, rgba(82, 178, 142, 0.15), transparent 32rem),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 107, 87, 0.35);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 28px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 13px 2px auto;
  height: 2px;
  background: #9cb5ae;
  transform: rotate(-18deg);
  transform-origin: center;
}

.brand-mark span {
  z-index: 1;
  display: block;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(24, 51, 45, 0.14);
}

.brand-mark span:nth-child(1) { background: var(--red); transform: translateY(5px); }
.brand-mark span:nth-child(2) { background: var(--yellow); }
.brand-mark span:nth-child(3) { background: var(--green); transform: translateY(-5px); }

.sound-chip {
  min-height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d6e4df;
  border-radius: 999px;
  color: #4b6961;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 650;
}

.sound-chip svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

main {
  flex: 1;
}

.screen {
  animation: screen-enter 300ms ease-out both;
}

.setup-screen {
  padding-top: 18px;
}

.hero-visual {
  width: 190px;
  height: 126px;
  margin: 0 auto -5px;
  position: relative;
}

.string-line {
  position: absolute;
  width: 184px;
  height: 2px;
  top: 61px;
  left: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #a4bbb5, #789a91);
  transform: rotate(-17deg);
  box-shadow: 0 2px 5px rgba(24, 51, 45, 0.14);
}

.hero-ball {
  position: absolute;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 25px rgba(26, 66, 56, 0.18), inset -7px -8px 13px rgba(44, 47, 45, 0.14), inset 7px 7px 12px rgba(255, 255, 255, 0.28);
}

.hero-ball::after {
  content: "";
  position: absolute;
  width: 24%;
  height: 18%;
  top: 18%;
  left: 24%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.64);
  filter: blur(1px);
}

.hero-ball-red { width: 66px; height: 66px; left: 8px; bottom: 6px; background: var(--red); }
.hero-ball-yellow { width: 58px; height: 58px; left: 70px; top: 32px; background: var(--yellow); }
.hero-ball-green { width: 50px; height: 50px; right: 4px; top: 5px; background: var(--green); }

.intro-copy {
  text-align: center;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

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

.intro-copy h1,
.complete-screen h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.intro-note {
  max-width: 360px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.setup-card,
.rule-card,
.counts-card,
.summary-card {
  border: 1px solid rgba(214, 229, 223, 0.9);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 32px rgba(33, 76, 65, 0.06);
}

.setup-card {
  padding: 17px;
  border-radius: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.step-number {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: var(--brand);
  background: #e5f1ed;
  font-size: 12px;
  font-weight: 850;
}

.distance-list {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.distance-item {
  min-width: 0;
  padding: 12px 8px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 5px;
  border-radius: 15px;
  background: #f7f9f8;
  color: var(--muted);
  font-size: 12px;
}

.distance-item strong {
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 18px;
}

.distance-item small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.mini-ball {
  width: 9px;
  height: 9px;
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
  box-shadow: inset -1px -2px 2px rgba(0, 0, 0, 0.12);
}

.distance-red .mini-ball,
.count-red .mini-ball,
.distance-pill .mini-ball { background: var(--red); }
.distance-yellow .mini-ball,
.count-yellow .mini-ball { background: var(--yellow); }
.distance-green .mini-ball,
.count-green .mini-ball { background: var(--green); }

.rule-card {
  margin-top: 10px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 18px;
}

.rule-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--brand);
  background: #edf5f2;
}

.rule-icon svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.rule-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.rule-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.start-actions {
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #1b775f, #105a49);
  box-shadow: 0 12px 26px rgba(23, 107, 87, 0.24);
  font-size: 16px;
  font-weight: 750;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-button:active {
  transform: translateY(1px) scale(0.995);
  box-shadow: 0 8px 18px rgba(23, 107, 87, 0.22);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-button svg path[d^="M8 5.5"] {
  fill: currentColor;
  stroke: none;
}

.volume-hint {
  margin: 10px 0 0;
  color: #758983;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.training-screen {
  padding-top: 22px;
}

.training-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.meta-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.training-meta strong {
  font-size: 16px;
}

.distance-pill {
  min-height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2eae7;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 11px;
}

.distance-pill strong {
  color: var(--ink);
  font-size: 12px;
}

.round-progress {
  height: 5px;
  margin: 13px 0 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe9e5;
}

.round-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 100ms linear;
}

.command-card {
  --command-color: var(--red);
  --command-deep: var(--red-deep);
  min-height: 426px;
  padding: 18px 18px 20px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--command-color) 12%, transparent), transparent 47%),
    rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
  transition: background 220ms ease;
}

.command-yellow { --command-color: var(--yellow); --command-deep: var(--yellow-deep); }
.command-green { --command-color: var(--green); --command-deep: var(--green-deep); }
.command-move { --command-color: var(--move); --command-deep: #334fa8; }

.command-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.voice-active {
  min-height: 26px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  color: var(--brand);
  background: #eaf4f0;
  font-size: 10px;
}

.voice-wave {
  height: 11px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-wave i {
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: currentColor;
  animation: voice-wave 900ms ease-in-out infinite alternate;
}

.voice-wave i:nth-child(2) { height: 10px; animation-delay: 160ms; }
.voice-wave i:nth-child(3) { height: 7px; animation-delay: 320ms; }

.command-visual {
  width: 150px;
  height: 150px;
  margin: 15px auto -2px;
  position: relative;
  display: grid;
  place-items: center;
}

.focus-halo {
  position: absolute;
  inset: 9px;
  border: 1px solid color-mix(in srgb, var(--command-color) 28%, transparent);
  border-radius: 50%;
  animation: halo 2.2s ease-in-out infinite;
}

.focus-halo::after {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1px solid color-mix(in srgb, var(--command-color) 20%, transparent);
  border-radius: 50%;
}

.focus-ball {
  width: 82px;
  height: 82px;
  position: relative;
  z-index: 1;
  border: 6px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: var(--command-color);
  box-shadow: 0 17px 28px color-mix(in srgb, var(--command-color) 28%, transparent), inset -10px -12px 16px rgba(42, 43, 43, 0.14), inset 8px 8px 13px rgba(255, 255, 255, 0.28);
}

.focus-ball::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 12px;
  top: 15px;
  left: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  transform: rotate(-22deg);
}

.move-icon {
  display: none;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--move) 22%, transparent);
  border-radius: 50%;
  color: var(--move);
  background: color-mix(in srgb, var(--move) 9%, white);
}

.move-icon svg {
  width: 70px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.command-move .focus-halo,
.command-move .focus-ball {
  display: none;
}

.command-move .move-icon {
  display: grid;
}

.command-text {
  margin: 0;
  color: var(--command-deep);
  font-size: 40px;
  font-weight: 850;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-indent: 0.08em;
}

.command-detail {
  min-height: 22px;
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.timer {
  --timer-progress: 0deg;
  width: 82px;
  height: 82px;
  margin: 0 auto;
  padding: 5px;
  border-radius: 50%;
  background: conic-gradient(var(--command-color) var(--timer-progress), #e7eeeb 0deg);
}

.timer-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 15px;
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
}

.timer strong {
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer span {
  margin-left: 2px;
  color: var(--muted);
  font-size: 10px;
}

.counts-card {
  margin-top: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border-radius: 19px;
}

.count-item {
  min-width: 0;
  min-height: 46px;
  padding: 0 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 5px;
  border-radius: 13px;
  color: var(--muted);
  font-size: 10px;
  transition: background 180ms ease;
}

.count-item strong {
  grid-column: 1 / -1;
  padding-left: 14px;
  color: var(--ink);
  font-size: 11px;
}

.count-item b {
  font-size: 14px;
}

.count-red.is-active { background: #fff0f1; }
.count-yellow.is-active { background: #fff8e6; }
.count-green.is-active { background: #eaf7f1; }

.pause-notice {
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid #dae4e0;
  border-radius: 15px;
  background: #fff;
  text-align: center;
}

.pause-notice strong,
.pause-notice span {
  display: block;
}

.pause-notice strong {
  margin-bottom: 2px;
  font-size: 12px;
}

.pause-notice span {
  color: var(--muted);
  font-size: 10px;
}

.training-actions {
  margin-top: 13px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #d6e3de;
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 750;
}

.secondary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.secondary-button .play-icon,
.secondary-button.is-paused .pause-icon {
  display: none;
}

.secondary-button.is-paused .play-icon {
  display: block;
  fill: currentColor;
}

.text-button {
  min-width: 92px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.complete-screen {
  padding-top: clamp(65px, 15vh, 120px);
  text-align: center;
}

.complete-mark {
  width: 104px;
  height: 104px;
  margin: 0 auto 25px;
  display: grid;
  place-items: center;
  border-radius: 34px;
  color: var(--brand);
  background: #dff1ea;
  box-shadow: 0 17px 38px rgba(23, 107, 87, 0.16);
  transform: rotate(-5deg);
}

.complete-mark svg {
  width: 72px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 6;
  transform: rotate(5deg);
}

.complete-screen h1 {
  margin-bottom: 12px;
}

.complete-copy {
  margin-bottom: 27px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.summary-card {
  margin-bottom: 18px;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: 20px;
}

.summary-card div {
  padding: 11px 5px;
  border-right: 1px solid #e4ebe8;
}

.summary-card div:last-child {
  border-right: 0;
}

.summary-card span,
.summary-card strong {
  display: block;
}

.summary-card span {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}

.summary-card strong {
  font-size: 14px;
}

footer {
  padding-top: 18px;
  color: #82938e;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

@keyframes screen-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes halo {
  0%, 100% { transform: scale(0.94); opacity: 0.6; }
  50% { transform: scale(1); opacity: 1; }
}

@keyframes voice-wave {
  from { transform: scaleY(0.55); }
  to { transform: scaleY(1); }
}

@media (max-width: 359px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .intro-copy h1 { font-size: 29px; }
  .command-card { min-height: 408px; }
  .distance-item { padding-left: 6px; padding-right: 6px; }
}

@media (max-height: 730px) {
  .training-screen { padding-top: 13px; }
  .round-progress { margin-bottom: 10px; }
  .command-card { min-height: 374px; padding-top: 14px; }
  .command-visual { width: 125px; height: 125px; margin-top: 7px; }
  .focus-ball { width: 72px; height: 72px; }
  .command-text { font-size: 36px; }
  .command-detail { margin-bottom: 8px; }
  .timer { width: 72px; height: 72px; }
  .timer-inner { padding-top: 12px; }
  .timer strong { font-size: 24px; }
}

@media (min-width: 700px) {
  .app-shell { padding-left: 28px; padding-right: 28px; }
  .setup-screen { padding-top: 25px; }
  .command-card { min-height: 445px; }
}

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