/* Theme tokens */
:root {
  color-scheme: light;
  --ink: #20274b;
  --muted: #626b83;
  --accent: #5145b5;
  --light: #eeecff;
  --line: #e2e5ee;
  --green: #176348;
  --red: #a52e45;
  --radius: 20px;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: #f6f7fc;
  font-size: 16px;
}

/* Page layout and navigation */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}
button,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
a {
  color: inherit;
  text-decoration: none;
}
button:disabled {
  cursor: default;
  opacity: 0.6;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #e2a120;
  outline-offset: 4px;
}
button {
  color: var(--ink);
}
.skip {
  position: absolute;
  top: -100px;
  padding: 12px;
  background: white;
  z-index: 20;
}
.skip:focus {
  top: 8px;
}
.topbar {
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.nav-wrap {
  max-width: 1120px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 750;
  font-size: 1.15rem;
}
.brand-mark {
  font-family: "Kailasa", "Noto Sans Tibetan", "Microsoft Himalaya", serif;
  font-size: 1.7rem;
  background: var(--accent);
  color: white;
  width: 44px;
  text-align: center;
  line-height: 1.7;
  border-radius: 12px;
}
.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a {
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
}
.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--light);
  color: var(--accent);
}
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 38px 28px 60px;
}
h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
  margin: 8px 0 12px;
  line-height: 1.2;
}
h2 {
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}
p {
  line-height: 1.65;
}
.muted,
.subtitle {
  color: var(--muted);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  font-weight: 750;
  color: var(--accent);
}
.page-heading {
  margin-bottom: 28px;
}
.page-heading p {
  margin: 0;
  max-width: 680px;
}
/* Score displays and game menu cards */
.progress-strip,
.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.progress-strip {
  margin: 24px 0 32px;
}
.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 20px;
  flex: 1;
  min-width: 125px;
}
.metric strong {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 3px;
}
.metric span {
  font-size: 0.875rem;
  color: var(--muted);
}
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 16px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.activity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  transition:
    transform 0.15s,
    border-color 0.15s;
}
.activity:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.activity-icon {
  background: var(--light);
  color: var(--accent);
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
}
.activity:nth-child(3n + 2) .activity-icon {
  background: #e4f3ed;
  color: #246b52;
}
.activity:nth-child(3n) .activity-icon {
  background: #fff1d7;
  color: #855900;
}
.activity p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 24px;
}
.activity-foot {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--muted);
}
.activity-foot b {
  color: var(--accent);
  font-size: 1.3rem;
}
/* Game layout and controls */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.game-main {
  max-width: 900px;
}
.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.back {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.pill {
  border-radius: 30px;
  background: var(--light);
  color: var(--accent);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}
.settings {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  flex-wrap: wrap;
}
select {
  padding: 11px 35px 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-width: 100%;
}
.button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 20px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
}
.button:hover {
  background: #f2f2fb;
}
.button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.button.primary:hover {
  background: #403497;
}
.button.sound {
  background: var(--light);
  border-color: transparent;
  color: var(--accent);
}
.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 22px 0;
}
.stage {
  text-align: center;
  padding: 22px 0;
}
.tibetan {
  font-family: "Kailasa", "Noto Sans Tibetan", "Microsoft Himalaya", serif;
  font-weight: 400;
  line-height: 1.9;
}
.prompt-letter {
  font-size: 6rem;
  margin: 5px 0 12px;
}
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 20px auto;
  max-width: 600px;
}
.letter-choice {
  font-size: 3rem;
  padding: 8px 20px;
  background: #f8f8fe;
  border: 2px solid var(--line);
  border-radius: 16px;
  min-height: 108px;
}
.letter-choice:hover {
  border-color: var(--accent);
  background: var(--light);
}
.sound-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  flex-wrap: wrap;
}
.sound-choice .button {
  flex: 1;
}
.sound-choice.correct,
.correct {
  border-color: var(--green) !important;
  background: #e3f5ec !important;
}
.incorrect {
  border-color: var(--red) !important;
  background: #fff0f2 !important;
}
.feedback {
  min-height: 30px;
  text-align: center;
  font-weight: 650;
  margin: 16px 0;
  color: var(--muted);
}
.feedback[data-tone="good"] {
  color: var(--green);
}
.feedback[data-tone="bad"] {
  color: var(--red);
}
#audio-status,
#storage-status {
  font-size: 0.875rem;
  color: var(--red);
  line-height: 1.5;
}
#audio-status:empty,
#storage-status:empty {
  display: none;
}
.stats {
  margin-bottom: 24px;
}
.stats .metric {
  background: #f8f9fd;
  padding: 12px 16px;
  min-width: 90px;
}
.stats .metric strong {
  font-size: 1.2rem;
}
.instruction {
  max-width: 580px;
  margin: 12px auto;
  color: var(--muted);
}
/* Memory Match */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.memory-card {
  border: 2px solid var(--line);
  background: var(--light);
  border-radius: 14px;
  min-height: 124px;
  font-size: 2rem;
}
.memory-card.revealed {
  background: white;
}
.memory-card.matched {
  background: #e3f5ec;
  border-color: #87bea5;
  opacity: 1;
}
.memory-card small {
  display: block;
  font: 500 0.8rem system-ui;
  color: var(--muted);
}
.memory-card .tibetan {
  font-size: 2.7rem;
}
/* Letter Targets */
.arena {
  position: relative;
  overflow: hidden;
  height: 410px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(#f2f1ff, #fafaff);
  margin: 20px 0;
}
.target {
  position: absolute;
  width: 80px;
  min-height: 85px;
  border: 2px solid #b6afe5;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 0 #e1ddf5;
  font-size: 2.8rem;
  padding: 0;
}
.target:hover {
  background: var(--light);
  border-color: var(--accent);
}
.arena-label {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}
/* Alphabet Ordering */
.order-bank,
.order-slots {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 20px 0;
}
.order-tile,
.order-slot {
  min-width: 78px;
  min-height: 100px;
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 2.4rem;
  background: #fff;
  padding: 4px 12px;
}
.order-slot {
  border-style: dashed;
  background: #f7f7fc;
}
.order-slot.empty {
  font: 500 1rem system-ui;
  color: var(--muted);
}
.order-tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--light);
}
progress {
  width: 100%;
  height: 16px;
  accent-color: var(--accent);
}
/* End-of-round results */
.result {
  text-align: center;
}
.result h2 {
  font-size: 2rem;
}
.result-score {
  font-size: 3.5rem;
  font-weight: 750;
  color: var(--accent);
}
.stars {
  font-size: 2rem;
  color: #a66a00;
  letter-spacing: 6px;
}
.review-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}
.review-letters button {
  font-size: 2rem;
}
/* Learn flashcards */
.learn-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}
.learn-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.learn-card .tibetan {
  display: block;
  font-size: 3rem;
}
.learn-card small {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
  margin: 4px 0;
}
.learn-card:hover {
  border-color: var(--accent);
  background: var(--light);
}
.progress-list {
  display: grid;
  gap: 12px;
}
.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  flex-wrap: wrap;
}
.note {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 32px;
}
.pause-banner {
  padding: 16px;
  background: var(--light);
  border-radius: 12px;
  text-align: center;
  margin: 12px 0;
}
[hidden] {
  display: none !important;
}

