/* ==========================================================================
   Reader — kid-app design
   ========================================================================== */

:root {
  --bg: #fff7e8;
  --bg-2: #ffe9d4;
  --bg-3: #d6e4ff;
  --bg-4: #d3f9d8;
  --ink: #2b2540;
  --ink-soft: #6c6486;
  --card: #ffffff;
  --line: #f0e8f7;

  --primary: #6c5ce7;
  --primary-dark: #4c3dd6;
  --primary-light: #a594ff;

  --sun: #ffd43b;
  --coral: #ff7a8a;
  --coral-dark: #ff5673;
  --tangerine: #ff9f43;
  --mint: #4fcf9a;
  --sky: #4dabf7;
  --grape: #b197fc;

  --good: #2f9e44;
  --warn: #f59f00;
  --bad: #e03131;

  --shadow-sm: 0 4px 12px rgba(43, 37, 64, 0.08);
  --shadow: 0 12px 28px rgba(43, 37, 64, 0.12);
  --shadow-lg: 0 22px 50px rgba(43, 37, 64, 0.16);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 32px;

  /* per-level color (set inline) */
  --level-color: var(--primary);
  --level-color-2: var(--primary-light);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Fredoka', 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 0% -10%, var(--bg-2), transparent 70%),
    radial-gradient(1000px 600px at 110% 0%, var(--bg-3), transparent 70%),
    radial-gradient(900px 700px at 50% 130%, var(--bg-4), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary-dark); }

/* Material Symbols defaults */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-weight: 500;
  font-style: normal;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 48;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
  user-select: none;
}

/* ==========================================================================
   Floating decorative blobs (background candy)
   ========================================================================== */
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
}
body::before {
  background-image:
    radial-gradient(40px 40px at 8% 18%, rgba(255, 212, 59, 0.55), transparent 70%),
    radial-gradient(60px 60px at 92% 22%, rgba(122, 168, 255, 0.45), transparent 70%),
    radial-gradient(28px 28px at 14% 78%, rgba(255, 122, 138, 0.5), transparent 70%),
    radial-gradient(34px 34px at 88% 80%, rgba(79, 207, 154, 0.5), transparent 70%);
  animation: floatA 12s ease-in-out infinite alternate;
}
body::after {
  background-image:
    radial-gradient(20px 20px at 30% 8%, rgba(177, 151, 252, 0.5), transparent 70%),
    radial-gradient(22px 22px at 70% 92%, rgba(255, 159, 67, 0.5), transparent 70%);
  animation: floatB 14s ease-in-out infinite alternate;
}
@keyframes floatA {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(8px, -10px, 0); }
}
@keyframes floatB {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-12px, 6px, 0); }
}

main, header { position: relative; z-index: 1; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(43, 37, 64, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: var(--primary-dark);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-icon {
  font-size: 28px;
  color: var(--primary);
  filter: drop-shadow(0 2px 0 rgba(76, 61, 214, 0.18));
}
.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}
.user-hi {
  color: var(--ink);
  background: var(--sun);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}
.link-btn {
  background: none;
  border: 0;
  color: var(--primary-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.link-btn:hover { background: rgba(108, 92, 231, 0.1); }
.inline { display: inline; margin: 0; padding: 0; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

/* ==========================================================================
   Auth shell — landing, login, register, etc.
   ========================================================================== */
.auth-body {
  display: flex;
  min-height: 100vh;
  position: relative;
}
.auth-shell {
  margin: auto;
  width: 100%;
  max-width: 460px;
  padding: 36px 22px;
  position: relative;
  z-index: 1;
}
.brand-auth {
  display: inline-flex;
  margin: 0 auto 20px;
  font-size: 32px;
  width: 100%;
  justify-content: center;
}
.brand-auth .brand-icon { font-size: 34px; }

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  box-shadow: var(--shadow);
  position: relative;
  border: 1px solid var(--line);
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--coral), var(--sun) 35%, var(--mint) 70%, var(--sky));
  z-index: -1;
  opacity: 0.5;
  filter: blur(14px);
}

.auth-title {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 32px;
  margin: 0 0 6px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.auth-sub {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 17px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.auth-form input {
  padding: 14px 16px;
  border: 2px solid var(--line);
  background: #fafaff;
  border-radius: 14px;
  font-size: 17px;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input:hover { background: #fff; }
.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.18);
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 15px;
  flex-wrap: wrap;
  gap: 10px;
}
.auth-links a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 700;
}
.auth-links a:hover { text-decoration: underline; }
.auth-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-soft);
}
.alert {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  font-weight: 700;
}
.alert.error {
  background: #ffe3e3;
  color: #c92a2a;
  border: 2px solid #ffc9c9;
}

