/* Rolling Polygon v2.2 - "Drafting Table": graph paper, navy ink outlines, glossy toy-like colours with soft depth, hard offset shadows, paper grain. */
@font-face {
  font-family: 'Bricolage';
  src: url(../assets/fonts/bricolage.woff2) format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
:root {
  --paper: #fff6e0;
  --paper2: #ffeec2;
  --grid: #cfe3f5;
  --ink: #1b2a5c;
  --ink2: #4a5b8a;
  --white: #fff;
  --tomato: #ff5d4f;
  --sun: #ffc61a;
  --mint: #1fcf9b;
  --sky: #35a7ff;
  --violet: #8d63ff;
  --pink: #ff7ab8;
  --font: 'Bricolage', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bw: 3px;
  --sh: 5px;
  --gloss: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.62),
    rgba(255, 255, 255, 0.1) 55%,
    rgba(255, 255, 255, 0) 56%
  );
  --soft: 0 12px 22px rgba(27, 42, 92, 0.2);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .16 0 0 0 0 .36 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --bh: clamp(52px, 8vh, 68px);
  --rb: clamp(52px, 8vh, 66px);
  --fs: clamp(17px, 2.8vh, 24px);
  --db: clamp(46px, min(8.2vh, 11.6vw), 72px);
  --infoh: clamp(92px, 14vh, 108px);
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
body {
  position: fixed;
  inset: 0;
  width: 100%;
  color: var(--ink);
  font: 600 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  background:
    linear-gradient(rgba(53, 167, 255, 0.28) 1.5px, transparent 1.5px) 0 0/160px 160px,
    linear-gradient(90deg, rgba(53, 167, 255, 0.28) 1.5px, transparent 1.5px) 0 0/160px 160px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0/32px 32px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0/32px 32px,
    radial-gradient(120% 90% at 50% 0%, #fffaf0, var(--paper) 55%, var(--paper2));
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: var(--grain);
  opacity: 0.07;
  mix-blend-mode: multiply;
}
img {
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
#app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1800px;
  margin: 0 auto;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px
    calc(16px + env(safe-area-inset-bottom, 0px));
}
.screen.active {
  display: flex;
  animation: in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
h1 {
  font-size: 20px;
  white-space: nowrap;
  font-weight: 800;
}

/* ---------- icons ---------- */
.ic {
  display: block;
  width: 1em;
  height: 1em;
  flex: none;
  overflow: visible;
  pointer-events: none;
}

/* ---------- buttons: glossy colour, navy outline, hard shadow + soft shadow (pill .gb, round .rb) ---------- */
.gb,
.rb {
  --c: var(--sun);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--c) 82%, #fff),
    var(--c) 55%,
    color-mix(in srgb, var(--c) 88%, #1b2a5c)
  );
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 var(--sh) 0 var(--ink),
    0 calc(var(--sh) + 8px) 16px rgba(27, 42, 92, 0.22),
    inset 0 -4px 0 rgba(27, 42, 92, 0.12),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  transition:
    transform 0.12s,
    box-shadow 0.12s,
    filter 0.2s,
    opacity 0.2s;
}
.gb::before,
.rb::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4%;
  height: 44%;
  border-radius: 999px 999px 60% 60%/999px 999px 40% 40%;
  background: var(--gloss);
  pointer-events: none;
}
.gb > *,
.rb > * {
  position: relative;
}
.gb {
  border-radius: 999px;
  min-height: var(--bh);
  padding: 0 clamp(22px, 5vw, 34px);
  font-size: var(--fs);
}
.gb .ic {
  width: calc(var(--bh) * 0.5);
  height: calc(var(--bh) * 0.5);
}
.gb.sm {
  min-height: 44px;
  font-size: 15px;
  padding: 0 18px;
  --sh: 4px;
}
.rb {
  border-radius: 50%;
  width: var(--rb);
  height: var(--rb);
  padding: 0;
  flex: none;
  font-size: calc(var(--rb) * 0.56);
}
.rb .ic {
  width: 1em;
  height: 1em;
}
.flip .ic {
  transform: scaleX(-1);
}
.c-green {
  --c: var(--mint);
}
.c-blue {
  --c: var(--sky);
}
.c-orange {
  --c: var(--sun);
}
.c-red {
  --c: var(--tomato);
}
.c-grey {
  --c: #e4e8f3;
}
.c-sky {
  --c: #9fd6ff;
}
.c-pink {
  --c: var(--pink);
}
.bt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 3px;
}
.bt em {
  font-style: normal;
}
.bt small {
  font-size: 0.55em;
  font-weight: 600;
  opacity: 0.85;
}
@media (hover: hover) {
  .gb:not(:disabled):hover,
  .rb:not(:disabled):hover {
    transform: translateY(-3px);
    filter: saturate(1.12) brightness(1.04);
    box-shadow:
      0 calc(var(--sh) + 3px) 0 var(--ink),
      0 calc(var(--sh) + 14px) 22px rgba(27, 42, 92, 0.26),
      inset 0 -4px 0 rgba(27, 42, 92, 0.12),
      inset 0 2px 0 rgba(255, 255, 255, 0.6);
  }
  .gb:not(:disabled):hover .ic,
  .rb:not(:disabled):hover .ic {
    animation: wig 0.5s ease-in-out;
  }
}
@keyframes wig {
  25% {
    transform: rotate(-12deg) scale(1.08);
  }
  60% {
    transform: rotate(9deg) scale(1.08);
  }
}
.gb:active,
.rb:active {
  transform: translateY(calc(var(--sh) - 1px)) !important;
  box-shadow:
    0 1px 0 var(--ink),
    0 3px 6px rgba(27, 42, 92, 0.2),
    inset 0 -2px 0 rgba(27, 42, 92, 0.12),
    inset 0 2px 0 rgba(255, 255, 255, 0.4) !important;
  filter: brightness(0.98);
}
.gb:focus-visible,
.rb:focus-visible,
.mplay:focus-visible,
.lv:focus-visible,
.tab:focus-visible,
.sw:focus-visible {
  outline: 4px solid var(--violet);
  outline-offset: 4px;
}
.gb:disabled,
.rb:disabled {
  background: #e4e8f3;
  opacity: 0.55;
  pointer-events: none;
  box-shadow: 0 2px 0 var(--ink);
  transform: translateY(3px);
  filter: grayscale(0.5);
}
.gb:disabled::before,
.rb:disabled::before {
  opacity: 0.4;
}
.rb.sm {
  width: max(42px, calc(var(--db) * 0.86));
  height: max(42px, calc(var(--db) * 0.86));
  --sh: 4px;
  font-size: calc(max(42px, calc(var(--db) * 0.86)) * 0.56);
}
/* press feedback: a ring of light grows from the touch point */
.ping {
  position: fixed;
  z-index: 70;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(27, 42, 92, 0.35);
  pointer-events: none;
  animation: ping 0.5s ease-out forwards;
}
@keyframes ping {
  to {
    transform: scale(5);
    opacity: 0;
  }
}

