/* Elias — base theme: deep-space navy, gold crown accents, glowing blue panels, green play buttons. */
:root {
  --bg: #050b1f;
  --bg2: #0a1534;
  --panel: rgba(9, 20, 48, 0.86);
  --panel-2: rgba(14, 30, 68, 0.9);
  --line: rgba(82, 150, 255, 0.35);
  --glow: rgba(58, 140, 255, 0.45);
  --ink: #eef4ff;
  --muted: #9fb3d9;
  --gold: #ffc72c;
  --gold-2: #ffdd6e;
  --green: #22c55e;
  --green-2: #16a34a;
  --blue: #2f80ff;
  --red: #ef4444;
  --purple: #a855f7;
  --radius: 16px;
  --font-head: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-hand: 'Kalam', 'Comic Sans MS', cursive;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 500 16px/1.5 var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(47, 128, 255, 0.25), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(120, 60, 255, 0.18), transparent 60%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  /* star field */
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff8, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 55% 40%, #fff9, transparent),
    radial-gradient(1px 1px at 75% 85%, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 90% 15%, #fff8, transparent),
    radial-gradient(1px 1px at 45% 95%, #fff5, transparent);
  background-size: 420px 420px;
}
img { max-width: 100%; display: block; }
a { color: #7cc4ff; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.1; margin: 0 0 .4em; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Banner ---------- */
.banner {
  position: relative;
  height: 170px;
  background: url('../img/ui/banner.webp') center 40% / cover no-repeat;
  border-bottom: 1px solid var(--line);
}
.banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 50%, rgba(5, 11, 31, .9)); }
.logo {
  position: absolute; left: 70px; top: 10px; z-index: 6;
  width: 230px; filter: drop-shadow(0 8px 24px rgba(0,0,0,.6)) drop-shadow(0 0 18px rgba(255,199,44,.25));
  transition: transform .3s;
}
.logo:hover { transform: scale(1.04) rotate(-2deg); }
.tagline {
  position: absolute; right: 230px; top: 14px; z-index: 2;
  font: 700 30px/1.05 var(--font-hand); color: #fff; transform: rotate(-8deg);
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
.tagline span { display: block; }
.tagline span:nth-child(2) { padding-left: 10px; }
.tagline span:nth-child(3) { padding-left: 20px; }
.tagline .crown { color: var(--gold); }

/* ---------- Top nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px 10px 330px;
  background: rgba(5, 11, 31, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topnav { display: flex; gap: 4px; margin: 0 auto; flex-wrap: wrap; }
.topnav a {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; text-decoration: none;
  color: var(--ink); font-weight: 700;
  border: 1px solid transparent;
}
.topnav a:hover { background: rgba(47,128,255,.12); }
.topnav a.active { background: linear-gradient(180deg, #13306b, #0c1f4a); border-color: var(--line); box-shadow: 0 0 16px var(--glow) inset, 0 0 12px rgba(47,128,255,.35); }
.player-chip { display: flex; align-items: center; gap: 12px; }
.player-chip .avatar {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  border: 2px solid var(--blue); box-shadow: 0 0 14px var(--glow); background: #0b1d45;
}
.player-chip b { display: block; font-size: 18px; }
.player-chip small { color: var(--muted); }
.coins { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.icon-btn { background: none; border: 0; font-size: 22px; padding: 6px; border-radius: 10px; text-decoration: none; }
.icon-btn:hover { background: rgba(255,255,255,.08); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; padding: 20px 20px 0 0; max-width: 1600px; margin: 0 auto; }
.sidebar { position: sticky; top: 90px; align-self: start; padding: 50px 0 20px; display: flex; flex-direction: column; gap: 4px; }
.sidebar a {
  display: flex; align-items: center; gap: 14px; padding: 11px 20px; text-decoration: none; color: var(--ink);
  font-weight: 700; font-size: 16px; border-radius: 0 14px 14px 0; border-left: 4px solid transparent;
}
.sidebar a span { font-size: 22px; width: 28px; text-align: center; }
.sidebar a:hover { background: rgba(47,128,255,.1); }
.sidebar a.active { background: linear-gradient(90deg, rgba(255,199,44,.18), rgba(255,199,44,.02)); border-left-color: var(--gold); color: var(--gold-2); }
#view { min-width: 0; padding-bottom: 30px; }

.grid-home { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.row2 { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; }

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset, 0 0 24px rgba(47,128,255,.15), 0 10px 30px rgba(0,0,0,.35);
  padding: 16px 18px;
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 10px; }
.ph-icon { font-size: 24px; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-title { font-size: clamp(30px, 4vw, 48px); margin: 6px 0 4px; }
.page-title em { font-style: normal; color: var(--gold); }
.page-lead { color: var(--muted); margin: 0 0 18px; max-width: 60ch; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 800; text-decoration: none;
  background: #1d3f86; color: #fff; transition: transform .12s, filter .12s, box-shadow .12s;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-lg { padding: 14px 28px; font-size: 20px; }
.btn-green { background: linear-gradient(180deg, #34d76c, var(--green-2)); box-shadow: 0 4px 0 #0e6b31, 0 0 14px rgba(34,197,94,.35); }
.btn-gold { background: linear-gradient(180deg, #ffd650, #f5a70a); color: #1b1300; box-shadow: 0 4px 0 #a86a00, 0 0 18px rgba(255,199,44,.4); }
.btn-blue { background: linear-gradient(180deg, #3b8bff, #1f5fd1); box-shadow: 0 0 12px rgba(47,128,255,.35); }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.btn-red { background: linear-gradient(180deg, #f87171, #dc2626); }
.input, select.input, textarea.input {
  background: #071433; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font: inherit; min-width: 0;
}
.input:focus { border-color: var(--gold); outline: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(47,128,255,.14); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.chip.on, .chip[aria-pressed="true"] { background: var(--gold); color: #1b1300; border-color: var(--gold); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 1px solid var(--line); background: rgba(47,128,255,.1); padding: 8px 16px; border-radius: 999px; font-weight: 800; }
.tabs button[aria-pressed="true"] { background: var(--gold); color: #1b1300; border-color: var(--gold); }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: rgba(255,199,44,.18); color: var(--gold-2); font-weight: 800; font-size: 13px; }
.progress { height: 12px; border-radius: 999px; background: #0a1a3d; border: 1px solid var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #22d3ee, #3b82f6); border-radius: 999px; transition: width .4s; }

/* ---------- Cards grid (games, courses, stories) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card {
  background: #0a1838; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 0 22px var(--glow); }
.card img { aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { font-size: 17px; margin: 0; }
.card-body p { margin: 0; color: var(--muted); font-size: 13px; }
.card-body .btn { margin-top: auto; width: 100%; }

/* ---------- Quiz / exercise shared ---------- */
.quiz-q { font: 800 clamp(22px, 3vw, 34px) var(--font-head); margin: 10px 0 14px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.option { padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: #0b1d45; font-weight: 800; font-size: 18px; text-align: center; }
.option:hover { border-color: var(--blue); }
.option.right { background: #0f5132; border-color: var(--green); }
.option.wrong { background: #5c1a1a; border-color: var(--red); }
.feedback { min-height: 1.6em; font-weight: 800; margin: 10px 0; }
.feedback.good { color: #4ade80; } .feedback.bad { color: #f87171; }
.speak-btn { background: rgba(255,199,44,.15); border: 1px solid rgba(255,199,44,.5); color: var(--gold-2); border-radius: 999px; padding: 4px 10px; font-weight: 800; }
.speak-btn:hover { background: rgba(255,199,44,.3); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 140%); z-index: 100;
  background: linear-gradient(180deg, #ffd650, #f5a70a); color: #1b1300; font-weight: 900; padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: transform .3s; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 18px; color: var(--ink); border-top: 1px solid var(--line); margin-top: 20px; background: rgba(5,11,31,.8); }
.footer span { margin: 0 10px; }
.footer small { display: block; color: var(--muted); margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1250px) {
  .grid-home { grid-template-columns: 1fr; }
  .tagline { right: 40px; }
}
@media (max-width: 980px) {
  .banner { height: 130px; }
  /* the <img> height attribute (561) otherwise wins over the CSS width and stretches the logo */
  .logo { width: 150px; height: auto; left: 16px; top: 6px; }
  .tagline { font-size: 22px; right: 20px; }
  .topbar { padding-left: 180px; }
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .sidebar { display: none; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { padding: 8px 12px 8px 130px; flex-wrap: wrap; gap: 6px; }
  .logo { width: 110px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .topnav a { padding: 8px 10px; font-size: 14px; white-space: nowrap; }
  .player-chip small, .coins { font-size: 14px; }
  .tagline { display: none; }

  /* Logo (110×119) now sits fully inside the 130px banner, so the bar no longer reserves space for it */
  .topbar { padding: 8px 12px; justify-content: flex-end; }
  .player-chip { margin-right: auto; gap: 10px; min-width: 0; }
  .player-chip .avatar { width: 40px; height: 40px; font-size: 21px; flex: none; }
  .player-chip b { font-size: 16px; }

  /* Every nav item visible: compact icon-over-label grid instead of a clipped scrolling row */
  .topnav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; overflow: visible; margin: 0; }
  .topnav a { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 12px; line-height: 1.2; text-align: center; min-width: 0; }
  .topnav a span { font-size: 18px; line-height: 1; }
}
@media (max-width: 360px) {
  .topnav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