/* Mascot for landing/auth — material icon variant */
.mascot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  margin: 0 auto 14px;
  border-radius: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 64px;
  box-shadow: 0 14px 30px rgba(108, 92, 231, 0.35);
  animation: bobble 3.5s ease-in-out infinite;
}
.mascot.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 48;
}
@keyframes bobble {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-8px) rotate(3deg); }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.big-btn {
  --btn-bg: var(--primary);
  --btn-bg-2: var(--primary-dark);
  --btn-shadow: 0 6px 0 rgba(76, 61, 214, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 24px;
  border-radius: 18px;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 19px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  background: linear-gradient(180deg, var(--btn-bg), var(--btn-bg-2));
  color: #fff;
  box-shadow: var(--btn-shadow);
  transition: transform 0.06s ease, box-shadow 0.18s ease, filter 0.18s ease;
  letter-spacing: 0.01em;
}
.big-btn:hover { filter: brightness(1.05); }
.big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(76, 61, 214, 0.4);
}
.big-btn.primary { /* default */ }
.big-btn.secondary {
  --btn-bg: #fff;
  --btn-bg-2: #fff;
  --btn-shadow: 0 6px 0 rgba(43, 37, 64, 0.12);
  color: var(--primary-dark);
  border: 2px solid var(--line);
}
.big-btn.secondary:hover { background: #fafaff; }
.big-btn.coral {
  --btn-bg: var(--coral);
  --btn-bg-2: var(--coral-dark);
  --btn-shadow: 0 6px 0 rgba(255, 86, 115, 0.4);
}

/* ==========================================================================
   Home / dashboard
   ========================================================================== */
.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
  padding: 22px 24px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: 'auto_awesome';
  font-family: 'Material Symbols Rounded', sans-serif;
  font-variation-settings: 'FILL' 1;
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 64px;
  color: var(--sun);
  opacity: 0.32;
  transform: rotate(8deg);
  pointer-events: none;
}
.hero-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: 42px;
  box-shadow: 0 10px 22px rgba(108, 92, 231, 0.3);
  flex-shrink: 0;
  animation: bobble 3.5s ease-in-out infinite;
}
.hero-emoji.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 48;
}
.hero-text { flex: 1; min-width: 0; }
.hero-title {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 32px;
  margin: 0 0 4px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.hero-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 500;
}

.levels {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.level-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 24px 26px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.level-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 96px;
  background: linear-gradient(135deg, var(--level-color), var(--level-color-2));
  opacity: 0.18;
  pointer-events: none;
}
.level-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  position: relative;
}
.level-emoji {
  font-size: 40px;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--level-color), var(--level-color-2));
  color: #fff;
  box-shadow: 0 8px 18px rgba(43, 37, 64, 0.18);
  flex-shrink: 0;
}
.level-emoji.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 48;
}
.level-title {
  margin: 0;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 28px;
  color: var(--level-color);
  letter-spacing: -0.01em;
}
.level-sub {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 500;
}
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.set-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid var(--line);
  position: relative;
  transition: transform 0.12s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.set-tile::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--level-color);
  opacity: 0.15;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.set-tile:hover {
  border-color: var(--level-color);
  background: #fffefb;
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow: 0 12px 24px rgba(43, 37, 64, 0.1);
}
.set-tile:hover::after {
  opacity: 0.5;
  transform: scale(1.15);
}
.set-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--level-color);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.set-num::before { content: 'Set '; }
.set-name {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.set-count {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ==========================================================================
   Play screen
   ========================================================================== */
.play-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--level-color);
  position: relative;
}
.back-btn {
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 12px;
  background: #fafaff;
  border: 2px solid var(--line);
  font-size: 15px;
  transition: background 0.15s ease, transform 0.06s ease;
}
.back-btn:hover { background: #fff; transform: translateX(-2px); }
.back-btn { display: inline-flex; align-items: center; gap: 6px; }
.back-btn .material-symbols-rounded { font-size: 18px; }
.play-title-icon {
  font-size: 22px;
  color: var(--level-color);
  margin-right: 4px;
}
.play-title { display: inline-flex; align-items: center; gap: 4px; justify-content: center; flex-wrap: wrap; }
.play-title {
  margin: 0;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 18px;
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}
.progress-pill {
  background: linear-gradient(135deg, var(--level-color), var(--level-color-2));
  color: #fff;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 15px;
  box-shadow: 0 4px 0 rgba(43, 37, 64, 0.15);
}

.play-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 24px 30px;
  text-align: center;
  position: relative;
  border: 1px solid var(--line);
  overflow: hidden;
}
.play-card::before {
  content: "";
  position: absolute;
  inset: -2px -2px auto -2px;
  height: 14px;
  background: linear-gradient(90deg, var(--coral), var(--sun), var(--mint), var(--sky), var(--grape));
}
.play-card::after {
  content: "";
  position: absolute;
  bottom: -50px;
  right: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at center, var(--level-color), transparent 60%);
  opacity: 0.12;
  pointer-events: none;
}
.play-card.finish { padding: 50px 24px 36px; }

