/* Akshara - learn the Sanskrit letters */

:root {
  --bg: #0a0a14;
  --panel: #15152a;
  --panel-2: #1c1c36;
  --line: #2a2a4a;
  --text: #eceaf6;
  --muted: #9a9ac0;
  --accent: #5858FD;
  --saffron: #f2851c;
  --green: #2ec46b;
  --red: #e23b3b;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Devanagari is served by whatever the device already has: Nirmala UI on
   Windows, Noto on Android, Devanagari Sangam on iOS and macOS. Every one of
   them shapes matras and conjuncts correctly, and none of them costs a download
   on a phone connection, which a webfont of this script certainly would. */
[lang="sa"] {
  font-family: "Nirmala UI", "Noto Sans Devanagari", "Noto Serif Devanagari",
               "Devanagari Sangam MN", "Kohinoor Devanagari", "Mangal", serif;
  font-feature-settings: "kern" 1, "liga" 1;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 18px 16px 40px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: rgba(10, 10, 20, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { margin: 0; font-weight: 700; letter-spacing: 0.5px; }
.back { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.back::before { content: "< "; }
.back:hover { color: var(--text); }
.hud-btn {
  padding: 8px 14px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.hud-btn:hover { color: var(--text); border-color: var(--accent); }
.hud-btn[aria-pressed="true"] { color: #ff8c8c; border-color: rgba(255, 140, 140, 0.35); }

/* Intro */
.intro-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(120% 130% at 8% 0%, rgba(242, 133, 28, 0.16), rgba(0, 0, 0, 0) 60%),
    radial-gradient(120% 130% at 95% 100%, rgba(88, 88, 253, 0.18), rgba(0, 0, 0, 0) 58%),
    var(--panel);
}
.kicker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--saffron);
}
h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -0.7px; }
.lede { margin: 0 0 16px; color: var(--muted); font-size: 15px; line-height: 1.65; max-width: 60ch; }

.overall { margin: 0 0 16px; }
.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--saffron), var(--accent));
  transition: width .35s ease;
}
.overall-text { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.beta {
  margin: 18px 0 6px;
  padding: 12px 14px;
  border: 1px solid rgba(242, 133, 28, 0.4);
  border-radius: 12px;
  background: rgba(242, 133, 28, 0.08);
  color: #f6d5b4;
  font-size: 13px;
  line-height: 1.6;
}
.beta a { color: #ffd7ae; }

.section-title {
  margin: 26px 0 12px;
  font-size: 12px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Groups */
.groups { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.group {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  flex-wrap: wrap;
}
.group.is-complete { border-color: rgba(46, 196, 107, 0.45); }
.group-sample {
  font-size: 26px;
  letter-spacing: 3px;
  color: var(--text);
  flex: 0 0 auto;
}
.group-copy { flex: 1 1 220px; min-width: 0; }
.group-copy h3 { margin: 0 0 3px; font-size: 16px; }
.group-copy p { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.group-count { margin: 6px 0 0 !important; font-size: 12px !important; }
.group-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* Buttons */
.btn {
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4646e0; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }

/* Learn */
.view-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.view-head h2 { margin: 0; font-size: 20px; }
.view-note { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

.chart {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tile:hover { border-color: var(--accent); }
.tile.is-on { border-color: var(--saffron); background: rgba(242, 133, 28, 0.12); }
.tile.is-known { box-shadow: inset 0 -3px 0 rgba(46, 196, 107, 0.7); }
.tile-ch { font-size: 30px; line-height: 1.25; }
.tile-iast { font-size: 11.5px; color: var(--muted); text-align: center; }

.detail {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.detail-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.detail-ch { font-size: 64px; line-height: 1.1; }
.detail-iast { margin: 0; font-size: 20px; font-weight: 700; }
.detail-like { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.detail-ex {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.ex-label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.ex-word { margin: 0; font-size: 32px; line-height: 1.35; }
.ex-gloss { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.detail-none { margin: 14px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.6; }

/* Play */
.round-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.round-bar { flex: 1 1 auto; }
.round-count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.prompt-label { margin: 0 0 10px; text-align: center; color: var(--muted); font-size: 14px; }
.prompt {
  margin: 0 auto 24px;
  text-align: center;
  line-height: 1.2;
}
.prompt.is-letter { font-size: clamp(84px, 30vw, 140px); }
.prompt.is-sound { font-size: clamp(34px, 11vw, 54px); font-weight: 700; color: var(--saffron); }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.option {
  padding: 18px 12px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option-letter { font-size: 40px; line-height: 1.15; }
.option-sound { font-size: 19px; font-weight: 600; }
.option.is-right { border-color: var(--green); background: rgba(46, 196, 107, 0.18); }
.option.is-wrong { border-color: var(--red); background: rgba(226, 59, 59, 0.16); }

.feedback { margin: 16px 0 0; min-height: 44px; text-align: center; font-size: 15px; line-height: 1.5; }
.feedback.is-right { color: #8ff0b5; }
.feedback.is-wrong { color: #ffc7c7; }
.key-hint { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

/* Result */
.done-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}
.done-card h2 { margin: 0 0 6px; font-size: 22px; }
.done-score {
  margin: 0 0 8px;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.missed-label {
  margin: 20px 0 8px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.missed-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.missed {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(226, 59, 59, 0.45);
  border-radius: 10px;
  background: rgba(226, 59, 59, 0.1);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.missed span { font-size: 26px; line-height: 1.2; }
.missed em { font-style: normal; font-size: 11px; color: var(--muted); }
.done-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

.foot {
  padding: 22px 16px max(22px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.foot a { color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .options.is-sounds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  h1 { font-size: 24px; }
  .group { gap: 12px; }
  .group-actions { width: 100%; }
  .group-actions .btn { flex: 1 1 auto; }
  .view-head { gap: 10px; }
  .view-head .btn { flex: 0 0 auto; }
}
