:root {
  --bg: #f5efe4;
  --bg-deep: #f0e3ce;
  --paper: #fbf7f0;
  --ink: #1b1b1f;
  --muted: #5f5b57;
  --accent: #0b6b6f;
  --accent-strong: #0f8b8d;
  --accent-warm: #e36c2f;
  --gold: #f2c572;
  --shadow: rgba(16, 26, 31, 0.18);
  --shadow-soft: rgba(16, 26, 31, 0.08);
  --stroke-ghost: rgba(11, 107, 111, 0.22);
  --stroke-user: rgba(15, 139, 141, 0.9);
  --stroke-wrong: rgba(227, 108, 47, 0.9);
  --radius-lg: 26px;
  --radius-md: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.hanzi-root {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  --safe-top: 0px;
  color: var(--ink);
  font-family: "Avenir Next", "Futura", "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 10%, #fffaf1 0%, var(--bg) 35%, var(--bg-deep) 100%);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.hanzi-root::before,
.hanzi-root::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  opacity: 0.35;
  pointer-events: none;
}

.hanzi-root::before {
  width: 420px;
  height: 420px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(242, 197, 114, 0.65), rgba(242, 197, 114, 0));
}

.hanzi-root::after {
  width: 520px;
  height: 520px;
  bottom: -220px;
  left: -180px;
  background: radial-gradient(circle, rgba(11, 107, 111, 0.45), rgba(11, 107, 111, 0));
}

.hanzi-app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 3vw, 24px);
  padding: clamp(16px, 3vw, 32px) clamp(16px, 4vw, 32px) clamp(24px, 5vw, 40px);
  min-height: 100%;
  height: auto;
}


.hero {
  display: block;
  animation: floatIn 600ms ease-out;
}

.card {
  background: rgba(251, 247, 240, 0.88);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 40px var(--shadow-soft);
  border: 1px solid rgba(27, 27, 31, 0.06);
  padding: clamp(16px, 3vw, 24px);
  backdrop-filter: blur(10px) saturate(1.1);
}

.exit-btn {
  position: fixed;
  top: calc(clamp(12px, 2.4vw, 20px) + var(--safe-top));
  right: clamp(12px, 2.4vw, 24px);
  z-index: 20;
  border: 1px solid rgba(27, 27, 31, 0.1);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(16, 26, 31, 0.1);
  backdrop-filter: blur(10px);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.exit-btn:hover {
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 18px rgba(16, 26, 31, 0.14);
}

.exit-btn:active {
  transform: translateY(1px) scale(0.98);
}

.exit-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  gap: clamp(16px, 3vw, 28px);
  align-items: center;
  position: relative;
}

.hero-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  position: relative;
  padding-inline: clamp(36px, 6vw, 52px);
}

