:root {
  --ink: #26353a;
  --muted: #6d7d7d;
  --line: #d9e3df;
  --paper: #fbfaf5;
  --panel: rgba(255, 255, 252, 0.86);
  --teal: #287a72;
  --teal-dark: #1d5d58;
  --coral: #df806d;
  --gold: #c79848;
  --shadow: 0 20px 60px rgba(33, 63, 60, 0.09);
}

body.dark-mode {
  --ink: #edf4f0;
  --muted: #b6c6c0;
  --line: #3a504b;
  --paper: #17211f;
  --panel: rgba(27, 40, 37, .94);
  --teal: #65c4b5;
  --teal-dark: #9be2d3;
  --coral: #f39a88;
  --gold: #e8c16a;
  background-image: radial-gradient(rgba(101, 196, 181, .08) .8px, transparent .8px), linear-gradient(135deg, #17211f 0%, #202d29 100%);
}

body.dark-mode::before { background: linear-gradient(180deg, rgba(44, 82, 73, .55), rgba(23, 33, 31, 0)); }
body.dark-mode .letter-button { color: var(--ink); background: #263833; }
body.dark-mode .letter-button:hover { color: var(--teal-dark); background: #315047; }
body.dark-mode .letter-button[aria-pressed="true"] { color: #17211f; background: var(--teal); }
body.dark-mode .lesson-image-slot { border-color: #45645b; background: #273934; }
body.dark-mode .vocabulary-bubble { border-color: #b9963d; background: #c5a84f; }
body.dark-mode .suggestion-form { border-color: #45645b; background: rgba(27, 40, 37, .9); }
body.dark-mode .suggestion-form input, body.dark-mode .suggestion-form textarea { color: var(--ink); border-color: #45645b; background: #21302c; }

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans Arabic", Tahoma, sans-serif;
  background-image: radial-gradient(rgba(40, 122, 114, 0.09) 0.8px, transparent 0.8px), linear-gradient(135deg, #fbfaf5 0%, #f4f7f0 100%);
  background-size: 18px 18px, 100% 100%;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0 0 auto;
  height: 320px;
  background: linear-gradient(180deg, rgba(216, 235, 221, 0.72), rgba(251, 250, 245, 0));
  clip-path: ellipse(78% 62% at 50% 0%);
}

.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 24px 0; }
.page-title { width: 100%; margin: 0 0 12px; color: var(--teal-dark); font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-size: clamp(20px, 2.4vw, 26px); font-weight: 700; line-height: 1.1; text-align: center; }
.intro { margin: 0; color: var(--muted); font-family: Amiri, serif; font-size: 20px; }
.alphabet-layout { display: grid; grid-template-columns: minmax(0, min(100%, calc((100vw + 700px) / 2))); justify-content: center; gap: 18px; align-items: stretch; direction: ltr; min-height: calc(100vh - 48px); }
.panel { direction: rtl; border: 1px solid rgba(205, 220, 214, .9); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.lesson-panel { min-height: 620px; padding: 28px 40px; animation: appear 700ms 180ms ease both; }
.panel h2 { margin: 2px 0 0; color: var(--ink); font-family: Amiri, serif; font-size: 31px; line-height: 1.2; }
.panel-heading { margin-bottom: 22px; text-align: center; }
.lessons-browser[hidden] { display: none; }
.letter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 0; }
.letter-button { position: relative; justify-self: stretch; width: 100%; min-height: 36px; padding: 3px 4px; border: 1px solid transparent; border-radius: 7px; color: var(--ink); background: #f3f6f0; cursor: pointer; font-family: Amiri, serif; font-size: 19px; line-height: 1.35; transition: transform 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease; }
.letter-button:hover { transform: translateY(-2px); color: var(--teal-dark); background: #e5f0e7; }
.letter-button[aria-pressed="true"] { color: white; background: var(--teal); box-shadow: 0 7px 16px rgba(40, 122, 114, .24); }
.reading-lesson { position: relative; max-width: 630px; margin: 4px auto 0; padding-bottom: 20px; text-align: center; }
.reading-lesson[hidden] { display: none; }
.lesson-navigation { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin: 0 0 14px; padding: 3px; border-bottom: 1px solid rgba(205, 220, 214, .9); }
.lesson-navigation-button { padding: 5px 10px 7px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-size: 14px; line-height: 1.4; transition: color 160ms ease, border-color 160ms ease, background 160ms ease; }
.lesson-navigation-button:hover, .lesson-navigation-button:focus-visible { color: var(--teal-dark); background: rgba(229, 240, 231, .55); outline: none; }
.lesson-navigation-button.is-active { border-bottom-color: var(--teal); color: var(--teal-dark); font-weight: 700; }
.lesson-navigation-button.utility-button { margin-inline-start: 2px; border: 1px solid rgba(40, 122, 114, .18); border-radius: 7px; padding: 4px 9px 6px; }
.lesson-navigation-button.utility-button.is-on { color: var(--teal-dark); background: rgba(229, 240, 231, .55); }
body.dark-mode .lesson-navigation-button.utility-button.is-on { background: rgba(101, 196, 181, .18); }
.suggestion-form { display: grid; gap: 10px; max-width: none; margin: 0 0 18px; padding: 24px 28px; border: 1px solid rgba(205, 220, 214, .9); border-radius: 12px; background: rgba(255, 255, 252, .72); text-align: right; }
.suggestion-form[hidden] { display: none; }
.section-view[hidden] { display: none; }
.letters-table-view[hidden] { display: none; }
.games-view[hidden] { display: none; }
.letters-poster { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; overflow: hidden; border: 2px solid var(--gold); border-radius: 10px; background: #f6efd8; box-shadow: var(--shadow); }
.letter-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 6px; border: 1px solid rgba(199, 152, 72, .4); }
.poster-letter-row { display: flex; align-items: baseline; justify-content: center; gap: 5px; }
.poster-letter { font-family: Amiri, serif; font-size: 40px; line-height: 1; }
.poster-name { display: flex; align-items: baseline; justify-content: center; gap: 4px; color: #4a3b28; font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-size: 12px; line-height: 1.25; }
.poster-ipa { color: var(--muted); font-size: 12px; }
.poster-decoration { color: var(--gold); font-size: 22px; }
.letter-card:nth-child(5n+1) .poster-letter { color: var(--teal-dark); }
.letter-card:nth-child(5n+2) .poster-letter { color: var(--coral); }
.letter-card:nth-child(5n+3) .poster-letter { color: var(--teal); }
.letter-card:nth-child(5n+4) .poster-letter { color: var(--gold); }
.letter-card:nth-child(5n+5) .poster-letter { color: var(--ink); }
body.sound-mode .poster-letter-row[data-audio], body.sound-mode .poster-name[data-audio] { cursor: pointer; }
.lesson-panel.suggestion-active .lesson-image-slot,
.lesson-panel.suggestion-active .reading-copy,
.lesson-panel.suggestion-active .vocabulary-bubble { display: none; }
.lesson-panel.section-active .lesson-image-slot,
.lesson-panel.section-active .reading-copy,
.lesson-panel.section-active .vocabulary-bubble,
.lesson-panel.section-active .suggestion-form { display: none; }
.section-view { display: grid; min-height: 620px; place-content: center; gap: 8px; color: var(--teal-dark); text-align: center; }
.section-view h2 { margin: 0; font-size: clamp(28px, 4vw, 44px); font-weight: 700; }
.section-view p { margin: 0; color: var(--muted); font-size: 16px; }
.section-view h2:empty, .section-view p:empty { display: none; }
.section-view.letters-only { min-height: 0; place-content: start stretch; gap: 0; }
.section-letters[hidden] { display: none; }
.section-letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(69px, 1fr)); gap: 10px; direction: rtl; width: 100%; }
.section-letter { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid rgba(199, 152, 72, .4); border-radius: 14px; color: var(--teal-dark); background: linear-gradient(145deg, #fffdf7, #f6efd8); box-shadow: 0 4px 0 rgba(199, 152, 72, .18); font-size: clamp(20px, 3.75vw, 30px); font-weight: 700; line-height: 1; cursor: default; transition: transform 160ms ease, box-shadow 160ms ease; }
.section-letter:hover { transform: translateY(-3px); box-shadow: 0 8px 14px rgba(40, 122, 114, .18); }
.section-letter:nth-child(4n+1) { color: var(--teal-dark); }
.section-letter:nth-child(4n+2) { color: var(--coral); }
.section-letter:nth-child(4n+3) { color: var(--teal); }
.section-letter:nth-child(4n+4) { color: var(--gold); }
body.dark-mode .section-letter { border-color: #45645b; background: linear-gradient(145deg, #2a3d38, #21302c); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }

.games-view { min-height: 620px; }
.games-catalogue { min-height: 620px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }
.game-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.game-card { min-width: 0; }
.game-art { position: relative; display: flex; align-items: center; justify-content: center; height: 100px; margin-bottom: 9px; overflow: hidden; border: 1px solid rgba(205, 220, 214, .9); border-radius: 12px; background: #edf5f0; }
.drawing-art::before { content: ""; width: 67px; height: 52px; border-radius: 8px; background: #fffdf7; box-shadow: 0 6px 0 rgba(40, 122, 114, .12); transform: rotate(-5deg); }
.art-pencil { position: absolute; top: 21px; right: 25%; color: #f5bb57; font-size: 22px; transform: rotate(24deg); }
.art-line { position: absolute; width: 35px; height: 17px; border: 5px solid #df806d; border-right: 0; border-bottom: 0; border-radius: 45px 0 0; transform: translate(-10px, 4px) rotate(-18deg); }
.art-dot { position: absolute; width: 13px; height: 13px; border: 3px solid #df806d; border-radius: 50%; transform: translate(14px, 7px); }
.coding-art { gap: 10px; direction: ltr; }
.coding-art::before { content: ""; position: absolute; width: 80px; height: 44px; border: 3px dashed #75a9a3; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; opacity: .7; }
.path-start, .path-target { z-index: 1; display: grid; width: 31px; height: 31px; place-items: center; border-radius: 9px; font-size: 18px; font-weight: 700; }
.path-start { color: #144b4e; background: #a8d9c5; transform: translate(-21px, 21px); }
.path-target { color: #713e55; background: #f1b4b2; transform: translate(20px, -20px); }
.path-arrow { z-index: 1; color: #f5bb57; font-size: 18px; transform: translateY(1px); }
.memory-art { gap: 8px; }
.memory-art span { display: grid; width: 37px; height: 48px; place-items: center; border-radius: 7px; color: #a45350; background: #f8d8ba; font-size: 23px; font-weight: 700; transform: rotate(-7deg); }
.memory-art span + span { color: #2f7270; background: #c8e2d7; transform: rotate(7deg); }
.colors-art { gap: 7px; }
.colors-art span { width: 25px; height: 43px; border-radius: 99px; background: #df806d; }
.colors-art span:nth-child(2) { height: 58px; background: #f6cf70; }
.colors-art span:nth-child(3) { background: #65b9ae; }
.game-card-placeholder { opacity: .72; }
.game-title-button { display: inline-flex; align-items: center; gap: 9px; padding: 0; border: 0; color: var(--teal-dark); background: transparent; cursor: pointer; font: inherit; font-size: 20px; font-weight: 700; text-decoration: none; }
.game-title-button span { direction: ltr; font-size: 23px; line-height: .6; }
.game-title-button:hover, .game-title-button:focus-visible { color: var(--coral); outline: none; }
.game-description { min-height: 42px; margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.drawing-game { max-width: 590px; margin: 0 auto; padding: 16px; border: 1px solid rgba(205, 220, 214, .9); border-radius: 16px; background: rgba(255, 255, 252, .72); }
.drawing-game[hidden], .games-catalogue[hidden] { display: none; }
.game-back-button { margin: 0 0 14px; padding: 0; border: 0; color: var(--teal-dark); background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.drawing-game-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.drawing-game-heading h3 { margin: 0; color: var(--teal-dark); font-size: 24px; }
.drawing-game-heading p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.game-badge { padding: 4px 9px; border-radius: 999px; color: #765521; background: #f6cf70; font-size: 12px; white-space: nowrap; }
#drawing-canvas { display: block; width: 100%; height: 300px; border: 2px dashed rgba(40, 122, 114, .35); border-radius: 12px; background: #fffdf7; cursor: crosshair; touch-action: none; }
.drawing-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.drawing-color, .drawing-size { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.drawing-color input { width: 30px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer; }
.drawing-size input { width: 82px; accent-color: var(--teal); }
.game-button { padding: 6px 10px; border: 0; border-radius: 7px; color: white; background: var(--teal); cursor: pointer; font: inherit; font-size: 12px; }
.game-button.secondary { margin-inline-start: auto; color: var(--teal-dark); background: rgba(40, 122, 114, .12); }
.drawing-status { min-height: 1.4em; margin: 9px 0 0; color: var(--muted); font-size: 12px; }
body.dark-mode .drawing-game { background: rgba(27, 40, 37, .9); }
body.dark-mode #drawing-canvas { background: #f8f5e9; }
.suggestion-form label { color: var(--ink); font-size: 14px; }
.suggestion-form input, .suggestion-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--ink); background: #fff; font: inherit; }
.suggestion-form textarea { resize: vertical; }
.suggestion-submit { justify-self: start; margin-top: 4px; padding: 7px 14px; border: 0; border-radius: 7px; color: white; background: var(--teal); cursor: pointer; font: inherit; }
.suggestion-submit:disabled { cursor: wait; opacity: .6; }
.suggestion-status { min-height: 1.5em; margin: 0; color: var(--teal-dark); font-size: 13px; }
.lesson-image-slot { display: grid; place-items: center; overflow: hidden; min-height: 153px; border: 1px solid #c9d9c6; border-radius: 15px; background: #f7f6e8; }
.lesson-image-slot img { display: block; width: 100%; height: 100%; min-height: 153px; object-fit: contain; }
.image-placeholder { margin: 0; color: var(--muted); font-family: Amiri, serif; font-size: 18px; }
.reading-copy { margin-top: 8px; color: #171c1c; font-family: Amiri, serif; font-size: clamp(24px, 3vw, 34px); font-weight: 700; line-height: 1.65; }
.reading-copy p { margin: 0; }
.audio-word { cursor: pointer; transition: color 160ms ease, transform 160ms ease; }
.audio-word:hover, .audio-word:focus-visible { color: var(--teal-dark); outline: none; }
.vocabulary-bubble { display: grid; place-content: center; gap: 0; width: 132px; height: 132px; margin: 20px auto 0 0; border: 1px solid #e2b94f; border-radius: 50%; background: #f6cf70; box-shadow: 0 8px 0 rgba(199, 152, 72, .14); transform: rotate(-4deg); }
.bubble-word { display: flex; flex-direction: column; align-items: center; order: 2; color: #c0392b; font-family: "Noto Sans Arabic", Tahoma, sans-serif; font-weight: 700; transform: rotate(4deg); }
.bubble-detail { order: 1; color: #1f292a; font-family: Amiri, serif; font-weight: 700; transform: rotate(4deg); }
.bubble-word { font-size: clamp(24px, 3vw, 34px); line-height: 1.1; cursor: pointer; transition: color 160ms ease, transform 160ms ease; }
.bubble-letter-character { display: block; width: 1em; height: 1.1em; line-height: 1.1; text-align: center; }
.bubble-letter-character[data-letter="ر"],
.bubble-letter-character[data-letter="ڕ"],
.bubble-letter-character[data-letter="ز"],
.bubble-letter-character[data-letter="ژ"] { transform: translateY(-0.45em); }
.bubble-word:hover, .bubble-word:focus-visible { color: var(--teal-dark); outline: none; }
.bubble-detail { font-size: clamp(24px, 3vw, 34px); line-height: 1.2; }
.letter-hero { display: flex; align-items: center; gap: 26px; margin-top: 31px; }
.big-letter-wrap { display: grid; flex: 0 0 156px; place-items: center; width: 156px; height: 156px; border: 1px solid rgba(199, 152, 72, .45); border-radius: 50%; background: #fffdf7; box-shadow: inset 0 0 0 10px rgba(247, 237, 213, .42); }
.big-letter { color: var(--coral); font-family: Amiri, serif; font-size: 108px; line-height: 1; transform: translateY(-5px); }
.letter-heading h2 { margin: 4px 0 4px; color: var(--teal-dark); font-family: Amiri, serif; font-size: 42px; }
.sound { margin: 0; color: var(--muted); font-family: Amiri, serif; font-size: 21px; }
.sound strong { color: var(--coral); direction: ltr; unicode-bidi: isolate; font-family: Georgia, serif; font-size: 19px; }
.lesson-divider { height: 1px; margin: 32px 0 24px; background: var(--line); }
.lesson-content { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.content-block + .content-block { border-right: 1px solid var(--line); padding-right: 28px; }
.word-card { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 12px; padding: 12px 15px; border-radius: 10px; background: #f8f1e3; }
.word { color: var(--teal-dark); font-family: Amiri, serif; font-size: 34px; line-height: 1.1; }
.word-meaning { color: var(--muted); font-family: Amiri, serif; font-size: 14px; }
.forms { display: flex; gap: 9px; margin-top: 12px; }
.form { display: grid; place-items: center; width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 9px; color: var(--teal-dark); background: #f7faf5; font-family: Amiri, serif; font-size: 28px; }
.form small { display: block; margin-top: -12px; color: var(--muted); font-family: "Noto Kufi Arabic", sans-serif; font-size: 8px; }
.lesson-note { display: flex; align-items: flex-start; gap: 10px; margin-top: 30px; padding: 14px 16px; border-right: 3px solid var(--coral); border-radius: 5px; background: #fff8f2; color: #6e6258; }
.note-icon { color: var(--gold); font-size: 14px; }
.lesson-note p { margin: 0; font-family: Amiri, serif; font-size: 16px; line-height: 1.8; }

.image-placeholder,
.reading-copy,
.bubble-word,
.bubble-detail {
  font-family: "Noto Sans Arabic", Tahoma, sans-serif;
}

.letter-button {
  font-family: "Noto Sans Arabic", Tahoma, sans-serif;
}
@keyframes appear { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 800px) { .page-shell { width: min(100% - 28px, 600px); padding-top: 28px; } .alphabet-layout { grid-template-columns: 1fr; min-height: 0; } .lesson-panel { padding: 28px 23px 23px; } }
@media (max-width: 560px) { .game-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 500px) { .intro { font-size: 17px; } .letter-hero { gap: 17px; } .big-letter-wrap { flex-basis: 112px; width: 112px; height: 112px; } .big-letter { font-size: 78px; } .letter-heading h2 { font-size: 34px; } .lesson-content { grid-template-columns: 1fr; gap: 22px; } .content-block + .content-block { border-right: 0; border-top: 1px solid var(--line); padding: 20px 0 0; } .word-card { display: block; } .word-meaning { display: block; margin-top: 4px; } }
