* { box-sizing: border-box; }

:root {
  --bg: #fff7e8;
  --card: #ffffff;
  --ink: #263238;
  --muted: #5c666d;
  --accent: #6c63ff;
  --accent-dark: #5149d9;
  --good: #268753;
  --bad: #c94552;
  --shadow: 0 8px 24px rgba(38, 50, 56, .10);
  --radius: 24px;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", "Nunito", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100%;
  text-align: center;
  animation: fade-in .22s ease-out;
}

.hidden { display: none !important; }

.brand-mark {
  font-size: clamp(3rem, 12vw, 5rem);
  margin-bottom: 4px;
}

h1, h2, p { margin-top: 0; }

h1 {
  font-size: clamp(2.1rem, 8vw, 3.5rem);
  margin-bottom: 8px;
  letter-spacing: -.04em;
}

h2 {
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  margin-bottom: 10px;
}

.subtitle {
  color: var(--muted);
  font-size: clamp(1rem, 4vw, 1.25rem);
  line-height: 1.45;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 30px 0 24px;
}

.mode-card {
  appearance: none;
  border: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 24px 22px;
  min-height: 155px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.mode-card:active { transform: scale(.985); }
.mode-card:focus-visible,
button:focus-visible {
  outline: 4px solid rgba(108, 99, 255, .28);
  outline-offset: 3px;
}

.mode-icon {
  font-size: 2.3rem;
  margin-bottom: 2px;
}

.mode-card strong { font-size: 1.35rem; }
.mode-card span:last-child { color: var(--muted); line-height: 1.35; }

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  padding: 14px 14px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 700;
}

.quiz-header {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.small-button {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1.35rem;
}

.progress-label {
  font-weight: 800;
  font-size: .95rem;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(38, 50, 56, .10);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 5%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .25s ease;
}

.prompt-area {
  margin: 8px auto 24px;
}

.prompt-label {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .8rem;
  margin-bottom: 10px;
}

.hear-button {
  width: min(100%, 390px);
  min-height: 76px;
  border: 0;
  border-radius: 22px;
  background: var(--accent);
  color: white;
  box-shadow: 0 7px 0 var(--accent-dark), var(--shadow);
  font-size: clamp(1.25rem, 5vw, 1.55rem);
  font-weight: 900;
  cursor: pointer;
  padding: 14px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .1s ease, box-shadow .1s ease;
}

.hear-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 var(--accent-dark), var(--shadow);
}

.audio-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: .95rem;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0 18px;
}

.choice {
  appearance: none;
  border: 3px solid rgba(38, 50, 56, .08);
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 24px;
  min-height: 190px;
  padding: 18px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.choice:active { transform: scale(.975); }

.letter-choice {
  font-size: clamp(5rem, 24vw, 9rem);
  font-weight: 900;
  line-height: 1;
}

.sequence-choice {
  flex-direction: column;
  gap: 6px;
  font-size: clamp(3.2rem, 14vw, 5rem);
  line-height: 1.05;
}

.sequence-word {
  font-size: clamp(.95rem, 4vw, 1.15rem);
  font-weight: 800;
  color: var(--muted);
}

.feedback {
  min-height: 42px;
  font-size: 1.2rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback.good { color: var(--good); }
.feedback.try-again { color: var(--bad); }

.shake {
  animation: gentle-shake .32s ease-in-out;
  border-color: var(--bad) !important;
}

.correct {
  border-color: var(--good) !important;
  background: #eef9f2;
}

.done-icon { font-size: 5rem; margin-bottom: 8px; }

.done-actions {
  display: grid;
  gap: 14px;
  max-width: 390px;
  margin: 28px auto 0;
}

.primary-button, .secondary-button {
  min-height: 62px;
  border-radius: 20px;
  border: 0;
  font-weight: 900;
  font-size: 1.15rem;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 0 var(--accent-dark);
}

.secondary-button {
  background: var(--card);
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.35);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  position: relative;
  width: min(100%, 520px);
  background: var(--card);
  border-radius: 28px;
  padding: 30px 24px;
  box-shadow: 0 18px 50px rgba(0,0,0,.2);
  text-align: left;
}

.modal-card h2 { padding-right: 28px; }
.modal-card p { line-height: 1.55; color: #4d585e; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #f3f3f3;
  font-size: 1.7rem;
  cursor: pointer;
}

.tiny-note { font-size: .85rem; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gentle-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@media (min-width: 620px) {
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .mode-card { min-height: 190px; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .app-shell { align-items: flex-start; }
  .quiz-header { margin-bottom: 12px; }
  .prompt-area { margin: 0 auto 10px; }
  .hear-button { min-height: 58px; }
  .choice { min-height: 135px; }
}
