/* KenKen — a mathematical notebook. Three moods (ivory paper, chalkboard,
   mint) switch by [data-theme]; everything else reads the variables. */

:root, [data-theme="ivory"] {
  --bg-a: #f1e9da;
  --bg-b: #dcd1bf;
  --rule: rgba(80, 110, 170, 0.11);
  --paper: #fbf7ef;
  --paper-2: #f1eadf;
  --ink: #2a2420;
  --ink-soft: #776a5c;
  --line: rgba(60, 45, 30, 0.18);
  --cage: #2b2420;
  --accent: #2f4f86;
  --accent-ink: #fff;
  --sel: rgba(47, 79, 134, 0.16);
  --cage-sel: rgba(190, 142, 72, 0.17);
  --peer: rgba(60, 45, 30, 0.045);
  --note: #8c8073;
  --bad: #a9372c;
  --bad-bg: rgba(200, 70, 60, 0.14);
  --good: #2e6f4a;
  --good-bg: rgba(90, 170, 120, 0.16);
  --glow: rgba(199, 165, 92, 0.7);
  --key-bg: rgba(255, 255, 255, 0.6);
  --key-line: rgba(60, 45, 30, 0.14);
  --primary-a: #4a6aa5;
  --primary-b: #2b4677;
  --blob-1: rgba(255, 250, 240, 0.9);
  --blob-2: rgba(120, 150, 210, 0.35);
  --blob-3: rgba(210, 170, 110, 0.3);
  --shadow: rgba(50, 35, 20, 0.35);
  --backdrop: rgba(40, 30, 20, 0.4);
}
[data-theme="chalk"] {
  --bg-a: #22433b;
  --bg-b: #131f23;
  --rule: transparent;
  --paper: #233d37;
  --paper-2: #2b4a43;
  --ink: #f4f1e7;
  --ink-soft: #b3c2b9;
  --line: rgba(255, 255, 255, 0.2);
  --cage: #f1ede0;
  --accent: #f2c75c;
  --accent-ink: #26302a;
  --sel: rgba(242, 199, 92, 0.24);
  --cage-sel: rgba(255, 255, 255, 0.12);
  --peer: rgba(255, 255, 255, 0.05);
  --note: #b7c8bf;
  --bad: #ff9d90;
  --bad-bg: rgba(230, 90, 80, 0.26);
  --good: #a3ecbb;
  --good-bg: rgba(120, 220, 160, 0.2);
  --glow: rgba(170, 240, 190, 0.6);
  --key-bg: rgba(255, 255, 255, 0.08);
  --key-line: rgba(255, 255, 255, 0.14);
  --primary-a: #f6d579;
  --primary-b: #d9a93a;
  --blob-1: rgba(120, 190, 160, 0.25);
  --blob-2: rgba(242, 199, 92, 0.16);
  --blob-3: rgba(90, 150, 200, 0.2);
  --shadow: rgba(0, 0, 0, 0.55);
  --backdrop: rgba(5, 12, 10, 0.55);
}
[data-theme="mint"] {
  --bg-a: #e6f4ed;
  --bg-b: #c6e0d3;
  --rule: rgba(47, 143, 111, 0.1);
  --paper: #f7fcf9;
  --paper-2: #e8f3ee;
  --ink: #1e3a31;
  --ink-soft: #5f7d72;
  --line: rgba(31, 77, 63, 0.2);
  --cage: #1f4d3f;
  --accent: #2f8f6f;
  --accent-ink: #fff;
  --sel: rgba(47, 143, 111, 0.2);
  --cage-sel: rgba(47, 143, 111, 0.11);
  --peer: rgba(47, 143, 111, 0.05);
  --note: #6f948a;
  --bad: #b4403c;
  --bad-bg: rgba(214, 86, 86, 0.14);
  --good: #1f7a55;
  --good-bg: rgba(72, 190, 140, 0.18);
  --glow: rgba(72, 190, 140, 0.6);
  --key-bg: rgba(255, 255, 255, 0.65);
  --key-line: rgba(31, 77, 63, 0.14);
  --primary-a: #4caa8a;
  --primary-b: #27735a;
  --blob-1: rgba(255, 255, 255, 0.9);
  --blob-2: rgba(80, 190, 150, 0.3);
  --blob-3: rgba(120, 170, 220, 0.25);
  --shadow: rgba(20, 50, 40, 0.35);
  --backdrop: rgba(20, 45, 35, 0.42);
}

