@font-face {
  font-family: "Bricolage Grotesque";
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/bricolagegrotesque-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/bricolagegrotesque-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/figtree-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/figtree-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --blue: #1a5feb;
  --blue-edge: #0f3fae;
  /* Player-local light wash (no site token fits); coral/leaf keep their
     score semantics so red/green/amber stay recognizable. */
  --tint: #dce7f8;
  --sun: #ffe066;
  --sun-edge: #0e1b3d;
  --sun-tint: #fff6bf;
  --coral: #ff6b5b;
  --coral-dark: #d94a3d;
  --coral-tint: #ffe9e6;
  --leaf: #22b07d;
  --leaf-dark: #178a61;
  --leaf-tint: #e0f5ec;
  --ink: #0e1b3d;
  --ink-soft: #2a3757;
  --line: #d3e2f5;
  --bg: #eef6ff;
  --card: #ffffff;
  --radius: 20px;
  --font-head: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(var(--line) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 30rem;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px var(--line);
}

@media (min-width: 34rem) {
  #app {
    min-height: calc(100vh - 3rem);
    min-height: calc(100dvh - 3rem);
    margin: 1.5rem auto;
    border-radius: 28px;
    overflow: hidden;
  }
}

.screen {
  padding: 1.25rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  animation: rise 0.25s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* progress header */
.topbar { display: flex; align-items: center; gap: 0.75rem; }
.brand {
  font-family: var(--font-head);
  width: 2.5rem; height: 2.5rem; flex: none;
  border-radius: 50%;
  background: var(--blue);
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 1.25rem;
  box-shadow: 0 3px 0 var(--blue-edge);
}
.segments { display: flex; gap: 0.4rem; flex: 1; }
.segments i {
  height: 0.8rem; flex: 1; border-radius: 99px; background: var(--line);
  overflow: hidden; position: relative;
}
.segments i.done { background: var(--sun); }
.segments i.now::after {
  content: ""; position: absolute; inset: 0;
  background: var(--blue); border-radius: 99px;
  transform-origin: left;
  animation: fill 0.4s ease-out;
}
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.step { font-weight: 800; color: var(--ink-soft); font-size: 0.9rem; white-space: nowrap; }

/* prompts */
h1 { font-family: var(--font-head); font-size: 1.4rem; margin: 0.25rem 0 0; }
.sub { color: var(--ink-soft); margin: 0; font-size: 1.05rem; }
.phrase-card {
  font-family: var(--font-head);
  background: var(--tint);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 1.5rem; font-weight: 800; text-align: center;
}
/* Vocal-only scripts: native characters lead, romanization follows. */
.phrase-card .native, .pick .native { display: block; }
.phrase-card .roman { display: block; font-size: 0.62em; font-weight: 600; opacity: 0.72; margin-top: 0.2em; }
.pick .roman { display: block; font-size: 0.78em; font-weight: 600; opacity: 0.72; }

/* chunky buttons */
.btn {
  font-family: var(--font-head);
  border: none; cursor: pointer;
  border-radius: 18px;
  padding: 1rem 1.25rem;
  font-size: 1.1rem; font-weight: 800;
  min-height: 56px;
  background: var(--blue); color: #fff;
  box-shadow: 0 4px 0 var(--blue-edge);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--blue-edge); }
.btn.sun { background: var(--sun); box-shadow: 0 4px 0 var(--sun-edge); color: var(--ink); }
.btn.sun:active { box-shadow: 0 0 0 var(--sun-edge); }
.btn.ghost {
  background: var(--card); color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line);
}
.btn.ghost:active { transform: none; box-shadow: inset 0 0 0 2px var(--ink); }
.btn:disabled { filter: grayscale(0.7); opacity: 0.6; cursor: default; }
.spacer { flex: 1; }

/* option grids */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.pick {
  font-family: inherit;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.6rem;
  cursor: pointer;
  min-height: 56px;
  transition: border-color 0.12s, background 0.12s, transform 0.06s;
}
.pick:active { transform: scale(0.97); }
.pick img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 14px; display: block;
}
.pick span { display: block; font-size: 1.05rem; font-weight: 700; padding: 0.6rem 0.25rem; }
.pick.correct { border-color: var(--leaf); background: var(--leaf-tint); }
.pick.wrong { border-color: var(--coral); background: var(--coral-tint); animation: shake 0.35s; }
@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.hero-img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--line);
}

