: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;
  --panel: rgba(255, 255, 255, 0.9);
  --shadow: 0 20px 46px rgba(25, 76, 120, 0.2);
}

* {
  box-sizing: border-box;
}

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

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 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%);
}

button,
a {
  font: inherit;
}

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

.builder-card {
  width: min(1060px, 100%);
  height: min(100%, calc(100dvh - 12px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: clamp(7px, 1.1svh, 11px);
  padding: clamp(10px, 1.7svh, 16px);
  overflow: hidden;
  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);
}

.top-row,
.score-pill,
.feedback-row,
.action-row,
.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-row {
  justify-content: space-between;
}

.home-link,
.score-pill,
.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);
}

.score-pill {
  gap: 12px;
}

.hero-row {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  gap: clamp(9px, 1.4vw, 14px);
}

.coach,
.sentence-stage {
  min-height: 0;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  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);
  box-shadow: inset 0 0 0 1px rgba(34, 48, 65, 0.05);
}

.coach {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 8px;
  padding: 12px;
}

.coach img {
  width: min(180px, 80%);
  align-self: center;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(20, 79, 126, 0.2));
}

.coach-bubble {
  width: 100%;
  min-height: 72px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 18px;
  border: 3px solid rgba(255, 196, 57, 0.78);
  background: linear-gradient(180deg, #ffffff, #fff9de);
  color: #5a3a00;
  font-size: clamp(16px, 2.2svh, 21px);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.sentence-stage {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  justify-items: center;
  align-items: center;
  gap: clamp(8px, 1.2svh, 12px);
  padding: clamp(12px, 1.8svh, 18px);
  text-align: center;
}

.prompt-type,
.target-hint {
  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);
  color: #5a3a00;
  font-size: clamp(15px, 2svh, 18px);
  font-weight: 800;
  line-height: 1.12;
}

.result-badge {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 999px;
  border: 2px solid rgba(31, 181, 115, 0.48);
  background: linear-gradient(180deg, #ffffff, #e9fff2);
  color: #0b7443;
  font-size: clamp(18px, 2.5svh, 24px);
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(31, 181, 115, 0.12), inset 0 -3px 0 rgba(31, 181, 115, 0.16);
}

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

.result-badge.hidden {
  display: none;
}

.target-hint {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(15, 161, 219, 0.18);
  color: var(--muted);
}

.picture-cue {
  width: clamp(78px, 15svh, 128px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: 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(48px, 9svh, 84px);
}

.word-bank {
  width: 100%;
  align-self: stretch;
  display: flex;
  align-content: center;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(8px, 1.2svh, 12px);
}

.word-tile {
  min-height: 48px;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  border: 2px solid rgba(15, 161, 219, 0.18);
  background: linear-gradient(180deg, #ffffff, #f0fbff);
  color: var(--ink);
  font-size: clamp(20px, 3svh, 28px);
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(20, 79, 126, 0.08);
}

.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);
  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);
}

.listen-status[data-state="wrong"] .listen-dot,
.listen-status[data-state="unclear"] .listen-dot {
  background: var(--danger);
}

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

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

.btn,
.text-btn {
  border: 0;
  border-radius: 18px;
  font-weight: 900;
  cursor: pointer;
}

.btn {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  font-size: clamp(18px, 2.5svh, 22px);
  box-shadow: 0 10px 0 rgba(20, 79, 126, 0.15), 0 14px 24px rgba(20, 79, 126, 0.14);
}

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

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

.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);
}

@media (max-width: 820px) {
  .sentence-app {
    padding: 6px;
  }

  .builder-card {
    height: calc(100dvh - 12px);
    border-radius: 18px;
    gap: 6px;
    padding: 8px;
  }

  .hero-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px;
  }

  .coach {
    grid-template-columns: clamp(58px, 16vw, 78px) minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
    padding: 8px;
  }

  .coach img {
    width: clamp(58px, 16vw, 78px);
  }

  .coach-bubble {
    min-height: 54px;
    font-size: clamp(14px, 3.8vw, 17px);
  }

  .sentence-stage {
    gap: 6px;
    padding: 8px;
  }

  .picture-cue {
    width: clamp(66px, 14svh, 96px);
    font-size: clamp(40px, 8svh, 64px);
  }

  .word-tile {
    min-height: 38px;
    padding: 6px 11px;
    border-radius: 14px;
    font-size: clamp(17px, 4.6vw, 22px);
  }

  .feedback-row {
    gap: 6px;
  }

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

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

  .action-row {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 6px;
  }

  .btn {
    min-height: 44px;
    border-radius: 15px;
    font-size: 17px;
  }

  .result-badge {
    min-height: 34px;
    padding: 0 13px;
    font-size: clamp(16px, 4.2vw, 20px);
  }

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

  .nav-row {
    gap: 6px;
  }

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