/* ═══════════════════════════════════════════════════════
   GALAXIE TRAINER — Cosmic Playground Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-deep: #0c0a1d;
  --bg-mid: #151233;
  --bg-surface: rgba(255, 255, 255, 0.06);
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-glow: rgba(99, 102, 241, 0.08);
  --ink: #e8eaf6;
  --ink-muted: #9fa8da;
  --ink-dim: #7986cb;
  --accent: #7c4dff;
  --accent-glow: rgba(124, 77, 255, 0.4);
  --accent-2: #ff9100;
  --success: #69f0ae;
  --success-glow: rgba(105, 240, 174, 0.3);
  --error: #ff5252;
  --error-glow: rgba(255, 82, 82, 0.3);
  --teal: #18ffff;
  --teal-glow: rgba(24, 255, 255, 0.2);
  --gold: #ffd740;
  --gold-glow: rgba(255, 215, 64, 0.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
  --radius: 1rem;
  --radius-lg: 1.4rem;
  --radius-pill: 999px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: "Baloo 2", cursive;
  --font-body: "Nunito", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
}

/* ─── Animated cosmic background ─── */

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 77, 255, 0.15), transparent),
    radial-gradient(ellipse 60% 50% at 80% 30%, rgba(24, 255, 255, 0.08), transparent),
    radial-gradient(ellipse 70% 60% at 50% 90%, rgba(255, 145, 0, 0.06), transparent),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
  animation: nebulaDrift 20s ease-in-out infinite alternate;
}

@keyframes nebulaDrift {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
  100% { opacity: 1; }
}

/* Starfield particles via CSS */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 55% 10%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 85% 75%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 45% 50%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 90% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 25% 35%, rgba(124,77,255,0.8), transparent),
    radial-gradient(1px 1px at 60% 80%, rgba(24,255,255,0.6), transparent),
    radial-gradient(1px 1px at 5% 55%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 75% 90%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 40% 25%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 95% 55%, rgba(255,215,64,0.5), transparent),
    radial-gradient(1px 1px at 50% 70%, rgba(255,255,255,0.4), transparent);
  background-size: 200% 200%;
  animation: starTwinkle 12s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes starTwinkle {
  0% { background-position: 0% 0%; opacity: 0.8; }
  100% { background-position: 3% 3%; opacity: 1; }
}

/* ─── Layout shell ─── */

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
}

/* ─── Top bar (slim sticky header) ─── */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: rgba(12, 10, 29, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.top-bar.hidden {
  display: none;
}

.top-bar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.top-bar-badges {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 800;
  margin-bottom: 0.15rem;
}

h1, h2, h3 {
  font-family: var(--font-display);
}

h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 800;
  background: linear-gradient(135deg, #e8eaf6, var(--teal), var(--accent), var(--gold));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 6s ease-in-out infinite;
  line-height: 1.2;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
}

h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.subtitle {
  margin-top: 0.15rem;
  color: var(--ink-dim);
  font-size: 0.92rem;
  font-weight: 600;
}

/* ─── Header badges ─── */

.streak-badge {
  background: linear-gradient(135deg, #ff5252, #ff9100);
  color: white;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(255, 82, 82, 0.3);
  transition: transform var(--transition);
}

.streak-badge:hover { transform: scale(1.05); }

.coin-badge {
  background: linear-gradient(135deg, var(--gold), #ff9100);
  color: #3e2723;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 0.85rem;
  box-shadow: 0 2px 12px var(--gold-glow);
  animation: none;
  transition: transform var(--transition);
  white-space: nowrap;
}

.coin-badge:hover { transform: scale(1.05); }

.dark-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-pill);
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  color: var(--ink);
}

.dark-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: rotate(20deg) scale(1.1);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ── View system ── */
.views-container {
  position: relative;
  min-height: calc(100vh - 80px);
  overflow: hidden;
}

.view {
  display: none;
  width: 100%;
  min-height: calc(100vh - 80px);
  padding: 2rem;
}

.view.view-active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view.view-enter {
  animation: viewSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.view.view-exit {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: viewSlideOut 0.3s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes viewSlideIn {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes viewSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-20px) scale(0.97); }
}

/* ── Bottom navigation bar ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  gap: 0;
  background: rgba(12, 10, 29, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  padding: 0.4rem 1rem calc(0.4rem + env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color var(--transition), transform var(--transition);
  font-family: var(--font-body);
}

.nav-item:hover, .nav-item.active {
  color: var(--accent);
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
}

.nav-icon {
  font-size: 1.4rem;
  transition: transform var(--transition);
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }

/* ── Home view ── */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: auto;
  padding-top: 3rem;
  padding-bottom: 1rem;
  position: relative;
  gap: 1rem;
}

#starfieldCanvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.home-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--teal) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  z-index: 1;
  animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.home-subtitle {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 400px;
  position: relative;
  z-index: 1;
}

.btn-xl {
  font-size: 1.3rem;
  padding: 1rem 3rem;
  border-radius: var(--radius-pill);
  position: relative;
  z-index: 1;
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(124, 77, 255, 0.2); }
}

.home-stats-row {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
  position: relative;
  z-index: 1;
}

.home-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.home-stat strong {
  font-size: 1.4rem;
  color: var(--ink);
}

.view[data-view="home"] .eyebrow {
  position: relative;
  z-index: 1;
}

/* ── Home inline stats (tight under hero) ── */

.home-stats-grid-inline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  width: 100%;
  max-width: 540px;
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

.home-stats-grid-inline .stat-tile {
  padding: 0.6rem 0.4rem;
}

.home-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  width: 100%;
  max-width: 540px;
  margin-top: 0.8rem;
  position: relative;
  z-index: 1;
}

@media (max-width: 560px) {
  .home-stats-grid-inline {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Dedicated stats view ── */

.stats-view-content {
  width: 100%;
  max-width: 700px;
}

.stats-view-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--ink);
}

.stats-view-title-badges {
  margin-top: 2rem;
}

.stats-grid.stats-view-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-tile-lg {
  padding: 1.2rem 0.8rem;
}

.stat-tile-lg .stat-value {
  font-size: 2rem;
}

.stat-tile-lg .stat-label {
  font-size: 0.85rem;
}

.badge-gallery-lg {
  gap: 0.8rem;
}

.badge-gallery-lg .badge-tile {
  width: 90px;
  padding: 0.8rem 0.4rem;
}

.badge-gallery-lg .badge-icon {
  font-size: 2rem;
}

@media (max-width: 560px) {
  .stats-grid.stats-view-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Immersive quiz view ── */
.view[data-view="quiz"] {
  justify-content: center;
  padding: 1.5rem;
}

.view[data-view="quiz"] .panel {
  width: 100%;
  max-width: 600px;
  padding: 2.5rem 2rem;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
}

.view[data-view="quiz"] .panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow), transparent 60%);
  pointer-events: none;
}

.view[data-view="quiz"] .letter-slots {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 3rem;
}

.view[data-view="quiz"] .slot {
  width: 2.2rem;
  height: 2.8rem;
  border-radius: 0.5rem;
  background: var(--bg-surface);
  border: 2px solid var(--card-border);
  transition: all 0.2s ease;
}

.view[data-view="quiz"] .slot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
  box-shadow: 0 0 12px var(--accent-glow);
}

.view[data-view="quiz"] .slot.correct-slot {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 12px var(--success-glow);
  animation: slotPop 0.3s ease;
}

.view[data-view="quiz"] .slot.wrong-slot {
  background: var(--error);
  border-color: var(--error);
  box-shadow: 0 0 12px var(--error-glow);
  animation: slotShake 0.4s ease;
}

@keyframes slotPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1.05); }
}

@keyframes slotShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.view[data-view="quiz"] #wordInput {
  font-size: 1.5rem;
  text-align: center;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 320px;
}

/* Mini confetti burst */
.mini-confetti {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: miniConfettiBurst 0.6s ease-out forwards;
}

@keyframes miniConfettiBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ── Celebration results screen ── */
.view[data-view="result"] {
  justify-content: center;
  padding: 1.5rem;
}

.view[data-view="result"] .panel {
  width: 100%;
  max-width: 560px;
  text-align: center;
  align-items: center;
  gap: 1.5rem;
}