/* ---------- panels and tabs ---------- */
.gp {
  position: relative;
  background: linear-gradient(180deg, #fff, #fff8e6);
  border: var(--bw) solid var(--ink);
  border-radius: 26px;
  padding: clamp(38px, 6vh, 50px) 20px 22px;
  color: var(--ink);
  box-shadow:
    0 8px 0 var(--ink),
    0 22px 40px rgba(27, 42, 92, 0.3);
}
.gp::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 2px dashed rgba(27, 42, 92, 0.14);
  border-radius: 19px;
  pointer-events: none;
}
.ribbon {
  --c: var(--sky);
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -52%);
  min-width: 54%;
  max-width: 92%;
  padding: 8px 26px;
  text-align: center;
  border-radius: 14px;
  font-weight: 800;
  font-size: clamp(20px, 3.2vh, 28px);
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 4px 0 var(--ink),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
  z-index: 2;
}
.ribbon.c-red {
  --c: var(--tomato);
}
.ribbon.c-green {
  --c: var(--mint);
}
.ribbon.c-orange {
  --c: var(--sun);
}
.ribbon.c-blue {
  --c: var(--sky);
}
.gs {
  background: linear-gradient(180deg, #fff, #f3f6ff);
  color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: 18px;
  box-shadow:
    0 4px 0 var(--ink),
    0 10px 18px rgba(27, 42, 92, 0.16);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(180deg, #fff, #f3f6ff);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: clamp(14px, 2.1vh, 17px);
  box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap;
}
.chip .ic {
  width: 22px;
  height: 22px;
}
.chip i {
  font-style: normal;
  opacity: 0.5;
}

/* ---------- loading ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background:
    linear-gradient(rgba(53, 167, 255, 0.28) 1.5px, transparent 1.5px) 0 0/160px 160px,
    linear-gradient(90deg, rgba(53, 167, 255, 0.28) 1.5px, transparent 1.5px) 0 0/160px 160px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0/32px 32px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0/32px 32px,
    radial-gradient(120% 90% at 50% 0%, #fffaf0, var(--paper) 55%, var(--paper2));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vh, 16px);
  text-align: center;
  transition:
    opacity 0.6s,
    transform 0.6s;
}
#loading.done {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}
#loading > * {
  position: relative;
}
.ll {
  height: clamp(100px, 26vh, 220px);
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: translateY(-8px);
  }
}
.lt {
  font-size: clamp(28px, min(6.8vh, 8.6vw), 56px);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.05;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(255, 198, 26, 0.9);
}
.lbar {
  width: min(80vw, 440px);
  margin-top: 34px;
  padding: 6px;
  border-radius: 999px;
  background: #fff;
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 6px 0 var(--ink),
    0 14px 24px rgba(27, 42, 92, 0.2);
}
.track {
  position: relative;
  height: clamp(18px, 3vh, 24px);
  border-radius: 999px;
  background: #e8eefb;
  border: 2px solid var(--ink);
}
.track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0 10px, transparent 10px 20px),
    var(--sun);
  background-size:
    100% 100%,
    28px 100%,
    100% 100%;
  animation: stripes 1s linear infinite;
}
@keyframes stripes {
  to {
    background-position:
      0 0,
      28px 0,
      0 0;
  }
}
.roller {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: clamp(44px, 6.4vh, 56px);
  height: clamp(44px, 6.4vh, 56px);
  margin-left: calc(clamp(44px, 6.4vh, 56px) / -2);
  margin-bottom: 4px;
}
.ltip {
  display: inline-block;
  background: #fff;
  border: var(--bw) solid var(--ink);
  font-weight: 700;
  font-size: clamp(14px, 2.2vh, 17px);
  padding: 6px 18px;
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  margin-top: 8px;
}
.ltip b {
  color: #e0432f;
}

/* ---------- menu: top bar / title / framed window / controls, stacked, never overlapping ---------- */
#menu {
  gap: clamp(10px, 2vh, 18px);
}
.mbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: none;
}
.ver {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink2);
}
.mcopy {
  flex: none;
  text-align: center;
}
.mtitle {
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: normal;
  line-height: 0.92;
  text-transform: uppercase;
  font-size: clamp(40px, min(11vh, 15vw), 104px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.mtitle > span:first-child {
  font-weight: 500;
  letter-spacing: 0.2em;
  font-size: 0.5em;
  color: var(--ink2);
  margin-bottom: 0.12em;
  padding-left: 0.2em;
}
.mtitle > span:last-child {
  position: relative;
  display: inline-block;
  color: var(--sun);
  -webkit-text-stroke: 0.075em var(--ink);
  paint-order: stroke fill;
  text-shadow:
    0 0.05em 0 var(--ink),
    0 0.09em 0 var(--ink),
    0 0.13em 0 var(--ink),
    0 0.2em 0.14em rgba(27, 42, 92, 0.3);
}
.mtitle .l {
  display: inline-block;
  animation: drop 0.75s both cubic-bezier(0.2, 1.5, 0.4, 1);
  animation-delay: calc(var(--i) * 55ms + 0.15s);
}
.mtitle > span:last-child .l:hover {
  animation: hop 0.45s;
}
@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-0.7em) rotate(-14deg) scale(0.6);
  }
}
@keyframes hop {
  40% {
    transform: translateY(-0.14em) scale(1.08);
  }
}
.tagline {
  margin-top: clamp(12px, 2.2vh, 20px);
  font-size: clamp(15px, 2.4vh, 20px);
  font-weight: 700;
  color: var(--ink2);
}
.mwin {
  position: relative;
  flex: 1 1 0;
  min-height: 130px;
  border: var(--bw) solid var(--ink);
  border-radius: 26px;
  box-shadow:
    0 8px 0 var(--ink),
    0 22px 36px rgba(27, 42, 92, 0.28);
  margin: 0 4px 8px;
  background: linear-gradient(#cfe9ff, #fffaf0);
}
#mscene {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 23px;
}
.ruler {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 0;
  height: 14px;
  pointer-events: none;
  opacity: 0.5;
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 60px);
  background-size:
    100% 7px,
    100% 14px;
  background-repeat: no-repeat;
  border-radius: 0 0 4px 4px;
}
.tape {
  position: absolute;
  width: 72px;
  height: 24px;
  top: -13px;
  background: linear-gradient(180deg, rgba(255, 226, 122, 0.95), rgba(255, 198, 26, 0.9));
  border: 2px solid rgba(27, 42, 92, 0.35);
  box-shadow: 0 3px 6px rgba(27, 42, 92, 0.2);
  pointer-events: none;
}
.tape.t1 {
  left: 22px;
  transform: rotate(-7deg);
}
.tape.t2 {
  right: 22px;
  transform: rotate(6deg);
}
.tape::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.35) 0 3px,
    transparent 3px 8px
  );
}
.mctl {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.8vh, 14px);
}
.mprog {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mbarwrap {
  flex: 1;
  min-width: 0;
}
.mbarx {
  height: 18px;
  border-radius: 99px;
  background: linear-gradient(180deg, #dfe6f5, #fff);
  border: 2.5px solid var(--ink);
  overflow: hidden;
  box-shadow: inset 0 3px 4px rgba(27, 42, 92, 0.18);
}
.mbarx i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0 8px, transparent 8px 16px),
    var(--mint);
  border-right: 2.5px solid var(--ink);
  transition: width 0.6s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.mplay {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: clamp(64px, 10vh, 84px);
  padding: 0 24px;
  border-radius: 999px;
  color: var(--ink);
  text-align: left;
  position: relative;
  background: linear-gradient(180deg, #ff8f7f, var(--tomato) 55%, #e8402f);
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 7px 0 var(--ink),
    0 18px 28px rgba(232, 64, 47, 0.35),
    inset 0 -5px 0 rgba(27, 42, 92, 0.14),
    inset 0 3px 0 rgba(255, 255, 255, 0.55);
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    filter 0.2s;
  animation: breathe 2.8s ease-in-out infinite;
}
.mplay::before {
  content: '';
  position: absolute;
  left: 5%;
  right: 5%;
  top: 4%;
  height: 44%;
  border-radius: 999px 999px 60% 60%/999px 999px 40% 40%;
  background: var(--gloss);
  pointer-events: none;
}
.mplay > * {
  position: relative;
}
@keyframes breathe {
  50% {
    transform: scale(1.015);
  }
}
.mplay .tri {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(40px, 6vh, 52px);
  height: clamp(40px, 6vh, 52px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #ffe9b0);
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 3px 0 rgba(27, 42, 92, 0.5),
    inset 0 -3px 0 rgba(255, 198, 26, 0.5);
  font-size: clamp(20px, 3.2vh, 26px);
}
.mplay .tri .ic {
  width: 1.15em;
  height: 1.15em;
  margin-left: 0.08em;
}
@media (hover: hover) {
  .mplay:hover .tri .ic {
    animation: wig 0.5s;
  }
}
.mplay .bt {
  flex: 1;
  gap: 2px;
}
.mplay em {
  font-style: normal;
  font-weight: 800;
  font-size: clamp(24px, 4vh, 32px);
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 2px 0 var(--ink),
    2px 0 0 var(--ink),
    -2px 0 0 var(--ink),
    0 -2px 0 var(--ink);
}
.mplay small {
  font-size: clamp(13px, 2vh, 16px);
  font-weight: 700;
  color: #fff;
  opacity: 1;
  text-shadow: 0 1px 0 var(--ink);
}
.mpair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mpair .gb {
  min-height: clamp(50px, 7.6vh, 60px);
  font-size: clamp(14px, 2.2vh, 17px);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 10px;
}
.mpair .gb .ic {
  width: 24px;
  height: 24px;
}
@media (hover: hover) {
  .mplay:hover {
    transform: translateY(-3px);
    filter: brightness(1.05);
    animation: none;
  }
}
.mplay:active {
  transform: translateY(6px);
  box-shadow: 0 1px 0 var(--ink);
  animation: none;
}
.mbar,
.mcopy,
.mwin,
.mctl {
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}
@media (orientation: portrait) {
  #menu {
    padding-left: 20px;
    padding-right: 20px;
  }
  .mwin,
  .mctl,
  .mcopy {
    max-width: 560px;
  }
  .mbar {
    max-width: 560px;
  }
}
/* landscape: copy and controls on the left, the window on the right */
@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  #menu.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto 1fr 1fr;
    grid-template-areas: 'bar bar' 'copy win' 'ctl win';
    column-gap: clamp(20px, 4vw, 56px);
    row-gap: clamp(10px, 2vh, 18px);
    align-content: stretch;
  }
  .mbar {
    grid-area: bar;
    max-width: none;
  }
  .mcopy {
    grid-area: copy;
    text-align: left;
    align-self: end;
    max-width: none;
  }
  .mwin {
    grid-area: win;
    max-width: none;
    margin: 0 4px 8px 0;
    min-height: 0;
    align-self: center;
    height: 100%;
    max-height: 760px;
  }
  .mctl {
    grid-area: ctl;
    max-width: none;
    align-self: start;
  }
  .mtitle {
    align-items: flex-start;
    font-size: clamp(38px, min(13vh, 8vw), 96px);
  }
  .mtitle > span:first-child {
    padding-left: 0;
  }
}

