:root {
  color-scheme: light dark;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: #28415c;
  background: #e9f7ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  --blue: #49b8e9;
  --deep-blue: #287fab;
  --yellow: #ffd35a;
  --coral: #ff8e78;
  --green: #63c99b;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: linear-gradient(180deg, #e9f7ff 0%, #fbfdff 74%);
}

button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid #e99745; outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.app {
  width: min(100%, 900px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

:root:not(.installed) .installed-only { display: none; }
.installed .install-guide { display: none; }
.install-guide {
  margin: 8px 0 16px;
  padding: 14px 18px;
  border-radius: 18px;
  background: #fff;
  font-size: .9rem;
  line-height: 1.5;
}
.install-guide h1 { font-size: 1.25rem; }
.install-guide ol { margin: 6px 0 0; padding-left: 20px; }
.install-guide p { margin: 0; }

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: #286d91;
  font-size: 1.4rem;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: -.04em;
}
.brand-train { width: 38px; height: 34px; margin-right: 5px; object-fit: contain; vertical-align: middle; }

.sound-toggle {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 #d1e4ee;
  font-size: 1.35rem;
  cursor: pointer;
}

main { flex: 1; display: flex; flex-direction: column; }
.screen { width: 100%; }
.home-screen { max-width: 620px; margin: auto; padding: 8px 0 18px; }

