/* «ألعاب الجرنال» — an old Egyptian newspaper sheet lying on a wooden table, same as the TikTok series.
   One deliberate look, so no dark theme: black ink and one red on aged paper. The only other colour is
   the paper itself: each game is printed on its own tinted newsprint (salmon, yellow, pale green), and
   what the reader writes is blue ballpoint. */
/* The fonts ship with the site so the installed app looks the same offline. */
/* Each face is split like Google Fonts: an Arabic file and a Latin file (brackets, punctuation, minus sign). */
@font-face { font-family: 'Aref Ruqaa'; font-weight: 700; font-display: swap; src: url('fonts/aref-ruqaa-arabic-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Amiri'; font-weight: 400; font-display: swap; src: url('fonts/amiri-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Amiri'; font-weight: 400; font-display: swap; src: url('fonts/amiri-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Amiri'; font-weight: 700; font-display: swap; src: url('fonts/amiri-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Amiri'; font-weight: 700; font-display: swap; src: url('fonts/amiri-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Reem Kufi'; font-weight: 700; font-display: swap; src: url('fonts/reem-kufi-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Reem Kufi'; font-weight: 700; font-display: swap; src: url('fonts/reem-kufi-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --paper: #efe5cf;
  --paper-hi: #f6eedb;
  --ink: #1d1a16;
  --faded: #6b6252;
  --pen: #1f4fbf;
  --stamp: #a8261d;
  --ok: #2f6b34;      /* green pen, for ticks only */
  --wood: #4a3222;
  --wood-dk: #2e1f15;
  --rule: rgba(29, 26, 22, 0.85);
  /* coloured newsprint, one sheet per game */
  --sheet-salmon: #efd2bd;
  --sheet-yellow: #efe0a8;
  --sheet-green: #dcdfc4;
  --hl: #f1e3ae;      /* highlighter: the current word / row */
  --hl-strong: #e6cc77;
  --accent: var(--ink);
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.27  0 0 0 0 0.15  0 0 0 0.09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --ruqaa: 'Aref Ruqaa', 'Amiri', 'Times New Roman', serif;
  --amiri: 'Amiri', 'Times New Roman', serif;
  --kufi: 'Reem Kufi', 'Amiri', 'Segoe UI', sans-serif;
  color-scheme: light;
}

[data-game="crossword"] { --sheet: var(--sheet-salmon); }
[data-game="sudoku"] { --sheet: var(--sheet-green); }
[data-game="charades"] { --sheet: var(--sheet-yellow); }
[data-game="wordsearch"], [data-game="secret"] { --sheet: #d9dde0; } /* pale blue-grey newsprint */

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* hidden always wins over component display rules */
html, body { margin: 0; }
body {
  background: var(--wood-dk);
  color: var(--ink);
  font-family: var(--amiri);
  font-size: 19px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }

/* the table + the sheet */
.table {
  min-height: 100vh;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.07) 0 2px, transparent 2px 9px, rgba(255,255,255,0.03) 9px 11px, transparent 11px 23px),
    linear-gradient(160deg, var(--wood) 0%, var(--wood-dk) 100%);
  padding-block: 28px 48px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.paper {
  position: relative;
  max-width: 1060px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(120, 90, 40, 0.18) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.27  0 0 0 0 0.15  0 0 0 0.09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(255, 255, 255, 0.4) inset;
  padding: 26px 34px 30px;
}
/* the fold down the middle of the sheet */
.paper::after {
  content: '';
  position: absolute;
  inset: 0 50% 0 auto;
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(80, 60, 30, 0.12) 15%, rgba(80, 60, 30, 0.12) 85%, transparent);
  pointer-events: none;
}

/* masthead: «الجرنال» between two small ear buttons (download the app · notifications) */
.masthead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; }
.masthead > .rule, .masthead > .notice { grid-column: 1 / -1; }
.title {
  grid-column: 2;
  display: inline-block;
  font-family: var(--ruqaa);
  font-weight: 700;
  font-size: clamp(42px, 11vw, 108px);
  line-height: 1.1;
  padding-bottom: 0.12em; /* room for the descenders above the rule */
  white-space: nowrap;
  text-decoration: none;
}
.ear-btn {
  grid-row: 1;
  width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper-hi); color: var(--ink);
  cursor: pointer;
}
#installBtn { grid-column: 1; justify-self: start; }
#bellBtn { grid-column: 3; justify-self: end; }
.ear-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ear-btn:hover { background: var(--hl); }
.ear-btn.on { background: var(--sheet-yellow); }
.ear-btn.on svg { fill: var(--ink); }
.notice {
  position: relative; text-align: right;
  margin-top: 10px; padding: 10px 14px 10px 40px;
  border: 2px solid var(--ink); background: var(--hl);
  font-size: 17px;
}
.notice b { display: block; font-family: var(--kufi); }
.notice .steps { margin: 4px 0 0; padding: 0 22px 0 0; list-style: arabic-indic; }
.notice .x { position: absolute; top: 4px; left: 6px; border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--faded); cursor: pointer; padding: 4px 6px; }
.rule { border-top: 3px solid var(--rule); }
.rule.double { border-top: 3px solid var(--rule); border-bottom: 2px solid var(--stamp); height: 7px; margin-top: 2px; }

/* section bar, like the tabs on every page of the episodes */
.bar { display: flex; align-items: center; gap: 14px; margin: 26px 0 12px; }
.bar > span {
  background: var(--sheet, var(--ink)); color: var(--ink);
  border: 2px solid var(--ink);
  font-family: var(--kufi); font-weight: 700; font-size: 20px;
  padding: 2px 18px 6px;
  white-space: nowrap;
}
.bar::after { content: ''; flex: 1; height: 3px; background: var(--ink); }
.bar > span { color: var(--paper); }
[data-game="crossword"] .bar > span, [data-game="sudoku"] .bar > span, [data-game="charades"] .bar > span, [data-game="wordsearch"] .bar > span, [data-game="secret"] .bar > span { color: var(--ink); }

h1, h2, h3 { margin: 0; font-weight: 700; text-wrap: balance; }
.headline { font-family: var(--ruqaa); font-size: clamp(38px, 7vw, 60px); line-height: 1.25; }
.deck { color: var(--faded); font-size: 18px; margin: 2px 0 0; }
.muted { color: var(--faded); }
.num { font-variant-numeric: tabular-nums; }

/* buttons look like printed coupons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--kufi); font-weight: 700; font-size: 17px;
  padding: 6px 18px 9px;
  border: 2px solid var(--accent);
  background: var(--accent); color: var(--paper);
  cursor: pointer; text-decoration: none;
  line-height: 1.3;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { font-size: 15px; padding: 3px 12px 6px; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- «نزّل التطبيق» card at the top of the front page (only while the app isn't installed) ---------- */
.cta {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px 16px;
  margin-top: 22px; padding: 14px 18px 14px 46px;
  border: 3px double var(--ink); outline: 1px solid var(--ink); outline-offset: 3px;
  background: var(--paper-hi);
}
.cta img { width: 64px; height: 64px; border: 2px solid var(--ink); }
.cta b { display: block; font-family: var(--ruqaa); font-size: 28px; line-height: 1.3; }
.cta span { font-size: 16px; color: var(--faded); }
.cta .btn { font-size: 18px; padding: 8px 22px 11px; }
.cta .x { position: absolute; top: 4px; left: 6px; border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--faded); cursor: pointer; padding: 4px 6px; }
.notice .btn { margin-top: 8px; }

/* ---------- front page: three sheets of coloured newsprint, then the leaderboard ---------- */
.daybar { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; gap: 10px; margin-top: 24px; touch-action: pan-y; }
.daynav {
  width: 52px; height: 52px; display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper-hi);
  font-size: 26px; line-height: 1; text-decoration: none; color: var(--ink);
}
a.daynav:hover { background: var(--hl); }
span.daynav { visibility: hidden; }
.dayname { text-align: center; }
.dayname b { display: block; font-family: var(--ruqaa); font-size: clamp(36px, 7vw, 52px); line-height: 1.15; }
.dayname span { color: var(--faded); font-size: 17px; }
/* the day's games: as many as were published, each a sheet of coloured newsprint */
/* the day's games: a 2×2 grid (any number of games fills it row by row) */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 300px)); justify-content: center; gap: 22px; margin-top: 20px; touch-action: pan-y; }
.tile {
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 14px 16px;
  background-color: var(--sheet);
  background-image: var(--grain);
  border: 1px solid rgba(29, 26, 22, 0.25);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12), 3px 5px 10px rgba(60, 40, 20, 0.16);
  text-decoration: none; color: var(--ink);
  transition: transform 0.15s;
}
.tile:nth-child(4n + 1) { transform: rotate(-0.6deg); }
.tile:nth-child(4n) { transform: rotate(0.5deg); }
.tile:hover { transform: translateY(-3px) rotate(0deg); }
.tile .art { display: block; flex: none; aspect-ratio: 1; border: 2px solid var(--ink); background: var(--paper-hi); overflow: hidden; }
.tile .art svg, .tile .art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile .meta { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; flex: 1; }
.tile h3 a { text-decoration: none; }
.tile .meta .stamp.small { position: absolute; top: 0; left: 0; margin: 0; font-size: 18px; }
.btn.big { width: 100%; font-size: 20px; padding: 9px 16px 13px; margin-top: auto; }
.tile .kind { font-family: var(--kufi); font-size: 14px; color: var(--faded); }
.tile h3 { font-family: var(--ruqaa); font-size: 36px; line-height: 1.2; }
.tile .sub { color: var(--faded); }
.tag { margin-top: 6px; font-family: var(--kufi); font-size: 16px; padding: 2px 16px 6px; border: 2px solid var(--ink); }
.tag.go { background: var(--ink); color: var(--paper); }
.stamp.small { margin-top: 6px; font-size: 22px; padding: 0 12px 4px; border-width: 3px; animation: none; }
.empty-day { margin: 28px 0 12px; text-align: center; font-size: 19px; color: var(--faded); }
.lb { max-width: 640px; margin: 10px auto 0; }
.lb .board { font-size: 19px; }
.you { margin: 12px 0 0; text-align: center; font-size: 17px; }

