:root {
  --paper: #f5f1e8;
  --ink: #17312d;
  --muted: #64716d;
  --teal: #0d7c74;
  --teal-deep: #095f59;
  --mint: #cfe8de;
  --coral: #ef735e;
  --coral-deep: #d95440;
  --yellow: #f5c95b;
  --white: #fffdf8;
  --line: rgba(23, 49, 45, .14);
  --shadow: 0 22px 60px rgba(38, 55, 50, .13);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.site-header {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 64px) 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.section-label {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 56px);
  line-height: .98;
  letter-spacing: -.045em;
}

h1 span {
  display: inline-block;
  margin-left: .24em;
  color: var(--muted);
  font-size: .46em;
  font-weight: 650;
  letter-spacing: -.02em;
}

.instruction { margin: 13px 0 0; color: var(--muted); font-size: 15px; letter-spacing: .02em; }
.instruction b { color: var(--coral); margin: 0 3px; }

.settings { position: relative; z-index: 20; }
.settings summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 253, 248, .7);
  font-size: 13px;
  font-weight: 750;
  user-select: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary span { margin-right: 4px; }
.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 9px);
  width: 230px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.settings-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.settings-panel input { position: absolute; opacity: 0; pointer-events: none; }
.settings-panel i {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 99px;
  background: #c8ceca;
  transition: .2s ease;
}
.settings-panel i::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px #678;
  transition: .2s ease;
}
.settings-panel input:checked + i { background: var(--teal); }
.settings-panel input:checked + i::after { transform: translateX(16px); }

main { max-width: 1480px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px) 20px; }

.game {
  display: grid;
  grid-template-columns: minmax(440px, 1.06fr) minmax(440px, .94fr);
  align-items: center;
  gap: clamp(30px, 5vw, 88px);
}

.wheel-column { min-width: 0; }
.wheel-wrap {
  position: relative;
  width: min(100%, 730px);
  aspect-ratio: 1;
  margin: 0 auto;
  filter: drop-shadow(0 22px 28px rgba(32, 62, 56, .14));
}