.result-score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--pct), var(--bg-surface) var(--pct));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: scoreReveal 1s ease-out forwards;
}

.result-score-circle::before {
  content: '';
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--bg-mid);
  position: absolute;
}

.result-score-number {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--ink);
}

@keyframes scoreReveal {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.coin-fly {
  position: fixed;
  font-size: 1.5rem;
  pointer-events: none;
  z-index: 9999;
  animation: coinFlyUp 1s ease-out forwards;
}

@keyframes coinFlyUp {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-100px) scale(0.5); opacity: 0; }
}

/* ─── Glass card ─── */

.card {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
}

.card:hover {
  border-color: rgba(124, 77, 255, 0.25);
  box-shadow: var(--shadow-md), 0 0 30px var(--card-glow);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.panel-enter {
  opacity: 0;
  transform: translateY(16px);
}

.panel-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Form elements ─── */

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

select, input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  transition: all var(--transition);
}

select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 20px var(--accent-glow);
  background: rgba(255, 255, 255, 0.08);
}

select option {
  background: var(--bg-mid);
  color: var(--ink);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.label-actions {
  display: flex;
  gap: 0.3rem;
}

.btn-micro {
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: var(--ink-muted);
  border-radius: 0.4rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
}

.btn-micro:hover {
  background: rgba(255,255,255,0.12);
  color: var(--ink);
  border-color: var(--accent);
}

/* ─── Letter group pill picker ─── */

.letter-group-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  min-height: 2.8rem;
  max-height: 8.5rem;
  overflow-y: auto;
  transition: border-color 0.15s, box-shadow 0.15s;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.letter-group-picker:focus-within,
.letter-group-picker:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.letter-group-picker.loading {
  pointer-events: none;
  align-items: center;
}

.lg-placeholder {
  color: var(--ink-dim);
  font-style: italic;
  font-weight: 400;
  font-size: 0.9rem;
}

.lg-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 800;
  font-family: var(--font-display);
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--ink-dim);
  transition: all 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lg-pill:hover {
  border-color: var(--accent);
  background: rgba(124,77,255,0.1);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.lg-pill:active {
  transform: translateY(0);
}

.lg-pill.selected {
  background: linear-gradient(135deg, var(--accent), #536dfe);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.lg-pill.selected::before {
  content: "\2713";
  font-size: 0.7rem;
  opacity: 0.85;
}

.lg-count {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-dim);
  font-weight: 600;
  text-align: right;
  min-height: 1rem;
}

/* ─── Buttons ─── */

.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 0.75rem 1.1rem;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font-display);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  isolation: isolate;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
  filter: brightness(0.95);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #536dfe);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn.primary:hover {
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn.secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink);
}

.btn.secondary:hover {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.25);
}

.small-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.build-info {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.2);
  padding: 1rem 0 0.5rem;
}

/* ─── Quiz panel ─── */

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.quiz-top h2 {
  font-size: 1.3rem;
}

#progressText {
  color: var(--teal);
  font-weight: 800;
  font-size: 0.9rem;
  font-family: var(--font-display);
  white-space: nowrap;
}

.progress-track {
  height: 0.6rem;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, var(--accent), var(--teal), var(--success));
  background-size: 200% 100%;
  animation: progressGlow 2s ease-in-out infinite;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 12px var(--accent-glow);
}

@keyframes progressGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.task-display {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(255, 145, 0, 0.3);
  background: rgba(255, 145, 0, 0.08);
  color: var(--accent-2);
  text-shadow: 0 0 20px rgba(255, 145, 0, 0.2);
}

.letter-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 2.4rem;
  justify-content: center;
  padding: 0.5rem 0;
}

.slot {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.2s ease;
}

.slot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: slotPop 0.2s ease;
}

@keyframes slotPop {
  0% { transform: scale(0.5); opacity: 0.3; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.slot.correct-slot {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}

.slot.wrong-slot {
  background: var(--error);
  border-color: var(--error);
  box-shadow: 0 0 8px var(--error-glow);
}

.quiz-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
}

#wordInput {
  font-size: 1.15rem;
  padding: 0.8rem 1rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: var(--radius);
}

