:root {
  color-scheme: light;
  font-family: ui-rounded, "Nunito", "Avenir Next", system-ui, sans-serif;
  background: #e8e3d7;
  color: #22241f;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 18% 0%, #fffdf6 0 17%, transparent 42%),
    #e8e3d7;
}

button, a { font: inherit; }

button {
  min-height: 44px;
  border: 1px solid #c7c1b3;
  border-radius: 14px;
  padding: 9px 14px;
  color: inherit;
  background: #fffdf8;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible, a:focus-visible { outline: 3px solid #176e83; outline-offset: 3px; }
button:disabled { opacity: .42; cursor: not-allowed; }

.shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(68px + env(safe-area-inset-top)) 12px calc(22px + env(safe-area-inset-bottom));
}

.topbar, .top-actions, .level-row, .map-heading, .controls, .result-actions {
  display: flex;
  align-items: center;
}

.topbar { min-height: 44px; justify-content: space-between; gap: 8px; }
.top-actions { gap: 5px; }

.lab-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #31574b;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.quiet-button, .icon-button {
  min-height: 44px;
  border-color: transparent;
  padding: 7px 9px;
  background: transparent;
  color: #4c5148;
  font-size: 13px;
  font-weight: 750;
}

.icon-button { width: 44px; padding: 0; font-size: 21px; }

