:root {
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: #fffaf0;
  background:
    radial-gradient(circle at top left, rgba(255, 214, 102, 0.3), transparent 24%),
    radial-gradient(circle at top right, rgba(99, 214, 255, 0.24), transparent 30%),
    linear-gradient(180deg, #0f2040 0%, #13274f 45%, #091122 100%);
  --panel: rgba(9, 17, 34, 0.78);
  --panel-border: rgba(255, 255, 255, 0.12);
  --soft-text: rgba(255, 250, 240, 0.8);
  --accent-yellow: #ffd95f;
  --accent-green: #7cf29a;
  --accent-coral: #ff9274;
  --accent-blue: #7ed8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 1rem 1.6rem;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.4rem;
}

.hero-card {
  position: relative;
  width: min(1200px, 100%);
  min-height: min(92vh, 900px);
  padding: 2rem;
  overflow: hidden;
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 36px;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.32);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.eyebrow,
.status-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.84rem;
  color: var(--soft-text);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
}

.badge--ok {
  color: #092313;
  background: var(--accent-green);
}

.badge--warn {
  color: #2f1d02;
  background: var(--accent-yellow);
}

.badge--bad {
  color: #fff8f6;
  background: var(--accent-coral);
}

.screen {
  display: none;
  min-height: calc(100% - 4rem);
}

.screen--active {
  display: grid;
  align-content: center;
  gap: 1.4rem;
}

.headline {
  max-width: 55rem;
  margin: 0 auto;
  text-align: center;
}

.headline h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 6rem);
  line-height: 0.95;
}

.headline p {
  margin: 1rem auto 0;
  max-width: 34rem;
  font-size: clamp(1.1rem, 2.8vw, 1.6rem);
  line-height: 1.6;
  color: var(--soft-text);
}

.start-card,
.notice,
.feedback-banner,
.status-panel {
  margin-inline: auto;
  width: min(900px, 100%);
}

.start-card {
  display: grid;
  justify-items: center;
  gap: 1.3rem;
  padding: 2rem;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.password-field {
  display: grid;
  gap: 0.6rem;
  width: min(28rem, 100%);
  text-align: left;
}

.password-field span {
  font-size: 1rem;
  font-weight: 700;
  color: var(--soft-text);
  letter-spacing: 0.04em;
}

.password-field input {
  width: 100%;
  min-height: 3.8rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  padding: 0.9rem 1.2rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fffaf0;
  font: inherit;
  font-size: 1.15rem;
}

.password-field input::placeholder {
  color: rgba(255, 250, 240, 0.45);
}

.password-field input:focus {
  outline: 2px solid rgba(255, 217, 95, 0.5);
  outline-offset: 2px;
}

.start-copy,
.notice,
.feedback-banner {
  text-align: center;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  line-height: 1.6;
}

.notice {
  min-height: 2rem;
  color: var(--soft-text);
}

.primary-button {
  min-width: 14rem;
  min-height: 4.2rem;
  color: #162241;
  background: linear-gradient(135deg, #ffe58b, #ffc857);
}

.secondary-button {
  min-width: 11rem;
  min-height: 3.8rem;
  color: #fffaf0;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.lesson-panel {
  display: grid;
  justify-items: center;
  gap: 0.8rem;
}

.prompt-text {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  font-weight: 800;
  color: #ffe58b;
}

.letter-card {
  display: grid;
  place-items: center;
  width: min(420px, 80vw);
  aspect-ratio: 1 / 1;
  border-radius: 36px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.02)),
    radial-gradient(circle at top, rgba(255, 217, 95, 0.38), transparent 62%);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.letter-card--success {
  animation: letter-pop 0.7s ease-out;
}

.letter-text {
  font-size: clamp(10rem, 26vw, 15rem);
  font-weight: 900;
  line-height: 1;
}

.word-text {
  margin: 0;
  font-size: clamp(2rem, 4.4vw, 4rem);
  font-weight: 800;
}

.feedback-banner {
  min-height: 4.8rem;
  padding: 1rem 1.3rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff5c4;
}

.feedback-banner--success {
  background: rgba(124, 242, 154, 0.2);
  color: #f2fff5;
}

.feedback-banner--retry {
  background: rgba(255, 217, 95, 0.15);
  color: #fff7d0;
}

.feedback-banner--error {
  background: rgba(255, 146, 116, 0.16);
  color: #fff1eb;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.mic-debug-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  width: min(900px, 100%);
  margin-inline: auto;
}

.speech-debug-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  width: min(900px, 100%);
  margin-inline: auto;
}

.status-item--wide-2 {
  grid-column: span 2;
}

.status-item {
  padding: 1rem 1.2rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-item strong {
  display: block;
  margin-top: 0.4rem;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  line-height: 1.4;
}

.meter-shell {
  height: 18px;
  margin-top: 0.85rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ed8ff, #7cf29a, #ffd95f);
  transition: width 100ms linear;
}

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.celebration-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.celebration-layer--active {
  opacity: 1;
}

.celebration-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 235, 152, 0.24), transparent 60%);
  animation: glow-pulse 1.2s ease-out forwards;
}

.celebration-burst {
  position: absolute;
  font-size: clamp(2.4rem, 5vw, 4rem);
  animation: burst-float 1.2s ease-out forwards;
}

.burst-one {
  left: 18%;
  top: 24%;
}

.burst-two {
  right: 18%;
  top: 18%;
}

.burst-three {
  left: 24%;
  bottom: 18%;
}

.burst-four {
  right: 22%;
  bottom: 22%;
}

.celebration-message {
  position: absolute;
  inset: auto 50% 18%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  width: min(90%, 34rem);
  padding: 1.3rem 1.5rem;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  text-align: center;
}

.celebration-message p,
.celebration-message strong {
  margin: 0;
}

.celebration-message p {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 900;
}

.celebration-message strong {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

@keyframes letter-pop {
  0% {
    transform: scale(0.86);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes glow-pulse {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes burst-float {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.7) rotate(-8deg);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-48px) scale(1.16) rotate(8deg);
  }
}

@media (max-width: 900px) {
  .hero-card {
    min-height: auto;
    padding: 1.2rem;
    border-radius: 26px;
  }

  .top-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-panel {
    grid-template-columns: 1fr;
  }

  .mic-debug-panel {
    grid-template-columns: 1fr;
  }

  .speech-debug-panel {
    grid-template-columns: 1fr;
  }

  .status-item--wide-2 {
    grid-column: span 1;
  }

  .celebration-message {
    bottom: 12%;
  }
}
