@font-face { font-family: 'Space Grotesk'; src: url('fonts/SpaceGrotesk.ttf') format('truetype'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Manrope'; src: url('fonts/Manrope.ttf') format('truetype'); font-weight: 200 800; font-display: swap; }

:root {
  --paper: #F2EFE8;
  --paper-hi: #FBF9F4;
  --ink: #20302D;
  --muted: #5F6D67;
  --line: #CDD0C9;
  --coral: #F48169;
  --cobalt: #6589ED;
  --yellow: #EFC45E;
  --mint: #70BE9A;
  /* safe areas: Capacitor's SystemBars (insetsHandling "css") injects --safe-area-inset-* on Android, where older
     WebViews report env() as 0; iOS and the web use env(). */
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font-body); overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
[hidden] { display: none !important; }

/* --banner-h: the native AdMob banner's height while one is placed (ads.js); the app sits above it */
#app { position: fixed; inset: 0 0 var(--banner-h, 0px) 0; }
html.has-banner .screen { --safe-bottom: 0px; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 24px);
}

/* menu screens: one centred column, 480 px at most (tablets), safe-area aware */
.screen.home, .screen.sub {
  --gutter: max(24px, calc((100% - 480px) / 2));
  padding-left: calc(var(--safe-left) + var(--gutter)); padding-right: calc(var(--safe-right) + var(--gutter));
}
.screen.enter { animation: screen-in .22s var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ink { color: var(--ink); }
.paper { color: var(--paper); }

/* ---------- Home: stacked wordmark, four colour plates, Continue ---------- */
.home { padding-top: calc(var(--safe-top) + 20px); padding-bottom: calc(var(--safe-bottom) + 20px); gap: 20px; }
.wordmark {
  flex: none; margin: 0 0 0 -.04em; display: grid; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(64px, 25vw, 128px); line-height: .82; letter-spacing: -.055em;
}
.wordmark span:last-child { padding-left: .62em; } /* the second line is shifted, like a plate off register */
.tagline { flex: none; margin: -4px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.plates {
  flex: 1 1 auto; min-height: 0; max-height: calc((min(100vw, 480px) - 48px) * 1.25); margin-top: auto; /* plates at most 4:5 */
  display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 12px;
}
.plate {
  position: relative; min-height: 96px; border: 0; border-radius: 12px; background: var(--a); color: var(--ink); padding: 14px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .12), 0 4px 0 rgba(32, 48, 45, .14);
  transition: transform .12s var(--ease-out), box-shadow .12s;
}
.plate::before { content: ""; position: absolute; inset: 7px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .24); pointer-events: none; }
.plate:active { transform: translateY(3px); box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .12), 0 1px 0 rgba(32, 48, 45, .14); }
.plate .sym { width: clamp(30px, 11vw, 46px); height: clamp(30px, 11vw, 46px); opacity: .86; }
.plate b { font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.1; letter-spacing: -.01em; }
.plate .label { display: grid; gap: 3px; }
.plate .label small { font-size: 12px; font-weight: 700; line-height: 1.2; }
.plate-n { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; opacity: .78; font-variant-numeric: tabular-nums; }
.plate-n svg { width: 13px; height: 13px; }
.continue-btn {
  flex: none; width: 100%; min-height: 76px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper);
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 20px; text-align: left;
  box-shadow: 0 4px 0 rgba(32, 48, 45, .2);
}
.continue-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(32, 48, 45, .2); }
.c-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.c-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.1; letter-spacing: -.01em; }
.c-sub { font-size: 14px; font-weight: 600; opacity: .72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-go { flex: none; width: 50px; height: 50px; padding: 13px; border-radius: 50%; background: var(--yellow); color: var(--ink); }

/* ---------- menu screens: bar + scrolling body ---------- */
.screen.sub { padding-bottom: var(--safe-bottom); }
.bar { display: flex; align-items: center; gap: 4px; min-height: 64px; flex: none; }
.bar-title { flex: 1; min-width: 0; margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-readout { flex: none; display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-display); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.bar-readout svg { width: 16px; height: 16px; color: var(--yellow); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.scroll-main {
  position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  margin: 0 -8px; padding: 4px 8px 28px; /* screen reserves the home-indicator area; 8 px for rings and shadows */
}
.lede { margin: 4px 0 20px; font-size: 15px; line-height: 1.45; color: #34433F; }

/* ---------- Workshops ---------- */
.levels-summary { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--muted); }
.lv { aspect-ratio: 1; min-width: 54px; min-height: 54px; padding: 3px; border: 0; background: none; }
.lv-plate { width: 100%; height: 100%; border-radius: 9px; display: grid; place-items: center; align-content: center; gap: 1px; }
.lv b { font-family: var(--font-display); font-weight: 700; font-size: 18px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.lv.solved .lv-plate { background: var(--a); box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .28), inset 0 -2px 0 rgba(0, 0, 0, .12); }
.lv-stars { display: flex; gap: 1px; }
.lv-stars i { display: block; width: 10px; height: 10px; opacity: .28; }
.lv-stars i.on { opacity: 1; }
.lv-stars svg { display: block; width: 100%; height: 100%; }
.lv-plate.ink .lv-stars i.on { opacity: .86; }
.lv.open .lv-plate { background: var(--paper-hi); border: 1.5px solid var(--line); }
.lv.current .lv-plate { background: var(--ink); color: var(--paper); border: 0; box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5px var(--yellow); }
.lv.locked { cursor: default; }
.lv.locked .lv-plate { border: 1.5px dashed #C7C9C1; color: #9AA19B; }
.lv:active:not(.locked) .lv-plate { transform: scale(.94); }
.lv.nudge .lv-plate { animation: nudge .32s ease-out; }
@keyframes nudge { 20% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 80% { transform: translateX(-1px); } }
/* ---------- Settings ---------- */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 0; border-bottom: 1.5px solid var(--line); }
.row .txt { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; }
.row .txt b { font-weight: 700; font-size: 16px; }
.row .txt small { font-size: 13px; line-height: 1.35; color: var(--muted); }
.row.link { width: 100%; min-height: 64px; border: 0; border-bottom: 1.5px solid var(--line); background: none; }
.row.link:active { background: #ECE9E1; }
.row .chev { flex: none; width: 20px; height: 20px; color: var(--muted); transform: scaleX(-1); }
.row.danger .txt b { color: #A23B26; }
.switch { position: relative; flex: none; width: 58px; height: 34px; padding: 0; border: 0; border-radius: 17px; background: #CFCBC2; transition: background-color .15s; }
.switch::before { content: ""; position: absolute; inset: -10px -4px; } /* 54 px hit target */
.switch .knob { position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: var(--paper-hi); box-shadow: 0 1px 2px rgba(0, 0, 0, .28); transition: transform .18s var(--ease-out); }
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"] .knob { transform: translateX(24px); background: var(--yellow); }
.row.lang { flex-wrap: wrap; row-gap: 10px; }
.seg { flex-basis: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button { height: 54px; padding: 0 6px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--paper-hi); font-weight: 600; font-size: 15px; }
.seg button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.status-line { min-height: 1.4em; margin: 16px 0 0; font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; }
.version { display: block; margin: 4px auto 0; min-height: 54px; padding: 0 16px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.devlog { margin: 12px 0 0; white-space: pre-wrap; word-break: break-word; font-size: 11px; line-height: 1.4; color: #34433F; user-select: text; -webkit-user-select: text; }

/* ---------- Shop: Remove ads (ink plate), hint packs (colour plates), Restore ---------- */
.hint-readout { gap: 6px; height: 36px; padding: 0 13px 0 9px; border-radius: 18px; background: var(--ink); color: var(--paper); }
.hint-readout svg { width: 20px; height: 20px; color: var(--yellow); stroke: none; }
.noads {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 12px; padding: 20px 18px 18px;
  border-radius: 12px; background: var(--ink); color: var(--paper); box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .1), 0 4px 0 rgba(32, 48, 45, .2);
}
.noads::before { content: ""; position: absolute; inset: 7px; border-radius: 8px; border: 1px solid rgba(242, 239, 232, .12); pointer-events: none; }
.noads .sym { grid-column: 2; grid-row: 1; width: 34px; height: 34px; color: var(--yellow); }
.noads-txt { grid-column: 1; grid-row: 1; display: grid; gap: 6px; }
.noads-txt b { font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1.05; letter-spacing: -.02em; }
.noads-txt small { font-size: 14px; line-height: 1.4; color: rgba(242, 239, 232, .74); }
.price-key, .owned { grid-column: 1 / -1; position: relative; height: 54px; border-radius: 6px; display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.price-key { border: 0; background: var(--yellow); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14); }
.price-key:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .14); }
.price-key:disabled { background: rgba(242, 239, 232, .14); color: rgba(242, 239, 232, .6); box-shadow: none; cursor: default; }
.owned { border: 1.5px solid rgba(112, 190, 154, .55); color: var(--mint); font-size: 17px; }
.owned svg { width: 20px; height: 20px; }
.shop-h { margin: 30px 0 2px; font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.15; letter-spacing: -.01em; }
.shop-lede { margin: 0 0 14px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pack {
  position: relative; min-width: 0; min-height: 156px; border: 0; border-radius: 12px; background: var(--a); color: var(--ink); padding: 14px 10px 10px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .12), 0 4px 0 rgba(32, 48, 45, .14);
  transition: transform .12s var(--ease-out), box-shadow .12s;
}
.pack::before { content: ""; position: absolute; inset: 6px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .24); pointer-events: none; }
.pack:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .12), 0 1px 0 rgba(32, 48, 45, .14); }
.pack .sym { flex: none; width: 24px; height: 24px; margin-left: 2px; opacity: .86; }
.pack-q { display: grid; margin: auto 0 0 2px; }
.pack-n { font-family: var(--font-display); font-weight: 700; font-size: 42px; line-height: .9; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.pack-cap { font-size: 13px; font-weight: 700; opacity: .78; }
.pack-price { position: relative; align-self: stretch; height: 38px; margin-top: 4px; border-radius: 6px; background: var(--paper-hi); display: grid; place-items: center; font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.pack:disabled { cursor: default; box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(0, 0, 0, .12); }
.pack:disabled .sym, .pack:disabled .pack-q { opacity: .5; }
.pack:disabled .pack-price { background: rgba(251, 249, 244, .5); color: rgba(32, 48, 45, .6); }
.shop-rows { margin-top: 24px; }
.shop-rows .row.link { border-top: 1.5px solid var(--line); }
.row.link:disabled { cursor: default; }
.row.link:disabled .txt b, .row.link:disabled .chev { opacity: .45; }
.shop-test { margin: 6px 0 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
/* the out-of-hints sheet: compact pack keys under the rewarded ad, then Shop | Close */
.offer-packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pack.compact { min-height: 0; padding: 9px 6px 6px; gap: 4px; align-items: center; text-align: center; }
.pack.compact::before { inset: 4px; border-radius: 6px; }
.pack.compact .sym { display: none; }
.pack.compact .pack-q { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 0; }
.pack.compact .pack-n { font-size: 26px; }
.pack.compact .pack-price { height: 34px; margin-top: 2px; font-size: 14px; }
.offer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.offer-row .ghost-btn:only-child { grid-column: 1 / -1; }
.sheet-actions button:disabled { opacity: .5; cursor: default; }
.sheet-actions .pack:disabled { opacity: 1; }

/* ---------- game: top bar ---------- */
.game-bar { display: flex; align-items: center; gap: 4px; min-height: 64px; flex: none; }
.bar-btn { width: 54px; height: 54px; margin-left: -16px; border: 0; background: transparent; display: grid; place-items: center; border-radius: 6px; flex: none; }
.bar-btn svg { width: 24px; height: 24px; }
.level-id { flex: 1; min-width: 0; }
.kicker { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.level-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.15; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-count { text-align: right; flex: none; }
.moves-n { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.moves-cap { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 3px; }

/* ---------- game: board ---------- */
.stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board-box { flex: none; }
.targets { position: relative; }
.target { position: absolute; top: 0; height: 100%; display: grid; place-items: center; border-radius: 6px; }
.target::before { content: ""; position: absolute; inset: 0; border-radius: 6px; background: var(--a); opacity: 0; transition: opacity .25s ease; }
.target::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 4px; border-radius: 2px; background: var(--a); }
.target .glyph { position: relative; width: 20px; height: 20px; color: var(--ink); }
.target.done::before { opacity: .32; }
.target.win::before { animation: target-win .5s ease-out; }
@keyframes target-win { 0% { opacity: .32; } 40% { opacity: .75; } 100% { opacity: .32; } }

.frame { position: relative; background: var(--ink); border-radius: 16px; box-shadow: 0 6px 0 rgba(32, 48, 45, .12); }
.board, .pivots { position: absolute; inset: 8px; }
.pivots { pointer-events: none; z-index: 3; }
.tile {
  position: absolute; left: 0; top: 0; border-radius: 9px; background: var(--a); will-change: transform;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .28), inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.tile::before { content: ""; position: absolute; inset: 10%; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .22); pointer-events: none; }
.tile.moving { z-index: 2; }
.tile .glyph { position: absolute; left: 28%; top: 28%; width: 44%; height: 44%; }
.glyph.ink { color: var(--ink); opacity: .86; }
.glyph.paper { color: var(--paper); }
.tile.double { background: linear-gradient(135deg, var(--a) calc(50% - .5px), var(--b) calc(50% + .5px)); }
.tile.double .g-a { left: 13%; top: 13%; width: 32%; height: 32%; }
.tile.double .g-b { left: 55%; top: 55%; width: 32%; height: 32%; }
.tile.double::before { display: none; }
/* locked: a pin at the top centre (corners belong to the pivots); the symbol moves down to make room */
.tile .pin { position: absolute; left: 36%; top: 7%; width: 28%; height: 28%; }
.tile.locked .glyph { left: 31%; top: 40%; width: 38%; height: 38%; }
.tile.locked { box-shadow: inset 0 0 0 3px rgba(32, 48, 45, .28), inset 0 1.5px 0 rgba(255, 255, 255, .28); }
.tile.accent { animation: accent .45s ease-out; }
@keyframes accent { 0% { filter: none; } 35% { filter: brightness(1.16) saturate(1.08); } 100% { filter: none; } }

.block-ring { position: absolute; z-index: 1; border-radius: 12px; pointer-events: none; box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5px var(--ink); }
.pivot { pointer-events: auto; position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px; padding: 0; border: 0; background: transparent; display: grid; place-items: center; border-radius: 50%; }
.pivot .disk {
  width: 30px; height: 30px; border-radius: 50%; background: var(--paper); border: 2.5px solid var(--ink); display: grid; place-items: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35); transition: transform .12s var(--ease-out), background-color .12s;
}
.pivot.free .disk::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.pivot .arrow { width: 26px; height: 26px; color: var(--ink); }
.pivot .arrow.ccw { transform: scaleX(-1); }
.pivot.oneway .disk { width: 38px; height: 38px; }
.pivot.disabled { cursor: default; }
.pivot.disabled .disk { background: #A9ADA6; border-color: #56625E; box-shadow: none; }
.pivot.disabled .disk::after { content: ""; width: 12px; height: 2.5px; border-radius: 2px; background: #56625E; }
.pivot:active:not(.disabled) .disk { transform: scale(.92); }
.pivot.selected .disk { background: var(--yellow); transform: scale(1.12); }
.pivot.hint .disk { box-shadow: 0 0 0 3px var(--mint), 0 2px 0 rgba(0, 0, 0, .35); }

/* ---------- game: guide line and controls ---------- */
.guide-line { flex: none; margin: 10px 4px 8px; min-height: 2.8em; font-size: 15px; font-weight: 500; line-height: 1.4; text-align: center; color: #34433F; display: flex; align-items: center; justify-content: center; }
.dirs { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dir-btn { height: 56px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; transition: background-color .15s, color .15s; }
.dir-btn svg { width: 26px; height: 26px; }
.dir-btn svg.ccw { transform: scaleX(-1); }
.dir-btn:disabled { background: #DEDAD1; color: #8C9590; cursor: default; }
.dir-btn:active:not(:disabled) { transform: translateY(1px); }
.dir-btn.hint { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--mint); }
.tools { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.tool { position: relative; height: 54px; padding: 0 4px; border: 1.5px solid var(--line); border-radius: 6px; background: var(--paper-hi); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; white-space: nowrap; }
.tool svg { width: 20px; height: 20px; flex: none; }
.tool:disabled { opacity: .42; cursor: default; }
.tool:active:not(:disabled) { background: #ECE9E1; }
/* the hint count sits on the key's top-right corner, so a long "free" label never squeezes the key's own label */
.badge { position: absolute; top: -7px; right: 4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--ink); color: var(--paper); font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--paper); }
.badge.free { background: var(--mint); color: var(--ink); font-size: 11px; }

/* first-run guide: a tapping hand (fingertip at the target point) */
.guide { position: absolute; left: 0; top: 0; width: 46px; aspect-ratio: 40 / 48; z-index: 20; pointer-events: none; translate: -30% -4%; }
#screen-game[aria-busy="true"] .guide { visibility: hidden; } /* never point while the tiles travel */
.guide .hand { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; transform-origin: 30% 4%; filter: drop-shadow(0 2px 2px rgba(34, 43, 53, .35)); }
.guide .palm { fill: var(--paper-hi); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
.guide .crease { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; opacity: .55; }
.guide .ripple { position: absolute; left: 30%; top: 4%; width: 48px; aspect-ratio: 1; border-radius: 50%; border: 2.5px solid var(--yellow); translate: -50% -50%; opacity: 0; }
.guide.tap .hand { animation: hand-tap 1.7s var(--ease-out) infinite; }
.guide.tap .ripple { animation: hand-ripple 1.7s ease-out infinite; }
@keyframes hand-tap { 0% { transform: translate(22%, 26%); opacity: 0; } 16% { opacity: 1; } 36%, 62% { transform: translate(0, 0) scale(1); } 46% { transform: translate(0, 0) scale(.86); } 84% { transform: translate(0, 0); opacity: 1; } 100% { transform: translate(22%, 26%); opacity: 0; } }
@keyframes hand-ripple { 0%, 44% { transform: scale(.25); opacity: 0; } 48% { opacity: .95; } 82%, 100% { transform: scale(1.2); opacity: 0; } }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(32, 48, 45, .42); opacity: 0; transition: opacity .28s ease; }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0 auto; max-width: 480px; background: var(--paper);
  border-radius: 16px 16px 0 0; padding: 28px calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 24px) calc(var(--safe-left) + 24px);
  transform: translateY(100%); transition: transform .28s var(--ease-out); text-align: center;
}
.sheet.open { transform: none; }
.sheet h2 { margin: 0 0 12px; font-family: var(--font-display); font-weight: 700; font-size: 28px; }
.sheet p { margin: 8px 0; font-size: 15px; line-height: 1.45; color: #34433F; }
.win-stars { display: flex; justify-content: center; gap: 10px; margin: 4px 0 12px; }
.win-stars svg { width: 40px; height: 40px; color: #DEDAD1; stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.win-stars svg.on { color: var(--yellow); }
.win-moves { font-family: var(--font-display); font-weight: 600; font-size: 17px !important; color: var(--ink) !important; }
.sheet-actions { display: grid; gap: 8px; margin-top: 20px; }
.sheet-kicker { margin: 0 0 4px !important; font-size: 13px !important; font-weight: 700; color: var(--muted) !important; }
.danger-btn { width: 100%; height: 56px; border: 0; border-radius: 6px; background: #A23B26; color: var(--paper); font-weight: 700; font-size: 16px; }
.primary-btn { width: 100%; height: 56px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 16px; }
.ghost-btn { width: 100%; height: 54px; border: 1.5px solid var(--line); border-radius: 6px; background: transparent; font-weight: 600; font-size: 15px; }

/* ---------- consent prelude (after level 5, before level 6) ---------- */
.screen.consent {
  --gutter: max(28px, calc((100% - 440px) / 2));
  padding-left: calc(var(--safe-left) + var(--gutter)); padding-right: calc(var(--safe-right) + var(--gutter));
  padding-bottom: calc(var(--safe-bottom) + 24px);
}
.consent-prelude { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0; }
.consent-inks { display: flex; gap: 10px; margin-bottom: 22px; }
.consent-inks .sym { width: 30px; height: 30px; }
.consent-inks .s0 { color: var(--coral); } .consent-inks .s1 { color: var(--cobalt); }
.consent-inks .s2 { color: var(--yellow); } .consent-inks .s3 { color: var(--mint); }
.consent-prelude h1 { margin: 0 0 12px; font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.05; letter-spacing: -.02em; }
.consent-prelude p { margin: 0; font-size: 17px; line-height: 1.5; color: #34433F; }
.consent-prelude .primary-btn { margin-top: 32px; }
.consent-prelude .primary-btn:disabled { opacity: .6; }
.offer .status-line { margin-top: 10px; }

/* ---------- narrow phones (iPhone SE 1st gen, 320 px): the three tool keys keep their labels on one line ---------- */
@media (max-width: 359px) {
  .tool { gap: 4px; font-size: 13px; }
  .tool svg { width: 18px; height: 18px; }
}

/* ---------- small phones ---------- */
@media (max-height: 700px) {
  .home { padding-top: calc(var(--safe-top) + 12px); gap: 14px; }
  .wordmark { font-size: clamp(60px, min(23vw, 13vh), 128px); }
  .continue-btn { min-height: 68px; }
  .c-title { font-size: 22px; }
  .bar { min-height: 56px; }
  .game-bar { min-height: 54px; }
  .moves-n { font-size: 28px; }
  .level-name { font-size: 19px; }
  .guide-line { margin: 6px 4px 6px; font-size: 14px; }
  .dir-btn { height: 54px; }
  .consent-inks { margin-bottom: 16px; }
  .noads { padding: 16px 16px 14px; gap: 12px; }
  .noads-txt b { font-size: 23px; }
  .shop-h { margin-top: 24px; }
  .pack { min-height: 132px; }
  .pack-n { font-size: 36px; }
  .consent-prelude h1 { font-size: 28px; }
  .consent-prelude p { font-size: 15.5px; line-height: 1.45; }
  .consent-prelude .primary-btn { margin-top: 24px; }
}

/* ---------- tablets: the Home composition is centred instead of spread over the tall screen ---------- */
@media (min-width: 600px) and (min-height: 900px) {
  .home { justify-content: center; gap: 24px; }
  .wordmark { font-size: 150px; }
  .plates { flex: none; height: 432px; margin-top: 16px; }
}

/* ---------- reduced motion (OS setting or the in-app switch → html.rm) ---------- */
@media (prefers-reduced-motion: reduce) {
  .guide.tap .hand, .tile.accent, .target.win::before, .screen.enter, .lv.nudge .lv-plate { animation: none; }
  .switch, .switch .knob, .plate, .pack { transition: none; }
  .guide .ripple { display: none; }
  .sheet, .scrim, .pivot .disk, .target::before { transition: none; }
}
html.rm .guide.tap .hand, html.rm .tile.accent, html.rm .target.win::before, html.rm .screen.enter, html.rm .lv.nudge .lv-plate { animation: none; }
html.rm .switch, html.rm .switch .knob, html.rm .plate, html.rm .pack { transition: none; }
html.rm .guide .ripple { display: none; }
html.rm .sheet, html.rm .scrim, html.rm .pivot .disk, html.rm .target::before { transition: none; }

/* Home: one wide level plate and two small utility plates. */
.plates { grid-template-rows: 1.1fr 1fr; max-height: 340px; }
#go-levels { grid-column: 1 / -1; flex-direction: row; align-items: center; }
#go-levels .sym { width: 58px; height: 58px; }
#go-levels .label { flex: 1; margin-left: 18px; }
#go-levels .label b { font-size: 28px; }
#go-levels .plate-n { margin-top: 6px; }
.level-pages { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 20px; font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.level-pages button { width: 54px; height: 54px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--paper-hi); font-size: 30px; }
.level-pages button:disabled { opacity: .35; cursor: default; }
.level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px 0; padding: 5px 0; }
@media (max-height: 700px) { #go-levels .sym { width: 38px; height: 38px; } #go-levels .label b { font-size: 23px; } }