:root {
  --radius: 18px;
  --ease: cubic-bezier(0.4, 0.1, 0.2, 1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px),
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  transition: background 0.8s, color 0.4s;
}

/* ---------------------------------------------------------- background */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.6; will-change: transform; transition: background 0.8s; }
.bg .b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: var(--blob-1); animation: drift 50s ease-in-out infinite alternate; }
.bg .b2 { width: 50vmax; height: 50vmax; right: -20vmax; bottom: -20vmax; background: var(--blob-2); animation: drift 64s ease-in-out infinite alternate-reverse; }
.bg .b3 { width: 40vmax; height: 40vmax; left: 30vw; bottom: -25vmax; background: var(--blob-3); animation: drift 76s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(8vmax, 6vmax) scale(1.12); }
}

/* -------------------------------------------------------------- layout */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 2px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22)); }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: 0.02em; }
.brand small { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.menu { display: flex; gap: 4px; }

.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: var(--peer); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg, .btn svg, .pad-key svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 16px 4px; }
.stat {
  background: var(--key-bg); border: 1px solid var(--key-line); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 12px; padding: 5px 8px; display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.stat span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.stat b { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }

.stage { flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; padding: 6px 16px 4px; }

.cage-info {
  margin: 0; padding: 2px 16px; min-height: 24px; text-align: center; font-size: 13.5px; line-height: 1.35; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center; gap: 9px; white-space: nowrap; overflow: hidden;
}
.cage-info b { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); }
.cage-info span { overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------------------------------------------- pad */
.pad { display: flex; gap: 6px; padding: 4px 16px; }
.pad-key {
  appearance: none; flex: 1; min-width: 0; height: 46px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--key-line); background: var(--key-bg); color: var(--ink);
  font: 600 22px var(--serif); display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.12s, background 0.2s, opacity 0.2s, color 0.2s;
}
.pad-key:active { transform: scale(0.94); }
.pad-key:disabled { opacity: 0.4; cursor: default; }
.pad-key.pad-on { background: var(--sel); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.pad-key[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ------------------------------------------------------------- actions */
.actions { display: flex; gap: 10px; padding: 6px 16px 14px; }
.btn {
  appearance: none; flex: 1; border: 1px solid var(--key-line); background: var(--key-bg); color: var(--ink);
  font: 500 15px var(--sans); padding: 11px 12px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
  transition: transform 0.15s, background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--primary-a), var(--primary-b)); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 4px 12px -4px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.subtle { flex: 0 0 auto; background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); font-size: 13.5px; margin: 18px auto 0; display: flex; }

/* --------------------------------------------------------------- board */
.kk-board {
  width: min(100cqw, 100cqh);
  aspect-ratio: 1;
  position: relative;
  --cell: 60px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.35), transparent 50%),
    var(--paper);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 18px 40px -16px var(--shadow),
    0 4px 10px -4px var(--shadow),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: background 0.6s;
}
[data-theme="chalk"] .kk-board {
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(circle at 80% 85%, rgba(255, 255, 255, 0.04), transparent 50%),
    var(--paper);
  box-shadow: 0 0 0 6px #5b4631, 0 0 0 7px #3a2b1d, 0 20px 40px -14px rgba(0, 0, 0, 0.8);
  border-radius: 3px;
}

.kk-cells {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  touch-action: none;
}
.kk-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.kk-lines path { fill: none; vector-effect: non-scaling-stroke; }
.kk-thin { stroke: var(--line); stroke-width: 1px; stroke-dasharray: 3 3; }
.kk-bleed { stroke: var(--cage); stroke-width: 7px; stroke-linecap: round; opacity: 0.13; }
.kk-thick { stroke: var(--cage); stroke-width: 2.6px; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="chalk"] .kk-thin { stroke-dasharray: none; }
[data-theme="chalk"] .kk-bleed { opacity: 0.22; stroke-width: 5px; }

