/* Malbuch – one stylesheet. Fonts ship with the app (offline, App Store):
   Chewy for the playful voice (wordmark, headings, names, buttons),
   Nunito for everything that has to be read small. */

@font-face { font-family: "Chewy"; src: url(../fonts/chewy-latin.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "Nunito"; src: url(../fonts/nunito-latin-var.woff2) format("woff2"); font-weight: 600 900; font-display: block; }

:root {
  --sky: #E6EEF5;
  --sky-deep: #D3E0EC;
  --card: #FFFFFF;
  --ink: #17121F;
  --ink-soft: #4A4458;
  --grape: #3B1466;
  --grape-2: #5A1F8F;
  --orb: #A51C8C;
  --sun: #FFD23F;
  --sun-ink: #2A1A00;
  --danger: #C6372E;
  --focus: #5A1F8F;
  --r-card: 16px;
  --shadow: 0 1px 2px rgba(23, 18, 31, .06), 0 10px 24px -8px rgba(23, 18, 31, .18);
  --shadow-lift: 0 1px 2px rgba(23, 18, 31, .06), 0 18px 30px -10px rgba(23, 18, 31, .26);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --display: "Chewy", "Nunito", ui-rounded, sans-serif;
  --tool: #E53935;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky);
  color: var(--ink);
  font-family: "Nunito", ui-rounded, system-ui, sans-serif;
  font-weight: 700;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; overflow: hidden; }
::selection { background: var(--sun); color: var(--sun-ink); }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .35; cursor: default; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

svg { width: 28px; height: 28px; flex: none; }

#app { height: 100%; }
.boot { display: grid; place-items: center; height: 100%; margin: 0; font-size: 22px; color: var(--ink-soft); }

.screen {
  height: 100%;
  padding: calc(22px + var(--safe-t)) calc(32px + var(--safe-r)) calc(22px + var(--safe-b)) calc(32px + var(--safe-l));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen::-webkit-scrollbar { width: 10px; }
.screen::-webkit-scrollbar-thumb { background: var(--sky-deep); border-radius: 10px; border: 3px solid var(--sky); }

/* ---- shared controls ---------------------------------------------------- */

.pill, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 26px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: .01em;
  transition: transform .2s var(--ease);
}
.pill svg, .btn svg { width: 24px; height: 24px; }
.pill-sun, .btn-primary { background: var(--sun); color: var(--sun-ink); box-shadow: 0 6px 14px -6px rgba(23, 18, 31, .35); }
.pill-ghost { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn-danger { color: var(--danger); }
.btn-quiet { background: none; box-shadow: none; color: var(--ink-soft); }
.pill:active, .btn:active, .round:active, .icon-btn:active, .tool-btn:active, .swatch:active { transform: scale(.94); }

.round, .icon-btn {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform .2s var(--ease);
}

.bar { display: flex; align-items: center; gap: 12px; }
.bar-spacer { flex: 1; }

/* ---- start -------------------------------------------------------------- */

.start { position: relative; padding: 0; overflow: hidden; background: var(--grape); color: #fff; }
.start-poster, .start-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.start-video { opacity: 0; transition: opacity .6s var(--ease); }
.start-video.ready { opacity: 1; }
.start-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(59, 20, 102, .55) 0%, rgba(59, 20, 102, 0) 26%),
    linear-gradient(0deg, rgba(43, 10, 74, .7) 0%, rgba(59, 20, 102, 0) 34%),
    radial-gradient(60% 30% at 50% 17%, rgba(43, 10, 74, .55), rgba(43, 10, 74, 0));
}
.start-top {
  position: absolute;
  top: calc(26px + var(--safe-t));
  left: calc(36px + var(--safe-l));
  right: calc(36px + var(--safe-r));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.brand { position: relative; padding-top: 34px; }
.brand .sitters { position: absolute; left: 0; top: 0; width: 300px; height: 66px; overflow: visible; }
.wordmark { font-family: var(--display); font-size: 76px; line-height: .9; color: #fff; text-shadow: 0 3px 0 rgba(43, 10, 74, .35); }
.parents { min-height: 46px; padding: 0 18px; font-size: 18px; }
.start-title {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(124px + var(--safe-t));
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-weight: 400;
  font-size: 56px;
  letter-spacing: .01em;
  text-shadow: 0 2px 16px rgba(30, 6, 50, .6);
}
/* the two children stand left and right of the dino, he stays in view */
.profiles {
  position: absolute;
  left: calc(56px + var(--safe-l));
  right: calc(56px + var(--safe-r));
  bottom: calc(44px + var(--safe-b));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.profile { display: grid; justify-items: center; gap: 12px; transition: transform .3s var(--ease); }
.profile:active { transform: scale(.95); }
.profile .disc {
  width: 184px;
  height: 184px;
  border-radius: 50%;
  display: grid;
  place-items: end center;
  overflow: hidden;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .9), 0 18px 30px -10px rgba(10, 0, 30, .6);
}
.profile .disc svg { width: 164px; height: 164px; margin-bottom: -14px; }
.profile .name { font-family: var(--display); font-size: 30px; padding: 4px 24px; border-radius: 999px; background: #fff; color: var(--ink); }

/* ---- home --------------------------------------------------------------- */

.home-head { display: flex; align-items: center; gap: 18px; }
.home-head .me { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: end center; overflow: hidden; }
.home-head .me svg { width: 60px; height: 60px; margin-bottom: -6px; }
.home-head h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 48px; letter-spacing: .01em; }

.hero {
  position: relative;
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  min-height: 214px;
  border-radius: 24px;
  overflow: hidden;
  background: var(--grape-2);
  color: #fff;
}
.hero-orb { position: absolute; right: 120px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: var(--orb); }
.hero-copy { position: relative; padding: 30px 34px; display: grid; gap: 14px; justify-items: start; }
.hero h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 38px; line-height: 1.05; letter-spacing: .01em; }
.hero p { margin: 0; color: #EBDCFA; font-size: 18px; max-width: 30ch; }
.hero-art {
  position: relative;
  justify-self: end;
  align-self: end;
  width: 300px;
  margin: 0 26px -18px 0;
  border-radius: 14px;
  transform: rotate(-4deg);
  background: #fff;
  box-shadow: 0 18px 40px -12px rgba(10, 0, 30, .6);
}
.hero-char { position: relative; justify-self: center; }
.hero-char svg { width: 190px; height: 190px; }

.row-title { margin: 30px 2px 14px; font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: .01em; }

.themes { display: flex; gap: 12px; flex-wrap: wrap; }
.theme {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 22px 7px 7px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-family: var(--display);
  font-size: 22px;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.theme img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #fff; }
.theme.on { background: var(--ink); color: #fff; }

.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.level {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  outline: 3px solid transparent;
  outline-offset: -3px;
  transition: outline-color .2s var(--ease);
}
.level svg { width: 62px; height: 62px; }
.level b { display: block; font-family: var(--display); font-weight: 400; font-size: 26px; }
.level span span { display: block; font-size: 15px; color: var(--ink-soft); }
.level.on { outline-color: var(--ink); }

.motifs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.motif {
  display: grid;
  gap: 10px;
  padding: 10px 10px 14px;
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow);
  font-family: var(--display);
  font-size: 22px;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.motif:active { transform: scale(.97); }
.motif img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 10px; background: #fff; }
.motif.blank { background: transparent; box-shadow: none; outline: 3px dashed #AFC3D6; outline-offset: -3px; color: var(--ink-soft); place-content: center; justify-items: center; }
.motif.blank svg { width: 64px; height: 64px; color: #7E97AE; }

.gallery { display: flex; gap: 16px; overflow-x: auto; padding: 2px 2px 20px; }
.shot { position: relative; flex: none; }
.shot-open img { display: block; width: 228px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.shot-missing { display: grid; place-items: center; align-content: center; gap: 6px; width: 228px; aspect-ratio: 4 / 3; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); color: var(--ink-soft); font-size: 14px; text-align: center; padding: 10px; }
.shot-missing svg { width: 64px; height: 64px; }
.shot-play, .shot-more {
  position: absolute;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.shot-play { left: 10px; background: var(--sun); color: var(--sun-ink); box-shadow: 0 6px 14px -6px rgba(23, 18, 31, .35); }
.shot-more { right: 10px; background: rgba(255, 255, 255, .94); color: var(--ink-soft); }
.shot-play svg, .shot-more svg { width: 22px; height: 22px; }
.empty { color: var(--ink-soft); font-size: 19px; margin: 4px; }

.dialog.wide { width: min(900px, 100%); }
.film { display: block; width: 100%; height: auto; border-radius: 16px; background: #fff; margin-bottom: 18px; box-shadow: var(--shadow); }

/* ---- paint -------------------------------------------------------------- */

.paint {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "rail stage" "rail palette";
  gap: 12px 18px;
  padding: calc(14px + var(--safe-t)) calc(22px + var(--safe-r)) calc(16px + var(--safe-b)) calc(22px + var(--safe-l));
  overflow: hidden;
  background: var(--sky);
}
.paint-bar { grid-area: bar; }
.input-hint { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; }
.input-hint svg { width: 18px; height: 18px; }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: currentColor; margin: 0 6px; opacity: .6; }
.done-btn { min-height: 58px; }

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 10px;
  border-radius: 34px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow-y: auto;
  flex: none;
}
.tool-btn {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  flex: none;
  border-radius: 20px;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.tool-btn svg { width: 38px; height: 38px; }
.tool-btn.on { background: var(--sky); box-shadow: inset 0 0 0 3px var(--ink); }
.help-btn { margin-top: auto; color: var(--ink-soft); }
.help-btn.on { color: #fff; background: var(--grape-2); box-shadow: none; }

/* medium and hard carry more tools: two columns, the landscape canvas is
   height-bound anyway, so the width is free */
.level-medium .rail, .level-hard .rail { display: grid; grid-template-columns: repeat(2, 58px); align-content: start; gap: 8px; }
.level-medium .tool-btn, .level-hard .tool-btn { width: 58px; height: 58px; border-radius: 18px; }
.level-medium .tool-btn svg, .level-hard .tool-btn svg { width: 32px; height: 32px; }
.level-medium .sizes, .level-hard .sizes { grid-column: 1 / -1; flex-direction: row; justify-content: center; }
.level-medium .size-btn, .level-hard .size-btn { width: 40px; }
.level-medium .help-btn, .level-hard .help-btn { grid-column: 1 / -1; width: 100%; margin-top: 0; }

.numbers-btn, .mirror-btn, .fit-btn { min-height: 58px; padding: 0 20px 0 14px; font-size: 20px; }
.numbers-btn svg { width: 34px; }
.numbers-btn.on, .mirror-btn.on { background: var(--grape-2); color: #fff; }
.fit-btn[hidden] { display: none; }
.swatch.numbered { display: grid; place-items: center; font-weight: 900; font-size: 18px; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .7), 0 0 1px #000; }

.sizes { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; border-top: 2px solid var(--sky); }
.size-btn { display: grid; place-items: center; width: 56px; height: 44px; border-radius: 14px; }
.size-btn i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.size-btn.on { background: var(--sky); box-shadow: inset 0 0 0 2px var(--ink); }

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  touch-action: none;
}
.paint-view {
  position: absolute;
  inset: 0;
  touch-action: none;
  border-radius: 12px;
}

.palette-wrap {
  grid-area: palette;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 12px 22px;
  border-radius: 34px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.palette { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.palette.two-rows { display: grid; grid-template-columns: repeat(12, auto); }
.stamps { display: flex; gap: 8px; justify-content: center; flex-basis: 100%; }
.stamps[hidden] { display: none; }
.stamp-btn { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--sky); }
.stamp-btn svg { width: 38px; height: 38px; }
.stamp-btn.on { box-shadow: inset 0 0 0 3px var(--ink); background: #fff; }
.level-easy .stamp-btn { width: 64px; height: 64px; }
.tones { display: grid; grid-template-columns: repeat(5, auto); gap: 6px; padding-left: 18px; border-left: 2px solid var(--sky-deep); }
.swatch {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12), inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: transform .2s var(--ease);
}
.swatch.on { transform: scale(1.14); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12), 0 0 0 4px #fff, 0 0 0 7px var(--ink); }
.tone { width: 42px; height: 42px; }

/* easy: fewer, bigger targets */
.level-easy .swatch { width: 60px; height: 60px; }
.level-easy .palette { gap: 14px; }
.level-easy .tool-btn { width: 76px; height: 76px; }
.level-medium .palette, .level-hard .palette { gap: 6px 8px; }
.level-medium .swatch, .level-hard .swatch { width: 42px; height: 42px; }
.level-hard .tone { width: 40px; height: 40px; }

/* ---- dialogs ------------------------------------------------------------ */

#layer:empty { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(30, 10, 52, .45);
  z-index: 10;
  animation: fade .18s ease-out;
}
.dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 30px;
  border-radius: 28px;
  background: var(--sky);
  box-shadow: 0 24px 60px -12px rgba(10, 0, 30, .45);
  text-align: center;
  animation: rise .3s var(--ease);
}
.dialog-title { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 12px; font-family: var(--display); font-weight: 400; font-size: 32px; }
.dialog-title.big { font-size: 48px; margin: 24px 0; }
.dialog-text { font-size: 22px; margin: 6px 0 20px; }
.dialog-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.dialog-actions.column { flex-direction: column; align-items: stretch; }
.dialog-preview { width: 100%; border-radius: 16px; margin-bottom: 18px; background: #fff; }

.gate-display { display: block; min-height: 44px; font-size: 32px; font-weight: 900; letter-spacing: 4px; margin-bottom: 10px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.key { min-height: 62px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); font-size: 26px; font-weight: 800; }

.settings-profile { border: 0; margin: 0 0 20px; padding: 18px; border-radius: 20px; background: var(--card); text-align: left; }
.settings-profile label { display: grid; gap: 6px; }
.settings-profile input {
  font: inherit;
  font-size: 22px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--sky-deep);
  color: var(--ink);
  caret-color: var(--grape-2);
  -webkit-user-select: text;
  user-select: text;
}
.settings-profile input:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.setting-label { margin: 14px 0 8px; }
.setting-hint { margin: 0 0 12px; color: var(--ink-soft); font-size: 16px; }
.privacy { text-align: left; }
.privacy h3 { margin: 18px 0 4px; font-size: 18px; }
.privacy p { margin: 0 0 6px; font-size: 16px; line-height: 1.45; }
.wipe-row { margin-top: 12px; }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-opt { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: end center; overflow: hidden; }
.avatar-opt svg { width: 54px; height: 54px; margin-bottom: -5px; }
.avatar-opt.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.seg { display: flex; gap: 8px; }
.seg-btn { flex: 1; min-height: 48px; border-radius: 14px; background: var(--sky); }
.seg-btn.on { background: var(--ink); color: #fff; }

.toast {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  padding: 22px 34px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 24px 60px -12px rgba(10, 0, 30, .45);
  font-family: var(--display);
  font-size: 34px;
  z-index: 20;
  overflow: hidden;
  animation: rise .3s var(--ease);
}

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.confetti i {
  position: absolute;
  top: -12px;
  left: calc(var(--i) * 4.2%);
  width: 10px;
  height: 16px;
  border-radius: 3px;
  background: hsl(calc(var(--i) * 47) 85% 58%);
  animation: fall 1.6s ease-in calc(var(--i) * 40ms) both;
}

.offscreen { position: fixed; left: -10000px; top: 0; width: 400px; height: 300px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes fall { to { transform: translateY(420px) rotate(540deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* portrait iPad: children above each other is not needed, but less room */
@media (max-aspect-ratio: 1/1) {
  .profile .disc { width: 150px; height: 150px; }
  .profile .disc svg { width: 134px; height: 134px; }
  .hero { grid-template-columns: 1fr; }
  .hero-art, .hero-char { display: none; }
}

@media (max-width: 760px) {
  .levels { grid-template-columns: 1fr; }
  .input-hint { display: none; }
}

/* ---- phone (MAL-42) --------------------------------------------------------
   The smallest iPad is 744 pt wide; anything below 600 pt in either direction
   is a phone. The picture gets the room, tools and colours become one strip
   each that scrolls sideways (portrait) or down (landscape). */
@media (max-width: 600px), (max-height: 600px) {
  .wordmark { font-size: 50px; }
  .brand { padding-top: 26px; }
  .brand .sitters { width: 200px; height: 44px; }
  .start-top { top: calc(14px + var(--safe-t)); left: calc(18px + var(--safe-l)); right: calc(18px + var(--safe-r)); }
  .parents { min-height: 40px; padding: 0 14px; font-size: 16px; }
  .start-title { top: calc(96px + var(--safe-t)); font-size: 34px; }

  .paint { gap: 8px; padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l)); }
  .paint-bar { gap: 8px; }
  .paint-bar .icon-btn { width: 46px; height: 46px; }
  .paint-bar .btn { min-height: 46px; padding: 0 16px; font-size: 18px; gap: 6px; }
  .numbers-btn span, .mirror-btn span, .fit-btn span { display: none; }
  .numbers-btn, .mirror-btn, .fit-btn { padding: 0 12px; }
  .input-hint { display: none; }

  .rail, .level-medium .rail, .level-hard .rail {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 24px;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar, .palette-wrap::-webkit-scrollbar { display: none; }
  .tool-btn, .level-easy .tool-btn, .level-medium .tool-btn, .level-hard .tool-btn { width: 50px; height: 50px; border-radius: 16px; }
  .tool-btn svg, .level-medium .tool-btn svg, .level-hard .tool-btn svg { width: 30px; height: 30px; }
  .sizes, .level-medium .sizes, .level-hard .sizes { flex: none; gap: 2px; padding: 0; border: 0; }
  .size-btn, .level-medium .size-btn, .level-hard .size-btn { width: 40px; height: 40px; }
  .help-btn, .level-medium .help-btn, .level-hard .help-btn { width: 50px; margin: 0; }

  .palette-wrap {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 24px;
    scrollbar-width: none;
  }
  .palette, .palette.two-rows { display: flex; flex-wrap: nowrap; gap: 8px; flex: none; }
  .stamps { flex: none; flex-basis: auto; }
  .tones { display: flex; flex: none; gap: 6px; padding-left: 10px; }
  .swatch, .level-easy .swatch, .level-medium .swatch, .level-hard .swatch { width: 40px; height: 40px; flex: none; }
  .tone, .level-hard .tone { width: 34px; height: 34px; flex: none; }
  .stamp-btn, .level-easy .stamp-btn { width: 44px; height: 44px; }
  .stamp-btn svg { width: 30px; height: 30px; }
}

/* phone upright: bar, picture, then a tool strip and a colour strip */
@media (max-width: 600px) {
  .paint {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "bar" "stage" "rail" "palette";
  }
  .rail, .level-medium .rail, .level-hard .rail { flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; }
  .sizes, .level-medium .sizes, .level-hard .sizes { flex-direction: row; padding-left: 6px; border-left: 2px solid var(--sky); }
  .palette-wrap { overflow-x: auto; overflow-y: hidden; }
}

/* phone on its side: tools left, picture, colours right */
@media (max-height: 600px) and (min-width: 601px) {
  .paint {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "bar bar bar" "rail stage palette";
  }
  .rail, .level-medium .rail, .level-hard .rail { flex-direction: column; align-items: center; overflow-y: auto; overflow-x: hidden; }
  .sizes, .level-medium .sizes, .level-hard .sizes { flex-direction: column; padding-top: 6px; border-top: 2px solid var(--sky); }
  .palette-wrap { flex-direction: column; overflow-y: auto; overflow-x: hidden; }
  .tool-btn, .level-easy .tool-btn, .level-medium .tool-btn, .level-hard .tool-btn { width: 44px; height: 44px; }
  .tool-btn svg, .level-medium .tool-btn svg, .level-hard .tool-btn svg { width: 26px; height: 26px; }
  .palette, .palette.two-rows { display: grid; grid-template-columns: repeat(2, 40px); }
  .tones { display: grid; grid-template-columns: repeat(2, 34px); padding: 10px 0 0; border-left: 0; border-top: 2px solid var(--sky-deep); }
  .stamps { flex-direction: column; }
}

/* the narrowest phones: the top bar must still show every button */
@media (max-width: 420px) {
  .paint-bar { gap: 6px; }
  .paint-bar .icon-btn { width: 42px; height: 42px; }
  .paint-bar .btn { min-height: 42px; padding: 0 12px; font-size: 16px; }
}