.welcome-art {
  position: relative;
  height: clamp(150px, 30vh, 220px);
  overflow: hidden;
  border-radius: 34px;
  background: linear-gradient(180deg, #94ddff 0%, #d2f3ff 76%, #a8e7ba 76%);
}
.welcome-art::after {
  position: absolute;
  right: -4%;
  bottom: -65px;
  left: -4%;
  height: 110px;
  border-radius: 50% 50% 0 0;
  background: #8ed8a8;
  content: "";
}
.cloud { position: absolute; z-index: 1; opacity: .8; font-size: 2rem; }
.cloud-one { top: 20px; left: 10%; }
.cloud-two { top: 43px; right: 12%; font-size: 1.5rem; }
.welcome-train-button {
  position: absolute;
  z-index: 2;
  bottom: 8px;
  left: 50%;
  width: clamp(8rem, 34vw, 14rem);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.welcome-train {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 5px 3px rgba(46, 117, 129, .18));
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}
.welcome-train-button:active .welcome-train { transform: translateY(3px); }
.welcome-train-button.animating .welcome-train {
  animation: welcome-train-whistle .72s ease-in-out both;
}
.welcome-train-button.animating::after {
  position: absolute;
  top: 0;
  right: 13%;
  pointer-events: none;
  content: "🎵";
  font-size: 1.55rem;
  animation: welcome-whistle-note .9s ease-out both;
}
@keyframes welcome-train-whistle {
  0%, 100% { transform: translateY(0) rotate(0); }
  28% { transform: translateY(-9px) rotate(-4deg); }
  58% { transform: translateY(1px) rotate(3deg); }
  78% { transform: translateY(-4px) rotate(-2deg); }
}
@keyframes welcome-whistle-note {
  0% { transform: translate(0, 0) scale(.7); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(18px, -42px) scale(1.25); opacity: 0; }
}

.welcome-copy { text-align: center; padding: 17px 4px 8px; }
.eyebrow { margin: 0 0 6px; color: #4586a5; font-size: .73rem; font-weight: 900; letter-spacing: .12em; }
h1 { margin: 0; color: #2b6687; font-size: clamp(1.7rem, 7vw, 2.45rem); letter-spacing: -.045em; }
.intro { margin: 8px 0 0; color: #668098; font-size: 1rem; }

.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.mode-card {
  position: relative;
  min-height: 154px;
  padding: 16px 12px 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: 25px;
  box-shadow: 0 6px 0 rgba(43, 102, 135, .12);
  color: #32506b;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.mode-card:active, .big-button:active, .piece-button:active, .wash-tool:active, .small-play-button:active { transform: translateY(3px); box-shadow: none; }
.go-card { background: #fff0be; }
.wash-card { background: #d9f3ff; }
.mode-art { font-size: 2.8rem; line-height: 1.1; }
.mode-art img { width: 70px; height: 54px; object-fit: contain; vertical-align: middle; }
.mode-name { font-size: clamp(1.05rem, 4vw, 1.25rem); font-weight: 900; }
.mode-hint { color: #607789; font-size: .78rem; }
.mode-arrow { position: absolute; top: 10px; right: 15px; color: rgba(40, 85, 110, .4); font-size: 1.7rem; }

.game-screen { position: relative; max-width: 760px; margin: auto; padding: 4px 0 16px; }
.game-heading {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  display: flex;
  pointer-events: none;
}
.game-heading .back-button { pointer-events: auto; }
.back-button {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 3px 0 #d1e4ee;
  color: #35799c;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.scene {
  position: relative;
  height: clamp(250px, 40vh, 370px);
  min-height: 250px;
  overflow: hidden;
  border-radius: 30px;
  background: linear-gradient(180deg, #a5e5ff 0%, #d5f4ff 70%, #b8ecc4 70%);
  isolation: isolate;
}
.sun { position: absolute; top: 18px; right: 22px; font-size: 2.5rem; }
.scene-cloud { position: absolute; opacity: .8; font-size: 2rem; }
.scene-cloud-one { top: 23px; left: 20px; }
.scene-cloud-two { top: 76px; left: 41%; font-size: 1.5rem; }
.station {
  position: absolute;
  z-index: 1;
  right: 10%;
  bottom: 93px;
  width: 104px;
  height: 121px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border: 5px solid #fff;
  border-bottom: 0;
  border-radius: 15px 15px 0 0;
  background: #ffcb70;
  box-shadow: 0 4px 0 rgba(83, 136, 122, .16);
}
.station::before, .station::after {
  position: absolute;
  top: 45px;
  width: 25px;
  height: 35px;
  border: 4px solid #fff;
  border-radius: 10px 10px 0 0;
  background: #b7e9f5;
  content: "";
}
.station::before { left: 9px; }
.station::after { right: 9px; }
.station-sign {
  position: absolute;
  top: -23px;
  left: 50%;
  z-index: 2;
  padding: 4px 8px;
  border: 3px solid #fff;
  border-radius: 9px;
  background: #ff967a;
  color: white;
  font-size: .69rem;
  font-weight: 900;
  white-space: nowrap;
  transform: translateX(-50%);
}
.station-animal { position: relative; z-index: 2; margin-bottom: -2px; font-size: 2.1rem; }
.station-greeting {
  position: absolute;
  z-index: 3;
  right: calc(100% + 12px);
  bottom: 69px;
  width: max-content;
  max-width: 145px;
  padding: 8px 11px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(46, 91, 114, .18);
  color: #28415c;
  font-size: .9rem;
  font-weight: 800;
}
.station-greeting::after {
  position: absolute;
  top: 50%;
  left: 100%;
  border: 7px solid transparent;
  border-right: 0;
  border-left-color: #fff;
  content: "";
}
.track {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.train-button {
  position: absolute;
  z-index: 3;
  top: calc(100% - 64px);
  left: 70px;
  width: 110px;
  aspect-ratio: 441 / 327;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1;
  cursor: pointer;
  transform: translate(-50%, -98%) rotate(var(--train-angle, 0rad));
  transform-origin: 50% 98%;
}
.train-button:disabled { cursor: default; }
.train-button img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px rgba(46, 91, 114, .18));
  transform: scaleX(var(--train-facing, 1));
}
.train-button.rolling img { animation: train-chug .27s ease-in-out infinite alternate; }
.train-button.rolling::before {
  position: absolute;
  z-index: 1;
  top: 4%;
  left: var(--chimney, 56%);
  width: 16%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: 9px 3px 0 -3px #fff, -5px -5px 0 -3px #fff;
  pointer-events: none;
  content: "";
  animation: train-steam .85s ease-out infinite;
}
@keyframes train-chug {
  to { transform: translateY(-3px) scaleX(var(--train-facing, 1)); }
}
@keyframes train-steam {
  from { transform: translate(-50%, 0) scale(.45); opacity: .9; }
  to { transform: translate(calc(var(--steam-drift, -28px) - 50%), -32px) scale(1.35); opacity: 0; }
}
.flowers { position: absolute; right: 0; bottom: 8px; left: 0; overflow: hidden; color: #539c68; text-align: center; white-space: nowrap; font-size: 1.3rem; }
.scene.wash-mode {
  background: linear-gradient(180deg, #c7f0ff 0 62%, #9ed5e4 62% 66%, #a8e7ba 66%);
}
.scene.wash-mode::before {
  position: absolute;
  z-index: 0;
  top: 10%;
  left: 50%;
  width: 58%;
  height: 58%;
  border: 12px solid #62bfd8;
  border-bottom: 0;
  border-radius: 100px 100px 0 0;
  content: "";
  transform: translateX(-50%);
}
.wash-mode .sun,
.wash-mode .scene-cloud,
.wash-mode .station,
.wash-mode .track,
.wash-mode .flowers { display: none; }
.wash-mode .train-button {
  width: 145px;
  pointer-events: none;
  --sponge-x: 50%;
  --sponge-y: 50%;
}
.wash-mode.scrub-selected { touch-action: none; cursor: grab; }
.wash-mode.scrubbing { cursor: grabbing; }
.train-dirt { display: none; }
.wash-mode .train-dirt {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  opacity: calc(1 - var(--wash-cleanliness, 0));
  transition: opacity .3s ease;
}
.train-dirt span {
  position: absolute;
  width: 13%;
  height: 8%;
  border-radius: 50%;
  background: #815333;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .4);
}
.train-dirt span:nth-child(1) { top: 31%; left: 31%; }
.train-dirt span:nth-child(2) { top: 43%; left: 54%; }
.train-dirt span:nth-child(3) { top: 58%; left: 38%; }
.train-dirt span:nth-child(4) { top: 28%; left: 68%; }
.train-dirt span:nth-child(5) { top: 60%; left: 72%; }
.wash-bubbles {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  grid-template: repeat(6, 1fr) / repeat(6, 1fr);
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}
.wash-bubbles button {
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
  width: clamp(24px, 25%, 34px);
  padding: 0;
  aspect-ratio: 1;
  border: 2px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #fff 0 8%, transparent 18%),
    radial-gradient(circle at 55% 60%, #7ed4ff55 28%, #e0bafa 90%);
  box-shadow: inset 0 0 9px #fff, 0 2px 5px #28415c40;
  animation: wash-bubbles 3s ease-out both;
}
.wash-bubbles button:disabled { visibility: hidden; }
.wash-bubbles button:focus-visible { opacity: 1; animation: none; }
.wash-bubbles button:nth-child(3n + 1) { width: clamp(24px, 32%, 38px); animation-delay: .12s; }
.wash-bubbles button:nth-child(4n + 2) { width: clamp(28px, 40%, 42px); animation-delay: .24s; }
.train-wet, .wash-sponge { display: none; }
.wash-mode .train-wet {
  position: absolute;
  inset: 33% 15% auto 26%;
  display: block;
  opacity: 0;
  text-align: center;
  font-size: 1.1rem;
  transition: opacity .8s ease;
}
.train-wet::before, .train-wet::after { position: absolute; content: "💧"; }
.train-wet::before { top: 80%; left: 0; }
.train-wet::after { top: 130%; right: 0; }
.wash-mode .train-button img { transition: filter .8s ease; }
.wash-mode.wash-wet .train-wet { opacity: 1; transition: none; }
.wash-mode.wash-wet .train-button img {
  filter: brightness(.84) saturate(1.2) drop-shadow(0 4px 2px rgba(46, 91, 114, .18));
  transition: none;
}
.wash-mode.scrub-selected .wash-sponge {
  position: absolute;
  top: var(--sponge-y);
  left: var(--sponge-x);
  display: block;
  width: 54px;
  height: 42px;
  border: 2px solid #a95f1b;
  border-radius: 35% 31% 37% 34% / 39% 36% 41% 36%;
  background:
    radial-gradient(ellipse at 18% 24%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 48% 18%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 76% 29%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 31% 55%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 64% 57%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 22% 81%, #a96222 0 2px, transparent 2.5px),
    radial-gradient(ellipse at 78% 82%, #a96222 0 2px, transparent 2.5px),
    linear-gradient(145deg, #ffe47a 0%, #ffc448 52%, #ef9b27 100%);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, .7), inset 0 -3px 2px rgba(169, 95, 27, .3), 0 3px 4px rgba(35, 54, 35, .4);
  transform: translate(-50%, -50%) rotate(-18deg);
  opacity: 1;
}
.wash-tool[aria-pressed="true"] {
  box-shadow: inset 0 0 0 3px #258ba9;
}
.wash-mode.wash-clean .train-button::after {
  position: absolute;
  top: -8%;
  right: 2%;
  pointer-events: none;
  content: "✨";
  font-size: 2rem;
  animation: wash-shine .9s ease-out both;
}
@keyframes wash-bubbles {
  0% { transform: translateY(14px) scale(.55); opacity: 0; }
  22%, 70% { opacity: .9; }
  100% { transform: none; opacity: .9; }
}
@keyframes wash-shine {
  0% { transform: scale(.4) rotate(-20deg); opacity: 0; }
  35% { transform: scale(1.2) rotate(12deg); opacity: 1; }
  100% { transform: scale(.8) rotate(35deg); opacity: 0; }
}

.game-controls { text-align: center; }
.game-message { min-height: 26px; margin: 12px 0 8px; color: #527187; font-size: 1rem; font-weight: 800; }
.big-button {
  min-height: 68px;
  min-width: min(100%, 270px);
  padding: 10px 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 23px;
  box-shadow: 0 5px 0 rgba(42, 114, 147, .18);
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.whistle-button { background: #43b7e6; }
.small-play-button {
  min-height: 52px;
  margin: 10px 4px 0;
  padding: 9px 18px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 #d8eaf1;
  color: #4c7085;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.piece-button {
  min-width: 92px;
  min-height: 76px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 #d8eaf1;
  color: #45677e;
  font-size: .77rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.wash-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.wash-tool {
  min-width: 0;
  min-height: 76px;
  padding: 6px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 4px 0 #d8eaf1;
  color: #45677e;
  font-size: .68rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.wash-tool span:first-child { font-size: 1.8rem; line-height: 1; }
footer {
  position: relative;
  min-height: 34px;
  padding: 10px 4px 0;
  color: #7892a2;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
}
footer span { padding: 0 4px; }
.version-watermark {
  position: absolute;
  right: 0;
  bottom: 1px;
  color: #7892a2;
  font-size: .62rem;
  font-weight: 600;
  opacity: .7;
}

@media (prefers-color-scheme: dark) {
  :root { color: #e5eff7; background: #131f2e; }
  body { background: linear-gradient(180deg, #131f2e 0%, #182838 74%); }

  .brand, h1 { color: #b6e4ff; }
  .eyebrow, .intro, .game-message, footer, .version-watermark { color: #b3c8d9; }
  .install-guide { background: #253b50; }
  .sound-toggle, .back-button, .small-play-button, .piece-button {
    background: #253b50;
    box-shadow: 0 4px 0 #0c1622;
    color: #d3edff;
  }
  .mode-card { color: #f5f3eb; box-shadow: 0 6px 0 #0c1622; }
  .go-card { background: #534526; }
  .mode-hint, .mode-arrow { color: #d0dcd9; }
  .whistle-button { background: #20698e; }

  .welcome-art { background: linear-gradient(180deg, #213a60 0%, #385573 76%, #2e594b 76%); }
  .welcome-art::after { background: #25483e; }
  .scene { background: linear-gradient(180deg, #233f62 0%, #415d78 70%, #315447 70%); }
  .flowers { color: #a0d3a7; }
}

@media (max-height: 650px) and (min-width: 600px) {
  .home-screen { padding-top: 0; }
  .welcome-art { height: 145px; }
  .mode-card { min-height: 125px; }
  .scene { height: 250px; }
}

@media (max-width: 380px) {
  .app { padding-right: 14px; padding-left: 14px; }
  .mode-picker { gap: 10px; }
  .mode-card { min-height: 144px; padding-right: 6px; padding-left: 6px; }
  .mode-hint { font-size: .7rem; }
  .piece-button { min-width: 83px; }
}

.installed,
.installed body {
  overflow: hidden;
  overflow: clip;
  overscroll-behavior: none;
}

.installed body {
  position: fixed;
  top: 0;
  left: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

@media (orientation: portrait) {
  .installed body {
    left: 100vw;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    padding: max(8px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-top));
    transform: rotate(90deg);
    transform-origin: top left;
  }
}

.installed .app {
  width: 640px;
  height: 360px;
  min-height: 0;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
  transform: scale(var(--app-scale, 1));
}
.installed main { min-height: 0; padding: 6px 0; }
.installed .topbar { flex: 0 0 44px; }
.installed .sound-toggle { width: 44px; height: 44px; }
.installed footer { min-height: 20px; padding-top: 4px; }

.installed .home-screen,
.installed .game-screen {
  display: grid;
  gap: 12px;
  max-width: none;
  height: 100%;
  margin: 0;
  padding: 0;
}
.installed .home-screen {
  grid-template: auto auto auto / minmax(0, 2fr) minmax(0, 3fr);
  align-content: center;
}
.installed .welcome-art { grid-row: span 3; height: auto; }
.installed .welcome-copy { padding: 0; }
.installed .mode-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 0; }
.installed .mode-card { min-height: 110px; padding: 8px; }

.installed .game-screen {
  gap: 6px;
  grid-template: minmax(0, 1fr) auto / minmax(0, 1fr);
}
.installed .game-heading { margin: 0; }
.installed .back-button { flex-basis: 44px; width: 44px; height: 44px; }
.installed .scene { height: auto; min-height: 0; }
.installed .station { bottom: 76px; }
.installed .game-controls {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 4px;
}
.installed .game-message { flex: 1 1 130px; min-width: 100px; min-height: 0; margin: 0; }
.installed .big-button,
.installed .small-play-button {
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 4px 10px;
}
.installed #go-controls .whistle-button { flex: 2 1 170px; }
.installed #go-controls #go-button { flex: 0 1 110px; }
.installed #go-controls .animal-picker { flex: 1 1 180px; }
.installed #wash-controls .game-message { flex: 0 1 145px; }
.installed #wash-controls .wash-picker { flex: 1 1 240px; }
.installed .animal-picker { display: flex; justify-content: center; gap: 6px; margin: 0; }
.installed .piece-button { min-width: 0; min-height: 54px; flex: 1; padding: 4px; }
.installed .wash-tool { min-height: 58px; padding: 4px 1px; border-radius: 13px; font-size: .6rem; }
.installed .wash-tool span:first-child { font-size: 1.5rem; }
.animal-picker .piece-button { font-size: 1.65rem; }
.game-controls button:disabled { opacity: .48; cursor: default; }
.scene.whistling .train-button::after {
  position: absolute;
  top: 2px;
  left: 45%;
  pointer-events: none;
  content: "🎵";
  animation: whistle-note .65s ease-out both;
}

@keyframes whistle-note {
  to { transform: translateY(-32px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .wash-bubbles button,
  .welcome-train-button.animating .welcome-train,
  .train-button.rolling img { animation: none; }
  .wash-bubbles button { opacity: .9; }
  .welcome-train-button.animating::after,
  .scene.whistling .train-button::after,
  .wash-mode.wash-clean .train-button::after,
  .train-button.rolling::before { content: none; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.jigsaw-card { background: #d9f4da; }
.installed .mode-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.installed .mode-picker .mode-arrow { display: none; }

.jigsaw-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  height: 100%;
}

.jigsaw-heading, .jigsaw-controls, .jigsaw-selection-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.jigsaw-heading h1 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.8rem); }
.jigsaw-selection {
  display: grid;
  align-content: center;
  gap: 8px;
  width: min(100%, 800px);
  margin: auto;
}

.jigsaw-selection fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.jigsaw-selection legend {
  margin-bottom: 4px;
  padding: 0;
  font-weight: bold;
}

.jigsaw-scenes, .jigsaw-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.jigsaw-selection label {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #e2f1f8;
  color: #28415c;
  text-align: center;
  font-weight: bold;
  cursor: pointer;
}
.jigsaw-selection label:has(:checked) { border-color: #287fab; background: #cbeeff; }
.jigsaw-selection label:has(:focus-visible) { outline: 3px solid #e99745; outline-offset: 1px; }
.jigsaw-selection input { position: absolute; opacity: 0; }
.jigsaw-scenes img { width: min(100%, 170px); max-height: 90px; object-fit: contain; border-radius: 5px; }
.jigsaw-counts { flex: 1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.jigsaw-counts label { min-height: 36px; }
.jigsaw-selection-actions { align-items: end; }
.jigsaw-selection-actions > button { min-width: 95px; }

.jigsaw-play {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
}
.jigsaw-controls p { flex: 1; margin: 0; font-weight: bold; }
.jigsaw-controls [aria-pressed="true"] { background: #b9e0f4; color: #264f68; }

.jigsaw-workspace {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  align-items: center;
  justify-items: center;
  gap: 16px;
  container-type: size;
}

.jigsaw-board, .jigsaw-tray {
  position: relative;
  width: min(100%, 160cqh);
  aspect-ratio: 8 / 5;
  border-radius: 8px;
  background: #e6f4f8;
}
.jigsaw-board { outline: 2px solid #abcbd9; }
#jigsaw-reference, #jigsaw-outline, .jigsaw-grid, #jigsaw-placed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#jigsaw-reference { opacity: .45; pointer-events: none; }
.jigsaw-guided #jigsaw-reference { opacity: .65; }
#jigsaw-reference.finished { opacity: 1; border-radius: inherit; }
.jigsaw-grid, .jigsaw-tray {
  display: grid;
  grid-template: repeat(var(--jigsaw-rows), minmax(0, 1fr)) / repeat(var(--jigsaw-columns), minmax(0, 1fr));
}
.jigsaw-grid button {
  padding: 0;
  border: 0;
  background: transparent;
}
.jigsaw-grid button:focus-visible { z-index: 1; outline-offset: -4px; }
#jigsaw-placed, #jigsaw-ghost { pointer-events: none; }
#jigsaw-placed img, #jigsaw-ghost {
  position: absolute;
  width: calc(150% / var(--jigsaw-columns));
  height: calc(150% / var(--jigsaw-rows));
  transform: translate(-50%, -50%);
}
#jigsaw-ghost { z-index: 3; filter: drop-shadow(0 2px 3px #28415c88); }
.jigsaw-tray { background: #c5dfe9; }
.jigsaw-tray button {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
}
.jigsaw-tray button img { display: block; width: 100%; height: 100%; pointer-events: none; }
.jigsaw-tray button[aria-pressed="true"] { background: #fcedb4; box-shadow: inset 0 0 0 2px #b97b2a; }
.jigsaw-tray button.dragging img { opacity: .24; }
.jigsaw-complete { display: grid; gap: 10px; }

@media (prefers-color-scheme: dark) {
  .jigsaw-card { background: #27534d; }
}

.album-button { justify-self: start; }
.album-screen { max-width: 760px; margin-inline: auto; }
.album-heading { display: flex; align-items: center; gap: 10px; }
.album-heading h1 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.8rem); }
.postcards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 4px 0;
}
.postcard {
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 6px;
  border: 2px solid #fff;
  border-radius: 18px;
  background: #fff0be;
  box-shadow: 0 4px 0 #e0bd71;
  color: #28415c;
  font-weight: 900;
  cursor: pointer;
}
.postcard:nth-child(3n + 2) { background: #d9f3ff; box-shadow: 0 4px 0 #a6cedf; }
.postcard:nth-child(3n) { background: #d9f4da; box-shadow: 0 4px 0 #aad3ae; }
.postcard span { font-size: 1.8rem; }
.album-greeting { margin: 12px 4px 0; }