/* ---------- level select ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex: none;
}
.ttl {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(20px, min(3.6vh, 6vw), 32px);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.tot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  background: #fff;
  border: var(--bw) solid var(--ink);
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow:
    0 3px 0 var(--ink),
    0 8px 14px rgba(27, 42, 92, 0.16);
  min-width: 96px;
  justify-content: center;
  font-size: clamp(14px, 2.2vh, 17px);
}
.tot .ic {
  width: 24px;
  height: 24px;
}
#levels > * {
  width: 100%;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  flex: none;
  padding: 0 2px 4px;
}
.tab {
  --c: var(--sky);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: clamp(46px, 7vh, 56px);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #eef2fb);
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 4px 0 var(--ink),
    0 8px 14px rgba(27, 42, 92, 0.14);
  font-weight: 800;
  font-size: clamp(17px, 2.8vh, 22px);
  line-height: 1;
  transition:
    transform 0.1s,
    box-shadow 0.1s;
}
.tab small {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
  letter-spacing: 0.2px;
}
.tab::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4%;
  height: 40%;
  border-radius: 12px 12px 60% 60%/12px 12px 40% 40%;
  background: var(--gloss);
  pointer-events: none;
  opacity: 0.7;
}
@media (hover: hover) {
  .tab:not(.on):hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--c) 25%, #fff));
  }
}
.tab.on {
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.wb {
  --c: var(--sky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 16px;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 5px 0 var(--ink),
    0 12px 18px rgba(27, 42, 92, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
  flex: none;
  margin-bottom: 4px;
}
.wb b {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(15px, 2.4vh, 20px);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.wb span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(14px, 2.2vh, 18px);
  white-space: nowrap;
  flex: none;
}
.wb span .ic {
  width: 24px;
  height: 24px;
}
.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: min-content;
  gap: 18px 14px;
  align-content: center;
  padding: 6px 6px 12px;
}
.lv {
  --c: var(--sky);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
  aspect-ratio: 1/1.08;
  border-radius: 20px;
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(24px, 4.2vh, 36px);
  line-height: 1;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--c) 78%, #fff),
    var(--c) 58%,
    color-mix(in srgb, var(--c) 90%, #1b2a5c)
  );
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 5px 0 var(--ink),
    0 12px 18px rgba(27, 42, 92, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.55);
  animation: in 0.4s both;
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    filter 0.2s;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
}
.lv::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4%;
  height: 38%;
  border-radius: 14px 14px 60% 60%/14px 14px 40% 40%;
  background: var(--gloss);
  pointer-events: none;
}
.lv > * {
  position: relative;
}
.lv .st {
  display: flex;
  gap: 2px;
}
.lv .st .ic {
  width: clamp(16px, 2.6vh, 22px);
  height: clamp(16px, 2.6vh, 22px);
}
.lv.done::after {
  content: '';
  position: absolute;
  right: -7px;
  top: -9px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mint)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center/70% no-repeat;
  border: 2.5px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}
@media (hover: hover) {
  .lv:not(.locked):hover {
    transform: translateY(-4px);
    filter: saturate(1.12) brightness(1.04);
    box-shadow:
      0 9px 0 var(--ink),
      0 18px 24px rgba(27, 42, 92, 0.24),
      inset 0 2px 0 rgba(255, 255, 255, 0.55);
  }
}
.lv:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}
.lv.next {
  animation:
    in 0.4s both,
    bump 1.4s ease-in-out infinite 0.4s;
}
@keyframes bump {
  50% {
    transform: translateY(-5px);
  }
}
.lv.locked {
  background:
    repeating-linear-gradient(135deg, rgba(154, 166, 198, 0.18) 0 8px, transparent 8px 16px),
    #e9edf7;
  border-color: #9aa6c6;
  box-shadow: 0 5px 0 #9aa6c6;
  pointer-events: none;
  text-shadow: none;
}
.lv.locked::before {
  opacity: 0.35;
}
.lv.locked .ic {
  width: 38%;
  height: 38%;
  opacity: 0.8;
}

/* ---------- game ---------- */
#play {
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px
    calc(8px + env(safe-area-inset-bottom, 0px));
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 0 4px 4px;
}
.hudbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, #fff, #f1f5ff);
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 4px 0 var(--ink),
    0 10px 16px rgba(27, 42, 92, 0.16);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(13px, 2vh, 16px);
  padding: 6px 16px;
  border-radius: 999px;
  white-space: nowrap;
  min-width: 0;
}
.hudbar .stars {
  display: flex;
  gap: 3px;
}
.hudbar .stars .ic {
  width: clamp(20px, 3vh, 26px);
  height: clamp(20px, 3vh, 26px);
  transition:
    transform 0.3s,
    opacity 0.3s;
}
.hudbar .stars .off {
  transform: scale(0.85);
}
.sdots {
  display: flex;
  gap: 6px;
}
.sdots i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: #fff;
  border: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: all 0.25s;
}
.sdots i.on {
  background: var(--sun);
}
.sdots i.done {
  background: var(--mint);
}
.arena {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 2vw, 26px);
  align-items: stretch;
  padding: 4px 6px 10px;
}
#stage {
  grid-column: 2;
  min-width: 0;
  position: relative;
  min-height: 150px;
  border-radius: 24px;
  overflow: hidden;
  background: #dff1ff;
  border: var(--bw) solid var(--ink);
  box-shadow:
    0 7px 0 var(--ink),
    0 20px 34px rgba(27, 42, 92, 0.28);
}
#stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 21px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.55),
    inset 0 -30px 50px -30px rgba(27, 42, 92, 0.2);
  z-index: 1;
}
canvas#cv {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
}
.rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 2.4vh, 22px);
  padding: 0 4px;
}
.lrail {
  grid-column: 1;
}
.rrail {
  grid-column: 3;
}
.rail .rb {
  width: var(--db);
  height: var(--db);
}
.rbw {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cap {
  font-size: clamp(11px, 1.6vh, 13px);
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.rail .rb.big {
  width: calc(var(--db) * 1.3);
  height: calc(var(--db) * 1.3);
  flex-direction: column;
  gap: 2px;
  font-size: clamp(12px, 2.2vh, 18px);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  --sh: 6px;
  --c: var(--tomato);
}
.rb.big .ic {
  width: 1.9em;
  height: 1.9em;
}
.badge {
  position: absolute;
  top: -8px;
  right: -10px;
  display: flex;
  align-items: center;
  gap: 1px;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--tomato);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0 6px 0 5px;
  z-index: 2;
}
.badge .ic {
  width: 12px;
  height: 12px;
}
#nbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: calc(var(--db) * 1.1);
  min-height: var(--db);
  padding: 3px 0 4px;
  gap: 1px;
}
#nbox b {
  font-size: clamp(24px, 4.2vh, 36px);
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
  transition: transform 0.15s;
}
#nbox b.bump {
  transform: scale(1.25);
}
#nbox span {
  font-size: 11px;
  line-height: 1;
  color: var(--ink2);
  font-weight: 700;
}
.rb.on {
  background: var(--sun);
}
.info {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  height: var(--infoh);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 2;
  pointer-events: none;
}
#msg {
  max-width: min(100%, 640px);
  text-align: center;
  color: var(--ink);
  font-size: clamp(12px, 1.9vh, 15px);
  font-weight: 700;
  line-height: 1.28;
  background: linear-gradient(180deg, #fff, #f6f8ff);
  border: 2.5px solid var(--ink);
  padding: 5px 14px;
  border-radius: 14px;
  box-shadow:
    0 3px 0 var(--ink),
    0 8px 14px rgba(27, 42, 92, 0.15);
}
#facts {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
  max-width: 560px;
}
#facts span {
  flex: 1 1 0;
  min-width: 0;
  max-width: 112px;
  background: linear-gradient(180deg, #fffaf0, var(--paper2));
  color: var(--ink2);
  border: 2px solid var(--ink);
  border-radius: 11px;
  padding: 2px 4px;
  text-align: center;
  font-size: clamp(12px, 1.7vh, 13px);
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#facts b {
  display: block;
  color: var(--ink);
  font-size: clamp(14px, 2.2vh, 17px);
  font-weight: 800;
}
.keys {
  display: none;
  flex: none;
  text-align: center;
  font-size: 12px;
  color: var(--ink2);
}
@media (hover: hover) and (pointer: fine) {
  .keys {
    display: block;
  }
}
#ov {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 44px 16px 16px;
  background: rgba(27, 42, 92, 0.38);
  text-align: center;
  z-index: 6;
}
#ov.on {
  display: flex;
}
#card {
  width: 100%;
  max-width: 370px;
  padding-top: clamp(38px, 6vh, 48px);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#card .ribbon {
  font-size: clamp(17px, 2.9vh, 22px);
  padding: 8px 18px;
  min-width: 70%;
  max-width: 98%;
}
#card.win .ribbon {
  --c: var(--mint);
}
#card.lose .ribbon {
  --c: var(--tomato);
}
#card p {
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 18px;
  line-height: 1.45;
  font-size: 15px;
}
#stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
#stars .ic {
  width: 54px;
  height: 54px;
}
#stars .ic:nth-child(2) {
  margin-top: -14px;
  width: 66px;
  height: 66px;
}
#stars .on {
  filter: drop-shadow(0 4px 0 rgba(27, 42, 92, 0.25));
  animation: starpop 0.55s both cubic-bezier(0.2, 1.5, 0.4, 1);
}
#stars .on:nth-child(2) {
  animation-delay: 0.18s;
}
#stars .on:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes starpop {
  from {
    transform: scale(0) rotate(-120deg);
  }
  to {
    transform: none;
  }
}
#ob {
  width: 100%;
  font-size: clamp(18px, 3vh, 24px);
}
.pulse {
  outline: 4px solid var(--violet);
  outline-offset: 5px;
  animation: glow 1s ease-in-out infinite;
}
@keyframes glow {
  50% {
    outline-color: rgba(141, 99, 255, 0.2);
    outline-offset: 9px;
  }
}