#pinyin-wheel { width: 100%; height: 100%; overflow: visible; }
.segment-path { stroke: rgba(255,255,255,.68); stroke-width: 2; transition: fill .16s ease, filter .16s ease; }
.outer-segment:nth-child(odd) .segment-path { fill: #cfe8de; }
.outer-segment:nth-child(even) .segment-path { fill: #b8ddd0; }
.inner-segment:nth-child(odd) .segment-path { fill: #ef7a64; }
.inner-segment:nth-child(even) .segment-path { fill: #e96853; }
.segment-label {
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
  font-weight: 800;
  letter-spacing: -.02em;
  pointer-events: none;
}
.outer-segment .segment-label { font-size: 18px; }
.inner-segment .segment-label { fill: white; font-size: 22px; }
.segment.selected .segment-path { fill: var(--yellow); filter: drop-shadow(0 0 8px rgba(245, 201, 91, .72)); }
.segment.selected .segment-label { fill: var(--ink); font-size: 24px; }
.wheel-core { fill: var(--white); stroke: rgba(23,49,45,.08); stroke-width: 4; }

.pointer {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: -2px;
  width: 46px;
  height: 55px;
  transform: translateX(-50%);
  pointer-events: none;
}
.pointer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transform: translateX(-50%);
  box-shadow: 0 3px 0 rgba(0,0,0,.13);
}
.pointer span {
  position: absolute;
  left: 50%;
  top: 13px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 38px solid var(--ink);
}

.spin-button {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  width: 156px;
  height: 156px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  box-shadow: 0 10px 0 var(--teal-deep), 0 16px 28px rgba(9,95,89,.28);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease;
}
.spin-button:hover:not(:disabled) { transform: translate(-50%, -52%); box-shadow: 0 12px 0 var(--teal-deep), 0 19px 32px rgba(9,95,89,.3); }
.spin-button:active:not(:disabled) { transform: translate(-50%, -47%); box-shadow: 0 5px 0 var(--teal-deep); }
.spin-button:disabled { cursor: wait; opacity: .72; }
.spin-en { display: block; font-size: 34px; font-weight: 900; letter-spacing: .04em; line-height: 1; }
.spin-zh { display: block; margin-top: 7px; font-size: 16px; font-weight: 700; letter-spacing: .08em; }

.wheel-actions { display: flex; align-items: center; justify-content: center; gap: 14px 24px; flex-wrap: wrap; margin-top: -4px; }
.wheel-actions p { margin: 0; color: var(--muted); font-size: 12px; }
kbd { padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--white); font-size: 10px; }
.er-button {
  border: 1px solid rgba(13,124,116,.3);
  border-radius: 999px;
  padding: 9px 15px;
  color: var(--teal-deep);
  background: rgba(207,232,222,.55);
  font-weight: 850;
  cursor: pointer;
}
.er-button span { margin-right: 5px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.er-button[hidden] { display: none; }

.result-panel {
  min-width: 0;
  padding: clamp(24px, 3.5vw, 48px);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 30px;
  background: rgba(255,253,248,.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-label span { margin-left: 5px; color: var(--muted); font-weight: 650; letter-spacing: 0; text-transform: none; }
.pair-details { display: flex; gap: 20px; color: var(--muted); font-size: 13px; }
.pair-details b { margin-left: 4px; color: var(--ink); font-size: 16px; }
.status-pill { padding: 7px 10px; border-radius: 999px; color: var(--teal-deep); background: var(--mint); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .07em; }
.status-pill.spinning { color: #8b3a2c; background: #f8d7ce; }

.syllable-stage { position: relative; padding: clamp(28px, 4vw, 52px) 0 32px; text-align: center; }
.prompt { margin: 0 0 2px; color: var(--muted); font-size: 13px; }
.base-syllable {
  min-height: 1.15em;
  font-family: Georgia, "Times New Roman", "STSong", serif;
  font-size: clamp(68px, 7vw, 104px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
}
.play-all {
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  color: white;
  background: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.play-all:disabled { opacity: .34; cursor: not-allowed; }

.tone-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tone-card {
  position: relative;
  min-width: 0;
  padding: 17px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  text-align: center;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.tone-card:hover { transform: translateY(-2px); border-color: rgba(13,124,116,.34); }
.tone-pinyin {
  display: block;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 3vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
}
.tone-number { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.speaker {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-top: 11px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  cursor: pointer;
}
.speaker svg { width: 17px; height: 17px; fill: currentColor; }
.speaker:disabled { color: #89918e; background: #e0e3df; cursor: not-allowed; }
.tone-card.playing { border-color: var(--yellow); background: #fff8df; }
.tone-placeholder { color: #abb3af; }

.recent-row { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.recent-list { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0 0; padding: 0; list-style: none; }
.recent-list li { padding: 7px 11px; border-radius: 999px; color: var(--muted); background: rgba(23,49,45,.055); font-family: Georgia, serif; font-weight: 700; }

footer {
  max-width: 1480px;
  margin: 4px auto 0;
  padding: 18px clamp(20px, 4vw, 64px) 28px;
  display: flex;
  gap: 12px 22px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}
footer span:last-child { margin-left: auto; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.initial-dot { background: var(--coral); }
.final-dot { background: var(--mint); }

button:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

@media (max-width: 980px) {
  .game { grid-template-columns: 1fr; }
  .wheel-wrap { width: min(100%, 660px); }
  .result-panel { max-width: 720px; width: 100%; margin: 0 auto; }
}

@media (max-width: 560px) {
  .site-header { padding-top: 20px; }
  h1 span { display: block; margin: 8px 0 0; font-size: .54em; }
  .settings summary { padding: 9px; font-size: 0; }
  .settings summary span { margin: 0; font-size: 16px; }
  main { padding-left: 10px; padding-right: 10px; }
  .game { gap: 24px; }
  .wheel-wrap { width: 100%; }
  .pointer { top: -8px; transform: translateX(-50%) scale(.78); }
  .spin-button { width: 104px; height: 104px; box-shadow: 0 7px 0 var(--teal-deep), 0 12px 22px rgba(9,95,89,.24); }
  .spin-en { font-size: 24px; }
  .spin-zh { margin-top: 4px; font-size: 12px; }
  .outer-segment .segment-label { font-size: 17px; }
  .inner-segment .segment-label { font-size: 21px; }
  .wheel-actions { margin-top: 4px; }
  .wheel-actions p { display: none; }
  .result-panel { padding: 22px 14px; border-radius: 24px; }
  .base-syllable { font-size: clamp(60px, 22vw, 86px); }
  .tone-grid { grid-template-columns: repeat(2, 1fr); }
  .tone-pinyin { font-size: 34px; }
  footer span:last-child { width: 100%; margin: 0; }
}

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

