:root {
  --sky1: #bde7ff;
  --sky2: #9dd8ff;
  --sky3: #eaf8ff;
  --ink: #223041;
  --muted: rgba(34, 48, 65, 0.68);
  --accent: #ffb300;
  --success: #1fb573;
  --danger: #ff6f61;
  --blue: #0fa1db;
  --orange: #ff8a2a;
  --pink: #ff8fbe;
  --mint: #5fd69d;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(34, 48, 65, 0.12);
  --shadow: 0 20px 46px rgba(25, 76, 120, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100dvh;
  margin: 0;
  overscroll-behavior: none;
  overflow: hidden;
}

body {
  font-family: "Fredoka", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.9) 0 38px, transparent 39px),
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.72) 0 54px, transparent 55px),
    radial-gradient(circle at 78% 14%, rgba(255, 255, 255, 0.85) 0 44px, transparent 45px),
    linear-gradient(180deg, var(--sky3) 0%, var(--sky1) 42%, var(--sky2) 100%);
}

body::before {
  content: "";
  position: fixed;
  left: -8vw;
  right: -8vw;
  bottom: -14vh;
  height: 34vh;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 22% 100%, rgba(76, 190, 124, 0.52) 0 42%, transparent 43%),
    radial-gradient(ellipse at 78% 100%, rgba(44, 169, 132, 0.42) 0 38%, transparent 39%),
    linear-gradient(180deg, transparent 0 34%, rgba(122, 213, 137, 0.48) 35% 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 9% 54%, rgba(255, 196, 57, 0.38) 0 5px, transparent 6px),
    radial-gradient(circle at 92% 58%, rgba(255, 143, 190, 0.34) 0 6px, transparent 7px),
    radial-gradient(circle at 62% 8%, rgba(15, 161, 219, 0.18) 0 5px, transparent 6px);
}

button,
a {
  font: inherit;
}

.voice-app {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(6px, 1.4svh, 12px);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.practice-shell {
  width: min(1160px, 100%);
  height: min(100%, calc(100dvh - 12px));
}

.stage {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(250px, 0.8fr) minmax(360px, 1.35fr);
  gap: clamp(10px, 1.6vw, 18px);
  align-items: stretch;
}

.character-panel,
.question-panel {
  position: relative;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 196, 57, 0.22), transparent 30%),
    radial-gradient(circle at 100% 18%, rgba(255, 143, 190, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.character-panel::before,
.question-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  pointer-events: none;
}

.character-panel > *,
.question-panel > * {
  position: relative;
  z-index: 1;
}

.character-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: clamp(8px, 1.4svh, 14px);
  padding: clamp(10px, 1.6svh, 16px);
}

.top-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-link,
.support-badge,
.text-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 999px;
  border: 2px solid rgba(255, 196, 57, 0.72);
  background: linear-gradient(180deg, #ffffff, #fff4c8);
  color: #7a5000;
  text-decoration: none;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(138, 84, 0, 0.1), inset 0 -3px 0 rgba(255, 196, 57, 0.24);
}

.support-badge {
  min-width: 108px;
  border-color: rgba(31, 181, 115, 0.35);
  background: linear-gradient(180deg, #ffffff, #eafff3);
  color: #0f7b49;
}

.support-badge[data-state="off"] {
  border-color: rgba(255, 111, 97, 0.35);
  background: linear-gradient(180deg, #ffffff, #fff0ec);
  color: #9a372d;
}

.character-panel img {
  width: min(245px, 72%);
  align-self: center;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 20px 28px rgba(20, 79, 126, 0.22));
}

.speech-bubble {
  width: min(370px, 100%);
  min-height: clamp(66px, 11svh, 92px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 15px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #fff9de);
  border: 3px solid rgba(255, 196, 57, 0.78);
  box-shadow: 0 14px 26px rgba(138, 84, 0, 0.12), inset 0 -4px 0 rgba(255, 196, 57, 0.22);
  color: #5a3a00;
  font-size: clamp(17px, 2.3svh, 22px);
  font-weight: 800;
  line-height: 1.16;
  text-align: center;
}

.question-panel {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto auto auto;
  align-content: stretch;
  gap: clamp(7px, 1.1svh, 11px);
  padding: clamp(10px, 1.7svh, 16px);
}

.progress-row,
.feedback-row,
.action-row,
.choice-row,
.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-row {
  justify-content: space-between;
  color: rgba(34, 48, 65, 0.72);
  font-weight: 900;
}

.progress-row span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 65, 0.04);
}

.question-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(8px, 1.1svh, 13px);
  min-height: 0;
  padding: clamp(12px, 1.6svh, 18px);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(232, 248, 255, 0.72)),
    repeating-linear-gradient(45deg, rgba(15, 161, 219, 0.06) 0 8px, transparent 8px 16px);
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 65, 0.05);
  text-align: center;
}

.prompt-type {
  margin: 0;
  width: fit-content;
  max-width: 100%;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #fff4c8);
  border: 2px solid rgba(255, 196, 57, 0.58);
  box-shadow: 0 10px 18px rgba(138, 84, 0, 0.1), inset 0 -3px 0 rgba(255, 196, 57, 0.28);
  color: #5a3a00;
  font-size: clamp(15px, 2svh, 18px);
  font-weight: 800;
  line-height: 1.12;
}

h2 {
  max-width: 100%;
  margin: 0;
  color: #223041;
  font-size: clamp(28px, 4.7svh, 50px);
  line-height: 1.02;
  letter-spacing: 0;
}