/* ---------- dialogs ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 92, 0.55);
  display: grid;
  place-items: center;
  padding: 34px 18px 18px;
  z-index: 20;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.modal[hidden] {
  display: none;
}
.dialog {
  max-width: 430px;
  width: 100%;
  text-align: center;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.dialog .body {
  max-height: calc(100vh - 250px);
  max-height: calc(100dvh - 250px);
  overflow: auto;
  padding: 2px 8px 24px;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
}
.dialog > .rows {
  margin-top: 12px;
}
.dialog p {
  font-weight: 600;
  color: var(--ink2);
  margin: 6px 0;
}
.dialog ol {
  text-align: left;
  padding-left: 0;
  list-style: none;
  counter-reset: s;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  margin: 6px 0;
}
.dialog li {
  counter-increment: s;
  position: relative;
  margin: 8px 0;
  padding-left: 38px;
  min-height: 28px;
}
.dialog li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe27a, var(--sun));
  border: 2.5px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}
.dialog .rows {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}
.setrow {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  text-align: left;
  border-bottom: 2px dashed var(--grid);
}
.setrow label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  text-transform: uppercase;
  color: var(--ink);
  letter-spacing: 0.5px;
}
.setrow label .ic {
  width: 24px;
  height: 24px;
}
.setrow .ctl {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
input[type='range'] {
  --p: 50%;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--mint) var(--p), #e8eefb var(--p));
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 3px 4px rgba(27, 42, 92, 0.15);
}
input[type='range']::-moz-range-track {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--mint) var(--p), #e8eefb var(--p));
  border: 2.5px solid var(--ink);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff2b0, var(--sun) 60%);
  border: 3px solid var(--ink);
  box-shadow:
    0 3px 0 var(--ink),
    0 8px 12px rgba(27, 42, 92, 0.22);
  transition: transform 0.12s;
}
input[type='range']::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff2b0, var(--sun) 60%);
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
input[type='range']:active::-webkit-slider-thumb {
  transform: scale(1.12);
}
/* on/off switch */
.sw {
  position: relative;
  width: 70px;
  height: 38px;
  border-radius: 999px;
  border: var(--bw) solid var(--ink);
  background: linear-gradient(180deg, #d6ddee, #e9edf7);
  box-shadow:
    inset 0 3px 5px rgba(27, 42, 92, 0.2),
    0 3px 0 var(--ink);
  transition: background 0.2s;
}
.sw::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e3e9f8 70%);
  border: 2.5px solid var(--ink);
  box-shadow: 0 2px 0 rgba(27, 42, 92, 0.5);
  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.sw[aria-checked='true'] {
  background: linear-gradient(180deg, #5de6bd, var(--mint));
}
.sw[aria-checked='true']::after {
  transform: translateX(32px);
}
input[type='range']:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 4px;
  border-radius: 8px;
}
.note {
  font-size: 12px;
  color: var(--ink2);
  margin-top: 10px;
}