#wordInput:focus {
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 30px var(--accent-glow);
}

.feedback {
  min-height: 1.25rem;
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
  transition: color var(--transition);
}

.ok { color: var(--success); }
.bad { color: var(--error); }

.hidden { display: none !important; }

/* ─── Results panel ─── */

.result-highlight {
  background: linear-gradient(135deg, rgba(105, 240, 174, 0.12), rgba(124, 77, 255, 0.12));
  border-radius: var(--radius);
  padding: 1.1rem;
  border: 1px solid rgba(105, 240, 174, 0.2);
  text-align: center;
}

.rating {
  font-size: 1.6rem;
  font-family: var(--font-display);
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.score-line {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

#coinRewardLine {
  color: var(--gold);
  font-size: 0.95rem;
}

/* ─── Mistakes / correction lab ─── */

#mistakesBlock {
  transition: all 0.4s ease;
  overflow: hidden;
}

#mistakesBlock.collapsed {
  max-height: 0 !important;
  opacity: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

#mistakesList {
  display: grid;
  gap: 0.55rem;
}

.mistake-item {
  display: grid;
  gap: 0.45rem;
  background: rgba(255, 145, 0, 0.06);
  border: 1px solid rgba(255, 145, 0, 0.2);
  border-radius: var(--radius);
  padding: 0.7rem;
  transition: all 0.3s ease;
}

.mistake-item.corrected {
  background: rgba(105, 240, 174, 0.08);
  border-color: rgba(105, 240, 174, 0.25);
}

.mistake-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent-2);
}

.mistake-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.speak-wrong {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
}

.correction-success {
  text-align: center;
  padding: 1rem;
  color: var(--success);
  font-weight: 800;
  font-size: 1.1rem;
  animation: successPulse 0.5s ease;
}

@keyframes successPulse {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

#playAgainBtn {
  background: linear-gradient(135deg, var(--success), #00e676);
  color: #1b5e20;
  font-size: 1.1rem;
  padding: 0.85rem 1.5rem;
  box-shadow: 0 4px 20px var(--success-glow);
}

#playAgainBtn:hover {
  box-shadow: 0 8px 30px var(--success-glow);
}

/* ─── Stats grid ─── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}

.stat-tile {
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.06);
  transition: all var(--transition);
}

.stat-tile:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--teal);
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.1rem;
}

/* ─── Achievement badges ─── */

.badge-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 4.5rem;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
  transition: all 0.2s ease;
}

.badge-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(124,77,255,0.15);
  border-color: var(--accent);
}

.badge-tile.locked {
  opacity: 0.25;
  filter: grayscale(1);
}

.badge-tile:not(.locked) {
  box-shadow: 0 0 12px rgba(124,77,255,0.1);
  border-color: rgba(124,77,255,0.2);
}

.badge-icon {
  font-size: 1.5rem;
}

.badge-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--ink-dim);
  line-height: 1.1;
}

/* ─── Toast notifications ─── */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, rgba(124,77,255,0.9), rgba(83,109,254,0.9));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: 0.75rem 1.15rem;
  font-weight: 700;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: white;
  box-shadow: 0 8px 32px rgba(124,77,255,0.3);
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ─── Arcade view ─── */

.arcade-view-title {
  font-size: 1.6rem;
  margin-bottom: 1.2rem;
  text-align: center;
}

.arcade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  width: 100%;
  max-width: 920px;
}

.game-card {
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  position: relative;
  overflow: hidden;
  border: 1px solid;
  transition: transform var(--transition), box-shadow var(--transition);
}

.game-card:hover {
  transform: translateY(-4px);
}

.game-card--tetris {
  background: linear-gradient(135deg, rgba(124,77,255,0.15), rgba(96,165,250,0.1));
  border-color: rgba(124,77,255,0.3);
  box-shadow: 0 8px 32px rgba(124,77,255,0.15);
}
.game-card--tetris:hover {
  box-shadow: 0 12px 40px rgba(124,77,255,0.25);
}

.game-card--snake {
  background: linear-gradient(135deg, rgba(74,222,128,0.15), rgba(24,255,255,0.1));
  border-color: rgba(74,222,128,0.3);
  box-shadow: 0 8px 32px rgba(74,222,128,0.15);
}
.game-card--snake:hover {
  box-shadow: 0 12px 40px rgba(74,222,128,0.25);
}