.visual-cue {
  width: clamp(104px, 18svh, 156px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.95), transparent 38%),
    linear-gradient(180deg, #ffffff, #eaf8ff);
  border: 3px solid rgba(15, 161, 219, 0.18);
  box-shadow: 0 16px 30px rgba(20, 79, 126, 0.12), inset 0 -10px 0 rgba(15, 161, 219, 0.08);
  font-size: clamp(56px, 10svh, 96px);
}

.feedback-row {
  align-items: stretch;
}

.listen-status,
.transcript-box {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 65, 0.05);
  color: var(--muted);
  font-weight: 800;
}

.listen-status {
  flex: 0 0 auto;
}

.transcript-box {
  flex: 1 1 auto;
  justify-content: space-between;
  min-width: 0;
}

.transcript-box strong {
  min-width: 0;
  color: var(--ink);
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listen-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(34, 48, 65, 0.36);
  box-shadow: 0 0 0 4px rgba(34, 48, 65, 0.06);
}

.listen-status[data-state="listening"] .listen-dot {
  background: var(--danger);
  animation: pulse 0.85s infinite;
}

.listen-status[data-state="correct"] .listen-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(31, 181, 115, 0.16);
}

.listen-status[data-state="wrong"] .listen-dot,
.listen-status[data-state="unclear"] .listen-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.14);
}

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

.action-row,
.choice-row,
.nav-row {
  flex-wrap: wrap;
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
}

.btn {
  min-height: 54px;
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 0 18px;
  color: #fff;
  font-size: clamp(19px, 2.6svh, 23px);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(20, 79, 126, 0.15), 0 14px 24px rgba(20, 79, 126, 0.14);
}

.btn:active,
.answer-chip:active,
.text-btn:active,
.home-link:active {
  transform: translateY(2px);
}

.btn:disabled,
.answer-chip:disabled,
.text-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.btn.primary {
  background: linear-gradient(180deg, #25c4ef, var(--blue));
}

.btn.secondary {
  background: linear-gradient(180deg, #ffc850, var(--orange));
}

.answer-chip {
  min-height: 48px;
  flex: 1 1 160px;
  padding: 8px 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 18px;
  border: 2px solid rgba(15, 161, 219, 0.16);
  background: linear-gradient(180deg, #ffffff, #f0fbff);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(15, 161, 219, 0.08);
}

.answer-chip[data-result="correct"] {
  border-color: rgba(31, 181, 115, 0.6);
  background: linear-gradient(180deg, #ffffff, #e9fff2);
  color: #0b7443;
}

.answer-chip[data-result="wrong"] {
  border-color: rgba(255, 111, 97, 0.62);
  background: linear-gradient(180deg, #ffffff, #fff0ec);
  color: #9a372d;
}

.nav-row {
  justify-content: flex-end;
}

.text-btn {
  min-height: 34px;
  cursor: pointer;
  border-color: rgba(34, 48, 65, 0.1);
  background: rgba(255, 255, 255, 0.74);
  color: rgba(34, 48, 65, 0.72);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 65, 0.04);
}

@media (max-width: 820px) {
  html,
  body {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .voice-app {
    height: 100dvh;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
    padding: 6px;
  }

  .practice-shell {
    height: calc(100dvh - 12px);
  }

  .stage {
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
  }

  .character-panel,
  .question-panel {
    min-height: 0;
    height: auto;
    border-radius: 18px;
  }

  .character-panel {
    grid-template-columns: clamp(64px, 18vw, 86px) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px 10px;
    padding: 8px;
  }

  .top-strip {
    grid-column: 1 / -1;
  }

  .character-panel img {
    width: clamp(64px, 18vw, 86px);
  }

  .speech-bubble {
    width: 100%;
    min-height: 58px;
    padding: 9px 11px;
    border-radius: 16px;
    font-size: clamp(15px, 4vw, 18px);
  }

  .question-panel {
    grid-template-rows: auto minmax(150px, 1fr) auto auto auto;
    align-content: stretch;
    gap: 7px;
    padding: 8px;
  }

  .progress-row span {
    min-height: 28px;
    padding: 0 10px;
    font-size: 14px;
  }

  .question-card {
    min-height: 0;
    gap: 7px;
    padding: 9px;
    border-radius: 16px;
  }

  .prompt-type {
    padding: 6px 13px;
    font-size: 14px;
  }

  h2 {
    font-size: clamp(25px, 7vw, 38px);
  }

  .visual-cue {
    width: clamp(82px, 18svh, 122px);
    border-radius: 18px;
    font-size: clamp(50px, 10svh, 80px);
  }

  .feedback-row {
    flex-direction: row;
    gap: 6px;
  }

  .listen-status,
  .transcript-box {
    min-height: 34px;
    padding: 6px 9px;
    border-radius: 14px;
    font-size: 14px;
  }

  .listen-status {
    width: auto;
  }

  .listen-dot {
    width: 10px;
    height: 10px;
  }

  .transcript-box {
    width: auto;
    align-items: center;
    flex-direction: row;
  }

  .transcript-box strong {
    text-align: right;
    white-space: nowrap;
  }

  .btn,
  .answer-chip {
    flex-basis: 0;
  }

  .action-row {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }

  .btn {
    min-height: 46px;
    border-radius: 15px;
    font-size: 19px;
    box-shadow: 0 7px 0 rgba(20, 79, 126, 0.13);
  }

  .answer-chip {
    min-height: 42px;
    padding: 5px 8px;
    border-radius: 14px;
    font-size: clamp(15px, 3.9vw, 17px);
  }

  .text-btn,
  .home-link,
  .support-badge {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  .nav-row {
    gap: 6px;
  }

  .text-btn {
    flex: 1 1 0;
  }
}