/* ---------- screen sizes ---------- */
@media (orientation: portrait) {
  /* phones and tablets held upright: one slim button dock under the canvas */
  .arena {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 14px 8px;
    padding: 4px 6px 4px;
  }
  #stage {
    grid-column: 1/-1;
    grid-row: 1;
  }
  .lrail {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row-reverse;
    justify-self: start;
    gap: 8px;
    padding: 0;
  }
  .rrail {
    grid-column: 2;
    grid-row: 2;
    flex-direction: row;
    justify-self: end;
    gap: 8px;
    padding: 0;
  }
  .cap {
    display: none;
  }
  :root {
    --db: clamp(34px, min(8.2vh, 10vw), 72px);
  }
  .rail .rb.big {
    width: auto;
    min-width: calc(var(--db) * 1.35);
    height: var(--db);
    border-radius: 999px;
    flex-direction: row;
    gap: 6px;
    padding: 0 10px;
    font-size: clamp(14px, 2.2vh, 17px);
  }
  .rb.big .ic {
    width: 18px;
    height: 18px;
  }
}
@media (max-width: 560px) and (orientation: portrait) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 16px;
    align-content: stretch;
    grid-auto-rows: minmax(0, 92px);
    padding-top: 10px;
    align-content: center;
  }
  .lv {
    aspect-ratio: auto;
    height: 100%;
    flex-direction: row;
    gap: 16px;
    font-size: 30px;
    border-radius: 18px;
  }
  .lv .st .ic {
    width: 20px;
    height: 20px;
  }
  .lv.locked .ic {
    width: 28px;
    height: 28px;
  }
  .tab small {
    display: none;
  }
}
@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --bh: 42px;
    --rb: 44px;
    --fs: 16px;
    --db: 42px;
    --infoh: 76px;
    --sh: 4px;
  }
  .screen {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    gap: 8px;
  }
  #play {
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    gap: 4px;
  }
  .cap,
  .keys {
    display: none !important;
  }
  .rail {
    gap: 9px;
  }
  .arena {
    padding: 2px 4px 6px;
    gap: 10px;
  }
  .hudbar {
    padding: 3px 12px;
  }
  .ll {
    height: 26vh;
  }
  .lbar {
    margin-top: 22px;
  }
  .tabs {
    gap: 8px;
  }
  .tab {
    min-height: 40px;
  }
  .tab small {
    display: none;
  }
  .grid {
    gap: 10px 12px;
    padding: 4px 6px 8px;
  }
  .lv {
    aspect-ratio: 1.5/1;
    border-radius: 16px;
    font-size: clamp(20px, 6vh, 26px);
    gap: 2px;
  }
  .lv .st .ic {
    width: 15px;
    height: 15px;
  }
  .wb {
    padding: 6px 14px;
  }
  .dialog .body {
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
  }
  .dialog:has(.setrow) {
    max-width: 640px;
  }
  .dialog .body:has(.setrow) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 26px;
  }
  .setrow {
    padding: 3px 2px;
    grid-template-columns: 78px 1fr;
    gap: 8px;
  }
  .setrow label {
    font-size: 14px;
  }
  .dialog.gp {
    padding: 30px 18px 14px;
  }
  .dialog .body {
    padding-bottom: 8px;
  }
  .dialog > .rows {
    margin-top: 4px;
  }
  .modal {
    padding: 26px 14px 10px;
  }
  .mtitle {
    font-size: clamp(30px, 12vh, 56px);
  }
  .tagline {
    font-size: 13px;
    margin-top: 4px;
  }
  .mplay {
    min-height: 54px;
  }
  .mpair .gb {
    min-height: 44px;
  }
  .mctl {
    gap: 8px;
  }
}
@media (max-height: 700px) and (orientation: portrait) {
  :root {
    --bh: 48px;
    --rb: 48px;
    --fs: 17px;
  }
  .mtitle {
    font-size: clamp(34px, 9.5vh, 56px);
  }
  .mwin {
    min-height: 96px;
  }
}
@media (max-width: 420px) {
  .hudbar {
    gap: 9px;
    padding: 5px 11px;
  }
  .gb {
    padding: 0 20px;
  }
}
@media (min-width: 1200px) and (min-height: 760px) {
  :root {
    --rb: 72px;
    --db: 78px;
    --infoh: 114px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
/* menu window animation */
.cloud {
  animation: drift 40s ease-in-out infinite alternate;
}
@keyframes drift {
  from {
    transform: translateX(-5%);
  }
  to {
    transform: translateX(7%);
  }
}
.fl {
  transform-box: fill-box;
  transform-origin: center;
  animation: spinp 20s linear infinite;
}
@keyframes spinp {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 340px) {
  :root {
    --db: 31px;
  }
  .lrail,
  .rrail {
    gap: 4px !important;
  }
  .rail .rb.big {
    min-width: 0 !important;
    padding: 0 8px !important;
  }
  .rail .rb.big span {
    font-size: 13px;
  }
  .hudbar {
    gap: 6px;
    padding: 4px 8px;
  }
}
/* big desktop screens: scale the menu up */
@media (min-width: 1500px) and (min-height: 880px) {
  .mtitle {
    font-size: 132px;
  }
  .tagline {
    font-size: 26px;
  }
  .mplay {
    min-height: 104px;
  }
  .mplay em {
    font-size: 42px;
  }
  .mplay small {
    font-size: 19px;
  }
  .mpair .gb {
    min-height: 72px;
    font-size: 21px;
  }
  .chip {
    font-size: 20px;
  }
  .mbarx {
    height: 20px;
  }
  .mbar .rb.sm {
    width: 64px;
    height: 64px;
  }
  .mwin {
    border-radius: 34px;
  }
}

/* extras: floating polygons, sparkles */
.sp {
  transform-box: fill-box;
  transform-origin: center;
  animation: twinkle 2.6s ease-in-out infinite;
}
@keyframes twinkle {
  50% {
    transform: scale(0.55) rotate(45deg);
    opacity: 0.4;
  }
}
.sunr {
  transform-box: fill-box;
  transform-origin: center;
  animation: spinp 40s linear infinite;
}
.bounce {
  animation: bobx 3s ease-in-out infinite;
}
@keyframes bobx {
  50% {
    transform: translateY(-5px);
  }
}

/* in-game tutorial */
.tut {
  text-align: center;
}
.tut .tart {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
  margin: 0 auto 6px;
  background: linear-gradient(180deg, #eaf6ff, #fff6e0);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(27, 42, 92, 0.25);
}
.tut h3 {
  margin: 8px 0 2px;
  font-size: clamp(20px, 3.4vh, 24px);
  font-weight: 800;
  color: var(--ink);
}
.tut p {
  margin: 4px 6px;
  font-size: clamp(15px, 2.4vh, 17px);
  line-height: 1.4;
}
.tdots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.tdots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(27, 42, 92, 0.2);
  border: 2px solid var(--ink);
  transition:
    transform 0.2s,
    background 0.2s;
}
.tdots i.on {
  background: var(--sun);
  transform: scale(1.35);
}
.dialog > .rows [hidden] {
  display: none;
}
@media (max-height: 480px) {
  .tut .tart {
    max-width: 210px;
    margin-bottom: 2px;
  }
  .tut h3 {
    margin: 2px 0 0;
    font-size: 18px;
  }
  .tut p {
    font-size: 14px;
    margin: 2px 6px;
    line-height: 1.3;
  }
  .tdots {
    margin-top: 6px;
  }
}
