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

:root {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --accent: #ffd400;
  --accent-dim: #b89600;
  --panel: #1a1a1a;
  --border: #444;
  --btn-bg: #222;
  --btn-active: #333;
  --danger: #ff6b6b;
  font-size: 16px;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.screen {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 0.65rem 0.9rem 1.1rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.setup-header h1 {
  font-size: 1.15rem;
  line-height: 1.25;
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-weight: 800;
}

.continue-hint {
  margin: 0 0 0.45rem;
  padding: 0.55rem 0.75rem;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.available-hint {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #bbb;
}

.audio-status,
.voice-note {
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.audio-status {
  color: #8ee7ff;
  background: #082631;
  border: 1px solid #17647e;
}

.audio-status.is-ready {
  color: #a9f5ae;
  background: #102913;
  border-color: #397d40;
}

.audio-status.is-error {
  color: #ffb4b4;
  background: #2a1010;
  border-color: var(--danger);
}

.voice-note {
  margin-top: 0.4rem;
  margin-bottom: 0;
  padding: 0;
  color: #bbb;
  background: transparent;
}

.choice-section,
.range-section {
  margin-bottom: 0.55rem;
}

.choice-section h2,
.range-section h2 {
  font-size: 0.78rem;
  margin: 0 0 0.4rem;
  color: var(--accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}

.chip-grid-wordbook {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.55rem 0.2rem;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 2.6rem;
  text-align: center;
}

.chip-option span {
  pointer-events: none;
}

.chip-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-option:has(input:checked) {
  border-color: var(--accent);
  background: #252200;
  color: var(--accent);
}

.range-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.range-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 2.6rem;
}

.range-option:has(input:checked) {
  border-color: var(--accent);
  background: #252200;
}

.range-option input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.range-option-wide {
  flex-wrap: wrap;
}

.range-option-wide input[type="number"] {
  width: 4.25rem;
  max-width: 30vw;
  font-size: 1rem;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

.custom-sep {
  font-size: 0.85rem;
  color: #aaa;
  margin-left: 0.15rem;
}

.setup-error {
  margin: 0 0 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #2a1010;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: #ffb4b4;
  font-size: 0.88rem;
  line-height: 1.35;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  min-height: 3.6rem;
  font-size: 1.25rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #000;
  cursor: pointer;
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.btn-primary:active {
  transform: scale(0.98);
}

.speech-hint {
  margin-top: 0.55rem;
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.35;
}

#run-screen {
  justify-content: space-between;
  gap: 0.75rem;
}

.run-top {
  text-align: center;
}

.meta-text {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.progress-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #eee;
  margin-bottom: 0.15rem;
}

.step-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ccc;
}

.main-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  min-height: 8rem;
}

.main-display .word-line {
  font-size: clamp(2.5rem, 12vw, 3.75rem);
  font-weight: 900;
  line-height: 1.15;
  color: var(--fg);
  word-break: break-word;
}

.main-display .sub-line {
  font-size: clamp(1.5rem, 7vw, 2.25rem);
  font-weight: 700;
  margin-top: 0.75rem;
  color: var(--accent);
  line-height: 1.3;
}

.main-display .chinese-line {
  font-size: clamp(2rem, 10vw, 3rem);
  font-weight: 800;
  color: #7ee787;
}

.lock-warning {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.35;
  color: #ffb347;
  background: #2a1f00;
  border-radius: 10px;
  border: 1px solid #664400;
  text-align: center;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.btn-control {
  min-height: 3.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--fg);
  cursor: pointer;
  padding: 0.5rem 0.35rem;
}

.btn-control:active {
  background: var(--btn-active);
}

.btn-control.is-on {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-control.is-paused {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 380px) {
  .chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  :root {
    font-size: 15px;
  }
}