.kk-cell {
  position: relative; display: grid; place-items: center; cursor: pointer;
  transition: background 0.22s, box-shadow 0.22s;
  opacity: 1;
}
.kk-enter .kk-cell { animation: cellin 0.5s var(--ease) var(--d) both; }
@keyframes cellin { from { opacity: 0; transform: scale(0.9); } }
.kk-cell.kk-peer { background: var(--peer); }
.kk-cell.kk-cage-sel { background: var(--cage-sel); }
.kk-cell.kk-sel { background: var(--sel); box-shadow: inset 0 0 0 2px var(--accent); z-index: 1; }
.kk-cell.kk-bad { background: var(--bad-bg); }
.kk-cell.kk-sel.kk-bad { box-shadow: inset 0 0 0 2px var(--bad); }
.kk-cell.kk-settle { animation: settle 1.1s ease-out; }
@keyframes settle {
  0% { box-shadow: inset 0 0 0 0 var(--glow); }
  35% { background: var(--good-bg); box-shadow: inset 0 0 0.55em var(--glow); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
.kk-cell.kk-hint { animation: hintglow 1.3s ease-in-out 2; }
@keyframes hintglow { 50% { background: var(--sel); box-shadow: inset 0 0 0 2px var(--accent), 0 0 0.6em var(--glow); } }
.kk-cell.kk-win .kk-val { animation: winpop 0.8s var(--ease) var(--d) both; color: var(--good); }
@keyframes winpop { 40% { transform: scale(1.3) rotate(-4deg); } }

.kk-label {
  position: absolute; top: 5%; left: 8%; z-index: 1;
  font: 600 calc(var(--cell) * 0.21) var(--serif); letter-spacing: 0.02em; color: var(--ink); opacity: 0.85; line-height: 1;
}
.kk-val {
  font: 600 calc(var(--cell) * 0.52) var(--serif); line-height: 1; color: var(--ink);
  transition: color 0.25s, transform 0.25s; margin-top: 6%;
}
.kk-val.drop { animation: drop 0.36s var(--ease); }
@keyframes drop {
  0% { transform: translateY(-28%) scale(1.5); opacity: 0; }
  60% { transform: translateY(3%) scale(0.96); opacity: 1; }
  100% { transform: none; }
}
.kk-cell.kk-same .kk-val { color: var(--accent); text-shadow: 0 0 0.35em var(--glow); }
.kk-cell.kk-bad .kk-val { color: var(--bad); }
.kk-cell.kk-done .kk-val { color: var(--good); }
.kk-cell.kk-done.kk-same .kk-val { color: var(--accent); }
.kk-notes {
  position: absolute; inset: 24% 8% 7%; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  font: italic 500 calc(var(--cell) * 0.2) var(--serif); color: var(--note); pointer-events: none;
}
.kk-notes i { visibility: hidden; display: grid; place-items: center; font-style: italic; }
.kk-notes i.on { visibility: visible; animation: notein 0.25s var(--ease); }
@keyframes notein { from { opacity: 0; transform: scale(0.6); } }
.kk-cell.has-val .kk-notes { display: none; }
[data-theme="chalk"] .kk-val, [data-theme="chalk"] .kk-label { text-shadow: 0 0 1px rgba(255, 255, 255, 0.45); }

/* -------------------------------------------------------- sheets, dialogs */
.backdrop { position: fixed; inset: 0; z-index: 20; background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; z-index: 21; max-width: 560px; max-height: 86dvh;
  display: flex; flex-direction: column; background: var(--paper); color: var(--ink);
  border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px var(--shadow); padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.32s var(--ease);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 22px; flex: 0 0 auto; }
.sheet h2, .dialog h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: 0.01em; }
.sheet-body { overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 22px 26px; font-size: 15px; line-height: 1.55; }
.sheet-body h3 { font-family: var(--serif); font-weight: 600; font-size: 17px; margin: 20px 0 8px; color: var(--ink); }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0; padding-left: 20px; }
.prose li { margin: 4px 0; }
.muted { color: var(--ink-soft); }
.about { font-size: 13px; margin-top: 22px; text-align: center; }

@media (min-width: 700px) and (min-height: 560px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 24px; max-height: 80dvh; animation: pop 0.28s var(--ease); }
}
@keyframes pop { from { opacity: 0; transform: translateY(-50%) scale(0.96); } }