/* Responsive layouts */
@media (max-width: 700px) {
  main {
    padding: 26px 18px 40px;
  }
  .nav-wrap {
    padding: 14px 18px;
    gap: 14px;
  }
  .nav a {
    padding: 8px 11px;
    font-size: 0.9rem;
  }
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .learn-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .panel {
    padding: 20px;
  }
  .game-header {
    flex-wrap: wrap;
  }
  .memory-card {
    min-height: 100px;
  }
  .sound-choice {
    padding: 12px;
  }
  .sound-choice .button {
    padding: 10px;
  }
  .stats .metric {
    min-width: 80px;
  }
  .arena {
    height: 350px;
  }
}
@media (max-width: 440px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .learn-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .nav {
    gap: 0;
  }
  .nav a {
    padding: 8px 10px;
  }
  .panel {
    padding: 16px;
  }
  .memory-grid {
    gap: 7px;
  }
  .memory-card {
    min-height: 92px;
  }
  .memory-card .tibetan {
    font-size: 2.2rem;
  }
  .choices {
    gap: 10px;
  }
  .target {
    width: 64px;
    min-height: 72px;
    font-size: 2.3rem;
  }
  .metric {
    padding: 12px;
    min-width: 110px;
  }
  .order-tile,
  .order-slot {
    min-width: 66px;
  }
  .sound-choice {
    flex-direction: column;
  }
  .sound-choice .button {
    width: 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
  .activity:hover {
    transform: none;
  }
}
