:root {
  color-scheme: dark;
  --navy: #160b38;
  --purple: #6a36b5;
  --cyan: #75e6ff;
  --yellow: #ffd166;
  --orange: #984700;
  --pink: #842b61;
  --green: #08705e;
  --space-blue: #174c87;
  --space-deep: #26124f;
  --space-teal: #087379;
  --white: #fffdf8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--navy);
  color: var(--white);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

.space {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, rgba(69, 127, 220, 0.46), transparent 34%),
    radial-gradient(circle at 82% 74%, rgba(33, 204, 222, 0.24), transparent 36%),
    linear-gradient(135deg, #15082f 0%, #2d1559 48%, #083f58 100%);
}

.stars,
.stars::before,
.stars::after {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    radial-gradient(circle, rgba(255,255,255,.92) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(161,231,255,.75) 0 1.5px, transparent 2px),
    radial-gradient(circle, rgba(255,235,142,.72) 0 1px, transparent 1.7px);
  background-position: 10px 20px, 70px 95px, 125px 46px;
  background-size: 141px 137px, 193px 181px, 227px 211px;
}

.stars::before {
  transform: rotate(11deg) scale(1.08);
  opacity: .55;
}

.stars::after {
  transform: rotate(-8deg) scale(1.18);
  opacity: .32;
}

.planet {
  position: absolute;
  border-radius: 50%;
  filter: blur(.2px);
}

.planet-one {
  width: min(45vw, 520px);
  aspect-ratio: 1;
  right: -14vw;
  top: -20vw;
  background: linear-gradient(145deg, rgba(48,167,211,.34), rgba(20,105,174,.12));
}

.planet-two {
  width: min(38vw, 430px);
  aspect-ratio: 1;
  left: -22vw;
  bottom: -20vw;
  border: 4px solid rgba(192,151,255,.12);
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  min-height: 100dvh;
}

.screen {
  display: none;
  min-height: 100svh;
  min-height: 100dvh;
  padding: calc(18px + var(--safe-top)) 24px calc(18px + var(--safe-bottom));
}

.screen.active {
  display: flex;
}

.home-content,
.results-content {
  width: min(100%, 880px);
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.studio-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255,255,255,.92);
  font-size: clamp(13px, 2vw, 17px);
  font-weight: 950;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.studio-mark {
  display: grid;
  width: clamp(48px, 8vh, 68px);
  height: clamp(48px, 8vh, 68px);
  place-items: center;
  font-size: clamp(40px, 6.5vh, 58px);
  line-height: 1;
  filter: drop-shadow(0 10px 14px rgba(26, 214, 241, .34));
  animation: hover 3.2s ease-in-out infinite;
}

.studio-name {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.12;
}

.studio-name small {
  margin-top: 4px;
  color: var(--cyan);
  font-size: .68em;
  letter-spacing: .34em;
}

@keyframes hover {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.eyebrow {
  margin: 6px 0 2px;
  color: #b9edff;
  font-size: clamp(12px, 2vw, 15px);
  font-weight: 900;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  color: var(--white);
  font-size: clamp(48px, 8vw, 82px);
  font-weight: 1000;
  letter-spacing: -.045em;
  line-height: .92;
  text-transform: uppercase;
  text-shadow: 0 7px 0 #421b78, 0 13px 28px rgba(0,0,0,.35);
}

h1 span {
  display: block;
}

h1 span:first-child {
  margin-bottom: 6px;
  color: #c8f4ff;
  font-size: .49em;
  letter-spacing: .12em;
  line-height: 1;
  text-shadow: 0 4px 0 #174c87, 0 8px 18px rgba(0,0,0,.3);
}

.tagline {
  margin: 12px 0 clamp(22px, 4vh, 34px);
  color: var(--cyan);
  font-size: clamp(17px, 3vw, 25px);
  font-weight: 800;
}

.tagline span {
  color: var(--yellow);
}

.pill-button,
.circle-button,
.speaker-button,
.word-card,
.video-play-button {
  border: 0;
  color: white;
  cursor: pointer;
  font-weight: 900;
  text-transform: uppercase;
}

.pill-button {
  min-height: 48px;
  padding: 12px 20px;
  border: 2px solid rgba(255,255,255,.46);
  border-radius: 999px;
  background: var(--button-color);
  background: linear-gradient(145deg, var(--button-color), color-mix(in srgb, var(--button-color) 62%, #14143b));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--button-color) 35%, transparent);
  letter-spacing: .025em;
  transition: transform .12s ease, filter .12s ease;
}

.pill-button:hover { filter: brightness(1.08); }
.pill-button:active { transform: scale(.95); }
.word-card { text-transform: none; }
.word-card.single-i,
.progress-word.single-i { font-family: Georgia, "Times New Roman", serif; }
.pill-button.large { min-height: 60px; padding-inline: 32px; font-size: 20px; }
.pill-button.primary { --button-color: var(--orange); min-width: min(280px, 82vw); }
.pill-button.purple { --button-color: #7936c4; }
.pill-button.teal { --button-color: #006b75; }
.pill-button.blue { --button-color: #075985; }
.pill-button.red { --button-color: #a3334e; }
.pill-button.test { --button-color: #08705e; min-width: min(280px, 82vw); }

.home-actions,
.result-actions,
.mode-actions,
.test-grade-buttons {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.mode-actions { margin-top: 4px; }
.test-controls { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.word-choices.testing {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}
.test-word-card {
  width: min(440px, 88vw);
  display: grid;
  place-items: center;
  cursor: default;
  text-transform: none;
}

.privacy-note {
  margin: 7px 0 0;
  color: rgba(255,255,255,.58);
  font-size: 13px;
  font-weight: 650;
}

.studio-signoff {
  margin-top: clamp(16px, 3.2vh, 30px);
  color: rgba(255,255,255,.78);
  font-size: clamp(12px, 1.8vw, 14px);
  font-weight: 750;
  line-height: 1.35;
}

.studio-signoff p { margin: 0; }
.studio-signoff p:first-child { color: #bfeeff; }
.studio-signoff p:last-child { margin-top: 2px; color: rgba(255,255,255,.52); font-size: .86em; }

.hidden { display: none !important; }
.phone-only { display: none; }

#play-screen {
  flex-direction: column;
  gap: 8px;
}

.game-header {
  width: min(100%, 1080px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.circle-button {
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,.48);
  border-radius: 50%;
  background: var(--space-deep);
  box-shadow: 0 8px 18px rgba(0,52,83,.42);
  font-size: 29px;
}

.round-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: rgba(255,255,255,.82);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.progress-track {
  height: 11px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.13);
  border-radius: 999px;
  background: rgba(0,0,0,.28);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd43c, #ffef8e);
  transition: width .32s ease;
}

.star-counter {
  min-width: 76px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.25);
  color: var(--yellow);
  font-size: 23px;
  font-weight: 950;
  text-align: center;
}

.play-content {
  width: min(100%, 1080px);
  flex: 1;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(15px, 3vh, 28px);
}

.listen-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.listen-area p {
  margin: 0;
  font-size: clamp(18px, 3vw, 25px);
  font-weight: 850;
}

.speaker-button {
  width: clamp(88px, 13vw, 116px);
  aspect-ratio: 1;
  border: 4px solid rgba(255,255,255,.6);
  border-radius: 50%;
  background: linear-gradient(145deg, #347fc2, #3b1a75);
  box-shadow: 0 10px 28px rgba(44,176,219,.42);
  font-size: clamp(38px, 6vw, 53px);
  transition: transform .12s ease;
}

.speaker-button:active { transform: scale(.92); }

.word-choices {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2.5vw, 24px);
}

.word-card {
  position: relative;
  min-width: 0;
  min-height: clamp(145px, 23vh, 196px);
  padding: 16px;
  overflow: hidden;
  border: 4px solid rgba(255,255,255,.68);
  border-radius: clamp(22px, 4vw, 35px);
  background: var(--card);
  background: linear-gradient(145deg, var(--card), color-mix(in srgb, var(--card) 62%, #282050));
  box-shadow: 0 15px 27px color-mix(in srgb, var(--card) 38%, transparent);
  font-size: clamp(34px, 6vw, 59px);
  line-height: 1;
  text-shadow: 0 3px 4px rgba(0,0,0,.28);
  transition: transform .15s ease, filter .15s ease;
}

.word-card:nth-child(1) { --card: #1d619d; }
.word-card:nth-child(2) { --card: #5a3b99; }
.word-card:nth-child(3) { --card: #08737a; }
.word-choices.testing .word-card { --card: #45227d; }
.word-card:hover { filter: brightness(1.08); transform: translateY(-3px); }
.word-card:active { transform: scale(.96); }
.word-card.correct { animation: correct .55s ease both; }
.word-card.wrong { animation: wrong .42s ease; }
.word-card:disabled { cursor: default; opacity: 1; }

@keyframes correct {
  40% { transform: scale(1.08) rotate(1deg); filter: brightness(1.18); }
  100% { transform: scale(1.04); }
}

@keyframes wrong {
  20% { transform: translateX(-7px) rotate(-2deg); }
  45% { transform: translateX(7px) rotate(2deg); }
  70% { transform: translateX(-4px); }
}

.feedback {
  min-height: 38px;
  margin: 0;
  color: white;
  font-size: clamp(19px, 3vw, 27px);
  font-weight: 950;
  text-align: center;
}

.feedback.success { color: var(--yellow); }

.results-content { gap: 18px; }
.result-icons { font-size: clamp(52px, 10vw, 82px); }
.results-content h2,
.progress-header h2 {
  margin: 0;
  color: var(--yellow);
  font-size: clamp(37px, 7vw, 61px);
  font-weight: 1000;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 6px 0 #45227d;
}
.results-content p { margin: 0; font-size: clamp(23px, 4vw, 32px); font-weight: 800; }

#progress-screen {
  flex-direction: column;
  overflow-y: auto;
}

.progress-header {
  width: min(100%, 1120px);
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.progress-header h2 { color: white; font-size: clamp(26px, 5vw, 38px); text-shadow: none; }
.progress-header p { margin: 5px 0 0; color: rgba(255,255,255,.66); font-size: 14px; font-weight: 700; }

.progress-grid {
  width: min(100%, 1120px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

.progress-tile {
  padding: 15px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(255,255,255,.095);
  text-align: center;
  backdrop-filter: blur(7px);
}

.progress-word { font-size: 25px; font-weight: 950; }
.mastery-dots { margin: 7px 0; color: rgba(255,255,255,.2); letter-spacing: 4px; }
.mastery-dots .earned { color: var(--yellow); }
.progress-detail { color: rgba(255,255,255,.62); font-size: 12px; font-weight: 650; }

dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: calc(18px + var(--safe-top)) 20px calc(18px + var(--safe-bottom));
  border: 0;
  background: rgba(4, 5, 22, .94);
  color: white;
}

dialog::backdrop { background: rgba(4,5,22,.94); }

.tutorial-card {
  width: min(100%, 960px);
  min-height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.tutorial-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.tutorial-card h2 {
  margin: 0;
  font-size: clamp(23px, 4vw, 32px);
  text-transform: uppercase;
}

.video-shell {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 2px solid rgba(255,255,255,.28);
  border-radius: 24px;
  background: black;
  box-shadow: 0 16px 38px rgba(23,207,234,.24);
}

.video-shell video { width: 100%; height: 100%; display: block; object-fit: contain; }
.video-play-button {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  min-width: min(270px, 74vw);
  min-height: 58px;
  padding: 13px 22px;
  border: 3px solid white;
  border-radius: 999px;
  background: rgba(105,42,181,.93);
  box-shadow: 0 9px 25px rgba(0,0,0,.46);
  font-size: clamp(15px, 3vw, 20px);
}

.tutorial-card > p { margin: 0; color: rgba(255,255,255,.62); text-align: center; font-size: 13px; }
.tutorial-actions { display: flex; justify-content: center; }

#celebration-layer { position: fixed; z-index: 30; inset: 0; pointer-events: none; overflow: hidden; }
.spark {
  position: absolute;
  top: 48%;
  left: 50%;
  color: var(--spark-color);
  font-size: var(--spark-size);
  animation: sparkle .9s ease-out forwards;
}

@keyframes sparkle {
  from { transform: translate(-50%, -50%) rotate(0) scale(.4); opacity: 1; }
  to { transform: translate(var(--spark-x), var(--spark-y)) rotate(240deg) scale(1.2); opacity: 0; }
}

@media (max-width: 720px), (orientation: portrait) and (max-height: 900px) {
  .screen { padding-inline: 14px; }
  .phone-only { display: initial; }
  .studio-lockup { gap: 8px; }
  .studio-mark { width: 50px; height: 50px; font-size: 42px; }
  .rocket { font-size: clamp(58px, 10vh, 84px); }
  .tagline { margin-bottom: 20px; }
  .studio-signoff { margin-top: 16px; }
  .game-header { gap: 10px; }
  .circle-button { width: 46px; height: 46px; font-size: 25px; }
  .star-counter { min-width: 64px; padding-inline: 10px; font-size: 20px; }
  .play-content { gap: 13px; }
  .speaker-button { width: clamp(78px, 12vh, 100px); }
  .word-choices { grid-template-columns: 1fr; gap: 10px; }
  .word-card { min-height: clamp(72px, 12vh, 102px); border-radius: 22px; font-size: clamp(34px, 10vw, 48px); }
  .progress-header { grid-template-columns: 1fr 1fr; }
  .progress-header > div { order: -1; grid-column: 1 / -1; }
  .progress-header .red { justify-self: end; }
  .result-actions { flex-direction: column; }
}

@media (max-height: 700px) {
  .screen { padding-top: calc(10px + var(--safe-top)); padding-bottom: calc(10px + var(--safe-bottom)); }
  .studio-mark { width: 44px; height: 44px; font-size: 38px; }
  .rocket { font-size: 54px; }
  h1 { font-size: 43px; }
  .eyebrow { margin-top: 2px; }
  .tagline { margin: 6px 0 12px; font-size: 17px; }
  .mode-actions, .home-actions { margin-top: 8px; }
  .pill-button.large { min-height: 52px; padding-block: 10px; font-size: 17px; }
  .studio-signoff { margin-top: 8px; }
  .privacy-note { margin-top: 5px; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .rocket { font-size: 72px; }
  h1 { font-size: 48px; }
  .tagline { margin: 6px 0 14px; }
  .studio-signoff { margin-top: 8px; }
  .play-content { display: grid; grid-template-columns: 150px 1fr; align-content: center; }
  .listen-area { grid-row: 1 / 3; }
  .word-choices { grid-column: 2; }
  .word-card { min-height: 130px; font-size: clamp(32px, 5vw, 50px); }
  .feedback { grid-column: 2; }
  .tutorial-card { max-width: 760px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
