/*
 * Copyright (C) 2026 Fabiano Braga // 4u-Labs (4u.ia.br)
 * Licensed under GNU AGPL-3.0
 */
:root {
  --bg: #071118;
  --surface: #0d212d;
  --surface-2: #122a39;
  --border: #17495d;
  --teal: #14b8a6;
  --teal-bright: #2dd4bf;
  --amber: #fbbf24;
  --rose: #fb7185;
  --text: #e6f4f9;
  --muted: #94b3c4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #103244 0%, #071118 55%, #040b10 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 16px;
  background: rgba(9, 22, 31, 0.94);
  border-bottom: 1px solid var(--border);
}

.brand-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-logo { height: 22px; width: auto; }
.app-icon-mini { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; border: 1px solid rgba(45, 212, 191, 0.5); }
.brand-icon { font-size: 1.25rem; }
.brand-name { font-weight: 800; font-size: 1rem; color: var(--teal-bright); letter-spacing: 0.02em; }
.xp-pill {
  background: rgba(20, 184, 166, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  color: var(--amber);
}

.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.top-btn, .mini-btn, .primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.top-btn {
  background: #102836;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 11px;
  font-size: 0.76rem;
}
.top-btn:hover { border-color: var(--teal-bright); background: #16374a; }
.install-btn { display: none; background: linear-gradient(135deg, #0d9488, #0284c7); border-color: #38bdf8; color: #fff; }
.eco-btn { border-color: #38bdf8; color: #7dd3fc; }
.donate-btn { border-color: #fb7185; color: #fda4af; }

.mini-btn {
  background: #102a38;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 0.78rem;
}
.mini-btn.active { background: rgba(20, 184, 166, 0.22); border-color: var(--teal-bright); color: var(--teal-bright); }
.mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  background: linear-gradient(135deg, #14b8a6, #0284c7);
  color: #fff;
  border: none;
  padding: 9px 16px;
  font-size: 0.85rem;
}
.primary-btn:hover { filter: brightness(1.08); }

/* Privacy Strip & Context Banner */
.privacy-strip {
  text-align: center;
  padding: 6px 12px;
  font-size: 0.76rem;
  color: #99f6e4;
  background: rgba(20, 184, 166, 0.1);
  border-bottom: 1px solid rgba(45, 212, 191, 0.2);
}

.context-banner {
  max-width: 1480px;
  margin: 10px auto 0;
  width: calc(100% - 24px);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.16), rgba(20, 184, 166, 0.16));
  border: 1px solid var(--amber);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.context-banner-text { font-weight: 700; font-size: 0.9rem; color: #fef3c7; }

/* Mode Tabs */
.mode-tabs {
  max-width: 1480px;
  width: 100%;
  margin: 10px auto 0;
  padding: 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.24), rgba(2, 132, 199, 0.24));
  border-color: var(--teal-bright);
  color: #fff;
}

/* Main */
.main-wrap {
  flex: 1;
  max-width: 1480px;
  width: 100%;
  margin: 10px auto 24px;
  padding: 0 14px;
  min-width: 0;
}

.tab-panel { min-width: 0; max-width: 100%; }
.tab-panel[hidden] { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
  min-width: 0;
  max-width: 100%;
}

.studio-grid > *, .arcade-stage > *, .l2-stage > *, .trails-grid > *, .params-grid > * {
  min-width: 0;
  max-width: 100%;
}

canvas { max-width: 100%; }

.muted { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

/* Trails Showcase & Sleek Carousel */
.trails-showcase {
  background: linear-gradient(145deg, rgba(16, 42, 56, 0.92), rgba(7, 25, 35, 0.94));
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 16px;
  padding: 12px 14px 10px;
  margin-bottom: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  min-width: 0;
  max-width: 100%;
}
.trails-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.trails-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.trails-pill {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.24), rgba(2, 132, 199, 0.24));
  border: 1px solid rgba(45, 212, 191, 0.55);
  color: #99f6e4;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.trails-hint { font-size: 0.8rem; color: var(--muted); }
.trails-controls { display: flex; align-items: center; gap: 6px; }
.scroll-arrow {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.4);
  background: #0a202c;
  color: var(--teal-bright);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.scroll-arrow:hover { border-color: var(--teal-bright); background: #103244; }
.scroll-arrow-sm { width: 28px; height: 28px; font-size: 1.05rem; }

.carousel-fade-wrap { position: relative; min-width: 0; max-width: 100%; }
.carousel-fade-wrap:not(.expanded)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 10px;
  width: 34px;
  background: linear-gradient(to left, rgba(9, 28, 39, 0.92), rgba(9, 28, 39, 0));
  pointer-events: none;
}

.trails-grid {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 2px 24px 10px 2px;
  margin-bottom: 0;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(45, 212, 191, 0.45) rgba(7, 27, 38, 0.35);
}
.trails-grid.expanded {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  overflow-x: visible;
  padding: 4px 4px 6px;
  max-height: 360px;
  overflow-y: auto;
}

.trail-card {
  flex: 0 0 202px;
  scroll-snap-align: start;
  background: #091d28;
  border: 1px solid var(--border);
  border-top: 3px solid var(--trail-accent, var(--teal));
  border-radius: 12px;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.trails-grid.expanded .trail-card { flex: unset; width: 100%; }
.trail-card:hover { transform: translateY(-1px); border-color: var(--teal-bright); }
.trail-card.active {
  background: linear-gradient(155deg, rgba(20, 184, 166, 0.2), #0d2b3b);
  border-color: var(--teal-bright);
  box-shadow: 0 0 0 1px var(--teal-bright), 0 8px 18px rgba(20, 184, 166, 0.18);
}
.trail-card-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 800; font-size: 0.86rem; }
.trail-card-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.trail-count-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.14);
  color: var(--teal-bright);
  white-space: nowrap;
  flex-shrink: 0;
}
.trail-card-desc {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Signs Strip */
.signs-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  min-width: 0;
  max-width: 100%;
}
.signs-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  margin-bottom: 0;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(45, 212, 191, 0.45) rgba(7, 27, 38, 0.35);
}

.trails-grid::-webkit-scrollbar,
.signs-strip::-webkit-scrollbar { height: 6px; width: 6px; }
.trails-grid::-webkit-scrollbar-track,
.signs-strip::-webkit-scrollbar-track { background: rgba(7, 27, 38, 0.45); border-radius: 999px; }
.trails-grid::-webkit-scrollbar-thumb,
.signs-strip::-webkit-scrollbar-thumb { background: rgba(45, 212, 191, 0.42); border-radius: 999px; }
.trails-grid::-webkit-scrollbar-thumb:hover,
.signs-strip::-webkit-scrollbar-thumb:hover { background: rgba(45, 212, 191, 0.72); }
.trails-grid::-webkit-scrollbar-button,
.signs-strip::-webkit-scrollbar-button { display: none; }
.sign-chip {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.sign-chip.active { background: var(--teal); color: #041318; border-color: var(--teal-bright); }
.sign-chip.done::after { content: ' ✓'; color: #fde047; }

/* Studio */
.studio-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.25fr;
  gap: 16px;
  align-items: start;
}

.studio-grid.cam-expanded {
  grid-template-columns: 1fr;
}

.studio-grid.cam-expanded .video-box {
  max-height: 70vh;
  min-height: 460px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 1.08rem; display: inline; }
.sign-emoji { font-size: 1.35rem; margin-right: 6px; }

.canvas-box { position: relative; max-width: 100%; border-radius: 12px; overflow: hidden; border: 1px solid rgba(34, 211, 238, 0.32); box-shadow: inset 0 0 28px rgba(34, 211, 238, 0.08); }
#demo-canvas { display: block; width: 100%; max-width: 100%; height: 420px; cursor: default; touch-action: pan-y; }
.practice-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.region-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(7, 17, 24, 0.82);
  color: #cbd5e1;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 7px;
}

.params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.param-item {
  background: rgba(7, 17, 24, 0.55);
  border: 1px solid rgba(23, 73, 93, 0.7);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 0.78rem;
}
.param-wide { grid-column: 1 / -1; }
.p-lbl { display: block; font-size: 0.68rem; color: var(--teal-bright); text-transform: uppercase; letter-spacing: 0.04em; }

/* Webcam Area */
.video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 360px;
  max-height: 58vh;
  border-radius: 12px;
  overflow: hidden;
  background: #061017;
  border: 1px solid var(--border);
}
#cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
#cam-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cam-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  background: rgba(7, 17, 24, 0.88);
}
.cam-placeholder p { color: var(--muted); font-size: 0.88rem; margin-bottom: 12px; max-width: 280px; }

.eval-bar-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.eval-bar-track { flex: 1; height: 10px; background: #07131a; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.eval-bar-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #f43f5e, #fbbf24, #22c55e); transition: width 0.12s ease; }
.eval-score { font-weight: 800; font-size: 0.86rem; color: var(--teal-bright); min-width: 40px; text-align: right; }

.eval-tip {
  margin-top: 8px;
  background: rgba(16, 42, 56, 0.8);
  border-left: 3px solid var(--amber);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  min-height: 36px;
}
.eval-tip.ok { border-left-color: #22c55e; color: #bbf7d0; }

.studio-footer-btns { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Quizzes */
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.quiz-opt {
  background: #102a38;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}
.quiz-opt:hover { border-color: var(--teal-bright); }
.quiz-opt.correct { background: rgba(34, 197, 94, 0.25); border-color: #22c55e; }
.quiz-opt.wrong { background: rgba(244, 63, 94, 0.25); border-color: #f43f5e; }

/* Kit Builder */
.kit-form-row { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.kit-form-row input, .kit-result input, #dict-search {
  background: #071118;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.9rem;
}
.kit-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(7, 17, 24, 0.55);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.kit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #102836;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.kit-thumb { width: 32px; height: 32px; border-radius: 7px; object-fit: cover; flex-shrink: 0; border: 1px solid rgba(45, 212, 191, 0.35); }
.mirror-left { transform: scaleX(-1); }
.kit-chip.selected { background: var(--teal); color: #041318; font-weight: 700; border-color: var(--teal-bright); }
.kit-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.kit-result { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.kit-result input { flex: 1; min-width: 220px; color: #f8fafc; background: #071118; font-family: monospace; font-size: 0.82rem; }

/* Arcade */
.arcade-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.arcade-stats { display: flex; gap: 14px; font-size: 1rem; background: #071118; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); }
.arcade-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; align-items: center; }
#arcade-canvas, #l2-canvas { display: block; width: 100%; max-width: 100%; height: 280px; border-radius: 12px; border: 1px solid var(--border); }
.arcade-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Dictionary, Pocket, Grammar */
.pocket-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-top: 10px; }
.pocket-btn {
  background: #102a38;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.pocket-btn:hover { border-color: var(--amber); }

.grammar-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.grammar-card { background: rgba(7, 17, 24, 0.58); border: 1px solid var(--border); border-radius: 10px; padding: 11px; font-size: 0.84rem; }
.grammar-pt { color: var(--muted); margin-bottom: 4px; }
.grammar-libras { color: var(--amber); font-weight: 800; margin-bottom: 6px; }

.dict-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dict-head h2 { margin: 0; }
.dict-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dict-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 8px; }
.dict-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #102a38;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  text-align: center;
}
.dict-item:hover { border-color: var(--teal-bright); transform: translateY(-1px); }
.dict-thumb { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; border: 1px solid rgba(45, 212, 191, 0.3); background: #071b26; }
.dict-item strong { display: block; font-size: 0.8rem; line-height: 1.25; }

/* Speller & Voice Bridge */
.speller-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.speller-controls input[type="text"] {
  flex: 1 1 240px;
  background: #071118;
  color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
}
.speller-stats { margin-top: 10px; font-size: 0.82rem; font-weight: 700; color: var(--teal-bright); }
.speller-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 8px; }
.speller-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: #0b2230;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 10px;
  padding: 7px;
  cursor: pointer;
  color: #e6f4f9;
}
.speller-tile:hover { border-color: var(--teal-bright); }
.speller-tile img { width: 88px; height: 88px; border-radius: 8px; object-fit: cover; }
.speller-tile strong { font-size: 0.78rem; color: var(--teal-bright); text-align: center; word-break: break-word; }
.speller-space { display: flex; align-items: center; justify-content: center; font-size: 0.72rem; color: var(--muted); border-style: dashed; opacity: 0.7; cursor: default; }

/* Memory Game */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.mem-card {
  min-height: 108px;
  background: linear-gradient(145deg, #102a38, #081a24);
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #e6f4f9;
  font-weight: 700;
  font-size: 0.84rem;
  text-align: center;
}
.mem-card.revealed { background: #0d2b3b; border-color: var(--amber); }
.mem-card.matched { background: rgba(20, 184, 166, 0.18); border-color: #22c55e; cursor: default; }
.mem-card img { width: 82px; height: 82px; border-radius: 9px; object-fit: cover; }
.mem-back { font-size: 1.5rem; opacity: 0.8; }
.mem-word-tag { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--teal-bright); opacity: 0.85; margin-bottom: 4px; }
.mem-word-txt { font-size: 1.05rem; font-weight: 800; line-height: 1.2; color: #f8fafc; }

.chip-mini-thumb { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; vertical-align: middle; margin-right: 4px; }

/* Printable A4 Sheet */
.print-sheet { display: none; }
@media print {
  body { background: #fff !important; color: #0f172a !important; }
  .topbar, .privacy-strip, .context-banner, .mode-tabs, .main-wrap, .site-footer, .modal-backdrop { display: none !important; }
  .print-sheet { display: block !important; padding: 10mm; font-family: system-ui, sans-serif; }
  .print-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #0d9488; padding-bottom: 6px; margin-bottom: 10px; }
  .print-header h1 { margin: 0; font-size: 18pt; color: #0f172a; }
  .print-header p { margin: 0; font-size: 9pt; color: #475569; }
  .print-grid { display: grid; gap: 8px; }
  .print-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
  .print-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .print-card { border: 1px solid #cbd5e1; border-radius: 8px; padding: 6px; text-align: center; break-inside: avoid; background: #fff; }
  .print-card img { width: 100%; max-width: 110px; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 6px; }
  .print-card strong { display: block; font-size: 10pt; margin-top: 4px; color: #0f172a; }
  .print-card span { display: block; font-size: 7.5pt; color: #475569; margin-top: 2px; }
}

/* L2 Stage */
.l2-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; align-items: center; }
.l2-prompt { font-weight: 700; font-size: 0.95rem; margin-top: 0; }

/* Footer & Modals */
.site-footer {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(7, 17, 24, 0.9);
}
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin-bottom: 4px; }
.site-footer a { color: var(--teal-bright); text-decoration: none; }

.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 1.05rem; color: var(--teal-bright); }
.modal-close { background: #102a38; color: #fff; border: 1px solid var(--border); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.eco-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.eco-col h3 { margin: 0 0 8px; font-size: 0.84rem; color: var(--amber); }
.eco-col a { display: block; padding: 5px 9px; margin-bottom: 4px; background: #0a1a24; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 0.82rem; }
.eco-col a:hover { color: var(--teal-bright); }
.modal-foot { margin-top: 14px; text-align: center; }
.paypal-cta { display: inline-block; padding: 9px 18px; border-radius: 999px; background: linear-gradient(135deg, #14b8a6, #0284c7); color: #fff; text-decoration: none; font-weight: 700; font-size: 0.85rem; }
.help-modal-card { max-width: 680px; }
.help-body { display: flex; flex-direction: column; gap: 11px; }
.help-section {
  background: rgba(7, 17, 24, 0.58);
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 12px;
  padding: 11px 14px;
}
.help-section h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--amber);
}
.help-list { margin: 0; padding-left: 18px; font-size: 0.84rem; line-height: 1.55; color: #cbd5e1; }
.help-list li { margin-bottom: 4px; }
.help-list li:last-child { margin-bottom: 0; }
.help-list strong { color: #f8fafc; }
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.help-table th, .help-table td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.help-table thead th {
  background: rgba(20, 184, 166, 0.14);
  color: var(--teal-bright);
  font-weight: 700;
}
.help-table tbody tr:last-child td { border-bottom: none; }
.help-table td strong { color: #f8fafc; white-space: nowrap; }
.pocket-sign-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }

/* Featured Bridge Tab, Home Bridge Bar, Textarea Speller, Infinite Dict & Sequence Player */
.tab-btn-featured {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.16);
  color: #cffafe;
}
.trails-search-wrap { margin: 8px 0 10px; }
.trails-search-wrap input {
  width: 100%;
  background: #091923;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
}
.trail-new-badge {
  font-size: 0.72rem;
  margin-left: 4px;
  color: #38bdf8;
}
.home-bridge-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
  padding: 9px 12px;
  background: linear-gradient(135deg, rgba(16, 48, 66, 0.92), rgba(11, 33, 46, 0.92));
  border: 1px solid rgba(34, 211, 238, 0.38);
  border-radius: 14px;
}
.home-bridge-label { font-size: 0.82rem; font-weight: 700; color: var(--teal-bright); white-space: nowrap; }
.home-bridge-bar input {
  flex: 1 1 240px;
  min-width: 0;
  background: #07151f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.84rem;
}
.home-bridge-bar input:focus { outline: none; border-color: var(--teal-bright); }
.home-bridge-actions { display: flex; gap: 6px; align-items: center; }

.speller-controls { display: flex; flex-direction: column; gap: 10px; }
.speller-controls textarea {
  width: 100%;
  min-height: 76px;
  max-height: 220px;
  resize: vertical;
  background: #07151f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.94rem;
  line-height: 1.45;
}
.speller-controls textarea:focus { outline: none; border-color: var(--teal-bright); box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.18); }
.speller-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.speller-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.speller-ex-chip {
  background: #0f2938;
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.76rem;
  cursor: pointer;
}
.speller-ex-chip:hover { background: #163a4f; border-color: var(--teal-bright); }

#dict-trail-filter {
  background: #091923;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.82rem;
  max-width: 220px;
}
.dict-status-bar { font-size: 0.8rem; color: var(--muted); margin: 8px 0 10px; }
.dict-sentinel { display: flex; justify-content: center; padding: 14px 0 4px; min-height: 24px; }

.seq-modal-card { max-width: 520px; width: 94vw; }
.seq-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #081822;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.seq-img { width: 100%; max-width: 300px; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 14px; background: #0b2532; }
.seq-caption { font-size: 1.35rem; font-weight: 800; color: var(--teal-bright); text-align: center; }
.seq-progress { width: 100%; height: 6px; background: #102a38; border-radius: 999px; overflow: hidden; }
#seq-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #14b8a6, #38bdf8); transition: width 0.2s ease; }
.seq-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
.seq-speeds { display: flex; gap: 4px; margin-left: 4px; }

/* Mobile */
@media (max-width: 900px) {
  .studio-grid, .arcade-stage, .l2-stage, .eco-grid { grid-template-columns: 1fr; }
  .studio-grid { gap: 12px; }
  #demo-canvas { height: 320px; }
  #arcade-canvas, #l2-canvas { height: 240px; }
  .video-box { min-height: 260px; max-height: 52vh; max-width: 100%; }
  .quiz-options { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
  .mode-tabs { gap: 6px; padding: 0 10px; }
  .tab-btn { flex: 1 1 auto; justify-content: center; font-size: 0.78rem; padding: 8px 10px; }
  .scroll-arrow { display: none; }
  .trails-showcase { padding: 10px; }
}

@media (max-width: 600px) {
  .topbar { padding: 8px 10px; }
  .main-wrap { padding: 0 10px; }
  .card { padding: 12px; border-radius: 14px; }
  .params-grid { gap: 6px; }
  .param-item { min-width: 0; overflow-wrap: anywhere; }
  .speller-controls input[type="text"] { min-width: 0; width: 100%; }
}
