/* Cross-World Puzzles - phone first, then a two-column layout on wide screens. */

/* Bengali is the one script older computers often lack, so it ships with
   the site (Noto Sans Bengali, SIL Open Font License). The unicode-range
   means a browser only downloads it when it actually has Bengali to draw.
   Served from our own files, not Google, which is blocked in mainland China. */
@font-face {
  font-family: "CW Bengali";
  src: url("../fonts/noto-sans-bengali.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+25CC;
}

:root {
  --cell: 37px;
  --ink: #1b1f2a;
  --line: #222;
  --block: #000;
  --bc: #f7a39a;           /* salmon, as on the current site */
  --word: #ffe9b8;         /* the rest of the current word */
  --solved: #86fa72;       /* green, as on the current site */
  --clue-bg: #4a78e8;
  --letter-bg: #6f6f78;
  --letter-ink: #ffef3a;
  --arrow: #128a12;
  font-family: "CW Bengali", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
    "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR",
    "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
    "Nirmala UI", "Noto Sans Bengali", "Noto Sans Devanagari",
    "Noto Naskh Arabic", "Segoe UI Arabic", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #fff; }
body { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 6px;
  max-width: 560px; margin: 0 auto; padding: 4px 10px 0;
}
.nav { display: inline-flex; width: 34px; height: 34px; }
.nav img { width: 100%; height: 100%; }
.nav.off { opacity: .25; pointer-events: none; }
.score { flex: 1; text-align: center; font-weight: 700; font-size: 20px; letter-spacing: 1px; }
#correct { color: #2bb51e; }
#total { color: #e01b1b; }
.slash { margin: 0 3px; }

/* ---------- sponsor banner (fixed spot on every page) ---------- */
.sponsor {
  width: 320px; max-width: calc(100% - 16px); height: 50px; margin: 4px auto;
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed #c9a227; background: #fff6d6; color: #8a6d00;
  font: 600 13px/1 system-ui, sans-serif; border-radius: 6px;
}

/* ---------- board ---------- */
#board { max-width: 560px; margin: 0 auto; padding: 0 8px; }
#gridwrap { display: flex; justify-content: center; margin: 4px 0; }
#grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
}
.cell, .block, .gap { width: var(--cell); height: var(--cell); }
.block { background: var(--block); }
.cell {
  position: relative; border: 1px solid var(--line); margin: 0 -1px -1px 0;
  background: #fff; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: center;
}
.cell .num {
  position: absolute; top: 1px; left: 2px;
  font-size: calc(var(--cell) * .3); line-height: 1; color: #000;
}
.cell .ch { font-size: calc(var(--cell) * .58); font-weight: 600; visibility: hidden; }
.cell.solved { background: var(--solved); }
.cell.solved .ch { visibility: visible; }
.cell.inword:not(.solved) { background: var(--word); }
.cell.bc { background: var(--bc); animation: blink 1s linear infinite; }
.cell .arrow {
  position: absolute; color: var(--arrow); font-weight: 700;
  font-size: calc(var(--cell) * .62); line-height: 1; pointer-events: none;
}
@keyframes blink { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
.cell.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-3px) } 75% { transform: translateX(3px) } }

/* ---------- level buttons ---------- */
.levels { display: flex; justify-content: center; gap: 16px; margin: 4px 0 6px; }
.levels button {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 36px; padding: 0; border: 0; background: none;
  border-radius: 50%; cursor: pointer; opacity: .55;
}
.levels button img { width: 100%; height: 100%; display: block; }
.levels button.on { opacity: 1; box-shadow: 0 0 0 3px #1b1f2a; }

/* ---------- clue bar ---------- */
.cluebar {
  background: var(--clue-bg); color: #fff; border-radius: 9px;
  padding: 6px 10px; min-height: 48px; margin: 0 0 6px;
  display: flex; align-items: center;
}
.clue { display: flex; align-items: baseline; gap: 7px; font-size: 15px; line-height: 1.35; }
.cnum { font-weight: 700; white-space: nowrap; }
.cbody { flex: 1; }
.en { font-weight: 600; direction: ltr; unicode-bidi: isolate; }
.tr { unicode-bidi: isolate; }
.sep { opacity: .8; }

/* ---------- letter bar ---------- */
/* All 8 letters always on one row: a second row would steal height from
   the grid. The buttons share the width, up to 46px each. */
.letters { display: flex; justify-content: center; gap: 4px; flex-wrap: nowrap; padding-bottom: 6px; }
.letter {
  /* No browser button styling: iPhone Safari adds its own padding and look
     to buttons, which can push the letter off centre. */
  -webkit-appearance: none; appearance: none; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  flex: 1 1 0; min-width: 0; max-width: 46px; height: 46px; border: 0; border-radius: 9px;
  background: var(--letter-bg); color: var(--letter-ink);
  font-size: 20px; font-weight: 700; cursor: pointer;
}
.letter:active { transform: scale(.94); background: #55555c; }

/* ---------- finished ---------- */
.done-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.well { font-size: 22px; font-weight: 700; font-style: italic; color: #a630e0; }
.again {
  -webkit-appearance: none; appearance: none; border: 0; cursor: pointer;
  background: #6868ff; color: #fff; text-decoration: none; padding: 9px 14px;
  border-radius: 12px; font-weight: 600; font-size: 15px; line-height: 1.2;
}
.again.replay { background: #1f9d55; }
.cluelist { background: #eef2fd; border-radius: 10px; padding: 8px 10px; }
.listsec + .listsec { margin-top: 8px; }
.listhead { font-weight: 700; color: var(--clue-bg); margin-bottom: 2px; }
.cluelist .clue { padding: 3px 0; font-size: 14.5px; }
.cluelist .clue.now { background: #dbe5ff; border-radius: 6px; }
.cluelist .cnum { color: var(--clue-bg); min-width: 2.4em; }
.ans { font-weight: 700; color: #1d7a1d; letter-spacing: .5px; }

.desk { display: none; }
.oops { padding: 20px; text-align: center; }

/* ---------- wide screens: grid left, clues right ---------- */
@media (min-width: 900px) {
  .bar, #board { max-width: 1100px; }
  #board { display: flex; gap: 24px; align-items: flex-start; justify-content: center; }
  #gridwrap { margin-top: 8px; }
  .side { width: 420px; }
  .levels { justify-content: flex-start; }
  .desk { display: block; margin-top: 10px; max-height: 60vh; overflow: auto; }
  .finished .desk { display: none; }
}