.hero-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.char-symbol {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif;
  font-size: clamp(64px, 11vw, 130px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.char-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pinyin-btn {
  border: 1px solid rgba(11, 107, 111, 0.28);
  background: rgba(11, 107, 111, 0.08);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: clamp(18px, 4vw, 34px);
  font-weight: 600;
  color: var(--accent);
  text-transform: lowercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.pinyin-btn:hover {
  background: rgba(11, 107, 111, 0.14);
  box-shadow: 0 10px 18px rgba(16, 26, 31, 0.12);
}

.pinyin-btn:active {
  transform: translateY(1px) scale(0.98);
}

.pinyin-btn.is-empty,
.pinyin-btn:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.icon-btn {
  border: 1px solid rgba(11, 107, 111, 0.28);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent);
  box-shadow: 0 10px 18px rgba(16, 26, 31, 0.12);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 20px rgba(16, 26, 31, 0.16);
}

.icon-btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 6px 12px rgba(16, 26, 31, 0.12);
}

.char-details {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(11, 107, 111, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.char-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 8px 16px rgba(11, 107, 111, 0.25);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(11, 107, 111, 0.28);
}

.primary-btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 6px 12px rgba(11, 107, 111, 0.22);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.ety-text {
  font-size: clamp(16px, 1.9vw, 20px);
  line-height: 1.5;
  color: var(--ink);
}

.chip-inline {
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: none;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-chip {
  border: 1px solid rgba(27, 27, 31, 0.12);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(16, 26, 31, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.icon-chip svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play-chip {
  width: 48px;
  height: 48px;
}

.icon-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 18px rgba(16, 26, 31, 0.16);
}

.icon-chip:active {
  transform: translateY(1px) scale(0.98);
}

.icon-chip.active {
  background: rgba(11, 107, 111, 0.12);
  color: var(--accent);
  border-color: rgba(11, 107, 111, 0.3);
}

.score-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(27, 27, 31, 0.08);
  overflow: hidden;
  opacity: 0;
  transition: opacity 160ms ease;
}

.score-bar.is-active {
  opacity: 1;
}

.score-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c24b3a 0%, #d2873f 35%, #d4c34a 60%, #2f8a6a 100%);
  border-radius: inherit;
  transition: width 240ms ease;
}

.panel-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.meta-right {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.total-score {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  transition: transform 200ms ease, color 200ms ease;
}

.total-score.is-pulse {
  transform: scale(1.08);
  color: var(--accent-strong);
}
.meta-divider {
  color: var(--muted);
}

.complete-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.complete-count svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.score-burst {
  position: absolute;
  top: -22px;
  right: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 120ms ease, transform 280ms ease;
  pointer-events: none;
}

.score-burst.is-active {
  opacity: 1;
  transform: translateY(0);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: clamp(16px, 3vw, 24px);
  flex: 1;
  min-height: 0;
  align-items: start;
  --panel-height: clamp(360px, 58vh, 620px);
}

.panel {
  background: rgba(251, 247, 240, 0.92);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2.6vw, 20px);
  box-shadow: 0 18px 40px var(--shadow);
  border: 1px solid rgba(27, 27, 31, 0.08);
  min-height: 0;
}

.draw-panel,
.examples-panel {
  height: var(--panel-height);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(11, 107, 111, 0.12);
  padding: 6px 10px;
  border-radius: 999px;
}

.panel-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.panel-subtitle {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(27, 27, 31, 0.12);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(16, 26, 31, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  transform: translateY(-50%);
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-prev {
  left: clamp(6px, 1.6vw, 14px);
}

.nav-next {
  right: clamp(6px, 1.6vw, 14px);
}

.nav-btn:hover {
  transform: translateY(calc(-50% - 1px));
  box-shadow: 0 12px 20px rgba(16, 26, 31, 0.16);
}

.nav-btn:active {
  transform: translateY(calc(-50% + 1px)) scale(0.98);
}

.nav-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
  box-shadow: none;
}

.panel-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-btn {
  border: 1px solid rgba(27, 27, 31, 0.2);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.toggle-btn.active {
  background: rgba(11, 107, 111, 0.12);
  color: var(--accent);
  border-color: rgba(11, 107, 111, 0.4);
}

.toggle-btn:active {
  transform: translateY(1px) scale(0.98);
}

.canvas-shell {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(27, 27, 31, 0.08);
  padding: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.canvas-shell::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 24px;
  border: 1px dashed rgba(11, 107, 111, 0.25);
  pointer-events: none;
}

.canvas-layer {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
}

.writer-layer {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  pointer-events: none;
}

.writer-layer svg,
.writer-layer canvas {
  width: 100%;
  height: 100%;
}

.canvas-overlay {
  position: absolute;
  bottom: 26px;
  right: 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.score {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  background: rgba(11, 107, 111, 0.12);
  color: var(--accent);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.action-btn.secondary {
  background: rgba(27, 27, 31, 0.08);
  color: var(--ink);
  border: 1px solid rgba(27, 27, 31, 0.18);
}

.action-btn:active {
  transform: translateY(1px) scale(0.98);
}

.examples-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: start;
}

.examples-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding-right: 6px;
  flex: 1;
  min-height: 0;
}

.example-card {
  background: #fffaf4;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 8px 18px rgba(16, 26, 31, 0.08);
  border: 1px solid rgba(27, 27, 31, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.example-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.example-text {
  font-size: 18px;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif;
}

.example-romanization {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.example-translations {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.speak-btn {
  border: none;
  background: rgba(11, 107, 111, 0.12);
  color: var(--accent);
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.speak-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.speak-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.examples-footer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

@keyframes floatIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
    --panel-height: clamp(320px, 55vh, 520px);
  }
}

@media (max-width: 720px) {
  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-right {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .panel-actions {
    justify-content: flex-start;
  }
  .workspace {
    --panel-height: clamp(320px, 60vh, 560px);
  }
}

@media (max-height: 700px) {
  .hanzi-app {
    gap: 14px;
  }
  .workspace {
    --panel-height: clamp(280px, 50vh, 480px);
  }
}
