@font-face {
  font-family: Amiri;
  src: url("../fonts/amiri.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #1d2430;
  --muted: #5c6b78;
  --sand: #efe2cc;
  --paper: #fffaf3;
  --line: #e2d3ba;
  --coral: #c4512c;
  --teal: #1d6b63;
  --navy: #1c3348;
  --gold: #8a5a12;
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background:
    linear-gradient(#1d6b63 0 7px, transparent 7px),
    var(--sand);
  color: var(--ink);
  font: 1rem/1.45 "Segoe UI", system-ui, sans-serif;
}
button, a { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
#app { max-width: 980px; margin: 0 auto; padding: 28px 16px 72px; }
.top h1, .play h1, .result h1, .letter-name, .sheet h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1.12;
  margin: 4px 0 8px;
}
.top h1 { font-size: 2.5rem; }
.mark {
  margin: 0;
  color: var(--coral);
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: .76rem;
}
.lead, .prompt { font-size: 1.12rem; }
.back, .btn-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--navy);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sample, .level, .page, .sheet, .play, .result {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.sample { padding: 18px 18px 8px; margin: 18px 0 8px; }
.sample h2, .block-title { margin: 4px 0 8px; font-size: 1.28rem; }
.block-title { margin-top: 22px; }
.fact {
  background: #f4ead8;
  border-left: 4px solid var(--coral);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}
.forms, .levels, .pages, .choices, .grid-cells, .memory, .strip {
  display: grid;
  gap: 10px;
}
.forms { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 12px 0 16px; }
.forms.pair { grid-template-columns: repeat(2, minmax(120px, 200px)); justify-content: center; }
.form, .tile, .level, .page, .choice, .cell, .mem {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  color: var(--ink);
}
.form, .tile { text-align: center; padding: 10px 8px 8px; }
.form span, .tile span, .choice span, .blurb, .lvl-text, .lvl-meta { display: block; color: var(--muted); }
.ar {
  font-family: Amiri, "Noto Naskh Arabic", serif;
  line-height: 1.45;
  display: inline-block;
  color: var(--ink);
}
.form .ar, .tile .ar, .choice .ar, .cell .ar, .mem .ar { color: var(--ink); }
.form-ar, .tile-ar { font-size: 3.15rem; line-height: 1.55; padding: 0 4px; }
.hero {
  font-size: 4.6rem;
  line-height: 1.55;
  display: block;
  text-align: center;
  margin: 4px 0 8px;
}
.fact-ar { font-size: 1.7rem; line-height: 1; vertical-align: -6px; padding: 0 2px; }
.levels { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.level, .page { text-align: left; padding: 14px 16px 16px; }
.level strong, .page strong { display: block; margin: 2px 0; font-size: 1.18rem; color: var(--ink); }
.lvl { color: var(--teal); font-weight: 800; }
.strip { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); margin-bottom: 8px; }
.pages { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.page-no { color: var(--navy); font-weight: 800; }
.diff {
  display: inline-block;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3eee4;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.diff.легко { color: var(--teal); }
.diff.средне { color: var(--gold); }
.diff.сложнее { color: var(--coral); }
.stars { color: var(--coral); font-weight: 700; }
.page.done { box-shadow: inset 4px 0 0 var(--teal); }
.play, .result, .sheet { padding: 18px 18px 20px; }
.play { margin-top: 8px; }
.playbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.play-title { font-weight: 800; color: var(--navy); }
.meter {
  height: 6px;
  margin: 8px 0 0;
  background: #e7dcc8;
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill { display: block; height: 100%; background: var(--teal); }
.choices { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.choice, .cell, .mem {
  min-height: 76px;
  padding: 10px;
  text-align: center;
}
.choice-ar { font-size: 2.5rem; line-height: 1.3; }
.choice.lone .choice-ar, .cell .choice-ar { font-size: 3.3rem; line-height: 1.55; }
.choice.good, .cell.good, .mem.good { border-color: var(--teal); background: #e5f4f1; }
.choice.bad, .cell.bad { border-color: var(--coral); background: #fde8e2; }
.choice.picked, .cell.picked { outline: 3px solid var(--navy); outline-offset: 0; }
.choice:disabled { opacity: 1; }
.go, .ghost {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--coral);
  color: #fff;
  font-weight: 800;
}
.ghost { background: var(--navy); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.feedback { display: none; margin-top: 16px; }
.feedback.show { display: block; padding: 12px 14px; border-radius: 14px; }
.feedback p { margin: 6px 0 0; }
.feedback .go { margin-top: 12px; }
.feedback.good { background: #e5f4f1; }
.feedback.bad { background: #fde8e2; }
.grid-cells, .memory { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 8px; }
.mem { position: relative; }
.mem-face { display: none; }
.mem.open .mem-face, .mem.good .mem-face { display: inline; }
.mem.open .mem-back, .mem.good .mem-back { display: none; }
.mem-back { font-size: 1.6rem; font-weight: 800; color: var(--navy); }
.mem .mem-face { font-size: 1.05rem; }
.sheet {
  position: fixed;
  z-index: 21;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  box-shadow: 0 18px 50px #1d243044;
}
.veil {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: #1d243073;
}
.sub { color: var(--muted); }
.gap-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin: 4px 0;
}
.gap-ar { font-size: 3.2rem; }
.gap-miss { font-size: 2.4rem; color: var(--coral); font-weight: 800; }
.result { margin-top: 12px; }
@media (hover: hover) {
  .level:hover, .page:hover, .choice:hover, .cell:hover, .tile:hover, .mem:hover {
    border-color: var(--teal);
  }
}
@media (max-width: 700px) {
  html { font-size: 17px; }
  .forms, .memory, .grid-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { font-size: 3.6rem; }
  .playbar { flex-wrap: wrap; }
}