.dialog {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 22; width: min(92vw, 400px);
  background: var(--paper); color: var(--ink); border-radius: 24px; padding: 26px 24px 22px; box-shadow: 0 20px 60px var(--shadow);
  text-align: center; animation: popc 0.3s var(--ease); overflow: hidden;
}
@keyframes popc { from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); } }
.dialog p { margin: 8px 0 18px; color: var(--ink-soft); font-size: 15.5px; line-height: 1.5; }
.dialog .row { display: flex; gap: 10px; }
.result .glow { position: absolute; inset: -40% -20% auto; height: 70%; background: radial-gradient(ellipse at 50% 40%, var(--glow), transparent 65%); pointer-events: none; opacity: 0.7; }
.result h2 { position: relative; font-size: 30px; animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 50% { text-shadow: 0 0 18px var(--glow); } }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.result-stats div, .summary div { display: flex; flex-direction: column; align-items: center; background: var(--paper-2); border-radius: 12px; padding: 8px 4px; line-height: 1.2; }
.result-stats span, .summary span { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.result-stats b, .summary b { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.final-score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 18px; }
.final-score span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.final-score b { font-family: var(--serif); font-size: 44px; font-weight: 600; line-height: 1.05; }

.sizes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 4px 0 16px; }
.size-opt {
  appearance: none; cursor: pointer; border: 1.5px solid var(--key-line); background: var(--paper-2); color: var(--ink);
  border-radius: 16px; padding: 12px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.size-opt:active { transform: scale(0.97); }
.size-opt b { font: 600 26px var(--serif); }
.size-opt span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.size-opt.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }

/* ------------------------------------------------------------- results */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { text-align: left; vertical-align: bottom; font-weight: 500; color: var(--ink-soft); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; padding: 4px; border-bottom: 1px solid var(--line); }
td { padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.c-time, .c-hints, .c-undos, .c-score, .c-games { text-align: right; }
td.c-score { font-family: var(--serif); font-weight: 600; font-size: 15px; }
td.c-size { font-family: var(--serif); font-weight: 600; }
@media (max-width: 420px) { .c-undos { display: none; } td { padding: 7px 3px; } }

/* ------------------------------------------------------------- settings */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  appearance: none; border: 1.5px solid var(--key-line); background: var(--paper-2); color: var(--ink);
  font: 500 14px var(--sans); padding: 8px 14px 8px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.opt:active { transform: scale(0.97); }
.opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
.opts.lang .opt { padding-left: 14px; min-width: 96px; justify-content: center; }
.swatch {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  background: var(--sw); color: var(--sw2); font: 600 14px var(--serif); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.toggle { display: flex; align-items: center; gap: 12px; margin-top: 20px; cursor: pointer; font-size: 15px; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: var(--key-line); position: relative; transition: background 0.25s; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s var(--ease); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(18px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(10px); z-index: 15;
  background: rgba(30, 26, 22, 0.93); color: #fff; padding: 10px 16px; border-radius: 16px; font-size: 14px; line-height: 1.4;
  max-width: min(88vw, 420px); text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
[data-theme="chalk"] .toast { background: rgba(244, 241, 231, 0.95); color: #1d2b27; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- small screens */
@media (max-height: 640px) {
  .top { padding-top: 4px; }
  .brand small { display: none; }
  .brand b { font-size: 19px; }
  .brand img { width: 32px; height: 32px; }
  .stat b { font-size: 16px; }
  .stat { padding: 3px 6px; }
  .actions { padding-bottom: 8px; }
  .btn { padding: 8px 10px; }
  .pad-key { height: 40px; font-size: 20px; }
  .cage-info { min-height: 20px; font-size: 12.5px; }
}
@media (max-width: 520px) {
  .btn { flex-direction: column; gap: 3px; padding: 8px 6px 7px; font-size: 12.5px; }
  .btn span { white-space: nowrap; }
  .btn svg { width: 21px; height: 21px; }
  .pad { gap: 5px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .brand b { font-size: 26px; }
  .stage { padding: 14px 16px; }
  .pad { max-width: 520px; margin: 0 auto; width: 100%; }
  .actions { max-width: 520px; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bg .blob { animation: none; }
  .kk-cell, .kk-val, .kk-notes i, .sheet, .dialog, .backdrop, .result h2 { animation: none !important; transition-duration: 0.01s; }
}
