:root {
  --bg: #0e1222;
  --panel: #171d33;
  --panel2: #222a48;
  --line: #ffffff14;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --good: #3ddc84;
  --bad: #ff5d73;
  --gold: #ffd166;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(14, 18, 34, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 1.2rem; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; flex-shrink: 0; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; }
.me { display: flex; gap: 8px; align-items: center; font-size: .9rem; min-width: 0; }
.top-actions { min-width: 0; }
/* Small phones: keep the logo on one line; the player name shortens instead. */
@media (max-width: 420px) {
  .topbar { padding: 10px 12px; }
  .logo { font-size: 1.05rem; }
  .top-actions { gap: 6px; }
  .topbar .me .nm { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.lang-btn {
  font: inherit; font-size: .8rem; font-weight: 700;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 4px 12px; cursor: pointer;
}
.bottomnav a b { font-weight: inherit; }
.lv {
  background: var(--accent); color: #fff;
  padding: 1px 8px; border-radius: 99px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
main { max-width: 720px; margin: 0 auto; padding: 16px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; text-align: center;
  padding: 8px 0 10px;
  color: var(--muted); font-size: .8rem;
  display: flex; flex-direction: column; gap: 2px;
}
.bottomnav a span { font-size: 1.3rem; }
.bottomnav a.on { color: var(--text); font-weight: 700; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; margin-top: 16px; }
.section-title { margin: 24px 0 10px; font-size: 1.05rem; }

/* ---------- Controls ---------- */
.btn {
  font: inherit; font-weight: 700;
  border: 0; border-radius: 12px;
  padding: 11px 18px;
  background: var(--panel2); color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b8cff); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.danger-solid { background: var(--bad); color: #fff; }
.danger-text { color: var(--bad); }
a.muted.small { text-decoration: underline; }

input {
  font: inherit;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px;
  flex: 1; min-width: 0;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* ---------- Home ---------- */
.welcome { text-align: center; margin-top: 24px; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.welcome h1, .welcome h2 { font-size: 1.4rem; }
.emoji-big { font-size: 3.5rem; }
details { text-align: start; }
summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }

.hello h2 { margin-bottom: 12px; }
.xp-top { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.bar { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: inherit; transition: width .5s; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.game-card {
  --c: var(--accent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 30%, var(--panel)), var(--panel) 75%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .15s, border-color .15s;
}
.game-card:hover { border-color: var(--c); }
.game-card:active { transform: scale(.97); }
.game-card .emoji { font-size: 2.2rem; }
.game-card small {
  color: var(--muted); font-size: .8rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.game-card em { font-style: normal; font-size: .8rem; color: var(--gold); margin-top: 4px; }

/* ---------- Game page ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-head h1 { flex: 1; }
.back {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 1.2rem;
}
.best { color: var(--gold); font-size: .9rem; }

.game-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hud {
  width: 100%; max-width: 460px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .95rem;
}
.hud b { font-size: 1.15rem; color: var(--gold); }
.hint { color: var(--muted); font-size: .85rem; margin: 0; text-align: center; }

.board-canvas { border-radius: 14px; touch-action: none; display: block; }

.dpad {
  direction: ltr;
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px);
  gap: 8px; user-select: none;
}
.dpad button {
  font-size: 1.3rem; border: 0; border-radius: 14px;
  background: var(--panel2); color: var(--text);
  touch-action: manipulation;
}
.dpad button:active { background: var(--accent); }
.dpad [data-d="up"] { grid-column: 2; }
.dpad [data-d="left"] { grid-column: 1; grid-row: 2; }
.dpad [data-d="down"] { grid-column: 2; grid-row: 2; }
.dpad [data-d="right"] { grid-column: 3; grid-row: 2; }

/* 2048 */
.g2048 {
  direction: ltr;
  width: min(100%, 420px); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 10px;
  padding: 10px; background: #2a2f4a; border-radius: 14px;
  touch-action: none; user-select: none;
}
.tile {
  background: #3a4062; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: clamp(1.1rem, 6vw, 2rem);
  color: #2b2b2b;
}
.tile.new { animation: pop .18s ease-out; }
.tile.merged { animation: bump .18s ease-out; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.12); } }
.t2 { background: #eee4da; }
.t4 { background: #ede0c8; }
.t8 { background: #f2b179; color: #fff; }
.t16 { background: #f59563; color: #fff; }
.t32 { background: #f67c5f; color: #fff; }
.t64 { background: #f65e3b; color: #fff; }
.t128 { background: #edcf72; color: #fff; font-size: clamp(1rem, 5vw, 1.7rem); }
.t256 { background: #edcc61; color: #fff; font-size: clamp(1rem, 5vw, 1.7rem); }
.t512 { background: #edc850; color: #fff; font-size: clamp(1rem, 5vw, 1.7rem); }
.t1024 { background: #edc53f; color: #fff; font-size: clamp(.9rem, 4vw, 1.4rem); }
.t2048 { background: #edc22e; color: #fff; font-size: clamp(.9rem, 4vw, 1.4rem); box-shadow: 0 0 20px #edc22e88; }
.t4096 { background: #7c5cff; color: #fff; font-size: clamp(.9rem, 4vw, 1.4rem); }

/* Memory */
.memory {
  width: min(100%, calc(var(--cols, 4) * 105px));
  display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 8px;
}
.mcard {
  aspect-ratio: 1; border: 0; padding: 0; background: none;
  position: relative; cursor: pointer;
  perspective: 600px;
}
.mcard .face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  backface-visibility: hidden;
  transition: transform .35s;
}
.mcard .f-back { background: linear-gradient(135deg, var(--accent), #5b8cff); font-size: clamp(1.2rem, 6vw, 1.8rem); }
.mcard .f-front { background: var(--panel2); transform: rotateY(180deg); }
.mcard.flipped .f-back { transform: rotateY(180deg); }
.mcard.flipped .f-front { transform: rotateY(0); }
.mcard.matched .f-front { background: color-mix(in srgb, var(--good) 35%, var(--panel2)); }

/* Overlay */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(5, 8, 20, .7);
  display: grid; place-items: center; padding: 16px;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.overlay-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px; width: min(100%, 340px); text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.overlay-box .big { font-size: 2.2rem; font-weight: 800; color: var(--gold); margin: 4px 0; }
.overlay-box p { margin: 0; }
.overlay-box .row { justify-content: center; margin-top: 12px; }

/* ---------- Leaderboard ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.tab {
  white-space: nowrap; padding: 7px 14px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--line); font-size: .85rem;
}
.tab.on { background: var(--accent); border-color: var(--accent); }
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.lb li:last-child { border-bottom: 0; }
.lb li.me { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 10px; }
.lb .rank { width: 32px; text-align: center; font-weight: 800; }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb b { color: var(--gold); }
.lb b small { color: var(--muted); font-weight: 400; }

/* ---------- Profile ---------- */
.stats { width: 100%; border-collapse: collapse; }
.stats th, .stats td { padding: 9px 4px; text-align: start; border-bottom: 1px solid var(--line); }
.stats th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stats tr:last-child td { border-bottom: 0; }
.token {
  direction: ltr; display: block; word-break: break-all;
  background: var(--bg); padding: 10px; border-radius: 10px; font-size: .85rem;
}

/* ---------- Online ---------- */
.or { text-align: center; color: var(--muted); }
#codeIn { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; }
.room-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.code { font-size: 1.4rem; letter-spacing: 4px; color: var(--gold); }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.player {
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
  padding: 10px; display: flex; align-items: center; gap: 8px; min-width: 0;
}
.player .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.active { border-color: var(--accent2); box-shadow: 0 0 14px #22d3ee44; }
.player.empty { color: var(--muted); justify-content: center; border-style: dashed; }
.status { text-align: center; font-size: 1.15rem; font-weight: 700; margin: 6px 0 14px; min-height: 1.8em; }
.mk { font-weight: 800; }
.mk-X { color: var(--accent2); }
.mk-O { color: var(--bad); }
.disc { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 50%; vertical-align: middle; }
.disc.R { background: var(--bad); }
.disc.Y { background: var(--gold); }

.board-xo {
  direction: ltr;
  width: min(100%, 340px); aspect-ratio: 1; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.board-xo button {
  border: 0; border-radius: 14px; background: var(--panel2);
  font-size: clamp(2rem, 12vw, 3.4rem); cursor: pointer; color: var(--text);
}
.board-xo button:disabled { cursor: default; }
.board-xo button.win { background: color-mix(in srgb, var(--good) 40%, var(--panel2)); }

.board-c4 {
  direction: ltr;
  width: min(100%, 420px); margin: 0 auto;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  padding: 8px; background: #2346a8; border-radius: 14px;
}
.board-c4 .slot {
  aspect-ratio: 1; border-radius: 50%; background: var(--bg);
  display: grid; place-items: center; cursor: pointer;
}
.board-c4 .slot .disc { width: 100%; height: 100%; }
.board-c4 .slot.last .disc { animation: drop .3s ease-out; }
.board-c4 .slot.win .disc { box-shadow: 0 0 0 3px #fff inset; }
@keyframes drop { from { transform: translateY(-200%); } }

/* ---------- Avatars, flags ---------- */
.av {
  --s: 36px;
  width: var(--s); height: var(--s); flex: none;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: calc(var(--s) * .58); line-height: 1;
}
.av.sm { --s: 28px; }
.av.lg { --s: 52px; }
.av.xl { --s: 88px; }
.flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; vertical-align: middle; flex: none; }
.me .nm { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field small { font-size: .78rem; }
select {
  font: inherit; flex: 1; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px;
}
input[type="date"] { color-scheme: dark; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; }
.flag-prev { min-width: 20px; }

.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; font: inherit; font-weight: 700;
  border: 0; border-radius: 9px; padding: 9px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.seg button.on { background: var(--panel2); color: var(--text); }

.pw { position: relative; display: flex; }
.pw input { padding-inline-start: 44px; }
.pw-toggle {
  position: absolute; inset-inline-start: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; font-size: 1.1rem; cursor: pointer; opacity: .7;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .9rem;
  border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 14px; background: var(--bg); color: var(--text); cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); }

.av-current { display: flex; justify-content: center; }
.av-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.av-opt {
  border: 2px solid transparent; border-radius: 50%; padding: 2px;
  background: none; cursor: pointer; aspect-ratio: 1;
  display: grid; place-items: center;
}
.av-opt .av { --s: min(44px, 11vw); }
.av-opt.on { border-color: var(--gold); }

/* ---------- Profile ---------- */
.hello-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hello-top h2 { margin: 0; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.profile-head p { margin: 0; }
.profile-head .xp { width: 100%; margin: 6px 0; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; text-align: start; }
.section-title small { font-weight: 400; font-size: .8rem; }

/* ---------- Game hub & levels ---------- */
.game-card .badge {
  align-self: flex-start; font-size: .72rem; font-weight: 700;
  background: #ffffff1a; padding: 2px 8px; border-radius: 99px; margin-top: 2px;
}
.hub-desc { margin: -4px 0 14px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.small { font-size: .82rem; }
.center { text-align: center; }
.section-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.levels.wide { grid-template-columns: repeat(3, 1fr); }
.level {
  font: inherit; color: var(--text);
  aspect-ratio: 1; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; transition: transform .1s;
}
.levels.wide .level { aspect-ratio: auto; padding: 14px 6px; }
.level b { font-size: 1.2rem; }
.level.open { border-color: var(--accent); box-shadow: 0 0 12px #7c5cff44; }
.level.done { background: color-mix(in srgb, var(--gold) 12%, var(--panel)); }
.level.locked { opacity: .45; cursor: default; }
.level:active { transform: scale(.96); }
.lock { font-size: .9rem; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: .85rem; white-space: nowrap; }
.stars i { font-style: normal; color: #ffffff26; }
.overlay-box .stars { font-size: 2.4rem; }

.rules { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }
.rules-p { margin: 0; line-height: 1.7; }

.level-goal { display: flex; flex-direction: column; gap: 2px; text-align: center; margin-bottom: 12px; padding: 10px 14px; }
.ai-players { width: 100%; max-width: 420px; margin: 0 0 4px; }
.warn { color: var(--bad) !important; }

/* ---------- Sudoku ---------- */
.sudoku-pick { width: min(100%, 360px); text-align: center; }
.sudoku {
  direction: ltr; container-type: inline-size;
  width: min(100%, 460px); aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  border: 2px solid #aab3d6; border-radius: 10px; overflow: hidden;
  background: var(--panel); user-select: none; touch-action: manipulation;
}
.sudoku .cell {
  position: relative;
  border-right: 1px solid #ffffff1c; border-bottom: 1px solid #ffffff1c;
  display: grid; place-items: center; cursor: pointer;
  font-size: calc(100cqw / var(--n) * .55); font-weight: 600; color: #8fb4ff; line-height: 1;
  min-width: 0; min-height: 0; overflow: hidden;
  transition: background .1s;
}
.sudoku .cell.given { color: var(--text); font-weight: 800; }
.sudoku .cell.wrong { color: var(--bad); }
.sudoku .cell.hinted { color: var(--gold); }
.sudoku .cell.peer { background: #ffffff0b; }
.sudoku .cell.same { background: #7c5cff40; }
.sudoku .cell.sel { background: #7c5cff8c; }
.sudoku .cell.br { border-right: 2px solid #aab3d6; }
.sudoku .cell.bb { border-bottom: 2px solid #aab3d6; }
.sudoku .notes {
  position: absolute; inset: 1px;
  display: grid; grid-template-columns: repeat(var(--nb), 1fr); grid-auto-rows: 1fr;
  font-size: calc(100cqw / var(--n) * .22); font-weight: 600; color: var(--muted); line-height: 1;
}
.sudoku .notes i { font-style: normal; display: grid; place-items: center; }

.sudoku-tools { width: min(100%, 460px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sudoku-tools button {
  font: inherit; color: var(--text); background: var(--panel); cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.sudoku-tools button span { font-size: 1.2rem; }
.sudoku-tools button small { font-size: .75rem; color: var(--muted); }
.sudoku-tools button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 25%, var(--panel)); }
.sudoku-pad { direction: ltr; width: min(100%, 460px); display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; }
.sudoku-pad button {
  font: inherit; font-size: 1.4rem; font-weight: 700; color: var(--text);
  background: var(--panel2); border: 0; border-radius: 10px; padding: 10px 0; cursor: pointer;
  touch-action: manipulation;
}
.sudoku-pad button:active { background: var(--accent); }
.sudoku-pad button.done { opacity: .3; }

/* ---------- Online: more players ---------- */
.players.many { grid-template-columns: 1fr 1fr; }
.player .score { margin-inline-start: auto; color: var(--gold); font-size: 1.1rem; }

/* ---------- Dots & Boxes ---------- */
.dots-wrap { display: flex; justify-content: center; width: 100%; }
.dots {
  direction: ltr;
  width: min(100%, 420px); aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--c), 20px minmax(0, 1fr)) 20px;
  grid-template-rows: repeat(var(--c), 20px minmax(0, 1fr)) 20px;
  touch-action: manipulation;
}
.dots .dot { background: #cfd5f0; border-radius: 50%; margin: 5px; }
.dots .box { margin: 2px; border-radius: 4px; transition: background .3s; }
.dots .ln { position: relative; display: block; }
.dots .ln::after {
  content: ''; position: absolute; border-radius: 3px; background: #ffffff14; transition: background .15s;
}
.dots .ln.h::after { left: 2px; right: 2px; top: 7px; bottom: 7px; }
.dots .ln.v::after { top: 2px; bottom: 2px; left: 7px; right: 7px; }
.dots .ln.free { cursor: pointer; }
.dots .ln.free:hover::after { background: #ffffff40; }
.dots .ln.on::after { background: var(--lc); }
.dots .ln.last::after { box-shadow: 0 0 10px var(--lc); }

/* ---------- Catdoku ---------- */
.catdoku {
  width: min(100%, 440px); aspect-ratio: 1; margin: 0 auto;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  border: 3px solid #1e1b2e; border-radius: 10px; overflow: hidden;
  touch-action: manipulation; user-select: none;
}
.catdoku .cell {
  border: 0; border-right: 1px solid #0003; border-bottom: 1px solid #0003; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: #1e1b2e; font-weight: 800;
  font-size: calc(min(440px, 92vw) / var(--n) * .5); line-height: 1;
}
.catdoku .cell.er { border-right: 3px solid #1e1b2e; }
.catdoku .cell.eb { border-bottom: 3px solid #1e1b2e; }
.catdoku .cell.dim { filter: brightness(.82) saturate(.6); }
.catdoku .cell.bad { animation: shake .3s; box-shadow: inset 0 0 0 3px var(--bad); }
.catdoku .cell.shown { animation: pop .25s ease-out; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Minesweeper ---------- */
.mines {
  direction: ltr;
  width: min(100%, calc(var(--w) * 38px));
  display: grid; grid-template-columns: repeat(var(--w), minmax(0, 1fr)); gap: 2px;
  touch-action: manipulation; user-select: none;
}
.m-cell {
  aspect-ratio: 1; border: 0; border-radius: 4px; padding: 0; cursor: pointer;
  background: #3a4268; color: var(--text); font: inherit; font-weight: 800;
  font-size: min(1.1rem, calc(90vw / var(--w) * .5)); line-height: 1;
}
.m-cell.open { background: #1a2038; cursor: default; }
.m-cell.boom { background: var(--bad); }
.m-cell.n1 { color: #60a5fa; } .m-cell.n2 { color: #3ddc84; } .m-cell.n3 { color: #ff5d73; }
.m-cell.n4 { color: #a78bfa; } .m-cell.n5 { color: #fb923c; } .m-cell.n6 { color: #22d3ee; }
.m-cell.n7 { color: #f472b6; } .m-cell.n8 { color: #e5e7eb; }
.btn.on { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 25%, transparent); }

/* ---------- Sliding puzzle ---------- */
.slide {
  direction: ltr;
  width: min(100%, 400px); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px;
  padding: 6px; background: #2a2f4a; border-radius: 14px; touch-action: none; user-select: none;
}
.tile-s {
  border: 0; border-radius: 10px; cursor: pointer; color: #fff; font: inherit; font-weight: 800;
  font-size: calc(min(400px, 90vw) / var(--n) * .38);
  background: hsl(var(--h) 60% 45%);
}
.tile-s.ok { box-shadow: inset 0 0 0 3px #ffffff55; }
.tile-s.gap { background: transparent; }

/* ---------- Word search ---------- */
.wgrid {
  width: min(100%, 440px); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px;
  touch-action: none; user-select: none;
}
.wgrid span {
  display: grid; place-items: center; border-radius: 6px; background: var(--panel);
  font-weight: 700; font-size: calc(min(440px, 92vw) / var(--n) * .5); cursor: pointer;
  transition: background .15s;
}
.wgrid span.sel { background: var(--accent) !important; }
.wlist { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: min(100%, 440px); }
.wlist span { padding: 4px 10px; border-radius: 99px; background: var(--panel2); font-weight: 600; font-size: .9rem; }
.wlist span.done { background: var(--wc); text-decoration: line-through; opacity: .8; }

/* ---------- Block Drop ---------- */
.blocks-wrap { direction: ltr; display: flex; gap: 8px; justify-content: center; align-items: flex-start; width: 100%; }
.blocks-wrap canvas { flex: none; }
.blocks-side { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.next-box { width: 56px; height: 56px; display: grid; place-items: center; background: var(--panel); border-radius: 10px; }
.next-box > div { display: grid; grid-template-columns: repeat(var(--n), 11px); gap: 1px; }
.next-box i { width: 11px; height: 11px; border-radius: 2px; }
.blocks-pad { direction: ltr; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: min(100%, 340px); }
.blocks-pad button {
  font-size: 1.3rem; border: 0; border-radius: 12px; padding: 12px 0;
  background: var(--panel2); color: var(--text); touch-action: manipulation; user-select: none;
}
.blocks-pad button:active { background: var(--accent); }

/* ---------- Word of the Day ---------- */
.wd-board { display: grid; gap: 6px; width: min(100%, 300px); }
.wd-line { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wd-line.shake { animation: shake .3s; }
.wd-line span {
  aspect-ratio: 1; display: grid; place-items: center;
  border: 2px solid #ffffff22; border-radius: 8px;
  font-size: 1.6rem; font-weight: 800;
}
.wd-line span.typed { border-color: #ffffff66; animation: pop .1s; }
.wd-line span.correct { background: #22a35a; border-color: #22a35a; }
.wd-line span.present { background: #c9a227; border-color: #c9a227; }
.wd-line span.absent { background: #3a3f55; border-color: #3a3f55; }
.wd-keys { display: flex; flex-direction: column; gap: 6px; width: min(100%, 480px); user-select: none; }
.wd-row { display: flex; gap: 4px; justify-content: center; }
.wd-row button {
  flex: 1; min-width: 0; max-width: 44px; height: 50px; padding: 0;
  border: 0; border-radius: 8px; background: #4a5070; color: var(--text);
  font: inherit; font-weight: 700; font-size: 1.05rem; cursor: pointer; touch-action: manipulation;
}
.wd-row button.wide { max-width: 64px; flex: 1.5; }
.wd-row button.correct { background: #22a35a; }
.wd-row button.present { background: #c9a227; }
.wd-row button.absent { background: #23283d; color: #8088a8; }

/* ---------- Picture Cross ---------- */
.nono {
  direction: ltr;
  width: min(100%, 460px); margin: 0 auto;
  display: grid;
  grid-template-columns: max-content repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: max-content repeat(var(--n), auto);
  gap: 1px; touch-action: none; user-select: none;
}
.nono .clue {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px;
  font-size: min(.78rem, calc(80vw / var(--n) * .32)); line-height: 1.1; color: var(--text); font-weight: 800;
  padding: 2px 1px; border-radius: 4px; background: var(--panel);
}
.nono .clue.row { flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: flex-end; min-width: 28px; }
.nono .clue.col { min-height: 28px; }
.nono .clue i { font-style: normal; min-width: 1.25em; padding: 1px 2px; border-radius: 3px; text-align: center; }
.nono .clue.done { opacity: .35; }
.nono .cell { aspect-ratio: 1; background: #e8ebf7; border-radius: 2px; cursor: pointer; position: relative; }
.nono .cell.er { margin-right: 2px; }
.nono .cell.eb { margin-bottom: 2px; }
.nono .cell.x::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #9aa3c7; font-size: 70%; }
.nono .cell.bad { animation: shake .3s; box-shadow: inset 0 0 0 2px var(--bad); }
.nono.solved .cell.x { background: #fff; }
.nono.solved .cell.x::after { content: none; }
.nono.solved .clue { opacity: .3; }
.nono-tools { display: flex; gap: 10px; justify-content: center; margin: 6px 0; }
.nono-tools .swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; background: var(--c);
  cursor: pointer; font-weight: 800; color: #1e1b2e;
}
.nono-tools .swatch.x { background: #e8ebf7; }
.nono-tools .swatch.on { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }

/* ---------- Fruit Match ---------- */
.match {
  direction: ltr;
  width: min(100%, 420px); aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px;
  padding: 6px; background: #2a2f4a; border-radius: 14px; touch-action: none; user-select: none;
}
.match button {
  border: 0; border-radius: 8px; background: #ffffff10; padding: 0; cursor: pointer;
  font-size: calc(min(420px, 92vw) / 8 * .58); line-height: 1;
}
.match button.sel { background: #ffffff40; transform: scale(1.08); }
.match button.pop { animation: popout .22s forwards; }
.match button.nope { animation: shake .25s; }
@keyframes popout { to { transform: scale(0); opacity: 0; } }

/* ---------- Dama ---------- */
.dama {
  direction: ltr; width: min(100%, 420px); aspect-ratio: 1; margin: 0 auto;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr));
  border: 4px solid #7c5a36; border-radius: 8px; overflow: hidden; touch-action: manipulation;
}
.dama .sq { display: grid; place-items: center; cursor: pointer; position: relative; }
.dama .sq.light { background: #e9d3b0; }
.dama .sq.dark { background: #d6b98c; }
.dama .sq.last { box-shadow: inset 0 0 0 3px #22d3ee88; }
.dama .sq.can .dm-piece { box-shadow: 0 0 0 3px #3ddc84, 0 3px 0 #0006; }
.dama .sq.sel { background: #9fd8a8; }
.dama .sq.target::after { content: ''; width: 34%; height: 34%; border-radius: 50%; background: #3ddc84aa; }
.dm-piece {
  width: 78%; aspect-ratio: 1; border-radius: 50%; display: inline-grid; place-items: center;
  box-shadow: 0 3px 0 #0006; font-size: .9em;
}
.players .dm-piece { width: 1.1em; }
.dm-piece.s0 { background: radial-gradient(circle at 35% 30%, #fff, #d6d3d1); }
.dm-piece.s1 { background: radial-gradient(circle at 35% 30%, #57534e, #1c1917); }
.dm-piece.king::after { content: '👑'; font-size: calc(min(420px, 90vw) / 8 * .4); }

/* ---------- Dominoes ---------- */
.domino { width: 100%; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.d-chain {
  width: 100%; min-height: 70px; padding: 10px; border-radius: 14px;
  background: #14532d; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center;
}
.d-hand { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tile-d {
  --u: 15px;
  display: inline-flex; background: #fafaf9; border-radius: 5px; padding: 2px; gap: 2px;
  box-shadow: 0 2px 0 #0005; flex: none;
}
.d-hand .tile-d { --u: 21px; cursor: default; opacity: .55; }
.d-hand .tile-d.can { cursor: pointer; opacity: 1; box-shadow: 0 0 0 3px #3ddc84; }
.d-hand .tile-d.sel { transform: translateY(-6px); box-shadow: 0 0 0 3px #ffd166; }
.tile-d.double { flex-direction: column; }
.tile-d.last { box-shadow: 0 0 0 3px #22d3ee; }
.tile-d .dh {
  width: var(--u); height: var(--u); display: grid; grid-template-columns: repeat(3, 1fr); padding: 1px;
}
.tile-d:not(.double) .dh + .dh { border-left: 1px solid #a8a29e; }
.tile-d.double .dh + .dh { border-top: 1px solid #a8a29e; }
.tile-d .dh i { border-radius: 50%; margin: 12%; }
.tile-d .dh i.on { background: #1c1917; }
.d-end { border: 0; border-radius: 8px; background: #ffd166; font-size: 1.1rem; padding: 6px 8px; cursor: pointer; }

/* ---------- Ludo ---------- */
.ludo-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ludo-dice { min-height: 48px; }
.ludo {
  /* Shrinks on short screens so the whole board fits above the bottom bar. */
  width: min(100%, 420px, max(260px, calc(100dvh - 520px))); aspect-ratio: 1; display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr)); border: 3px solid #cbd5e1; border-radius: 8px; overflow: hidden;
  background: #f8fafc; touch-action: manipulation;
}
.lc { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1px; position: relative; }
.lc.track { background: #fff; box-shadow: inset 0 0 0 .5px #cbd5e1; }
.lc.safe::before { content: '★'; position: absolute; color: #94a3b8; font-size: calc(min(420px, 92vw) / 15 * .6); }
.lc.base.b0, .lc.homecol.b0, .lc.start.b0, .lc.center.b0 { background: #ef4444; }
.lc.base.b1, .lc.homecol.b1, .lc.start.b1, .lc.center.b1 { background: #22c55e; }
.lc.base.b2, .lc.homecol.b2, .lc.start.b2, .lc.center.b2 { background: #eab308; }
.lc.base.b3, .lc.homecol.b3, .lc.start.b3, .lc.center.b3 { background: #3b82f6; }
.lc.yard { background: #fff; }
.lc.yard.y0 { box-shadow: inset 0 0 0 1px #fecaca; }
.lc.yard.y1 { box-shadow: inset 0 0 0 1px #bbf7d0; }
.lc.yard.y2 { box-shadow: inset 0 0 0 1px #fef08a; }
.lc.yard.y3 { box-shadow: inset 0 0 0 1px #bfdbfe; }
.lc.center { background: #e2e8f0; }
.lc.center.home { background: conic-gradient(from 45deg, #22c55e 0 25%, #eab308 0 50%, #3b82f6 0 75%, #ef4444 0); }
.tok {
  width: 70%; max-width: 22px; aspect-ratio: 1; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 1px 2px #0008; position: relative; z-index: 1;
}
.lc:has(.tok + .tok) .tok { width: 45%; }
.tok.can { cursor: pointer; animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 3px #fff, 0 0 10px 3px #fff; } }
.die { font-size: 2.6rem; line-height: 1; }

/* ---------- Tawla ---------- */
.tawla-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tawla {
  width: min(100%, 460px); aspect-ratio: 13 / 11; display: flex; flex-direction: column; justify-content: space-between;
  background: #7c4a1e; border: 6px solid #4a2c12; border-radius: 10px; padding: 4px; touch-action: manipulation;
}
.t-row { display: grid; grid-template-columns: repeat(6, 1fr) .8fr repeat(6, 1fr); height: 46%; }
.pt { position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; padding: 1px; }
.pt.bottom { flex-direction: column-reverse; }
.pt::before {
  content: ''; position: absolute; left: 6%; right: 6%; top: 0; bottom: 8%;
  clip-path: polygon(0 0, 100% 0, 50% 100%); z-index: 0;
}
.pt.bottom::before { top: 8%; bottom: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pt.even::before { background: #f4e1c1; }
.pt.odd::before { background: #a3402b; }
.pt.can::before { filter: brightness(1.3); }
.pt.can .ck, .bar-can .bar-cell .ck { box-shadow: 0 0 0 2px #3ddc84, 0 1px 2px #000a; }
.pt.sel .ck { box-shadow: 0 0 0 3px #ffd166; }
.pt.sel::before { background: #3ddc84; }
.pt.target::before { background: #ffd166; }
.pt.last::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px #22d3ee88; }
.bar-cell { background: #4a2c12; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; }
.bar-cell.bottom { flex-direction: column-reverse; }
.bar-can .bar-cell { box-shadow: inset 0 0 0 3px #3ddc84; }
.bar-sel .bar-cell { background: #166534; }
.ck {
  width: 86%; aspect-ratio: 1; border-radius: 50%; position: relative; z-index: 1; margin-top: -8%;
  display: grid; place-items: center; font-size: .7rem; font-weight: 800; box-shadow: 0 1px 2px #000a;
}
.players .ck { width: 1.1em; margin: 0; display: inline-block; }
.ck.s0 { background: radial-gradient(circle at 35% 30%, #fff, #d6d3d1); color: #1c1917; }
.ck.s1 { background: radial-gradient(circle at 35% 30%, #f87171, #991b1b); color: #fff; }
.t-controls .dice { font-size: 2.2rem; line-height: 1; }

/* ---------- Draw & Guess ---------- */
.draw-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.draw-top { width: min(100%, 520px); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 1.05rem; }
.draw-top .blanks { letter-spacing: 3px; font-weight: 800; direction: ltr; }
.draw-time { color: var(--gold); }
.draw-canvas { background: #fff; border-radius: 12px; display: block; cursor: crosshair; }
.draw-tools { width: min(100%, 520px); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.draw-tools [data-color] { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #ffffff44; cursor: pointer; }
.draw-tools [data-color].on { outline: 3px solid var(--accent2); outline-offset: 1px; }
.draw-tools .size { width: 34px; height: 34px; border-radius: 10px; background: var(--panel2); border: 0; display: grid; place-items: center; cursor: pointer; }
.draw-tools .size i { background: var(--text); border-radius: 50%; }
.draw-tools .size.on { outline: 2px solid var(--accent2); }
.draw-guess { width: min(100%, 520px); flex-wrap: nowrap; }
.draw-feed {
  width: min(100%, 520px); max-height: 140px; overflow-y: auto; margin: 0; padding: 8px 12px; list-style: none;
  background: var(--panel); border-radius: 12px; font-size: .9rem; display: flex; flex-direction: column; gap: 3px;
}
.draw-feed li.ok { color: var(--good); }
.draw-feed li.sys { color: var(--gold); font-weight: 700; }

/* ---------- Trivia ---------- */
.quiz { width: min(100%, 520px); display: flex; flex-direction: column; gap: 12px; }
.quiz-timer { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.quiz-timer i { display: block; height: 100%; background: var(--accent2); border-radius: inherit; transition: width .1s linear; }
.quiz-timer i.warn { background: var(--bad); }
.quiz-q { font-size: 1.25rem; text-align: center; line-height: 1.5; margin: 6px 0; }
.quiz-a { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-a button {
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel2);
  border: 2px solid transparent; border-radius: 14px; padding: 16px 10px; cursor: pointer; min-height: 64px;
}
.quiz-a button:disabled { cursor: default; }
.quiz-a button.picked { border-color: var(--accent2); }
.quiz-a button.right { background: #15803d; border-color: #22c55e; }
.quiz-a button.wrong { background: #991b1b; border-color: #ef4444; }

/* ---------- Home: favourites & sorting ---------- */
.game-card { position: relative; }
.game-card .fav {
  position: absolute; top: 8px; inset-inline-end: 8px;
  border: 0; background: #0005; color: #ffffff80; border-radius: 99px;
  width: 30px; height: 30px; font-size: 1rem; cursor: pointer; line-height: 1;
}
.game-card .fav.on { color: var(--gold); background: #0007; }
.game-card.is-hidden { opacity: .55; outline: 2px dashed var(--muted); }
.sort-pick { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.sort-pick select { padding: 6px 10px; flex: none; }

/* ---------- Feedback ---------- */
.bottomnav a span { position: relative; }
.unread-dot { position: absolute; top: -2px; inset-inline-end: -8px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
textarea {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; resize: vertical; width: 100%;
}
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.rate { display: flex; gap: 4px; direction: ltr; }
.rate button { border: 0; background: none; font-size: 1.8rem; color: #ffffff30; cursor: pointer; padding: 0; }
.rate button.on { color: var(--gold); }
.fb-item p, .fb-admin p { margin: 6px 0; white-space: pre-wrap; }
.fb-item.fresh { border-color: var(--accent2); }
.fb-reply { background: var(--panel2); border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
.fb-status { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--panel2); margin-inline-start: auto; }
.fb-status.s-done { background: #15803d; }
.fb-status.s-in_progress { background: #1d4ed8; }
.fb-status.s-rejected { background: #7f1d1d; }
.fb-admin { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Admin ---------- */
main.wide { max-width: 1150px; }
.adm-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.adm-tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: .9rem; }
.adm-tabs a.on { background: var(--accent); border-color: var(--accent); }
#adm { display: flex; flex-direction: column; gap: 14px; }
#adm h3 { margin: 0 0 10px; font-size: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi small { color: var(--muted); }
.kpi b { font-size: 1.6rem; }
.kpi span { font-size: .78rem; }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart { width: 100%; height: 140px; display: block; }
.chart-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 1.2fr) 2fr auto; gap: 8px; align-items: center; font-size: .85rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.table-wrap { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.adm-table th, .adm-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
.adm-table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.adm-table.clickable tbody tr { cursor: pointer; }
.adm-table.clickable tbody tr:hover, .adm-table tr:hover td { background: #ffffff06; }
.adm-table tr.dim td { opacity: .5; }
.adm-table td.meta { color: var(--muted); font-size: .78rem; max-width: 320px; }
.adm-table .av { vertical-align: middle; }
.nowrap { white-space: nowrap; }
.tag { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--panel2); white-space: nowrap; }
.tag.admin { background: var(--accent); }
.tag.bad { background: #991b1b; }
.tag.ok { background: #166534; }
.tag.off { background: transparent; border: 1px solid var(--line); color: var(--muted); text-decoration: line-through; }
.tag.ev-login_failed, .tag.ev-login_blocked, .tag.ev-account_delete { background: #7f1d1d; }
.tag.ev-register { background: #166534; }
.adm-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.adm-filters input, .adm-filters select { flex: 1 1 140px; padding: 8px 10px; }
.mini-user { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.mini-user b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.adm-user .stack { flex: 1; min-width: 260px; }
.order-list { margin: 0; padding-inline-start: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px; }
.order-list li { display: flex; align-items: center; gap: 6px; background: var(--panel2); border-radius: 10px; padding: 4px 8px; }
.order-list li span { color: var(--muted); width: 24px; }
.order-list li .btn:first-of-type { margin-inline-start: auto; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--panel2); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch i::before { content: ''; position: absolute; width: 18px; height: 18px; top: 3px; inset-inline-start: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::before { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + i::before { transform: translateX(-18px); }
.switch-row { display: flex; align-items: center; gap: 10px; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.lv-edit input, .lv-edit textarea { padding: 5px 7px; min-width: 70px; font-size: .82rem; border-radius: 8px; }
.lv-edit input[type="number"] { width: 80px; }
.lv-edit .bad { outline: 2px solid var(--bad); }
.sticky-save { position: sticky; bottom: 80px; z-index: 3; background: var(--bg); padding: 8px 0; }
.pager { margin: 4px 0; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #000c; color: #fff; padding: 10px 18px; border-radius: 99px;
  transition: .25s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.auth-logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto .5rem; }

/* Admin test play */
.test-banner { background: #ffd16622; border: 1px solid #ffd16688; border-radius: 10px; padding: .5rem .75rem; margin: 0 0 .75rem; font-size: .9rem; }

/* Admin game editor */
.ef-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.ef { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.ef.wide { grid-column: 1 / -1; }
.ef.bad { border-color: var(--bad); background: #ff5d7314; }
.ef-label { font-weight: 600; font-size: .9rem; }
.ef-input { display: flex; gap: 6px; align-items: center; }
.ef-input input, .ef-input select, .ef-input textarea { flex: 1; min-width: 0; }
.ef-input input[type="color"] { flex: 0 0 56px; height: 36px; padding: 2px; }
.ef small { font-size: .75rem; line-height: 1.4; }
.ef-err { color: var(--bad); font-size: .8rem; }
input.bad, textarea.bad { outline: 2px solid var(--bad); }
.lv-list { display: flex; flex-direction: column; gap: 12px; }
.lv-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #ffffff05; }
.lv-card.bad { border-color: var(--bad); }
.lv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.lv-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.lv-goal { margin: 0 0 8px; }
.draft-bar {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin: 12px 0;
  box-shadow: 0 6px 24px #0008;
}
.draft-bar #draftStatus { font-size: .9rem; }
.tag.draft { background: #ffd16633; color: #ffd166; }
.draft-bar[hidden] { display: none; }
@media (max-width: 600px) {
  .draft-bar { padding: 8px 10px; gap: 6px; }
  .draft-bar #draftStatus { font-size: .78rem; width: 100%; }
}
.draft-bar #pubNote { flex: 1 1 220px; min-width: 0; }

/* Logic puzzles: shared tools row */
.puzzle-tools { display: flex; gap: 8px; justify-content: center; margin: 4px 0 8px; }

/* Rectangles (Shikaku) */
.rects {
  width: min(100%, 460px); aspect-ratio: 1; margin: 0 auto;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  background: #1e1b2e; border: 3px solid #1e1b2e; border-radius: 10px; overflow: hidden; gap: 1px;
  touch-action: none; user-select: none;
}
.rects .cell {
  background: #e8ebf7; color: #1e1b2e; display: grid; place-items: center; cursor: pointer;
  font-weight: 800; font-size: calc(min(460px, 92vw) / var(--n) * .45); line-height: 1;
}
/* Piece edges: --l/--t draw the left/top edge, --r/--b the right/bottom edge (set from JS). */
.rects .cell.set { box-shadow: inset var(--l, 0) var(--t, 0) 0 #1e1b2e, inset calc(-1 * var(--r, 0)) calc(-1 * var(--b, 0)) 0 #1e1b2e; }
.rects .cell.pv { background: #7c5cff88 !important; }
.rects.shake { animation: shake .3s; }

/* Train Tracks */
.tracks {
  width: min(100%, 460px); margin: 0 auto;
  display: grid; grid-template-columns: 1.4fr repeat(var(--n), minmax(0, 1fr)); gap: 2px;
  touch-action: manipulation; user-select: none;
}
.tracks .clue { display: grid; place-items: center; font-weight: 800; font-size: .95rem; color: var(--text); min-height: 28px; }
.tracks .clue.done { color: #3ddc84; }
.tracks .cell {
  aspect-ratio: 1; background: #e8ebf7; border-radius: 4px; cursor: pointer; position: relative;
  display: grid; place-items: center; color: #9aa3c7; font-weight: 800; font-size: calc(min(460px, 92vw) / var(--n) * .4);
}
.tracks .cell svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tracks .cell.given { background: #fde68a; cursor: default; }
.tracks .cell.given svg .gap { stroke: #fde68a; }
.tracks .cell.entry { box-shadow: -4px 0 0 #3ddc84; }
.tracks .cell.exit { box-shadow: 0 4px 0 #ff5d73; }
.tracks .cell.bad { animation: shake .3s; box-shadow: inset 0 0 0 3px var(--bad); }
.tracks { position: relative; }
.tracks .clue:has(.station) { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding-inline-end: 2px; }
.tracks .clue .station { font-size: 1.15rem; }
.tracks .finish { display: grid; place-items: center; font-size: 1.2rem; line-height: 1; }
.tracks .cell.lit { background: #bbf7d0; transition: background .3s; }
.tracks .cell.lit svg .gap { stroke: #bbf7d0; }
.tracks .train { position: absolute; left: 0; top: 0; z-index: 2; line-height: 1; pointer-events: none; filter: drop-shadow(0 2px 2px #0006); }
.overlay-box .home-btn { display: block; width: 100%; margin-top: 10px; text-align: center; }

/* About page and footer */
.about-hero { text-align: center; }
.about-hero h2 { margin: .2rem 0; }
.about-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; text-align: center; margin-bottom: 8px; }
.about-facts div { background: var(--panel2); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; gap: 2px; }
.about-facts b { font-size: 1.3rem; }
.about-facts small { color: var(--muted); }
.about-maker { display: flex; align-items: center; gap: 14px; }
.about-maker h3 { margin: 0; }
.about-maker p { margin: 2px 0 0; }
.maker-badge {
  flex: 0 0 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #3ddc84, #7c5cff); color: #fff; font-weight: 800; font-size: 1.2rem;
}
.site-footer { max-width: 720px; margin: 8px auto 0; padding: 20px 16px 12px; text-align: center; color: var(--muted); font-size: .8rem; display: flex; flex-direction: column; gap: 4px; }
.site-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