.word {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: clamp(72px, 15vw, 152px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 22px;
  color: var(--ink);
  word-break: break-word;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(43, 37, 64, 0.06);
  transition: color 0.25s ease, opacity 0.28s ease, transform 0.18s ease;
  min-height: 1em;
}
.word.correct {
  color: var(--good);
  text-shadow: 0 4px 0 rgba(47, 158, 68, 0.18);
}
.word.wrong {
  color: var(--bad);
  text-shadow: 0 4px 0 rgba(224, 49, 49, 0.18);
  animation: shake 0.5s ease;
}
.word.fading {
  opacity: 0;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-10px); }
  40%      { transform: translateX(10px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

/* Mobile debug overlay (?debug=1) */
.dbg-panel {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-height: 40vh;
  background: rgba(15, 23, 41, 0.96);
  color: #a6e3a1;
  border-radius: 12px;
  z-index: 1000;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.dbg-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid #1e293b;
  color: #cdd6f4;
  font-weight: 700;
}
.dbg-head span { flex: 1; }
.dbg-head button {
  background: transparent;
  border: 1px solid #475569;
  color: #cdd6f4;
  padding: 2px 8px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.dbg-head .dbg-close { font-size: 16px; padding: 0 8px; }
#dbg-log {
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}
.status {
  font-size: 17px;
  color: var(--ink-soft);
  margin-bottom: 24px;
  min-height: 24px;
  font-weight: 600;
}

.mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 24px 38px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(76, 61, 214, 0.35);
  transition: transform 0.08s ease, filter 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  animation: bounceMic 2.6s ease-in-out infinite;
}
.mic-btn:hover { filter: brightness(1.05); }
.mic-btn:active {
  transform: translateY(4px);
  box-shadow: 0 6px 0 rgba(76, 61, 214, 0.35);
}
.mic-btn.recording {
  background: linear-gradient(180deg, var(--coral), var(--coral-dark));
  box-shadow: 0 10px 0 rgba(255, 86, 115, 0.4);
  animation: pulseMic 1.1s ease-in-out infinite;
}
.mic-btn.thinking {
  background: linear-gradient(180deg, var(--sun), #f5a623);
  box-shadow: 0 10px 0 rgba(245, 159, 0, 0.4);
  cursor: progress;
  animation: none;
}
.mic-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.mic-icon {
  font-size: 30px;
  display: inline-flex;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  align-items: center;
  justify-content: center;
  color: #fff;
}
.mic-icon.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48;
}
@keyframes bounceMic {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes pulseMic {
  0%, 100% { box-shadow: 0 10px 0 rgba(255, 86, 115, 0.4), 0 0 0 0 rgba(255, 122, 138, 0.5); }
  50%      { box-shadow: 0 10px 0 rgba(255, 86, 115, 0.4), 0 0 0 22px rgba(255, 122, 138, 0); }
}

.feedback {
  margin-top: 26px;
  padding: 18px 22px;
  border-radius: var(--radius);
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 19px;
  background: #f1f3f5;
  color: var(--ink);
  position: relative;
  animation: popIn 0.3s ease-out;
  border: 2px solid transparent;
}
@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.feedback::before {
  font-family: 'Material Symbols Rounded', sans-serif;
  font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48;
  font-size: 26px;
  margin-right: 10px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}
.feedback.perfect    { background: #d3f9d8; color: #2b8a3e; border-color: #b2f2bb; }
.feedback.perfect::before { content: 'star'; }
.feedback.great      { background: #e6fcf5; color: #099268; border-color: #c3fae8; }
.feedback.great::before   { content: 'thumb_up'; }
.feedback.close      { background: #fff3bf; color: #8d6900; border-color: #ffe066; }
.feedback.close::before   { content: 'sentiment_satisfied'; }
.feedback.almost     { background: #ffe8cc; color: #b54708; border-color: #ffd8a8; }
.feedback.almost::before  { content: 'fitness_center'; }
.feedback.try_again  { background: #ffe3e3; color: #c92a2a; border-color: #ffc9c9; }
.feedback.try_again::before { content: 'replay'; }
.feedback-heard {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Fredoka', sans-serif;
  opacity: 0.7;
  font-style: italic;
}

.hidden { display: none !important; }

.play-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.ghost-btn {
  background: #fafaff;
  border: 2px solid var(--line);
  color: var(--ink);
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
.ghost-btn { display: inline-flex; align-items: center; gap: 6px; }
.ghost-btn .material-symbols-rounded { font-size: 18px; color: var(--primary-dark); }
.ghost-btn:hover { background: #fff; border-color: var(--primary-light); }
.ghost-btn:active { transform: translateY(1px); }

.finish-title {
  margin: 0 0 6px;
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 36px;
  color: var(--good);
}
.finish-score {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 84px;
  font-weight: 800;
  margin: 8px 0 6px;
  background: linear-gradient(135deg, var(--coral), var(--sun), var(--mint), var(--sky));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.04em;
}
.finish-msg {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 18px;
  font-weight: 600;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti span {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}

/* Auto-listen state visual on the play card */
.play-card.is-listening {
  box-shadow: var(--shadow-lg), 0 0 0 0 rgba(255, 86, 115, 0.5);
  animation: cardGlow 1.4s ease-in-out infinite;
}
@keyframes cardGlow {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(255, 86, 115, 0.0); }
  50%      { box-shadow: var(--shadow-lg), 0 0 0 10px rgba(255, 86, 115, 0.18); }
}

.mic-meter { display: inline-block; }

/* Live audio visualizer — bars driven by getByteFrequencyData */
.vis {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 56px;
  margin: 0 auto 16px;
  padding: 0 12px;
  max-width: 320px;
  opacity: 0.35;
  transition: opacity 0.2s ease;
}
.vis.is-active { opacity: 1; }
.vis span {
  display: block;
  width: 10px;
  height: 6px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--coral) 0%, var(--sun) 100%);
  transition: height 60ms linear, background 0.2s ease;
}
.vis.is-mute span {
  height: 6px !important;
  background: linear-gradient(180deg, #d6dcf6 0%, #c0c5e0 100%);
}
.vis.vis-out span {
  background: linear-gradient(180deg, var(--primary) 0%, var(--grape) 100%);
}

/* Initial gate */
.start-gate {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  z-index: 5;
}
.start-gate h2 {
  font-family: 'Baloo 2', 'Fredoka', sans-serif;
  font-size: 28px;
  margin: 0;
  color: var(--ink);
}
.start-gate p { margin: 0; color: var(--ink-soft); font-weight: 600; }

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 600px) {
  .container { padding: 18px 16px 60px; }
  .hero { padding: 18px 18px; gap: 14px; }
  .hero-emoji { font-size: 48px; }
  .hero-title { font-size: 26px; }
  .level-card { padding: 20px 18px; }
  .level-emoji { width: 60px; height: 60px; font-size: 38px; border-radius: 18px; }
  .level-title { font-size: 24px; }
  .set-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
  .set-tile { padding: 14px; }
  .set-name { font-size: 18px; }
  .play-bar { grid-template-columns: auto 1fr auto; padding: 12px 14px; }
  .play-title { font-size: 15px; }
  .play-card { padding: 30px 18px 24px; }
  .mic-btn { padding: 20px 30px; font-size: 21px; }
  .topbar { padding: 12px 16px; }
  .user-hi { display: none; }
  .brand { font-size: 22px; }
  .brand::before { font-size: 22px; }
}

@media (max-width: 380px) {
  .play-title { font-size: 14px; }
  .back-btn { padding: 6px 10px; font-size: 14px; }
  .progress-pill { padding: 6px 10px; font-size: 13px; }
}