/* the reader's own card */
.card {
  border: 3px double var(--ink);
  outline: 1px solid var(--ink); outline-offset: 3px;
  padding: 14px 16px;
  background: var(--paper-hi);
}
.card .who { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .who b { font-size: 22px; }
.card .pts { font-family: var(--ruqaa); font-size: 46px; line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; border-top: 1px solid var(--rule); margin-top: 10px; padding-top: 8px; }
.stats b { display: block; font-size: 22px; line-height: 1.2; }
.stats span { font-size: 13px; color: var(--faded); }
.namebox { display: flex; gap: 6px; margin-top: 10px; }
.namebox input {
  flex: 1; min-width: 0;
  border: 0; border-bottom: 2px dotted var(--ink);
  background: transparent; font-size: 18px; color: var(--pen); padding: 2px 4px;
}
.namebox input:focus { outline: none; border-bottom-style: solid; }

/* leaderboard table */
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th { font-family: var(--kufi); font-size: 14px; color: var(--faded); text-align: right; font-weight: 700; padding: 4px 6px; border-bottom: 2px solid var(--ink); }
.board td { padding: 6px; border-bottom: 1px dotted var(--rule); }
.board td:first-child { width: 2.6em; font-weight: 700; }
.rank { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; line-height: 1; }
.rank.r1 { background: var(--sheet-yellow); box-shadow: inset 0 0 0 2px var(--ink); }
.rank.r2 { background: var(--sheet-green); }
.rank.r3 { background: var(--sheet-salmon); }
.board td:last-child, .board th:last-child { text-align: left; font-weight: 700; }
.board tr.me td { color: var(--pen); }
.board .empty td { text-align: center; color: var(--faded); padding: 18px 6px; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { border: 2px solid var(--ink); background: transparent; font-family: var(--kufi); font-size: 15px; padding: 2px 14px 5px; cursor: pointer; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.note { font-size: 15px; color: var(--faded); margin: 10px 0 0; }

/* ---------- play pages ---------- */
.playhead .headline { margin-top: 10px; line-height: 1.4; }
.playhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.ptschip { border: 2px solid var(--ink); background: var(--sheet, var(--paper-hi)); padding: 2px 14px 6px; font-size: 18px; white-space: nowrap; }
.ptschip b { font-size: 24px; }
.ptschip.done { border-color: var(--stamp); color: var(--stamp); }
.back { font-family: var(--kufi); font-size: 15px; text-decoration: none; color: var(--faded); }
.back:hover { color: var(--ink); }
.boardgrid > * { min-width: 0; }
.boardgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 26px; align-items: start; margin-top: 16px; }
.play { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 26px; align-items: start; margin-top: 16px; }

/* crossword grid: right-to-left, column 0 on the right */
.xw {
  --cell: min(58px, calc((100vw - 80px) / 7));
  display: grid; direction: rtl;
  grid-template-columns: repeat(var(--n), var(--cell));
  border: 3px solid var(--ink);
  width: max-content; max-width: 100%;
  background: var(--ink);
  gap: 2px;
}
.xw .cell { position: relative; width: var(--cell); height: var(--cell); background: var(--paper-hi); }
.xw .cell.block { background: var(--ink); background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(239, 229, 207, 0.07) 4px 5px); }
.xw .cell input {
  width: 100%; height: 100%; border: 0; padding: 0; margin: 0;
  background: transparent; text-align: center;
  font-family: var(--amiri); font-weight: 700; font-size: calc(var(--cell) * 0.56);
  color: var(--pen); caret-color: transparent; border-radius: 0;
}
.xw .cell input:focus { outline: none; }
.xw .cell.word { background: var(--hl); }
.xw .cell.cur { background: var(--hl-strong); }
.xw .cell.bad input { color: var(--stamp); text-decoration: line-through; }
.xw .cell.given input { color: var(--ink); }
.xw .cell sup { position: absolute; top: 1px; right: 3px; font-size: 11px; line-height: 1; pointer-events: none; font-weight: 700; }
.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.clues h4 { font-family: var(--kufi); font-size: 17px; margin: 0 0 4px; color: var(--accent); border-bottom: 2px solid var(--accent); }
.clues ol { list-style: none; margin: 0; padding: 0; }
.clues li { padding: 4px 6px; cursor: pointer; font-size: 17px; line-height: 1.45; }
.clues li b { margin-left: 6px; }
.clues li.on { background: var(--hl); }
.clues li.solved { color: var(--faded); text-decoration: line-through; text-decoration-color: var(--pen); }
.xwwrap { width: max-content; max-width: 100%; }
.cluebar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: stretch;
  margin-bottom: 8px; border: 2px solid var(--ink); background: var(--hl);
}
.cluebar .cnav { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--ink); }
.cluebar .cnav:first-child { border-left: 1px solid var(--ink); }
.cluebar .cnav:last-child { border-right: 1px solid var(--ink); }
.curclue { border: 0; background: transparent; text-align: right; font-size: 18px; line-height: 1.45; min-height: 3.1em; padding: 6px 10px; cursor: pointer; color: var(--ink); }
.curclue b { font-family: var(--kufi); margin-left: 6px; }