/* audio button */
.speaker {
  width: 5.5rem; height: 5.5rem; margin: 0.5rem auto;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--blue); color: #fff; font-size: 2rem;
  box-shadow: 0 5px 0 var(--blue-edge);
  transition: transform 0.06s, box-shadow 0.06s;
}
.speaker:active { transform: translateY(5px); box-shadow: none; }
.speaker.playing { animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 0 var(--blue-edge), 0 0 0 0 rgba(26,95,235,0.45); }
  50% { box-shadow: 0 5px 0 var(--blue-edge), 0 0 0 14px rgba(26,95,235,0); }
}

/* mic */
.mic-wrap { display: grid; place-items: center; padding: 1rem 0; }
.mic {
  width: 6.5rem; height: 6.5rem; border-radius: 50%; border: none; cursor: pointer;
  background: var(--coral); color: #fff; font-size: 2.4rem;
  box-shadow: 0 6px 0 var(--coral-dark);
  transition: transform 0.06s, box-shadow 0.06s;
}
.mic:active { transform: translateY(6px); box-shadow: none; }
.mic.recording { animation: pulse-red 1.1s infinite; }
.mic.recording.clock {
  animation: none;
  position: relative;
  background: conic-gradient(var(--coral-dark) calc(var(--sweep, 0) * 1%), var(--coral) 0);
}
.clock-hand {
  position: absolute; left: 50%; top: 50%;
  width: 5px; height: 2.9rem; border-radius: 3px;
  background: #fff; opacity: 0.9;
  transform-origin: 50% 0;
  transform: translateX(-50%) rotate(0deg);
  pointer-events: none;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 6px 0 var(--coral-dark), 0 0 0 0 rgba(255,107,91,0.5); }
  50% { box-shadow: 0 6px 0 var(--coral-dark), 0 0 0 18px rgba(255,107,91,0); }
}
.bars { display: flex; gap: 5px; justify-content: center; height: 2rem; align-items: flex-end; }
.bars i { width: 7px; border-radius: 4px; background: var(--coral); animation: bar 0.7s infinite ease-in-out; }
.bars i:nth-child(2) { animation-delay: 0.12s; }
.bars i:nth-child(3) { animation-delay: 0.24s; }
.bars i:nth-child(4) { animation-delay: 0.36s; }
.bars i:nth-child(5) { animation-delay: 0.48s; }
@keyframes bar { 0%, 100% { height: 0.6rem; } 50% { height: 1.8rem; } }
.dots { display: flex; gap: 0.5rem; justify-content: center; }
.dots i { width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--line); }
.dots i.used-green { background: var(--leaf); }
.dots i.used-yellow { background: var(--sun); }
.dots i.used-red { background: var(--coral); }

/* verdict banner */
.banner {
  border-radius: var(--radius); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 0.9rem;
  animation: rise 0.2s ease-out;
}
.banner .face {
  width: 3rem; height: 3rem; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 900; color: #fff;
}
.banner.green { background: var(--leaf-tint); }
.banner.green .face { background: var(--leaf); }
.banner.yellow { background: var(--sun-tint); }
.banner.yellow .face { background: var(--sun); }
.banner.red { background: var(--coral-tint); }
.banner.red .face { background: var(--coral); }
.banner b { font-family: var(--font-head); font-size: 1.2rem; display: block; }
.banner small { color: var(--ink-soft); font-size: 0.95rem; }

/* text input */
.write-row { display: flex; gap: 0.6rem; }
.write-row input {
  flex: 1; font-family: inherit; font-size: 1.2rem; font-weight: 700;
  border: 2px solid var(--line); border-radius: 18px;
  padding: 0 1rem; min-height: 56px; min-width: 0; color: var(--ink);
}
.write-row input:focus { outline: none; border-color: var(--blue); }

/* celebration */
.celebrate { text-align: center; padding-top: 2rem; display: flex; flex-direction: column; align-items: center; flex: 1; }.celebrate .btn { width: 100%; }
.celebrate .stars { font-size: 3.5rem; letter-spacing: 0.2rem; }
.celebrate h1 { font-size: 1.8rem; }
.confetti { position: fixed; top: -12px; width: 10px; height: 16px; z-index: 50; animation: fall 2.6s ease-in forwards; }
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.7; }
}

#offline-bar {
  position: sticky; top: 0; z-index: 60;
  background: var(--sun-tint); color: var(--ink-soft);
  border-bottom: 2px solid var(--sun);
  text-align: center; font-weight: 700; font-size: 0.95rem;
  padding: 0.5rem 1rem;
}

.loading { text-align: center; padding-top: 4rem; color: var(--ink-soft); }
.loading .spin {
  width: 3rem; height: 3rem; margin: 0 auto 1rem;
  border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { background: var(--coral-tint); border-radius: var(--radius); padding: 1rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