.game-card--moorhuhn {
  background: linear-gradient(135deg, rgba(255,145,0,0.15), rgba(255,215,64,0.1));
  border-color: rgba(255,145,0,0.3);
  box-shadow: 0 8px 32px rgba(255,145,0,0.15);
}
.game-card--moorhuhn:hover {
  box-shadow: 0 12px 40px rgba(255,145,0,0.25);
}

.game-card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.game-card-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}

.game-card-desc {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.4;
}

.game-card-stats {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.game-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

/* ─── Arcade stats collapsible ─── */

.arcade-stats-details {
  width: 100%;
  max-width: 920px;
  margin-top: 2rem;
  border-radius: var(--radius-lg);
  background: rgba(105, 240, 174, 0.04);
  border: 1px solid rgba(105, 240, 174, 0.15);
  overflow: hidden;
}

.arcade-stats-toggle {
  display: block;
  padding: 1rem 1.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: background var(--transition);
}

.arcade-stats-toggle::-webkit-details-marker { display: none; }

.arcade-stats-toggle::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.6rem;
  font-size: 0.75rem;
  transition: transform var(--transition);
}

.arcade-stats-details[open] .arcade-stats-toggle::before {
  transform: rotate(90deg);
}

.arcade-stats-toggle:hover {
  background: rgba(255,255,255,0.04);
}

.arcade-stats-content {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.arcade-buy {
  background: linear-gradient(135deg, var(--gold), #ff9100);
  color: #3e2723;
  box-shadow: 0 2px 12px var(--gold-glow);
}

.arcade-play {
  background: linear-gradient(135deg, #7c4dff, #536dfe);
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.arcade-play::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.ticket-badge {
  background: linear-gradient(135deg, rgba(255,82,82,0.15), rgba(255,215,64,0.15));
  border: 1px solid rgba(255,215,64,0.25);
  color: var(--gold);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 0.8rem;
  white-space: nowrap;
}

.coin-inline {
  background: linear-gradient(135deg, rgba(255,215,64,0.15), rgba(255,145,0,0.15));
  border: 1px solid rgba(255,215,64,0.25);
  color: var(--gold);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 0.82rem;
}

.ticket-inline {
  background: linear-gradient(135deg, rgba(255,82,82,0.12), rgba(255,215,64,0.12));
  border: 1px solid rgba(255,82,82,0.2);
  color: #ff8a80;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-pill);
  font-weight: 900;
  font-size: 0.82rem;
}

/* ─── Tetris Modal ─── */

.tetris-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tetris-modal {
  background: linear-gradient(160deg, #0a0820, #12103a, #080618);
  border: none;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.tetris-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  flex-shrink: 0;
}

.tetris-modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(90deg, #c5cae9, #7c4dff, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  flex-shrink: 0;
}

.tetris-modal-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.tetris-badge {
  font-size: 0.82rem;
}

.tetris-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink-muted);
  font-size: 1.5rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.tetris-close-btn:hover {
  background: rgba(255, 82, 82, 0.2);
  color: #ff8a80;
  border-color: rgba(255, 82, 82, 0.3);
}

.tetris-modal-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tetris-stage {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

.tetris-stats-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 85px;
}

.tetris-stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 0.6rem;
  padding: 0.45rem 0.55rem;
  text-align: center;
}

.tetris-stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
}

.tetris-stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
}

.next-piece-box { padding: 0.35rem; }

.next-piece-canvas {
  display: block;
  margin: 0.25rem auto 0;
  width: 72px;
  height: 72px;
  border-radius: 0.4rem;
  background: rgba(0, 0, 0, 0.3);
}

.tetris-canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tetris-canvas {
  display: block;
  border-radius: 0.6rem;
  border: 1.5px solid rgba(99, 102, 241, 0.3);
  background: linear-gradient(180deg, #020617, #0f0d24);
  height: calc(100dvh - 200px);
  width: auto;
  max-height: calc(100dvh - 200px);
}

.tetris-glow {
  position: absolute;
  inset: -4px;
  border-radius: 0.8rem;
  background: transparent;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.15), 0 0 40px rgba(99, 102, 241, 0.05);
  pointer-events: none;
  z-index: -1;
}

.tetris-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  width: 100%;
}

