:root {
  --bg: #0f172a;
  --card: #111827;
  --line: #263247;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22c55e;
  --accent2: #60a5fa;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", "Poppins", Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top, #1e293b, #0b1223 50%, #050816);
  color: var(--text);
  min-height: 100vh;
}

.space-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  display: block;
  background: radial-gradient(circle at center, #0b1630 0%, #050816 60%, #02030b 100%);
}

.space-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 0%, transparent 45%, #00000055 100%),
    radial-gradient(circle at 50% 50%, #60a5fa11 0%, transparent 40%);
}

.container {
  max-width: 1040px;
  margin: 24px auto;
  padding: 0 16px 32px;
}
header h1 { margin: 0; font-size: 2.7rem; letter-spacing: 0.3px; }
.subtitle { color: var(--muted); margin-top: 6px; font-size: 1.05rem; }
.center-header {
  text-align: center;
  margin-top: 10px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(6px);
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-icon { font-size: 1.1rem; }
.flag-btn { min-width: 52px; }

.card {
  background: rgba(17, 24, 39, 0.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
  backdrop-filter: blur(3px);
}

.profile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(2px);
  z-index: 70;
}

#profileCard {
  position: fixed;
  top: 8vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(980px, calc(100vw - 28px));
  max-height: 84vh;
  overflow: auto;
  z-index: 80;
  margin-top: 0;
}

