/* ===== Base ===== */
:root {
  --felt: #0f5132;
  --bar: #0a3d25;
  --back-outer: #1e4fa3;
  --back-inner: #2f6bd1;
  --back-line: rgba(255, 255, 255, 0.5);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1b1d22;
  --muted: #5d6470;
  --border: #e1e4ea;
  --accent: #f0b90b;
  --link: #1f6feb;
  --header-h: 56px;
  --ad-top-total: 80px; /* 50px banner + label + spacing */
  --radius: 12px;
  color-scheme: light;
}
/* Dark theme: follows the device unless the player picks Light or Dark in Settings. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #101318;
    --surface: #181c23;
    --text: #e9ecf1;
    --muted: #9aa3b2;
    --border: #2a303b;
    --link: #6ea8ff;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #101318;
  --surface: #181c23;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --border: #2a303b;
  --link: #6ea8ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--link); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

@media (min-width: 500px) { :root { --ad-top-total: 90px; } }
@media (min-width: 760px) { :root { --ad-top-total: 120px; } }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--bar);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
}
.brand svg { width: 28px; height: 28px; }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
}
.site-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.site-nav a[aria-current='page'] { background: rgba(255, 255, 255, 0.18); color: #fff; }
.nav-toggle {
  display: none;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 0;
  border-radius: 8px;
  width: 40px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
}
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bar);
    padding: 8px 12px 14px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  }
  .nav-open .site-nav { display: flex; }
  .site-nav a { padding: 12px; }
}

/* ===== Game shell ===== */
.game-shell {
  display: flex;
  flex-direction: column;
  /* One screen tall, minus the header and the top ad banner. */
  height: calc(100svh - var(--header-h) - var(--ad-top-total));
  min-height: 460px;
  max-height: 1100px;
  background: var(--felt);
  color: #fff;
  position: relative;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.18);
}
.readout { display: flex; align-items: center; gap: 14px; font-size: 13px; color: rgba(255, 255, 255, 0.75); }
.readout b { color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; margin-left: 2px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool, .variant {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 8px 12px;
  font: 600 14px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  min-height: 36px;
}
.variant { padding: 8px 10px; }
.variant option { color: #111; }
.tool.icon { padding: 8px 10px; }
.tool:hover:not(:disabled) { background: rgba(255, 255, 255, 0.26); }
.tool:disabled { opacity: 0.4; cursor: default; }
.tool:focus-visible, .variant:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.board { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }

.auto-finish {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #1a1a1a;
  border: 0;
  border-radius: 999px;
  padding: 12px 26px;
  font: 700 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* ===== Playing cards ===== */
.card-board { margin: 10px 0 0; }
.slot {
  position: absolute;
  width: var(--cw);
  height: var(--ch);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(var(--cw) * 0.09);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.22);
  font-weight: 700;
  font-size: calc(var(--cw) * 0.4);
  pointer-events: none;
}
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  cursor: pointer;
  touch-action: none;
}
.card.dragging { transition: none; cursor: grabbing; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35)); }
.celebrating .card { transition: none; }
.card .face, .card .back {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.09);
}
.card.down .face, .card.up .back { display: none; }
.card .face { background: #fff; border: 1px solid #b9bcc2; overflow: hidden; }
.card.red .face { color: #c62828; }
.card.black .face { color: #1a1a1a; }
.corner {
  position: absolute;
  top: calc(var(--cw) * 0.04);
  left: calc(var(--cw) * 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 800;
  font-size: calc(var(--cw) * 0.29);
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.pip {
  position: absolute;
  right: calc(var(--cw) * 0.06);
  bottom: calc(var(--ch) * 0.04);
  font-size: calc(var(--cw) * 0.5);
  line-height: 1;
}
.card .back {
  background: var(--back-outer);
  border: 1px solid #fff;
  padding: calc(var(--cw) * 0.07);
}
.card .back i {
  display: block;
  height: 100%;
  border-radius: calc(var(--cw) * 0.05);
  border: 1px solid var(--back-line);
  background:
    repeating-linear-gradient(45deg, transparent 0 4px, rgba(255, 255, 255, 0.07) 4px 5px),
    var(--back-inner);
}
.card.hint .face, .card.hint .back { box-shadow: 0 0 0 3px #4fc3f7, 0 0 14px #4fc3f7; }
.card.flip { animation: flip 0.2s ease-out; }
@keyframes flip { from { transform-origin: center; scale: 0 1; } to { scale: 1 1; } }
.shake { animation: shake 0.3s; }
@keyframes shake {
  25% { translate: -4px 0; }
  75% { translate: 4px 0; }
}

/* ===== Mahjong ===== */
.mahjong-board { margin: 0; }
.tile {
  position: absolute;
  width: var(--tw);
  height: var(--th);
  padding: 0;
  border: 1px solid #b8a98a;
  border-radius: calc(var(--tw) * 0.12);
  background: linear-gradient(160deg, #fffdf6, #f1e8d2);
  box-shadow:
    var(--depth) var(--depth) 0 #d8c7a0,
    calc(var(--depth) + 1px) calc(var(--depth) + 1px) 0 #9c8a63,
    calc(var(--depth) + 3px) calc(var(--depth) + 4px) 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: opacity 0.25s, transform 0.25s, filter 0.2s;
  font-family: inherit;
  color: #1a1a1a;
}
.tile .tf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0;
  line-height: 1;
}
.tile b { font-size: calc(var(--tw) * 0.52); font-weight: 800; }
.tile b.han { font-size: calc(var(--tw) * 0.55); font-weight: 700; }
.tile b.emoji { font-size: calc(var(--tw) * 0.5); }
.tile small { font-size: calc(var(--tw) * 0.2); margin-top: calc(var(--tw) * 0.04); color: #6b5e45; }
.tile .dots { color: #1565c0; }
.tile .bam { color: #2e7d32; }
.tile .red { color: #c62828; }
.white-dragon {
  width: calc(var(--tw) * 0.5);
  height: calc(var(--th) * 0.55);
  border: calc(var(--tw) * 0.06) solid #1565c0;
  border-radius: 3px;
}
.tile.blocked { filter: brightness(0.86) saturate(0.8); }
.tile.selected { background: linear-gradient(160deg, #fff6c9, #ffe27a); border-color: #c99a00; transform: translateY(-3px); }
.tile.hint { box-shadow: 0 0 0 3px #4fc3f7, 0 0 16px #4fc3f7; }
.tile.gone { opacity: 0; transform: scale(0.6); pointer-events: none; }
.tile:focus-visible { outline: 3px solid var(--accent); }

/* ===== Sudoku ===== */
.sudoku-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  touch-action: manipulation;
}
.sudoku-grid {
  --size: min(94vw, calc(100svh - var(--header-h) - var(--ad-top-total) - 230px), 540px);
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  background: #fff;
  border: 3px solid #1b1d22;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
@media (min-width: 900px) {
  .sudoku-board { flex-direction: row; }
  .sudoku-grid { --size: min(calc(100svh - var(--header-h) - var(--ad-top-total) - 100px), 560px); }
}
.cell {
  border: 0;
  border-right: 1px solid #c9ced8;
  border-bottom: 1px solid #c9ced8;
  background: #fff;
  color: #1f6feb;
  font: 600 calc(var(--size) / 15) / 1 inherit;
  font-family: inherit;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.cell[data-c='2'], .cell[data-c='5'] { border-right: 2px solid #1b1d22; }
.cell[data-r='2'], .cell[data-r='5'] { border-bottom: 2px solid #1b1d22; }
.cell.given { color: #1b1d22; font-weight: 700; }
.cell.peer { background: #eef3fb; }
.cell.same { background: #cfe0fb; }
.cell.sel { background: #ffe9a8; }
.cell.bad { color: #d32f2f; background: #fde4e4; }
.cell.hinted { animation: pulse 1.2s; }
@keyframes pulse { 0%, 100% { box-shadow: inset 0 0 0 0 #4fc3f7; } 30% { box-shadow: inset 0 0 0 4px #4fc3f7; } }
.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 2px; }
.notes-grid i { font: 500 calc(var(--size) / 36) / 1 inherit; font-style: normal; color: #5d6470; display: grid; place-items: center; }
.sudoku-grid.solved .cell { animation: pulse 0.9s; }
.sudoku-pad { width: min(94vw, 540px); max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) { .sudoku-pad { width: 260px; } .sudoku-pad .digits { grid-template-columns: repeat(3, 1fr); } }
.digits { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.pad-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pad-btn {
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #1b1d22;
  font: 700 20px/1 inherit;
  font-family: inherit;
  padding: 10px 0 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pad-btn small { font-size: 10px; color: #5d6470; min-height: 12px; }
.pad-row .pad-btn { font-size: 15px; padding: 12px 0; }
.pad-btn.on { background: var(--accent); }
.pad-btn.done { opacity: 0.35; }
@media (min-width: 900px) { .pad-btn { font-size: 24px; padding: 14px 0 8px; } }

/* ===== Ads =====
   Every placement reserves its exact size at every screen width, so nothing jumps when an
   ad loads and ads never overlap the game. Fixed placements use these sizes (Google's
   "exact size per screen width" setup); responsive ones let Google choose. */
.ad { text-align: center; margin: 0 auto; }
.ad[hidden] { display: none; }
.ad-label {
  font-size: 10px;
  line-height: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ad-unit { margin: 0 auto; }
.ad-placeholder {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(45deg, rgba(127, 127, 127, 0.07) 0 10px, rgba(127, 127, 127, 0.14) 10px 20px);
  border: 1px dashed rgba(127, 127, 127, 0.5);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Top banner: 320x50 phone · 468x60 small tablet · 728x90 tablet · 970x90 desktop.
   The padding under it keeps the ad clear of the game buttons. */
.ad-top { --ad-w: 320px; --ad-h: 50px; padding: 4px 8px 12px; background: var(--bg); }
.ad-top .ad-unit { width: var(--ad-w); height: var(--ad-h); }
@media (min-width: 500px) { .ad-top { --ad-w: 468px; --ad-h: 60px; } }
@media (min-width: 760px) { .ad-top { --ad-w: 728px; --ad-h: 90px; } }
@media (min-width: 1000px) { .ad-top { --ad-w: 970px; --ad-h: 90px; } }
.ad-top-home { margin-bottom: 0; }

/* Side rails beside the game: hidden on smaller screens, 160x600 on laptops, 300x600 on large monitors. */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.ad-rail { display: none; background: var(--bg); padding: 12px 10px; }
.ad-side .ad-unit { width: 160px; height: 600px; }
@media (min-width: 1180px) {
  .game-layout { grid-template-columns: 180px minmax(0, 1fr) 180px; }
  .ad-rail { display: block; }
}
@media (min-width: 1480px) {
  .game-layout { grid-template-columns: 320px minmax(0, 1fr) 320px; }
  .ad-side .ad-unit { width: 300px; height: 600px; }
}

/* In-content rectangle: 300x250 on phones, 336x280 elsewhere. */
.ad-rect { margin: 24px auto; }
.ad-rect .ad-unit { width: 300px; height: 250px; }
@media (min-width: 400px) { .ad-rect .ad-unit { width: 336px; height: 280px; } }

/* Responsive wide units (under the game, page bottom, home page). */
.ad-wide { max-width: 1000px; padding: 0 12px; margin: 20px auto; }
.ad-wide .ad-unit { width: 100%; min-height: 100px; }
.ad-wide .ad-placeholder { height: 250px; }
@media (min-width: 760px) { .ad-wide .ad-placeholder { height: 90px; } }

/* ===== Content pages ===== */
.content { max-width: 820px; margin: 0 auto; padding: 24px 18px 40px; }
.content h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.2; margin: 0.4em 0; }
.content h2 { font-size: 22px; margin-top: 1.6em; }
.content p, .content li { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hero { text-align: center; padding: 36px 18px 8px; max-width: 820px; margin: 0 auto; }
.hero h1 { font-size: clamp(28px, 6vw, 44px); margin: 0 0 8px; line-height: 1.15; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; }
.game-grid {
  max-width: 1000px;
  margin: 28px auto 0;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.game-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14); }
.game-card .thumb { height: 140px; display: grid; place-items: center; }
.game-card .thumb svg { width: 100%; height: 100%; }
.game-card .info { padding: 14px 16px 16px; }
.game-card h2 { font-size: 19px; margin: 0 0 4px; }
.game-card p { margin: 0; color: var(--muted); font-size: 14px; }
.play { display: inline-block; margin-top: 10px; font-weight: 700; color: var(--link); }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.site-footer nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }

/* ===== Modal, toast, buttons ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal.open { opacity: 1; }
.modal-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  padding: 22px;
  width: min(380px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.modal.open .modal-card { transform: scale(1); }
.modal-card h2 { margin: 0 0 12px; font-size: 22px; }
.modal-card strong { display: block; margin: 14px 0 8px; }
.win { text-align: center; }
.win h2 { font-size: 28px; }
.win p { margin: 6px 0; }
.record { color: #b8860b; font-weight: 700; }
.modal-actions { display: flex; justify-content: center; margin-top: 18px; gap: 10px; }
.modal-actions.spread { justify-content: space-between; align-items: center; }
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 22px;
  font: 700 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  background: var(--border);
  color: var(--text);
}
.btn.primary { background: var(--felt); color: #fff; }
.btn.link { background: none; padding: 10px 4px; }
.btn.danger { color: #d32f2f; }
.setting-row { display: flex; justify-content: space-between; align-items: center; }
.setting-row strong { margin: 0; }
.toggle { border: 0; border-radius: 999px; padding: 7px 18px; font-weight: 700; cursor: pointer; background: var(--border); color: var(--text); font-family: inherit; }
.toggle.on { background: var(--felt); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font: 11px inherit; font-family: inherit; }
.swatch .dot { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; }
.swatch .mini-back { width: 32px; height: 44px; border-radius: 5px; border: 3px solid transparent; box-shadow: inset 0 0 0 4px var(--in, transparent), inset 0 0 0 5px var(--l); }
.swatch.active .dot, .swatch.active .mini-back { border-color: var(--accent); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats-grid div { background: var(--bg); border-radius: 10px; padding: 10px 4px; text-align: center; }
.stats-grid b { display: block; font-size: 19px; }
.stats-grid span { font-size: 11px; color: var(--muted); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: rgba(20, 22, 26, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 11000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .card, .tile, .modal, .modal-card, .toast { transition: none !important; }
  .card.flip, .shake, .cell.hinted { animation: none !important; }
}

/* ===== SEO content blocks ===== */
.breadcrumb { font-size: 13px; color: var(--muted); margin-top: 4px; }
.breadcrumb a { color: var(--muted); }
.lead { font-size: 18px; }
.faq h3 { font-size: 17px; margin: 1.2em 0 0.3em; }
.faq p { margin: 0; color: var(--muted); }
.more-games { padding-left: 1.2em; }
.more-games li { margin: 6px 0; }
.game-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== Card options ===== */
:root[data-fourcolor] .card.suit-D .face { color: #1565c0; }
:root[data-fourcolor] .card.suit-C .face { color: #2e7d32; }
:root[data-large] .corner { font-size: calc(var(--cw) * 0.4); }
:root[data-large] .pip { font-size: calc(var(--cw) * 0.42); }
.card.dim .face { filter: brightness(0.78); }
.slot.free-slot { border-style: dashed; }
.slot.discard { border-style: dotted; }
:root[data-back-pattern='dots'] .card .back i { background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 1.3px, transparent 1.5px) 0 0 / 7px 7px, var(--back-inner); }
:root[data-back-pattern='grid'] .card .back i { background: linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 6px 6px, linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 6px 6px, var(--back-inner); }
:root[data-back-pattern='plain'] .card .back i { background: var(--back-inner); }

/* ===== Daily, badges, win dialog extras ===== */
.daily-badge { background: var(--accent); color: #1a1a1a; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.try-next { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center; align-items: center; }
.try-next a { font-weight: 600; text-decoration: none; }
.badges { margin-top: 12px; }
.badges summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.badge { display: flex; gap: 10px; align-items: center; padding: 6px 0; opacity: 0.45; filter: grayscale(1); }
.badge.on { opacity: 1; filter: none; }
.badge-icon { font-size: 22px; width: 30px; text-align: center; }
.badge b { display: block; font-size: 14px; }
.badge small { color: var(--muted); font-size: 12px; }
.badges-new { margin: 12px 0 4px; text-align: left; background: var(--bg); border-radius: 12px; padding: 8px 12px; }
.badges-new strong { margin: 4px 0; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; border: 0; border-radius: 10px; padding: 8px 6px; background: var(--border); color: var(--text); font: 600 13px inherit; font-family: inherit; cursor: pointer; }
.seg button.on { background: var(--felt); color: #fff; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--felt); }

/* ===== Minesweeper ===== */
.mines-board { overflow: auto; touch-action: manipulation; display: grid; place-items: safe center; padding: 6px; }
.mines-grid { display: grid; gap: 1px; background: rgba(0, 0, 0, 0.35); border: 3px solid rgba(0, 0, 0, 0.35); border-radius: 6px; user-select: none; -webkit-user-select: none; }
.mcell {
  width: var(--mc); height: var(--mc); border: 0; padding: 0; cursor: pointer;
  background: linear-gradient(145deg, #dfe6ee, #b9c3cf); color: #1b1d22;
  font: 800 calc(var(--mc) * 0.55) / 1 inherit; font-family: inherit; display: grid; place-items: center;
  -webkit-touch-callout: none;
}
.mcell:hover:not(.open) { filter: brightness(1.06); }
.mcell.open { background: #eef1f5; cursor: default; }
.mcell.flag { font-size: calc(var(--mc) * 0.5); }
.mcell.boom { background: #ff5a5a; }
.mcell.wrong { background: #ffd3d3; }
.mcell.hinted { animation: pulse 1.2s; }
.mcell.n1 { color: #1565c0; } .mcell.n2 { color: #2e7d32; } .mcell.n3 { color: #c62828; } .mcell.n4 { color: #283593; }
.mcell.n5 { color: #6d1b1b; } .mcell.n6 { color: #00838f; } .mcell.n7 { color: #222; } .mcell.n8 { color: #757575; }
.tool.on { background: var(--accent); color: #1a1a1a; }

/* ===== 2048 ===== */
.t48-board { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; }
.t48 {
  --size: min(92vw, calc(100svh - var(--header-h) - var(--ad-top-total) - 140px), 500px);
  --gap: calc(var(--size) * 0.03);
  --tile: calc((var(--size) - var(--gap) * 5) / 4);
  position: relative; width: var(--size); height: var(--size); background: #263544; border-radius: 14px;
  display: grid; grid-template-columns: repeat(4, var(--tile)); gap: var(--gap); padding: var(--gap); touch-action: none; outline: none;
}
.t48-cell { background: rgba(255, 255, 255, 0.08); border-radius: 10px; }
.t48-tiles { position: absolute; inset: 0; }
.t48-tile {
  position: absolute; left: 0; top: 0; width: var(--tile); height: var(--tile); border-radius: 6px;
  transform: translate(calc(var(--gap) + var(--c) * (var(--tile) + var(--gap))), calc(var(--gap) + var(--r) * (var(--tile) + var(--gap))));
  transition: transform 0.11s ease-in-out; display: grid; place-items: center; z-index: 1;
  font: 800 calc(var(--tile) * 0.42) / 1 inherit; font-family: inherit; color: #1e3a5f; background: #e3f2fd; border-radius: 10px;
}
.t48-tile span { display: block; }
.t48-tile.big { font-size: calc(var(--tile) * 0.32); }
.t48-tile.pop-in span { animation: t48pop 0.2s 0.08s both; }
.t48-tile.merge span { animation: t48merge 0.2s; }
@keyframes t48pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes t48merge { 50% { transform: scale(1.2); } }
.t48-tile.v2 { background: #e3f2fd; color: #1e3a5f; } .t48-tile.v4 { background: #bbdefb; color: #1e3a5f; } .t48-tile.v8 { background: #90caf9; color: #12324f; }
.t48-tile.v16 { background: #5aa9e6; color: #fff; } .t48-tile.v32 { background: #3d8bd9; color: #fff; } .t48-tile.v64 { background: #2f6fc0; color: #fff; }
.t48-tile.v128 { background: #26a69a; color: #fff; } .t48-tile.v256 { background: #1f8f62; color: #fff; } .t48-tile.v512 { background: #7cb342; color: #fff; }
.t48-tile.v1024 { background: #f9a825; color: #fff; } .t48-tile.v2048 { background: #f4511e; color: #fff; box-shadow: 0 0 20px rgba(244, 81, 30, 0.55); }
.t48-tile.v4096 { background: #8e24aa; color: #fff; }
.t48-help { margin: 0; color: rgba(255, 255, 255, 0.7); font-size: 13px; }

/* ===== Word Search ===== */
.ws-board { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 20px; padding: 10px; overflow: auto; }
.ws-grid {
  --size: min(94vw, calc(100svh - var(--header-h) - var(--ad-top-total) - 230px), 540px);
  width: var(--size); height: var(--size); display: grid; background: #fff; border-radius: 10px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); touch-action: none; user-select: none; -webkit-user-select: none;
}
@media (min-width: 900px) { .ws-grid { --size: min(calc(100svh - var(--header-h) - var(--ad-top-total) - 90px), 560px); } }
.ws-cell { display: grid; place-items: center; font: 700 calc(var(--size) / 21) / 1 inherit; font-family: inherit; color: #1b1d22; border-radius: 6px; cursor: pointer; }
.ws-cell.sel { background: #ffe082 !important; box-shadow: inset 0 0 0 2px #f0b90b; }
.ws-cell.hint { animation: pulse 0.9s 2; box-shadow: inset 0 0 0 3px #4fc3f7; }
.ws-side { width: min(94vw, 300px); }
.ws-help { margin: 0 0 8px; color: rgba(255, 255, 255, 0.75); font-size: 13px; }
.ws-words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ws-words li { background: rgba(255, 255, 255, 0.92); color: #1b1d22; border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.ws-words li.found { background: var(--wc); text-decoration: line-through; opacity: 0.75; }

/* ===== Daily page ===== */
.daily-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 16px 0; }
.daily-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; text-decoration: none; color: var(--text); }
.daily-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.daily-card .ic { font-size: 28px; }
.daily-card b { display: block; }
.daily-card small { color: var(--muted); }
.daily-card.done { border-color: #2e7d32; }
.daily-card.done small { color: #2e7d32; font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 360px; }
.cal span { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.cal span.on { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.cal span.today { outline: 2px solid var(--accent); }
.cal span.head { background: none; border: 0; color: var(--muted); font-weight: 700; }
.streak-big { font-size: 40px; font-weight: 800; margin: 0; }

/* ===== Home sections, guides, links ===== */
.games-section { scroll-margin-top: calc(var(--header-h) + 8px); }
.section-title { max-width: 1000px; margin: 28px auto 0; padding: 0 16px; font-size: 22px; }
.game-grid + .section-title { margin-top: 36px; }
.game-card h3 { font-size: 19px; margin: 0 0 4px; }
.hero-cta { margin-top: 16px !important; }
.hero-cta .btn { display: inline-block; text-decoration: none; }
.variant-links, .daily-link { font-size: 15px; }
.daily-link { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.guide-list { display: grid; gap: 12px; margin-top: 16px; }
.guide-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.guide-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.guide-card b { font-size: 18px; color: var(--link); }
.guide-card span { color: var(--text); }
.guide-card small { color: var(--muted); }
.cta-box { margin: 28px 0; padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; font-weight: 600; }
.cta-box .btn { text-decoration: none; }
.guide h2 { font-size: 20px; }

/* Reserve every ad's space in CSS so nothing moves when the ad (or placeholder) arrives. */
.ad-top { min-height: calc(var(--ad-h) + 30px); }
.ad-rect { min-height: 264px; }
@media (min-width: 400px) { .ad-rect { min-height: 294px; } }
.ad-wide { min-height: 264px; }
@media (min-width: 760px) { .ad-wide { min-height: 104px; } }
.ad[hidden] { min-height: 0; }

/* ===== Win celebration ===== */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9999; pointer-events: none; }
.modal.modal-win { background: rgba(5, 10, 20, 0.35); z-index: 10000; }
.win.fancy { text-align: center; position: relative; }
.modal-win .modal-card { border-top: 6px solid var(--accent); animation: winPop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes winPop { from { transform: scale(0.6) translateY(30px); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.trophy {
  position: relative; width: 92px; height: 92px; margin: -6px auto 6px; border-radius: 50%;
  display: grid; place-items: center; font-size: 54px;
  background: radial-gradient(circle at 50% 40%, #fff6d1, #ffd166 60%, #f0b90b);
  box-shadow: 0 0 0 6px rgba(240, 185, 11, 0.25), 0 10px 30px rgba(240, 185, 11, 0.45);
  animation: trophyBounce 1.2s ease-in-out infinite; overflow: hidden;
}
.trophy span { animation: trophyTilt 1.2s ease-in-out infinite; display: inline-block; }
.trophy .shine { position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.85) 50%, transparent 65%); transform: translateX(-120%); animation: shine 2.2s 0.4s infinite; }
@keyframes trophyBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes trophyTilt { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes shine { 60%, 100% { transform: translateX(120%); } }
.win-title {
  font-size: 30px !important; margin: 6px 0 10px !important;
  background: linear-gradient(90deg, #f0b90b, #ef476f, #4cc9f0, #06d6a0, #f0b90b); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: titleFlow 4s linear infinite;
}
@keyframes titleFlow { to { background-position: 300% 0; } }
.win-stats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 8px; }
.pill { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 14px; }
.win-records { display: flex; flex-direction: column; gap: 6px; align-items: center; margin: 6px 0; }
.record-chip { background: linear-gradient(90deg, #fff3c4, #ffe08a); color: #7a5a00; border-radius: 999px; padding: 5px 14px; font-weight: 800; font-size: 14px; animation: chipIn 0.5s 0.3s both; }
@keyframes chipIn { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.btn.big { padding: 14px 30px; font-size: 16px; box-shadow: 0 6px 16px rgba(15, 81, 50, 0.35); }
@media (prefers-reduced-motion: reduce) {
  .trophy, .trophy span, .trophy .shine, .win-title, .record-chip, .modal-win .modal-card { animation: none !important; }
}

/* No top banner on the page (no ad unit set): the game gets that space. */
body.no-top-ad { --ad-top-total: 0px; }
/* Fixed-size ad units are inline-blocks; align them so no baseline gap makes the slot taller than reserved. */
.ad .ad-unit { vertical-align: top; }
.ad-top, .ad-rect { line-height: 0; }
.ad-top .ad-label, .ad-rect .ad-label { line-height: 14px; }