.tetris-btn-start {
  background: linear-gradient(135deg, #69f0ae, #00e676);
  color: #1b5e20;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  box-shadow: 0 4px 16px var(--success-glow);
}

.tetris-btn-pause {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink);
  padding: 0.6rem 1.1rem;
}

.tetris-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-dim);
  text-align: center;
}

/* ─── Touch controls ─── */

.touch-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.touch-row {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.touch-btn {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(124, 77, 255, 0.3);
  background: rgba(124, 77, 255, 0.1);
  color: var(--ink-muted);
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-btn:active {
  background: rgba(124, 77, 255, 0.3);
  transform: scale(0.92);
}

.touch-drop {
  background: rgba(255, 82, 82, 0.12);
  border-color: rgba(255, 82, 82, 0.3);
  color: #ff8a80;
}

.touch-drop:active {
  background: rgba(255, 82, 82, 0.35);
}

.tetris-feedback {
  text-align: center;
  width: 100%;
}

.tetris-feedback.ok { color: var(--success); }
.tetris-feedback.bad { color: var(--error); }

/* ─── Snake Modal theme ─── */

.snake-theme .tetris-modal {
  background: linear-gradient(160deg, #021209, #082d12, #011008);
}

.snake-theme .tetris-modal-header {
  border-bottom-color: rgba(105, 240, 174, 0.2);
}

.snake-theme .tetris-stat-box {
  border-color: rgba(105, 240, 174, 0.15);
}

.snake-theme .tetris-stat-label {
  color: var(--success);
}

.snake-theme .tetris-badge {
  background: rgba(105, 240, 174, 0.1);
  border-color: rgba(105, 240, 174, 0.2);
}

.snake-theme .tetris-glow {
  box-shadow: 0 0 20px rgba(105, 240, 174, 0.2), 0 0 40px rgba(105, 240, 174, 0.05);
}

.snake-theme .tetris-close-btn {
  color: var(--success);
}

.snake-title {
  background: linear-gradient(90deg, #b9f6ca, #69f0ae, #00e676);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.snake-canvas {
  border-color: rgba(105, 240, 174, 0.3) !important;
  background: linear-gradient(180deg, #011008, #082d12) !important;
  height: min(calc(100dvh - 200px), calc(100vw - 120px)) !important;
  width: auto !important;
  max-height: min(calc(100dvh - 200px), calc(100vw - 120px)) !important;
}

.snake-stage { align-items: center; }

/* ─── Snake touch D-Pad ─── */

.snake-dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.snake-touch-btn {
  border-color: rgba(105, 240, 174, 0.3) !important;
  background: rgba(105, 240, 174, 0.1) !important;
  color: var(--success) !important;
}

.snake-touch-btn:active {
  background: rgba(105, 240, 174, 0.3) !important;
}

@media (hover: none) and (pointer: coarse) {
  .snake-dpad { display: flex; }
}

/* ─── Moorhuhn fullscreen ─── */

.mh-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0a0600;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.mh-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(180deg, #1a0f04, #2d1a0e);
  border-bottom: 2px solid #6b3a1f;
  flex-shrink: 0;
  flex-wrap: wrap;
  z-index: 2;
}

.mh-topbar-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
  color: #fcd34d;
  flex-shrink: 0;
}

.mh-topbar-badge { font-size: 0.8rem; flex-shrink: 0; }

.mh-topbar-stats {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  justify-content: center;
}

.mh-stat {
  font-size: 0.85rem;
  color: #d4a574;
  font-weight: 700;
  white-space: nowrap;
}

.mh-stat strong { color: #fef3c7; }

.mh-topbar-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.mh-btn-start {
  background: linear-gradient(135deg, #69f0ae, #00e676);
  color: #1b5e20;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.mh-btn-pause {
  background: rgba(255,255,255,0.1);
  color: white;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.mh-btn-reload {
  background: linear-gradient(135deg, #ff9100, #ff6d00);
  color: white;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.mh-btn-close {
  background: rgba(255, 82, 82, 0.2);
  border: 1px solid rgba(255, 82, 82, 0.3);
  color: #ff8a80;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.mh-canvas-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0600;
  overflow: hidden;
}

.mh-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: none;
  image-rendering: auto;
}

.mh-feedback {
  text-align: center;
  padding: 0.2rem 0.5rem;
  flex-shrink: 0;
  background: #1a0f04;
  color: #d4a574;
  min-height: 1.4rem;
  font-size: 0.85rem;
  margin: 0;
}

.mh-feedback.ok { color: var(--success); }
.mh-feedback.bad { color: var(--error); }

/* ─── Celebration ─── */

.celebration {
  pointer-events: none;
  position: fixed;
  top: -10px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: fall 1.8s linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(300deg);
    opacity: 0;
  }
}

/* ─── Shake animation ─── */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake { animation: shake 0.4s ease; }

/* ─── Body scroll lock when modal is open ─── */

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ─── Light mode (toggled via .light-mode on body) ─── */
/* Default is now dark/cosmic. "Dark toggle" switches to light. */

body.light-mode {
  --card: rgba(255, 255, 255, 0.75);
  --card-border: rgba(0, 0, 0, 0.08);
  --card-glow: rgba(99, 102, 241, 0.06);
  --ink: #1a1a2e;
  --ink-muted: #4a4a6a;
  --ink-dim: #7a7a9a;
  --accent: #6200ea;
  --accent-glow: rgba(98, 0, 234, 0.2);
  --success: #00c853;
  --success-glow: rgba(0, 200, 83, 0.2);
  --error: #d50000;
  --error-glow: rgba(213, 0, 0, 0.2);
  --teal: #0091ea;
  --teal-glow: rgba(0, 145, 234, 0.15);
  --gold: #ff8f00;
  --gold-glow: rgba(255, 143, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.15);
}

body.light-mode::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(98, 0, 234, 0.06), transparent),
    radial-gradient(ellipse 60% 50% at 80% 30%, rgba(0, 145, 234, 0.05), transparent),
    radial-gradient(ellipse 70% 60% at 50% 90%, rgba(255, 143, 0, 0.04), transparent),
    linear-gradient(180deg, #f5f3ff 0%, #e8eaf6 100%);
}

body.light-mode::after { display: none; }

body.light-mode .card {
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.8);
}

body.light-mode .top-bar {
  background: rgba(255, 255, 255, 0.85);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode select,
body.light-mode input {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--ink);
}

body.light-mode select option {
  background: white;
  color: var(--ink);
}

body.light-mode .letter-group-picker {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .lg-pill {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--ink-dim);
}

body.light-mode .lg-pill.selected {
  background: linear-gradient(135deg, #6200ea, #536dfe);
  color: white;
}

body.light-mode .streak-badge {
  box-shadow: 0 2px 8px rgba(255, 82, 82, 0.15);
}

body.light-mode .coin-badge {
  box-shadow: 0 2px 8px rgba(255, 143, 0, 0.15);
}

body.light-mode .dark-toggle {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .progress-track {
  background: rgba(0, 0, 0, 0.06);
}

body.light-mode .task-display {
  background: rgba(255, 143, 0, 0.06);
  border-color: rgba(255, 143, 0, 0.2);
}

body.light-mode .slot {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .result-highlight {
  background: linear-gradient(135deg, rgba(0, 200, 83, 0.08), rgba(98, 0, 234, 0.06));
  border-color: rgba(0, 200, 83, 0.15);
}

body.light-mode .mistake-item {
  background: rgba(255, 143, 0, 0.05);
  border-color: rgba(255, 143, 0, 0.15);
}

body.light-mode .mistake-item.corrected {
  background: rgba(0, 200, 83, 0.06);
  border-color: rgba(0, 200, 83, 0.2);
}

body.light-mode .stat-tile {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .stats-view-content {
  color: var(--ink);
}

body.light-mode .game-card--tetris {
  background: linear-gradient(135deg, rgba(98,0,234,0.08), rgba(83,109,254,0.06));
  border-color: rgba(98,0,234,0.2);
}
body.light-mode .game-card--snake {
  background: linear-gradient(135deg, rgba(0,200,83,0.08), rgba(0,145,234,0.06));
  border-color: rgba(0,200,83,0.2);
}
body.light-mode .game-card--moorhuhn {
  background: linear-gradient(135deg, rgba(255,143,0,0.08), rgba(255,215,64,0.06));
  border-color: rgba(255,143,0,0.2);
}
body.light-mode .arcade-stats-details {
  background: rgba(0, 200, 83, 0.04);
  border-color: rgba(0, 200, 83, 0.12);
}
body.light-mode .arcade-stats-toggle:hover {
  background: rgba(0, 0, 0, 0.03);
}

body.light-mode .ticket-badge {
  background: rgba(255, 82, 82, 0.08);
  border-color: rgba(255, 82, 82, 0.15);
  color: #d50000;
}

body.light-mode .btn.secondary {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

body.light-mode .btn-micro {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--ink-muted);
}

body.light-mode .toast {
  background: linear-gradient(135deg, rgba(98,0,234,0.92), rgba(83,109,254,0.92));
}

body.light-mode .badge-tile {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .badge-tile:not(.locked) {
  border-color: rgba(98, 0, 234, 0.15);
  box-shadow: 0 0 8px rgba(98, 0, 234, 0.06);
}

body.light-mode .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .nav-item {
  color: var(--ink-dim);
}

body.light-mode .nav-item:hover,
body.light-mode .nav-item.active {
  color: var(--accent);
}

body.light-mode .result-score-circle::before {
  background: #f5f3ff;
}

body.light-mode .home-subtitle {
  color: var(--ink-muted);
}

body.light-mode .game-card-desc {
  color: var(--ink-muted);
}

/* ─── Responsive ─── */

@media (max-width: 860px) {
  .quiz-controls { grid-template-columns: 1fr; }
  .arcade-grid { grid-template-columns: 1fr; }
  .home-stats-row { gap: 1rem; }
}

@media (max-width: 400px) {
  .home-stats-row { flex-wrap: wrap; justify-content: center; }
  .view { padding: 1rem; }
  .game-card { padding: 1.2rem; }
  .top-bar-badges { gap: 0.4rem; }
  .streak-badge, .coin-badge { font-size: 0.75rem; padding: 0.35rem 0.6rem; }
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: flex; }
  .tetris-hint-keyboard { display: none; }
}

@media (max-width: 520px) {
  .tetris-canvas {
    height: calc(100dvh - 160px);
    max-height: calc(100dvh - 160px);
  }

  .snake-canvas {
    height: min(calc(100dvh - 180px), calc(100vw - 20px)) !important;
    max-height: min(calc(100dvh - 180px), calc(100vw - 20px)) !important;
  }

  .tetris-modal-body { padding: 0.4rem 0.75rem 0.5rem; gap: 0.35rem; }
  .tetris-modal-header { flex-wrap: wrap; padding: 0.5rem 0.75rem; flex-shrink: 0; }

  .tetris-stage {
    flex-direction: column-reverse;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
    min-height: 0;
  }

  .tetris-stats-col {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: unset;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .tetris-stat-box { flex: 1; min-width: 50px; padding: 0.2rem 0.35rem; }
  .tetris-stat-label { font-size: 0.62rem; }
  .tetris-stat-value { font-size: 1rem; }
  .next-piece-box { flex: unset; }
  .next-piece-canvas { width: 44px; height: 44px; }
  .tetris-glow { display: none; }
  .tetris-controls { gap: 0.35rem; flex-shrink: 0; }

  .tetris-btn-start,
  .tetris-btn-pause { padding: 0.4rem 1rem; font-size: 0.9rem; }

  .tetris-feedback { flex-shrink: 0; min-height: unset; font-size: 0.8rem; }
  .touch-controls { gap: 0.15rem; flex-shrink: 0; }
  .touch-row { gap: 0.3rem; }
  .touch-btn { width: 2.8rem; height: 2.8rem; font-size: 1.2rem; }

  .snake-stage { flex-direction: column; align-items: center; }
  .snake-dpad { gap: 0.15rem; flex-shrink: 0; }
}