/* كلمة السر */
.rule { font-family: var(--ruqaa); font-size: 26px; margin: 8px 0 10px; }
.secret { list-style: arabic-indic; margin: 0; padding: 0 26px 0 0; max-width: 560px; }
.secret li { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 4px; border-bottom: 1px dotted var(--rule); font-size: 20px; }
.secret .a { color: var(--faded); white-space: nowrap; }
.secret .a b { color: var(--stamp); font-size: 1.15em; }
.secretboxes { justify-content: flex-start; margin-top: 16px; }
.secretboxes span { width: 46px; height: 54px; font-size: 30px; }
.older-note { display: block; margin-top: 4px; font-size: 15px; color: var(--faded); }

/* الكلمة المستخبية */
.wsclue { font-family: var(--ruqaa); font-size: 30px; margin: 8px 0 12px; }
.ws {
  --cell: min(64px, calc((100vw - 60px) / var(--cols)));
  display: grid; direction: rtl; grid-template-columns: repeat(var(--cols), var(--cell));
  width: max-content; max-width: 100%; border: 3px solid var(--ink); background: var(--paper-hi);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ws .cell {
  width: var(--cell); height: var(--cell); display: grid; place-items: center;
  border-left: 1px solid rgba(29, 26, 22, 0.3); border-bottom: 1px solid rgba(29, 26, 22, 0.3);
  font-weight: 700; font-size: calc(var(--cell) * 0.55); cursor: pointer;
}
.ws .cell.sel, .ws .cell.anchor { background: var(--hl-strong); }
.ws .cell.hinted { box-shadow: inset 0 0 0 3px var(--pen); color: var(--pen); }
.ws .cell.wrong { background: #e8b8a8; }
.ws .cell.found { background: var(--hl-strong); color: var(--stamp); }
.wshow { margin: 10px 0 0; font-size: 16px; }

/* sudoku */
.sd {
  --cell: min(50px, calc((100vw - 74px) / 9));
  display: grid; grid-template-columns: repeat(9, var(--cell));
  border: 3px solid var(--ink); width: max-content; max-width: 100%; background: var(--paper-hi);
}
/* the grid runs left → right (dir="ltr"), so box lines sit on the RIGHT of columns 3 and 6 */
.sd .cell { width: var(--cell); height: var(--cell); border-right: 1px solid rgba(29,26,22,0.45); border-bottom: 1px solid rgba(29,26,22,0.45); position: relative; }
.sd .cell.c2, .sd .cell.c5 { border-right: 3px solid var(--ink); }
.sd .cell.r2, .sd .cell.r5 { border-bottom: 3px solid var(--ink); }
.sd .cell.c8 { border-right: 0; }
.sd .cell.r8 { border-bottom: 0; }
.sd input {
  width: 100%; height: 100%; border: 0; padding: 0; background: transparent; text-align: center;
  font-family: var(--amiri); font-weight: 700; font-size: calc(var(--cell) * 0.58); color: var(--pen); caret-color: transparent; border-radius: 0;
}
.sd input:focus { outline: none; }
.sd .cell.given input { color: var(--ink); }
.sd .cell.peer { background: #e9e6c9; background: color-mix(in srgb, var(--accent) 12%, var(--paper-hi)); }
.sd .cell.same input { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.sd .cell.cur { background: var(--hl-strong); }
.sd .cell.bad input { color: var(--stamp); }
.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 360px; margin-top: 14px; }
.pad button { border: 2px solid var(--accent); color: var(--accent); background: var(--paper-hi); font-family: var(--amiri); font-weight: 700; font-size: 24px; padding: 2px 0 4px; cursor: pointer; }
.pad button.erase { font-family: var(--kufi); font-size: 15px; }

/* بدون كلام */
.cluechips { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.cluechips span { color: var(--accent); border: 2px solid var(--accent); padding: 2px 14px 5px; font-family: var(--kufi); font-size: 17px; background: var(--paper-hi); }
/* scenes sit side by side (first scene on the right) and stay small, so the answer box is on screen */
.panels { display: grid; grid-template-columns: repeat(var(--count, 2), minmax(0, 190px)); gap: 18px; }
.panel { position: relative; }
.panel .frame { border: 3px solid var(--ink); background: #fffaeb; box-shadow: 0 6px 12px rgba(0,0,0,0.13); overflow: hidden; }
.panel:nth-child(odd) .frame { transform: rotate(0.6deg); }
.panel:nth-child(even) .frame { transform: rotate(-0.5deg); }
.panel video, .panel img { display: block; width: 100%; height: auto; aspect-ratio: 390 / 420; object-fit: cover; }
.panel .n {
  position: absolute; top: -12px; right: -8px; z-index: 1;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--paper); border: 3px solid var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; line-height: 1;
}
.letters { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 10px; direction: rtl; }
.letters span {
  width: 30px; height: 38px;
  border: 2px solid var(--ink); background: var(--paper-hi);
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px; line-height: 1; color: var(--pen);
}
.letters span.given { color: var(--ink); }
.letters.won span { color: var(--stamp); }
.letterline { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 4px; }
.answer { display: flex; gap: 8px; margin-top: 14px; max-width: 520px; }
.answer input {
  flex: 1; min-width: 0;
  border: 0; border-bottom: 2px solid var(--ink); background: transparent;
  font-size: 26px; font-weight: 700; color: var(--pen); padding: 2px 6px;
}
.answer input:focus { outline: none; border-bottom-color: var(--pen); }
.msg { min-height: 1.6em; margin: 8px 0 0; font-weight: 700; }
.msg.bad { color: var(--stamp); }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* rubber stamp when a game is solved */
.stamp {
  display: inline-block;
  border: 4px solid var(--stamp); color: var(--stamp);
  font-family: var(--ruqaa); font-size: 34px; line-height: 1.2;
  padding: 2px 18px 8px;
  transform: rotate(-6deg);
  box-shadow: inset 0 0 0 2px rgba(168, 38, 29, 0.25);
  opacity: 0.88;
  animation: stampin 0.35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes stampin { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } }
.result { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding: 14px 16px; border: 2px solid var(--ink); background: var(--paper-hi); max-width: 560px; }
.result > * { min-width: 0; }
.result .top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.result p { margin: 0; }
.result .namebox { margin-top: 6px; }

/* solved: a green pen tick + the points (no dot that reads like a zero) */
.btn .tick { width: 1.15em; height: 1.15em; fill: none; stroke: var(--ok); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ic { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn.big.done { gap: 6px; }
.btn.big.done .tick { width: 1.4em; height: 1.4em; }

/* leaderboard: the streak, small and red, after the name; a «…» row before the reader when they're further down */
.board .sk { font-size: 0.72em; color: var(--stamp); white-space: nowrap; margin-inline-start: 4px; }
.board tr.gap td { text-align: center; color: var(--faded); padding-block: 0; letter-spacing: 4px; }
.note.total { text-align: center; }
.sharerow { display: flex; justify-content: center; margin-top: 18px; }

/* share sheet */
.sharebox { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(29, 20, 12, 0.55); }
.sharebox .sheet {
  position: relative; width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 16px;
  background: var(--paper); background-image: var(--grain); border: 2px solid var(--ink);
}
.sharebox .pic { aspect-ratio: 4 / 5; display: grid; place-items: center; border: 1px solid var(--rule); background: var(--paper-hi); }
.sharebox .pic img { display: block; width: 100%; height: 100%; }
.sharebox .row { justify-content: center; }
.sharebox .row .btn:first-child:not([hidden]) { flex: 1 1 100%; font-size: 19px; }
.sharebox .x { position: absolute; top: -2px; left: 4px; border: 0; background: transparent; font-size: 30px; line-height: 1; color: var(--ink); cursor: pointer; padding: 6px; z-index: 1; }

@media (max-width: 860px) {
  .play, .boardgrid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .cta { grid-template-columns: auto minmax(0, 1fr); padding: 12px 14px; }
  .cta .txt { padding-left: 22px; }
  .cta b { font-size: 24px; }
  .cta .btn { grid-column: 1 / -1; width: 100%; font-size: 19px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
  .tile { padding: 9px 9px 11px; gap: 8px; }
  .tile h3 { font-size: 24px; }
  .tile .sub { font-size: 14px; line-height: 1.4; }
  .tile .btn.big { font-size: 17px; padding: 6px 10px 9px; }
  .tile .meta .stamp.small { font-size: 14px; padding: 0 8px 3px; }
  body { font-size: 18px; }
  .table { padding-block: 0 24px; padding-left: 0; padding-right: 0; }
  .paper {
    padding-block: 16px 22px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .paper::after { display: none; }
  .clues { grid-template-columns: 1fr; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .stamp, .shake { animation: none; }
  .btn:hover { transform: none; }
}
