:root {
  --cocoa: #251b17;
  --cocoa-2: #3a2b25;
  --cream: #f4ede2;
  --paper: #fffaf2;
  --teal: #1c6963;
  --teal-light: #b9ded6;
  --coral: #ef7658;
  --gold: #d9ae69;
  --ink: #282320;
  --muted: #776d65;
  --line: #ded3c6;
  --shadow: 0 24px 60px rgba(42, 27, 20, .14);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  min-height: 78px;
  padding: 14px clamp(20px, 4vw, 64px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: var(--cocoa);
  color: white;
  border-bottom: 4px solid var(--teal);
}
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 2px solid var(--coral); border-radius: 50%;
  font-weight: 900; letter-spacing: -.06em;
}
.brand strong { display: block; font-size: 1.16rem; }
.brand small { display: block; color: var(--teal-light); font-size: .76rem; margin-top: 2px; }
.language-control { display: flex; align-items: center; gap: 12px; }
.language-control label { font-size: .82rem; color: #d9d0c8; }
.language-control select {
  color: white; background: #352721; border: 1px solid #695248;
  border-radius: 9px; min-height: 43px; padding: 0 36px 0 13px;
}

main { width: min(1460px, 100%); margin: 0 auto; padding: 46px clamp(20px, 4vw, 64px) 80px; }
.library-head { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 40px; }
.eyebrow { margin: 0 0 10px; color: var(--teal); font-weight: 850; font-size: .74rem; letter-spacing: .16em; }
h1 { max-width: 780px; margin: 0; color: var(--cocoa); font-size: clamp(2.25rem, 5vw, 4.6rem); line-height: .98; letter-spacing: -.055em; }
.intro { max-width: 700px; margin: 21px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.65; }
.coverage { min-width: 195px; padding: 23px 24px; border-left: 5px solid var(--coral); background: var(--paper); }
.coverage strong { display: block; color: var(--teal); font-size: 3rem; line-height: .9; }
.coverage span, .coverage small { display: block; }
.coverage span { margin-top: 8px; font-weight: 800; }
.coverage small { color: var(--muted); margin-top: 5px; }

.controls { margin-top: 42px; padding: 16px; background: var(--paper); border: 1px solid var(--line); display: flex; gap: 14px; align-items: center; }
.search-wrap { min-width: 280px; flex: 1; display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--cocoa); }
.search-wrap span { color: var(--teal); font-size: 1.55rem; }
.search-wrap input { width: 100%; padding: 13px 4px; border: 0; outline: 0; background: transparent; font-size: 1rem; }
.categories { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.category-button { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 9px 13px; border-radius: 999px; font-weight: 750; font-size: .82rem; }
.category-button:hover, .category-button.active { background: var(--teal); border-color: var(--teal); color: white; }

.workspace { margin-top: 20px; display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(360px, .68fr); gap: 20px; align-items: start; }
.catalog-panel, .guide-panel { background: var(--paper); border: 1px solid var(--line); }
.catalog-panel { padding: 24px; }
.catalog-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.catalog-meta h2 { margin: 0; color: var(--cocoa); font-size: 1.22rem; }
.catalog-meta span { color: var(--muted); font-size: .85rem; }
.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.game-card {
  position: relative; min-height: 174px; text-align: left; padding: 20px;
  border: 1px solid var(--line); background: white; color: inherit;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.game-card:hover { transform: translateY(-2px); border-color: var(--teal); box-shadow: 0 10px 28px rgba(39, 27, 21, .08); }
.game-card.active { border: 2px solid var(--teal); background: #f4fbf8; }
.game-num { color: var(--coral); font-weight: 900; font-size: .75rem; letter-spacing: .12em; }
.game-card h3 { margin: 18px 0 7px; font-size: 1.34rem; color: var(--cocoa); }
.game-card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.game-details { position: absolute; bottom: 17px; left: 20px; right: 20px; display: flex; justify-content: space-between; color: var(--teal); font-size: .75rem; font-weight: 800; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }

.guide-panel { position: sticky; top: 18px; overflow: hidden; box-shadow: var(--shadow); }
.guide-banner { background: var(--teal); color: white; padding: 24px 26px 22px; }
.guide-banner .eyebrow { color: var(--teal-light); }
.guide-banner h2 { margin: 0; font-size: 2rem; letter-spacing: -.035em; }
.guide-banner p { margin: 9px 0 0; color: #d9f0ec; }
.guide-body { padding: 25px 26px 28px; }
.quick-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 25px; }
.quick-facts div { background: var(--paper); padding: 13px 8px; text-align: center; }
.quick-facts strong { display: block; color: var(--cocoa); font-size: .92rem; }
.quick-facts span { display: block; color: var(--muted); font-size: .66rem; margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }
.instruction-list { list-style: none; padding: 0; margin: 0; }
.instruction-list li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); line-height: 1.47; }
.instruction-list strong { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: var(--cocoa); color: white; font-size: .75rem; }
.guide-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.primary-button, .secondary-button { min-height: 46px; border-radius: 6px; padding: 0 15px; font-weight: 850; }
.primary-button { border: 0; background: var(--coral); color: white; }
.primary-button:hover { background: #d95d42; }
.secondary-button { border: 1px solid var(--cocoa); background: transparent; color: var(--cocoa); }

.school-note { margin-top: 20px; background: var(--cocoa); color: white; padding: clamp(28px, 5vw, 54px); display: grid; grid-template-columns: .65fr 1.35fr; gap: 12px 50px; }
.school-note .eyebrow { color: var(--teal-light); grid-column: 1 / -1; }
.school-note h2 { margin: 0; max-width: 440px; font-size: clamp(1.8rem, 3vw, 3.1rem); line-height: 1.05; }
.school-note p { margin: 0; color: #e2d8cf; line-height: 1.65; font-size: 1.02rem; }
.school-note small { grid-column: 2; color: #bcaea4; line-height: 1.5; }

.qr-dialog { width: min(430px, calc(100% - 30px)); border: 0; border-radius: 12px; padding: 32px; color: var(--ink); background: var(--paper); box-shadow: 0 28px 90px rgba(0,0,0,.35); text-align: center; }
.qr-dialog::backdrop { background: rgba(27, 19, 15, .74); backdrop-filter: blur(3px); }
.qr-dialog h2 { margin: 0 0 16px; font-size: 1.7rem; }
.close-button { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 1.8rem; color: var(--muted); }
.qr-code { width: 248px; height: 248px; margin: 10px auto 16px; padding: 12px; background: white; border: 1px solid var(--line); }
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.copy-status { display: block; min-height: 20px; margin-top: 8px; color: var(--teal); font-size: .82rem; font-weight: 800; }
.rules-note { margin: 20px 0 0; padding: 18px 20px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); line-height: 1.55; font-size: .88rem; }
.rules-note strong { color: var(--cocoa); }
[dir="rtl"] .game-card, [dir="rtl"] .guide-panel, [dir="rtl"] .rules-note { text-align: right; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .guide-panel { position: static; order: -1; }
  .library-head { grid-template-columns: 1fr; }
  .coverage { width: 210px; }
  .school-note { grid-template-columns: 1fr; }
  .school-note small { grid-column: 1; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .language-control { flex-direction: column; align-items: flex-start; gap: 4px; }
  .controls { align-items: stretch; flex-direction: column; }
  .categories { justify-content: flex-start; }
  .game-grid { grid-template-columns: 1fr; }
  .guide-actions { grid-template-columns: 1fr; }
  main { padding-top: 32px; }
}