.title-screen { padding: clamp(58px, 13vh, 118px) 14px 32px; text-align: center; }
.eyebrow { margin: 0 0 7px; color: #757a70; font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(32px, 10vw, 45px); line-height: 1.05; letter-spacing: -.045em; }
.subtitle { max-width: 32ch; margin: 17px auto 25px; color: #5c6159; font-size: 16px; line-height: 1.45; }
.instruction { min-height: 1.4em; margin: 11px 2px; color: #62685d; font-size: 14px; line-height: 1.4; }
.title-screen .subtitle, .title-screen .instruction { display: none; }

.primary-button {
  border-color: #24645f;
  color: #fffdf8;
  background: #24645f;
  box-shadow: 0 4px 0 #174942;
  font-weight: 850;
}
.primary-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #174942; }

#play-screen { padding: 12px 0 0; }
.level-row { justify-content: space-between; gap: 12px; padding: 0 3px; }
.level-name { margin: 0; font-size: 18px; font-weight: 850; }
.move-count { margin: 0; color: #686d63; font-size: 13px; font-variant-numeric: tabular-nums; }

.board-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid #cfc7b7;
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: 0 6px 20px rgb(62 51 30 / .10);
}

#board { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.message { min-height: 1.4em; margin: 11px 5px 6px; color: #51574e; font-size: 14px; line-height: 1.35; }
.message.refused { color: #9b3b31; }

.controls { justify-content: center; gap: 9px; padding: 8px 0 11px; }
.controls button { min-width: 92px; font-weight: 750; }

.result-card {
  margin: 4px 0 12px;
  padding: 20px 16px 16px;
  border: 1px solid #a7c7a6;
  border-radius: 20px;
  background: #f5fbef;
  text-align: center;
}
.result-title { margin: 0; color: #24594c; font-size: 24px; font-weight: 900; }
.result-marks { margin: 7px 0 5px; font-size: 16px; font-weight: 800; }
.share-line { min-height: 1.4em; margin: 0 auto 14px; color: #5a6758; font-size: 13px; line-height: 1.4; }
.result-actions { justify-content: center; flex-wrap: wrap; gap: 8px; }
.result-actions button { font-weight: 750; }

.map-heading { justify-content: space-between; gap: 15px; padding: 12px 4px 3px; }
.map-heading h1 { font-size: 32px; }
.level-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 18px; }
.level-tile { min-height: 76px; padding: 10px 7px; text-align: left; }
.level-tile strong, .level-tile small { display: block; }
.level-tile strong { font-size: 17px; }
.level-tile small { margin-top: 4px; color: #687067; font-size: 11px; line-height: 1.25; }
.level-tile.complete { border-color: #79a982; background: #f4fbef; }

.hand-demo {
  position: absolute;
  z-index: 2;
  display: none;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgb(255 255 255 / .86);
  box-shadow: 0 2px 9px rgb(0 0 0 / .16);
  color: #24594c;
  font-size: 25px;
  line-height: 42px;
  text-align: center;
  pointer-events: none;
}
.hand-demo.running { display: block; animation: hand-pulse 1.8s ease-in-out infinite; }
@keyframes hand-pulse { 0%, 100% { transform: scale(.78); opacity: .15; } 42%, 60% { transform: scale(1); opacity: 1; } }

.success-effect { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.success-effect i { position: absolute; top: 47%; left: 50%; width: 9px; height: 9px; border-radius: 2px; opacity: 0; background: #e5a52d; }
.success-effect.on i { animation: confetti .72s ease-out both; }
.success-effect i:nth-child(2) { background: #4d91ae; animation-delay: .05s; }
.success-effect i:nth-child(3) { background: #bb5f70; animation-delay: .1s; }
.success-effect i:nth-child(4) { background: #5d9663; animation-delay: .02s; }
.success-effect i:nth-child(5) { background: #9d71ad; animation-delay: .12s; }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--x, 0), var(--y, 0)) rotate(240deg); opacity: 0; } }
.success-effect i:nth-child(1) { --x: -112px; --y: -105px; }.success-effect i:nth-child(2) { --x: 106px; --y: -96px; }.success-effect i:nth-child(3) { --x: 130px; --y: 92px; }.success-effect i:nth-child(4) { --x: -126px; --y: 78px; }.success-effect i:nth-child(5) { --x: 8px; --y: -145px; }

.load-error { margin: 54px 8px; padding: 18px; border: 1px solid #c4695e; border-radius: 14px; background: #fff5f2; color: #742f27; line-height: 1.4; }
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
@media (min-width: 700px) { .shell { margin-top: 18px; min-height: calc(100dvh - 36px); border: 1px solid rgb(117 110 96 / .2); border-radius: 28px; background: rgb(255 253 248 / .62); box-shadow: 0 20px 60px rgb(58 48 30 / .12); } }

/* ---- Telephone of Babel look: airmail letter (registry 2026-10-15) ---- */
:root {
  --pl-font: "Nunito", ui-rounded, "Avenir Next", system-ui, sans-serif;
  --pl-topbar-bg: #E6ECEF;
  --pl-topbar-text: #23418C;
  --pl-control-text: #1C2333;
  --pl-control-bg: #FBFAF4;
  --pl-control-border: #9AA3B2;
  --pl-focus: #23418C;
  --pl-overlay: rgb(28 35 51 / .62);
  --pl-card-bg: #FBFAF4;
  --pl-card-text: #1C2333;
  --pl-card-muted: #4C5468;
  --pl-card-border: #1C2333;
  --pl-primary: #23418C;
  --pl-primary-text: #FBFAF4;
  --pl-share-bg: #FBFAF4;
  --pl-radius-control: 6px;
  --pl-radius-card: 8px;
  --pl-radius-picture: 4px;
  background: #E6ECEF;
  color: #1C2333;
}
body {
  background:
    repeating-linear-gradient(0deg, rgb(28 35 51 / .035) 0 1px, transparent 1px 6px),
    #E6ECEF;
}
button { border-radius: 6px; border-color: #9AA3B2; background: #FBFAF4; }
.board-shell {
  border: 0; border-radius: 6px; padding: 5px;
  background: repeating-linear-gradient(135deg, #C8363D 0 12px, #FBFAF4 12px 18px, #23418C 18px 30px, #FBFAF4 30px 36px);
  box-shadow: 0 3px 0 rgb(28 35 51 / .18);
}
#board { border-radius: 3px; }
.level-name { font-family: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif; font-weight: 600; color: #1C2333; }
.move-count { color: #4C5468; }
.primary-button { border-color: #23418C; background: #23418C; box-shadow: 0 4px 0 #162a5c; }
.primary-button:active { box-shadow: 0 2px 0 #162a5c; }
.result-card { border: 2px dashed #3A2F4F; border-radius: 6px; background: #FBFAF4; }
.result-title { color: #23418C; font-family: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif; }
.level-tile { border-radius: 6px; }
.level-tile.complete { border-color: #23418C; background: #FBFAF4; box-shadow: inset 0 0 0 2px rgb(35 65 140 / .25); }
.hand-demo { color: #23418C; }
.move-count { white-space: nowrap; }
@media (max-width: 360px) { .level-name { font-size: 16px; } }
/* After sending, the result card replaces Undo/Reset so Share result stays on a phone screen. */
#play-screen > .instruction:empty { display: none; }
.level-row { margin-bottom: 8px; }
#play-screen:has(#result-screen:not([hidden])) > .controls { display: none; }
#play-screen:has(#result-screen:not([hidden])) .result-card { margin-top: 10px; padding: 12px 14px 12px; }
/* The crush's face is the result: the card fades in once the postcard has landed. */
@keyframes tob-card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.result-card:not([hidden]) { animation: tob-card-in 260ms ease-out both; animation-delay: var(--tob-reveal, 0ms); }
.reduced-motion .result-card:not([hidden]) { animation: none; }
@media (prefers-reduced-motion: reduce) { .result-card:not([hidden]) { animation: none; } }
.level-tile.today-tile { grid-column: 1 / -1; min-height: 64px; }
@media (max-width: 359px) { .level-map { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ONE-RULE PATCH: the New tag on a level's new rule */
.instruction.pl-new-rule { font-weight: 600; }
.pl-new-tag { display: inline-block; padding: 1px 7px; margin-right: 2px; border-radius: 999px; background: #d9482b; color: #fff;
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