.profile-head-row {
  justify-content: space-between;
  align-items: center;
}
.hero {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 6px 0 12px;
}
.row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
label { min-width: 140px; color: var(--muted); }
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
input, select, button {
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1220;
  color: var(--text);
  padding: 10px;
}
button { cursor: pointer; }
#startBtn, #checkSentencesBtn, .action, #loginBtn {
  background: var(--accent);
  color: #052e16;
  border: none;
  font-weight: 700;
}
.tabs {
  position: sticky;
  top: 56px;
  z-index: 30;
  display: flex;
  gap: 10px;
  margin: 10px 0 16px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(8, 12, 24, 0.86);
  backdrop-filter: blur(6px);
}
.tab {
  flex: 1;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0b1220;
  color: var(--text);
  border: 1px solid #334155;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
}
.tab-title { font-weight: 700; font-size: 0.96rem; }
.tab-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1f2937;
  overflow: hidden;
}
.tab-progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
  transition: width 180ms ease;
}
.tab small { color: #93c5fd; font-size: 0.75rem; }
.tab.active { background: #1f2937; border-color: var(--accent); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.word {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #0b1220;
}
.word small { color: var(--muted); display: block; }
.word-audio { cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.word-audio:hover { border-color: #38bdf8; box-shadow: 0 0 0 1px #38bdf833; }
.word-audio .speak-dot { opacity: 0.7; margin-left: 4px; }
.word-audio.is-speaking { border-color: #38bdf8; box-shadow: 0 0 0 1px #38bdf866, 0 0 14px #38bdf844; }

.numbers-repeat-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #0b1220;
  margin-bottom: 10px;
}
.numbers-repeat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.numbers-chip {
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px 8px;
  background: #111827;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.numbers-chip .speak-dot {
  opacity: 0.65;
  filter: drop-shadow(0 0 2px rgba(56,189,248,0.4));
}
.numbers-chip.is-speaking {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf866, 0 0 14px #38bdf844;
}
.numbers-chip.is-speaking .speak-dot {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(56,189,248,0.9));
}
.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #052e16;
  color: #86efac;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.session-summary-banner {
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  margin: 8px 0 10px;
  padding: 8px 10px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1220;
}

.quick-session-box {
  margin: 4px 0 10px;
}
.quick-session-box .row {
  margin: 6px 0;
}
.day-nav { gap: 10px; align-items: center; margin-bottom: 8px; }
.day-nav .pill { margin-bottom: 0; }
.exercise {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: #0b1220;
}
.exercise input { width: 180px; }
.special-char-btn {
  min-width: 34px;
  padding: 6px 8px;
  font-weight: 700;
}
.conj-box {
  margin-top: 8px;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  background: #111827;
}
.conj-box ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.conj-box li {
  margin: 2px 0;
}
.correct { color: #86efac; }
.wrong { color: #fca5a5; }
.hidden { display: none !important; }

#authCard {
  overflow: hidden;
  max-height: 420px;
  opacity: 1;
  transition: max-height 0.4s ease, opacity 0.35s ease, margin 0.35s ease, padding 0.35s ease;
  background: transparent;
  border: none;
  text-align: center;
  margin-top: 0;
  padding-top: 4px;
}
#authCard.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

.auth-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.auth-actions {
  justify-content: center;
}

.auth-bg-hero {
  position: relative;
  min-height: 300px;
  margin: 6px 0 0;
  pointer-events: none;
}
.auth-bg-rocket {
  width: min(760px, 95vw);
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 18px 44px #60a5fa77);
  opacity: 0.98;
  animation: authRocketFloat 3.8s ease-in-out infinite;
}

.start-planets {
  margin: -24px auto 2px;
  max-width: 900px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}
.start-planet {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px #00000088);
  opacity: 0.96;
}
.start-planet.p1 { transform: translateY(4px); }
.start-planet.p2 { transform: translateY(-10px); }
.start-planet.p3 { transform: translateY(6px); }
.start-planet.p4 { transform: translateY(-8px); }
.start-planet.p5 { transform: translateY(2px); }

@keyframes authRocketFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
.bonus-canvas-wrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.bonus-canvas {
  width: 100%;
  max-width: 900px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 20%, #14213d, #050816 70%);
}

.magnet-overlay-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  padding: 8px 10px;
}

.buddy-root {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 120;
}
.buddy-btn {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  border: 1px solid #38bdf8;
  background: radial-gradient(circle at 30% 30%, #1e3a8a, #0b1220);
  display: grid;
  place-items: center;
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.48);
}
.robot-svg { width: 52px; height: 52px; }
.r-shadow { fill: #0b1220; opacity: 0.6; }
.r-antenna-stick { stroke: #93c5fd; stroke-width: 3; }
.r-antenna-ball { fill: #38bdf8; }
.r-head, .r-body { fill: #1f2937; stroke: #93c5fd; stroke-width: 2; }
.r-ear { fill: #334155; }
.r-eye { fill: #e2e8f0; }
.r-smile { fill: none; stroke: #86efac; stroke-width: 4; stroke-linecap: round; }

.buddy-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: min(360px, calc(100vw - 28px));
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 36px rgba(2, 6, 23, 0.6);
}
.buddy-hd { display:flex; align-items:center; gap:8px; padding:8px; border-bottom:1px solid #263247; }
.buddy-title { font-weight: 700; margin-right: auto; }
.buddy-messages { max-height: 240px; overflow:auto; padding: 10px; display:grid; gap:8px; }
.bmsg { display:flex; }
.bmsg.-user { justify-content:flex-end; }
.bubble { background:#111827; border:1px solid #334155; border-radius:10px; padding:8px 10px; max-width: 88%; }
.bmsg.-user .bubble { background:#052e16; border-color:#166534; }
.buddy-input { display:flex; gap:8px; padding:8px; border-top:1px solid #263247; }
.buddy-input input { flex:1; }

.audio-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #0b1220;
}
summary { cursor: pointer; color: #93c5fd; }
a { color: #93c5fd; }

.flashcard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #0b1220;
  margin-top: 12px;
}
.flash-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.flash-word {
  font-size: 1.5rem;
  font-weight: 800;
}
.flash-muted { color: var(--muted); }
.flash-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.ghost-btn {
  border: 1px solid #334155;
  background: #111827;
  color: #cbd5e1;
}
.letter-bank {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #263244;
  background: linear-gradient(180deg, rgba(15,23,42,0.9), rgba(10,15,30,0.95));
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.08), 0 6px 22px rgba(2,6,23,0.35);
}
.letter-btn {
  min-width: 38px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: radial-gradient(circle at 30% 20%, #334155 0%, #1f2937 60%, #111827 100%);
  color: #e2e8f0;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(2,6,23,0.35);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.letter-btn:hover {
  transform: translateY(-1px);
  border-color: #60a5fa;
  box-shadow: 0 6px 14px rgba(30,64,175,0.28);
}
.letter-btn:active {
  transform: translateY(0);
}
.letter-btn:disabled { opacity: 0.35; }
.compose-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.compose-input {
  min-width: 240px;
}
.flash-image-wrap {
  margin: 12px 0;
  display: grid;
  gap: 8px;
}
.flash-image-wrap > p,
.flash-image-wrap > small,
.flash-image-wrap > strong {
  margin: 0;
  line-height: 1.35;
}
.flash-image {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f172a;
  margin-top: 4px;
}

.mnemonic-emoji {
  font-size: 1.6rem;
  margin: 6px 0 2px;
}

.planet-scene {
  position: relative;
  min-height: 260px;
  border: none;
  border-radius: 12px;
  background: transparent;
  padding: 14px 0;
  margin-bottom: 12px;
  overflow: hidden;
}

.planet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.planet-btn {
  border: none;
  background: transparent;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #dbeafe;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.planet-art {
  width: 140px;
  height: 140px;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px #00000088);
}
.planet-label {
  font-size: 0.9rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0b122099;
  border: 1px solid #334155;
}
.planet-btn:hover {
  transform: translateY(-4px) scale(1.05);
  filter: drop-shadow(0 0 12px #60a5fa88);
}
.planet-btn .flag { font-size: 1.7rem; }
.planet-btn.selected-source .planet-art,
.planet-btn.selected-target .planet-art {
  animation: pulsePlanet 1s ease-in-out infinite;
  filter: drop-shadow(0 0 14px #60a5facc) drop-shadow(0 12px 20px #00000088);
}

@keyframes pulsePlanet {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.rocket {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 10px #60a5fa88);
  transition: left 0.8s ease, top 0.8s ease, transform 0.8s ease;
}

.rocket-img {
  width: 102px;
  height: 102px;
  object-fit: contain;
  display: block;
}

.round-play-btn {
  width: 90px;
  height: 90px;
  border-radius: 999px;
  border: 1px solid #86efac;
  background: radial-gradient(circle at 30% 25%, #dcfce7, #22c55e 55%, #15803d 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px #052e1688;
  overflow: hidden;
}
.round-play-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.start-rocket-btn {
  width: 74px;
  height: 74px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 12px #00000066);
}

.round-play-btn.launching .start-rocket-btn {
  animation: launchNudge 0.7s ease;
}

@keyframes launchNudge {
  0% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-8px) scale(1.06); }
  55% { transform: translateY(-2px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

.unsupported {
  background: #3f1d0d;
  color: #fdba74;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #0b1220;
}
.stat-box strong { display: block; font-size: 1.1rem; }

.planet-card-head {
  justify-content: space-between;
}

.pair-progress-card {
  grid-column: 1 / -1;
}

.pair-progress-head,
.pair-progress-meta {
  justify-content: space-between;
  margin: 0 0 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #1f2937;
  border: 1px solid #334155;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #60a5fa);
}

.locked-box {
  border: 1px dashed #334155;
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: #0b122077;
}

@media (max-width: 700px) {
  header h1 { font-size: 2.2rem; }
  .auth-bg-hero { min-height: 220px; }
  .auth-bg-rocket { width: min(560px, 96vw); }
  .start-planets { gap: 6px; margin-top: -12px; }
  .start-planet { width: 84px; height: 84px; }
}
