@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ink: #2b2a3a;
  --glass: rgba(22, 24, 52, 0.42);
  --glass-strong: rgba(22, 24, 52, 0.68);
  --line: rgba(255, 255, 255, 0.35);
  --lilac: #a58cff;
  --blue: #6fa8ff;
  --pink: #ff7ab6;
  --gold: #ffd166;
  --mint: #7be0b0;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #141833;
  color: #fff;
  font-family: 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  color: inherit;
}

/* ------------------------------------------------------------------ HUD */
#hud {
  position: absolute;
  top: calc(8px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 10px;
  /* The pause button (the in-game menu) is pinned to the corner, outside the flow: a crowded HUD
     (small phone, notch insets, co-op badge, keys) compacts or wraps instead of pushing it off-screen. */
  padding-right: 54px;
  container: hud / inline-size;
  pointer-events: none;
  z-index: 5;
}
.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1.5px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  font-weight: 600;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.hud-left { display: flex; gap: 8px; }
.hud-hearts { gap: 2px; }
.hud-hearts svg { width: 22px; height: 22px; transition: transform .2s, opacity .2s; }
.hud-hearts svg.lost { opacity: .28; transform: scale(.8); }
.hud-hearts svg.pop { animation: pop .35s ease; }
.hud-lives img, .hud-lives svg { width: 28px; height: 28px; }
.hud-flowers svg { width: 26px; height: 26px; }
.hud-center { display: flex; gap: 8px; margin-left: auto; }
.hud-keys svg { width: 24px; height: 24px; }
.hud-keys .count { min-width: 1.6em; }
.hud-group.hidden { display: none; }
.hud-yarn svg { width: 22px; height: 22px; opacity: .3; filter: grayscale(1); transition: all .3s; }
.hud-yarn svg.got { opacity: 1; filter: none; animation: pop .5s ease; }
.hud-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.hud-btn {
  pointer-events: auto;
  position: absolute; top: 0; right: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--glass);
  border: 1.5px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.hud-btn svg { width: 20px; height: 20px; }
.count { min-width: 2.4em; font-variant-numeric: tabular-nums; }
.bump { animation: bump .3s ease; }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* ------------------------------------------------------------------ touch controls */
#touch { position: absolute; inset: 0; z-index: 4; pointer-events: auto; }
.stick {
  position: absolute;
  left: calc(26px + var(--safe-l));
  bottom: calc(22px + var(--safe-b));
  width: 132px; height: 132px;
  pointer-events: auto;
}
.stick-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.10), rgba(255,255,255,0.20));
  border: 2px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}
.stick-ring::before, .stick-ring::after {
  content: ''; position: absolute; top: 50%; width: 0; height: 0;
  border: 8px solid transparent; margin-top: -8px; opacity: .7;
}
.stick-ring::before { left: 10px; border-right-color: #fff; }
.stick-ring::after { right: 10px; border-left-color: #fff; }
.stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #dfe3ff 60%, #b9bff0);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 -3px 6px rgba(80,80,160,0.25);
  opacity: .85;
}
.stick.active .stick-knob { opacity: 1; }
.tbtn {
  position: absolute;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.40), rgba(255,255,255,0.12) 70%);
  border: 2px solid rgba(255,255,255,0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
  transition: transform .06s;
  touch-action: none;
}
.tbtn svg { width: 46%; height: 46%; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.tbtn-paw svg { width: 54%; height: 54%; }
.tbtn.down { transform: scale(0.9); background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.65), rgba(255,255,255,0.3) 70%); }
.tbtn-jump {
  right: calc(24px + var(--safe-r));
  bottom: calc(30px + var(--safe-b));
  width: 92px; height: 92px;
  background: radial-gradient(circle at 35% 30%, rgba(160,200,255,0.75), rgba(110,140,255,0.35) 70%);
}
.tbtn-paw {
  right: calc(128px + var(--safe-r));
  bottom: calc(24px + var(--safe-b));
  width: 70px; height: 70px;
  background: radial-gradient(circle at 35% 30%, rgba(255,180,220,0.75), rgba(255,110,170,0.35) 70%);
}

/* ------------------------------------------------------------------ screens */
#screens { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: auto;
  opacity: 0;
  transition: opacity .35s ease;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
}
.screen.show { opacity: 1; }
.screen.passthrough { pointer-events: none; }
.screen.passthrough .panel, .screen.passthrough button { pointer-events: auto; }

#boot {
  z-index: 50;
  background: radial-gradient(ellipse at 50% 40%, #2c3570, #141833 70%);
  gap: 20px;
}
.boot-title { font-size: 28px; font-weight: 500; letter-spacing: .5px; opacity: .9; }
.boot-title b { color: #c9b8ff; font-weight: 700; }
.boot-bar { width: 180px; height: 8px; border-radius: 99px; background: rgba(255,255,255,0.15); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 30%; border-radius: 99px; background: linear-gradient(90deg, #8fb4ff, #ff9ccf); animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

.panel {
  background: var(--glass-strong);
  border: 1.5px solid var(--line);
  border-radius: 26px;
  padding: 22px 26px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(10, 8, 40, 0.45);
  max-width: min(560px, 92vw);
  text-align: center;
}
.panel h2 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: .3px; }
.panel p { margin: 6px 0; font-size: 17px; line-height: 1.4; opacity: .92; }
.fact, .panel .fact { font-size: 15px; background: rgba(255,255,255,0.1); border-radius: 14px; padding: 8px 12px; margin: 10px 0 4px; }
.fact b { color: #ffd166; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px;
  white-space: nowrap;
  padding: 0 26px;
  border-radius: 999px;
  font-size: 20px; font-weight: 600;
  letter-spacing: .3px;
  color: #fff;
  background: linear-gradient(180deg, #8d7bff, #6a5ae6);
  box-shadow: 0 6px 0 #4a3db8, 0 10px 24px rgba(40, 30, 120, 0.35);
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #4a3db8, 0 4px 12px rgba(40, 30, 120, 0.35); }
.btn.pink { background: linear-gradient(180deg, #ff8fc4, #f0609f); box-shadow: 0 6px 0 #c2407a, 0 10px 24px rgba(160, 40, 100, 0.35); }
.btn.pink:active { box-shadow: 0 2px 0 #c2407a; }
.btn.gold { background: linear-gradient(180deg, #ffd978, #ffb84d); color: #5a3a00; text-shadow: none; box-shadow: 0 6px 0 #d18a1f, 0 10px 24px rgba(160, 100, 20, 0.35); }
.btn.gold:active { box-shadow: 0 2px 0 #d18a1f; }
.btn.ghost { background: rgba(255,255,255,0.14); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.45); }
.btn.ghost:active { transform: translateY(2px); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.45); }
.btn.small { min-height: 44px; font-size: 16px; padding: 0 18px; }
.btn svg { width: 22px; height: 22px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.col { display: flex; flex-direction: column; gap: 12px; align-items: stretch; margin-top: 14px; }

.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(30, 32, 72, 0.26);
  border: 1.5px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.off { opacity: .55; }

/* ------------------------------------------------------------------ title */
/* Poster layout: the canvas key art fills whatever the logo and the buttons leave free. */
.title-wrap {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: calc(64px + var(--safe-t)) calc(28px + var(--safe-r)) calc(30px + var(--safe-b)) calc(28px + var(--safe-l));
}
.title-text, .title-logo, .title-cta { display: flex; flex-direction: column; align-items: center; text-align: center; }
.title-text { grid-column: 2; gap: 18px; }
.logo-small {
  font-size: clamp(18px, 4.2vh, 36px);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 0 #5a46c8, 0 4px 14px rgba(40,30,90,0.6);
  margin-bottom: -4px;
}
.logo-big {
  font-size: clamp(40px, min(15vh, 9.6vw), 120px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 1px;
  white-space: nowrap;
  rotate: -3deg;
  background: linear-gradient(180deg, #ffffff 0%, #ffe6f3 35%, #c7b6ff 75%, #9f8cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #5a46c8) drop-shadow(0 0 2px #3c2c9a) drop-shadow(0 10px 22px rgba(40,20,100,0.55));
  margin: 4px 0 8px;
  padding: 0 6px;
}
.logo-sub {
  font-size: clamp(16px, 3.4vh, 27px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: .5px;
  background: linear-gradient(180deg, #ffffff 0%, #ffe6f3 55%, #ffc9e6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #5a46c8) drop-shadow(0 4px 10px rgba(40,30,90,0.55));
  margin: 0 0 10px;
}
.tagline { font-size: clamp(14px, 3vh, 19px); font-weight: 500; max-width: 24em; text-shadow: 0 1px 3px rgba(30,20,70,0.7), 0 2px 14px rgba(30,20,70,0.6); text-wrap: balance; }
.title-cta { gap: 12px; }
.title-cta .btn { min-width: 250px; }
.title-cta .btn.gold { min-height: 58px; font-size: 21px; }
.title-cta .btn svg { width: 22px; height: 22px; }
.title-story {
  position: absolute; left: calc(14px + var(--safe-l)); top: calc(14px + var(--safe-t));
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  font-size: 15px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  background: rgba(30, 32, 72, 0.32); border: 1.5px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.title-corner { position: absolute; right: calc(14px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: flex; gap: 8px; }
.title-foot { position: absolute; bottom: calc(10px + var(--safe-b)); left: 0; right: 0; text-align: center; font-size: 13px; opacity: .8; text-shadow: 0 1px 4px rgba(0,0,0,.6); pointer-events: none; }
/* portrait: logo and tagline on top, the cast in the middle, the two big buttons at the bottom */
@media (orientation: portrait) {
  .title-wrap { grid-template-columns: 1fr; align-items: stretch; padding: calc(70px + var(--safe-t)) calc(16px + var(--safe-r)) calc(38px + var(--safe-b)) calc(16px + var(--safe-l)); }
  .title-text { grid-column: 1; justify-content: space-between; gap: 0; }
  .logo-small { font-size: min(4.2vh, 7.4vw, 36px); }
  .logo-big { font-size: min(14vh, 19vw, 120px); }
  .logo-sub { font-size: min(3vh, 5.4vw, 27px); margin-bottom: 6px; }
  .tagline { font-size: clamp(14px, 4vw, 19px); max-width: 21em; }
  .title-cta { width: min(100%, 360px); gap: 10px; }
  .title-cta .btn { width: 100%; min-width: 0; }
}
@media (orientation: landscape) {
  .title-foot { right: 50%; }
}
@media (orientation: landscape) and (max-height: 420px) {
  .title-wrap { padding-top: calc(58px + var(--safe-t)); padding-bottom: calc(26px + var(--safe-b)); }
  .title-text { gap: 10px; }
  .title-cta { gap: 9px; }
  .title-cta .btn { min-width: 220px; }
  .title-cta .btn.gold { min-height: 50px; font-size: 19px; }
  .logo-sub { margin-bottom: 4px; }
  .tagline { font-size: 14px; }
}

/* ------------------------------------------------------------------ story */
.story-box {
  position: absolute;
  left: 50%; bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  width: min(720px, 92vw);
  padding: 18px 22px 16px;
  border-radius: 24px;
  background: var(--glass-strong);
  border: 1.5px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(10, 8, 40, 0.45);
}
.story-text { font-size: clamp(16px, 3.6vh, 21px); line-height: 1.45; min-height: 3em; display: flex; align-items: center; }
.story-text > span { display: block; }
.story-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.3); transition: background .2s, transform .2s; }
.dots i.on { background: #fff; transform: scale(1.25); }
@media (orientation: portrait) {
  .story-box { width: auto; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); transform: none; max-width: 640px; margin: 0 auto; padding: 16px 18px 14px; }
  .story-text { font-size: clamp(16px, 4.4vw, 21px); line-height: 1.42; }
}
.story.side .story-box { left: auto; right: calc(14px + var(--safe-r)); top: 50%; bottom: auto; transform: translateY(-50%); width: min(460px, 54vw); padding: 14px 16px 12px; }
.story.side .story-nav { gap: 8px; }
.story.side .story-text { font-size: clamp(15px, 4.4vh, 18px); line-height: 1.4; }

/* ------------------------------------------------------------------ map */
.map-head { position: absolute; top: calc(12px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(16px + var(--safe-r)); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.map-title { flex: 1; min-width: 0; font-size: clamp(18px, min(5vh, 3.6vw), 32px); font-weight: 700; line-height: 1.15; text-align: center; text-shadow: 0 2px 10px rgba(30,20,80,0.6); }
@media (orientation: landscape) { .map-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } }
.map-total { display: flex; gap: 10px; align-items: center; font-size: 17px; white-space: nowrap; }
.map-total svg { width: 22px; height: 22px; }
.levels {
  display: flex; gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 10px 6vw 18px;
  width: 100%;
  max-width: 100vw;
  touch-action: pan-x;
  scrollbar-width: none;
  margin-top: 30px;
}
.levels::-webkit-scrollbar { display: none; }
.level-card {
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: clamp(190px, 26vw, 240px);
  border-radius: 22px;
  overflow: hidden;
  background: var(--glass-strong);
  border: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 12px 30px rgba(10,8,40,0.4);
  text-align: left;
  padding: 0;
  transition: transform .15s;
  position: relative;
}
.level-card:active { transform: scale(0.97); }
.level-card canvas { display: block; width: 100%; height: clamp(90px, 22vh, 140px); object-fit: cover; }
.level-card .info { padding: 10px 14px 12px; }
.level-card .num { font-size: 13px; opacity: .8; letter-spacing: 1px; text-transform: uppercase; }
.level-card .name { font-size: 19px; font-weight: 700; line-height: 1.15; margin: 2px 0 6px; }
.level-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 15px; }
.level-card .stars { display: flex; gap: 2px; }
.level-card .stars svg { width: 20px; height: 20px; }
.level-card.locked canvas { filter: grayscale(0.8) brightness(0.55); }
.level-card.locked .lock {
  position: absolute; left: 0; right: 0; top: 0; height: clamp(90px, 22vh, 140px);
  display: grid; place-items: center;
}
.level-card.locked .lock svg { width: 40px; height: 40px; opacity: .9; }
.level-card.current { border-color: #ffd166; box-shadow: 0 0 0 3px rgba(255,209,102,0.35), 0 12px 30px rgba(10,8,40,0.4); }
@media (orientation: landscape) and (max-height: 420px) {
  .map-head { top: calc(8px + var(--safe-t)); }
  .levels { margin-top: 44px; padding-bottom: 12px; }
  .level-card .info { padding: 8px 12px 10px; }
  .level-card .name { font-size: 17px; margin-bottom: 4px; }
}
@media (orientation: landscape) and (min-height: 700px) and (min-width: 1000px) {
  .level-card { width: clamp(240px, 21vw, 320px); border-radius: 26px; }
  .level-card canvas, .level-card.locked .lock { height: clamp(140px, 17vh, 190px); }
  .level-card .info { padding: 12px 16px 14px; }
  .level-card .num { font-size: 14px; }
  .level-card .name { font-size: 22px; }
  .level-card .meta { font-size: 16px; }
  .level-card .stars svg { width: 24px; height: 24px; }
  .map-total { font-size: 19px; }
}
/* Portrait: top bar, heading, then a vertical list of wide cards */
@media (orientation: portrait) {
  .screen.map { justify-content: flex-start; padding: 0; }
  .map-head { position: static; flex: none; width: 100%; max-width: 760px; flex-wrap: wrap; row-gap: 4px; padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) 4px calc(14px + var(--safe-l)); }
  .map-title { order: 3; flex: 1 0 100%; font-size: clamp(21px, 6vw, 30px); }
  .levels {
    flex: 1; min-height: 0; max-width: 760px; margin: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-content: start; gap: 12px;
    overflow: hidden auto; scroll-snap-type: none; touch-action: pan-y;
    padding: 8px calc(14px + var(--safe-r)) calc(24px + var(--safe-b)) calc(14px + var(--safe-l));
    -webkit-mask-image: linear-gradient(transparent, #000 10px, #000 calc(100% - 18px), transparent);
    mask-image: linear-gradient(transparent, #000 10px, #000 calc(100% - 18px), transparent);
  }
  .level-card { display: flex; width: auto; height: clamp(104px, 14vh, 128px); }
  .level-card canvas { width: 44%; height: 100%; flex: none; }
  .level-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; }
  .level-card .name { font-size: clamp(17px, 4.8vw, 20px); }
  .level-card.locked .lock { right: auto; width: 44%; height: 100%; }
  .level-card .here { top: auto; bottom: 6px; left: 6px; font-size: 12px; padding-right: 8px; }
  .level-card .here svg, .level-card .here img { width: 22px; height: 22px; }
}

/* ------------------------------------------------------------------ in-game overlays */
.banner {
  position: absolute; left: 50%; top: 30%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 3px 16px rgba(20,10,60,0.6);
}
.banner .k { font-size: clamp(16px, 3.5vh, 22px); font-weight: 600; letter-spacing: 3px; text-transform: uppercase; text-shadow: 0 1px 3px rgba(20,10,60,0.7), 0 3px 16px rgba(20,10,60,0.6); }
.banner .n { font-size: clamp(34px, 9vh, 64px); font-weight: 700; line-height: 1.05; }
.banner .s { font-size: clamp(15px, 3.4vh, 20px); font-weight: 500; margin-top: 4px; text-shadow: 0 1px 3px rgba(20,10,60,0.7), 0 3px 16px rgba(20,10,60,0.6); }
.banner .keys { display: inline-block; margin-top: 14px; font-size: 14px; padding: 6px 12px; border-radius: 999px; background: rgba(20, 20, 50, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.banner .keys kbd { font-family: inherit; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); border-radius: 6px; padding: 1px 7px; margin: 0 2px; }

.bubble {
  position: absolute; left: 0; top: 0;
  max-width: min(320px, 70vw);
  padding: 10px 14px;
  border-radius: 16px;
  background: #fffdf6;
  color: #3a3550;
  font-size: 16px; line-height: 1.35; font-weight: 500;
  box-shadow: 0 8px 24px rgba(20,10,60,0.3);
  transform-origin: 50% 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 6;
}
.bubble.show { opacity: 1; }
.bubble::after {
  content: ''; position: absolute; left: var(--tx, 50%); bottom: -9px; margin-left: -9px;
  border: 9px solid transparent; border-top-color: #fffdf6; border-bottom: 0;
}
/* beside the speaker instead of above him: the tail points sideways at his head */
.bubble.tail-left::after, .bubble.tail-right::after { top: var(--ty, 50%); bottom: auto; margin: -9px 0 0; border: 9px solid transparent; }
.bubble.tail-left::after { left: -9px; border-right-color: #fffdf6; border-left: 0; }
.bubble.tail-right::after { left: auto; right: -9px; border-left-color: #fffdf6; border-right: 0; }
.bubble b { color: #7a5ae6; }
/* short landscape phones: smaller and wider, so it takes 2–3 lines instead of 5 */
@media (max-height: 520px) {
  .bubble { font-size: 14px; line-height: 1.3; padding: 7px 12px; max-width: min(400px, 50vw); border-radius: 14px; }
}

.results .stars-big { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; }
.results .stars-big svg { width: 56px; height: 56px; opacity: 0; transform: scale(0.3) rotate(-30deg); }
.results .stars-big svg.in { animation: starIn .5s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes starIn { to { opacity: 1; transform: scale(1) rotate(0); } }
.stat-row { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 8px 0 2px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; }
.stat svg { width: 24px; height: 24px; }

.toast {
  position: absolute; left: 50%; top: calc(64px + var(--safe-t));
  transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px;
  background: var(--glass-strong);
  border: 1.5px solid var(--line);
  font-weight: 600; font-size: 16px;
  pointer-events: none;
  opacity: 0; transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

.rotate-hint {
  position: absolute; left: 50%; bottom: calc(170px + var(--safe-b)); transform: translateX(-50%);
  padding: 8px 14px; border-radius: 999px; font-size: 14px;
  background: var(--glass-strong); border: 1.5px solid var(--line);
  pointer-events: none; white-space: nowrap;
}

.fade {
  position: absolute; inset: 0; background: #0d0c22; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30;
}
.fade.on { opacity: 1; }

.results .legend { font-size: 13px; opacity: .7; }

@media (max-height: 420px) {
  .panel { padding: 14px 18px; max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
  .panel h2 { font-size: 24px; }
  .btn { min-height: 46px; font-size: 18px; }
  .btn.small { min-height: 44px; font-size: 16px; }
  /* pause: title + sound toggles on the left, actions on the right */
  .pause { display: grid; grid-template-columns: auto minmax(200px, auto); column-gap: 24px; align-items: center; }
  .pause h2 { grid-area: 1 / 1; align-self: end; }
  .pause > p { grid-area: 2 / 1; margin: 0; }
  .pause .row { grid-area: 3 / 1; align-self: start; }
  .pause .col { grid-area: 1 / 2 / 4 / 3; margin: 0; }
  /* results: smaller stars, one row of buttons */
  .results { max-width: min(600px, 96vw); padding: 12px 18px; }
  .results h2 { margin-bottom: 0; }
  .results .stars-big { margin: 2px 0 4px; }
  .results .stars-big svg { width: 40px; height: 40px; }
  .results .stat-row { margin: 2px 0 0; }
  .results .fact { font-size: 14px; padding: 6px 10px; margin: 8px 0 2px; }
  .results .legend { font-size: 12px; margin: 4px 0 0; }
  .results .row { margin-top: 10px; gap: 10px; flex-wrap: nowrap; }
  .results .row .btn { padding: 0 16px; font-size: 16px; }
  .stick { width: 118px; height: 118px; }
  .tbtn-jump { width: 82px; height: 82px; }
  .tbtn-paw { width: 62px; height: 62px; right: calc(116px + var(--safe-r)); }
  .hud-group { font-size: 16px; padding: 4px 10px; }
  .hud-hearts svg { width: 21px; height: 21px; }
}

/* ------------------------------------------------------------------ ending */
.ending {
  position: absolute; right: calc(4vw + var(--safe-r));
  width: min(440px, 56vw);
  max-height: calc(100% - 20px - var(--safe-t) - var(--safe-b));
  display: flex; flex-direction: column;
}
.ending h2 { flex: none; }
.ending-body { min-height: 0; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; scrollbar-width: none; }
.ending-body::-webkit-scrollbar { display: none; }
.ending-body.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 34px), transparent); mask-image: linear-gradient(#000 calc(100% - 34px), transparent); }
.ending .thanks { opacity: .8; font-size: 15px; }
.ending .row { flex: none; }
@media (orientation: portrait) {
  .ending { left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); width: auto; max-width: 560px; margin: 0 auto; max-height: 72%; padding: 18px 18px 16px; }
  .ending h2 { font-size: clamp(22px, 6.6vw, 30px); }
  .ending p { font-size: clamp(15px, 4.2vw, 17px); }
}
@media (orientation: landscape) and (min-height: 700px) {
  .ending { width: min(520px, 44vw); padding: 28px 30px 24px; }
  .ending h2 { font-size: clamp(27px, 2.6vw, 34px); white-space: nowrap; }
  .ending p { font-size: 18px; }
  .ending .fact, .ending .thanks { font-size: 16px; }
}
@media (max-height: 460px) {
  .panel.ending { padding: 12px 16px; }
  .ending h2 { font-size: 22px; margin-bottom: 2px; }
  .ending p { font-size: 14.5px; line-height: 1.32; margin: 4px 0; }
  .ending .fact { font-size: 13.5px; padding: 6px 10px; margin: 6px 0 2px; }
  .ending .thanks { font-size: 13.5px; }
  .ending .stat-row { margin: 4px 0 0; gap: 14px; }
  .ending .stat { font-size: 16px; }
  .ending .stat svg { width: 20px; height: 20px; }
  .ending .row { margin-top: 10px; }
}
@media (max-height: 380px) {
  .ending h2 { font-size: 20px; }
  .ending p { font-size: 14px; line-height: 1.28; }
  .ending .fact, .ending .thanks { font-size: 13px; }
  .ending .btn { min-height: 44px; }
}

/* ------------------------------------------------------------------ rotate prompt */
.rotate-screen { background: rgba(14, 14, 40, 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 40; }
.rotate-panel { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px; }
.rotate-panel h2 { margin: 22px 0 6px; font-size: 28px; }
.rotate-panel p { margin: 0 0 22px; max-width: 16em; opacity: .9; font-size: 17px; line-height: 1.4; text-wrap: balance; }
.phone {
  width: 64px; height: 110px; margin: 0 auto;
  border: 5px solid #fff; border-radius: 14px; position: relative;
  animation: rot 2.2s ease-in-out infinite;
}
.phone::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 4px; margin-left: -7px; border-radius: 4px; background: #fff; }
@keyframes rot { 0%, 25% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

.no-fullscreen [data-action="full"] { display: none !important; }
/* the ⛶ buttons show "leave fullscreen" while in it (however it was entered or left) */
.fs-exit, .is-fullscreen .fs-enter { display: none; }
.is-fullscreen .fs-exit { display: inline; }


.title-cta .btn.gold { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.title-cta .btn.gold:active { animation: none; }
.logo-big { animation: float 4s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.level-card .here {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: rgba(20,20,50,0.6); font-size: 13px; font-weight: 600;
}
.level-card .here svg, .level-card .here img { width: 26px; height: 26px; }
.level-card.done .check {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  background: #7be08a; color: #164a22; display: grid; place-items: center; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.tbtn::after {
  content: attr(data-label);
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 2px);
  font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: #fff; opacity: .75; text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap; pointer-events: none;
}

/* ------------------------------------------------------------------ lobby: 1 or 2 players, the cats, the room */
.panel.lobby { width: min(620px, 94vw); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.panel.lobby h2 { margin: 0; }
.mode-row { display: flex; gap: 14px; width: 100%; justify-content: center; }
.mode-btn {
  flex: 1 1 0; max-width: 250px; min-height: 120px; padding: 14px 10px; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(255,255,255,0.12); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35), 0 6px 0 rgba(20,16,60,0.35);
  font-size: 20px; transition: transform .1s, background .15s;
}
.mode-btn:active { transform: translateY(3px); }
.mode-btn:hover { background: rgba(255,255,255,0.2); }
.mode-btn .mode-ico { font-size: 30px; line-height: 1; }
.mode-btn small { font-size: 14px; opacity: .8; font-weight: 400; }
.cat-row { display: flex; gap: 14px; width: 100%; justify-content: center; }
.cat-card {
  flex: 1 1 0; max-width: 250px; padding: 10px 10px 12px; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.1); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.cat-card canvas { width: 100%; height: clamp(110px, 24vh, 190px); display: block; }
.cat-card .cat-name { font-size: 21px; font-weight: 700; }
.cat-card .cat-desc { font-size: 13px; opacity: .85; line-height: 1.3; }
.cat-card.sel { background: rgba(255, 209, 102, 0.22); box-shadow: inset 0 0 0 3px #ffd166, 0 0 24px rgba(255, 209, 102, 0.35); transform: translateY(-3px); }
.cat-card[data-cat=bigode].sel { background: rgba(111, 195, 255, 0.2); box-shadow: inset 0 0 0 3px #6fc3ff, 0 0 24px rgba(111, 195, 255, 0.35); }
.cat-row.single .cat-card { max-width: 200px; }
.room-body { display: flex; gap: 18px; align-items: center; width: 100%; }
.room .qr { flex: 0 0 auto; width: clamp(150px, 34vh, 230px); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.room .qr svg { width: 100%; height: 100%; display: block; }
.room .qr-wait { width: 100%; height: 100%; display: grid; place-items: center; color: #1e2747; font-size: 30px; }
.room-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.room-info p { margin: 0; font-size: 15px; }
.room-code { font-size: 40px; font-weight: 700; letter-spacing: 8px; color: #ffd166; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.room-url { font-size: 13px; opacity: .85; word-break: break-all; user-select: all; -webkit-user-select: all; background: rgba(0,0,0,0.2); padding: 6px 8px; border-radius: 10px; }
.room-info .row { justify-content: flex-start; margin-top: 2px; }
.room-status { font-size: 15px; font-weight: 600; color: #bfe9ff; }
.panel.join p { margin: 0; }
@media (orientation: portrait) {
  .room-body { flex-direction: column; }
  .room-info { text-align: center; align-items: center; }
  .room-info .row { justify-content: center; }
}
@media (orientation: landscape) and (max-height: 460px) {
  .panel.lobby { gap: 8px; padding: 12px 18px; }
  .mode-btn { min-height: 92px; }
  .cat-card canvas { height: clamp(90px, 30vh, 130px); }
  .cat-card .cat-desc { display: none; }
  .room-code { font-size: 32px; }
}

/* co-op in game */
.hud-partner { gap: 6px; font-size: 15px; font-weight: 600; box-shadow: inset 0 0 0 2px #ff8fc4; }
.hud-partner[data-cat=bigode] { box-shadow: inset 0 0 0 2px #6fc3ff; }
.hud-partner .phearts { display: flex; gap: 1px; }
.hud-partner .phearts svg { width: 12px; height: 12px; }
.hud-partner .phearts svg.lost { opacity: .28; }
@media (max-width: 700px) { .hud-partner .pname { display: none; } }
.bubble.villain { background: #f4ecff; border: 2px solid #b48cff; }
.bubble.villain::after { border-top-color: #b48cff; }
.bubble.villain.tail-left::after { border-top-color: transparent; border-right-color: #b48cff; }
.bubble.villain.tail-right::after { border-top-color: transparent; border-left-color: #b48cff; }
.bubble.villain b { color: #e0712b; }
.panel .waiting { font-size: 16px; opacity: .9; margin: 10px 0 4px; }
.screen.passthrough .peer-note { margin-top: auto; margin-bottom: 8px; padding: 12px 18px; }
.peer-note h2 { font-size: 20px; }
.map-coop { display: block; font-size: 13px; font-weight: 500; opacity: .85; text-shadow: none; }

/* ------------------------------------------------------------------ super power */
.hud-power { gap: 6px; }
.hud-power .pw-ico { font-size: 16px; line-height: 1; filter: grayscale(0.6); opacity: .7; transition: all .2s; }
.hud-power[data-kind=glide] .pw-ico::before { content: ''; }
.hud-power .pw-bar { position: relative; width: 64px; height: 10px; border-radius: 99px; background: rgba(255,255,255,0.18); overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.35); }
.hud-power .pw-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: linear-gradient(90deg, #a9c4ff, #d2bbff, #ffc0de); transition: width .25s; }
.hud-power.ready .pw-ico { filter: none; opacity: 1; }
.hud-power.ready .pw-bar { box-shadow: inset 0 0 0 1.5px rgba(255,236,160,0.8), 0 0 10px rgba(255,214,120,0.55); }
.hud-power.on .pw-bar i { background: linear-gradient(90deg, #ffe08a, #ffb84d); }
.hud-power.empty { animation: pw-empty .55s ease-out; }
.hud-power.empty .pw-bar { box-shadow: inset 0 0 0 1.5px rgba(255,120,130,0.9), 0 0 10px rgba(255,90,110,0.55); }
@keyframes pw-empty { 0%, 100% { transform: none; } 15% { transform: translateX(-5px); } 35% { transform: translateX(5px); } 55% { transform: translateX(-3px); } 75% { transform: translateX(2px); } }
@media (max-width: 700px) { .hud-power .pw-bar { width: 44px; } }
.tbtn-power {
  right: calc(34px + var(--safe-r));
  bottom: calc(138px + var(--safe-b));
  width: 64px; height: 64px;
  background: radial-gradient(circle at 35% 30%, rgba(255,232,150,0.8), rgba(255,180,70,0.38) 70%);
}
.tbtn-power svg { width: 56%; height: 56%; }
@media (max-height: 420px) {
  .tbtn-power { width: 52px; height: 52px; right: calc(39px + var(--safe-r)); bottom: calc(134px + var(--safe-b)); }
}

/* HUD on narrow screens. Container queries on #hud, so notch insets and the co-op badge count:
   the groups get tighter before they would need a second row (7 hearts + the partner's 7). */
@container hud (max-width: 900px) {
  .hud-partner .pname { display: none; }
  .hud-group { padding-left: 9px; padding-right: 9px; }
  .hud-hearts svg { width: 19px; height: 19px; }
  .hud-yarn svg { width: 20px; height: 20px; }
  .hud-power .pw-bar { width: 48px; }
  .count { min-width: 1.5em; }
}
@container hud (max-width: 760px) {
  .hud-left, .hud-center, .hud-right { gap: 5px; }
  .hud-group { padding: 4px 7px; gap: 5px; font-size: 16px; }
  .hud-group.hud-hearts { gap: 1px; }
  .hud-hearts svg { width: 16px; height: 16px; }
  .hud-lives img, .hud-lives svg { width: 24px; height: 24px; }
  .hud-flowers svg, .hud-keys svg { width: 22px; height: 22px; }
  .hud-yarn { gap: 3px; }
  .hud-yarn svg { width: 18px; height: 18px; }
  .hud-partner .phearts svg { width: 10px; height: 10px; }
  .hud-power .pw-bar { width: 38px; }
  .count { min-width: 1.5em; }
}
@container hud (max-width: 620px) {
  .hud-group { padding: 3px 6px; gap: 4px; font-size: 15px; }
  .hud-hearts svg { width: 14px; height: 14px; }
  .hud-lives img, .hud-lives svg { width: 21px; height: 21px; }
  .hud-flowers svg, .hud-keys svg { width: 20px; height: 20px; }
  .hud-yarn svg { width: 16px; height: 16px; }
  .hud-partner .phearts svg { width: 9px; height: 9px; }
  .hud-power .pw-bar { width: 30px; }
}
@container hud (max-width: 520px) { .hud-group { padding-left: 5px; padding-right: 5px; } }

/* ------------------------------------------------------------------ menu (☰) and saved games */
.menu-fab { position: absolute; top: calc(12px + var(--safe-t)); left: calc(14px + var(--safe-l)); z-index: 12; color: #fff; }
.menu-fab svg { width: 22px; height: 22px; }
.menu-fab.hidden { display: none; }
.screen.menu-screen { z-index: 20; background: rgba(14, 14, 40, 0.45); }
.panel.game-menu { min-width: min(320px, 92vw); }
.panel.game-menu .col .btn { width: 100%; }
.panel.saves, .panel.save-dialog { width: min(720px, 96vw); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.panel.saves h2, .panel.save-dialog h2 { margin: 0; }
.saves-body, .save-form { display: flex; gap: 18px; align-items: flex-start; text-align: left; }
.saves-left, .save-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.panel .hint { font-size: 14px; opacity: .88; margin: 0; line-height: 1.35; }
.panel .hint.warn { color: #ffd0a0; opacity: 1; }
.name-field, .save-name label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 600; }
.name-field input, .save-name input {
  font: inherit; font-size: 20px; font-weight: 600; padding: 10px 14px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12); color: #fff; outline: none; user-select: text; -webkit-user-select: text;
}
.name-field input:focus, .save-name input:focus { border-color: #ffd166; background: rgba(255,255,255,0.18); }
.name-field input::placeholder, .save-name input::placeholder { color: rgba(255,255,255,0.5); }
.save-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.save-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,0.1); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.25); }
.save-card.here { background: rgba(255, 209, 102, 0.16); box-shadow: inset 0 0 0 2px rgba(255, 209, 102, 0.6); } /* the game being played */
.save-card .sc-open { flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: none; padding: 2px 0; min-height: 44px; justify-content: center; }
.sc-name { font-size: 18px; font-weight: 700; }
.sc-meta { font-size: 13px; opacity: .85; }
.sc-del { flex: 0 0 auto; min-width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,0.1); font-size: 16px; }
.save-card.confirm .sc-del { background: #e8546f; padding: 0 10px; font-weight: 600; }
@media (orientation: portrait) {
  .saves-body, .save-form { flex-direction: column; align-items: stretch; }
}
@media (orientation: landscape) and (max-height: 460px) {
  .panel.saves, .panel.save-dialog { padding: 12px 16px; gap: 6px; }
  .save-list { max-height: 34vh; }
}

/* ------------------------------------------------------------------ panels fit the screen
   Phones lose a lot of height to the browser bars (iPhone Safari ≈ 390×664 portrait, 844×340
   landscape). #app is position:fixed, so a .screen is exactly the visible area (safe areas in its
   padding) and a panel never grows past it: its middle part (.scrolly) scrolls, with a fade at the
   bottom while there is more below (dom.js), and the title and the buttons always stay in view. */
.screen > .panel:not(.ending) { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.panel .scrolly {
  flex: 0 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  scrollbar-width: none;
}
.panel .scrolly::-webkit-scrollbar { display: none; }
.panel .scrolly.more { -webkit-mask-image: linear-gradient(#000 calc(100% - 32px), transparent); mask-image: linear-gradient(#000 calc(100% - 32px), transparent); }
.panel .scrolly.up { -webkit-mask-image: linear-gradient(transparent, #000 20px); mask-image: linear-gradient(transparent, #000 20px); }
.panel .scrolly.up.more { -webkit-mask-image: linear-gradient(transparent, #000 20px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(transparent, #000 20px, #000 calc(100% - 32px), transparent); }
.panel.saves > :not(.scrolly), .panel.save-dialog > :not(.scrolly), .panel.lobby > :not(.scrolly) { flex: none; }
.panel .scrolly .save-list { max-height: none; overflow: visible; } /* one scroll area, not two */
/* QR and text side by side: centered while they fit, top-aligned (nothing above the scroll start)
   when they don't */
@media (orientation: landscape) {
  .room-body.scrolly { align-items: flex-start; }
  .room-body.scrolly > * { margin-block: auto; }
}
/* typing a name (on-screen keyboard up, little room left): the whole panel scrolls instead, so the
   field can always be brought into view; the buttons are back in place once the keyboard closes */
.panel:has(.scrolly input:focus) > .scrolly { flex: none; overflow: visible; -webkit-mask-image: none; mask-image: none; }
@media (orientation: portrait) {
  .room .qr { width: clamp(130px, 26vh, 230px); }
}
/* choosing a cat: the portraits shrink before anything else would */
.panel.lobby > .cat-row { flex: 0 1 auto; min-height: 0; }
.cat-card canvas { flex: 0 1 auto; min-height: 56px; }
/* titles on one line on narrow phones */
@media (orientation: portrait) {
  .panel.saves h2, .panel.save-dialog h2, .panel.lobby h2 { font-size: clamp(22px, 6.6vw, 30px); }
}
/* the ☰ menu on short screens: title and sound buttons on the left, the actions on the right */
@media (max-height: 420px) {
  .game-menu { display: grid; grid-template-columns: auto minmax(200px, auto); column-gap: 24px; align-items: center; }
  .game-menu h2 { grid-area: 1 / 1; align-self: end; }
  .game-menu .row { grid-area: 2 / 1; align-self: start; }
  .game-menu .col { grid-area: 1 / 2 / 3 / 3; margin: 0; }
}
@media (max-height: 340px) {
  .panel { padding-top: 10px; padding-bottom: 10px; }
  .pause .col { gap: 6px; }
}
/* the ☰ button floats over the screens that have it: keep the panels clear of it */
@media (orientation: landscape) { #app:has(> .menu-fab:not(.hidden)) .screen { padding-left: calc(76px + var(--safe-l)); } }
@media (orientation: portrait) { #app:has(> .menu-fab:not(.hidden)) .screen { padding-top: calc(70px + var(--safe-t)); } }

/* ------------------------------------------------------------------ difficulty (ui/difficulty-cards.js) */
.diff-card[data-diff=facil], .diff-badge[data-diff=facil] { --accent: #8fe3c0; --glow: rgba(143, 227, 192, 0.45); }
.diff-card[data-diff=medio], .diff-badge[data-diff=medio] { --accent: #ffb560; --glow: rgba(255, 181, 96, 0.45); }
.diff-card[data-diff=dificil], .diff-badge[data-diff=dificil] { --accent: #ff6f9a; --glow: rgba(255, 90, 140, 0.5); }
.panel.difficulty { width: min(780px, 100%); max-width: none; }
.diff-row { display: flex; gap: 14px; width: 100%; padding: 8px 10px 10px; }
.diff-card {
  flex: 1 1 0; min-width: 0; position: relative;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0; border-radius: 22px; overflow: hidden; text-align: center;
  background: rgba(255,255,255,0.08); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
  opacity: .6; filter: saturate(.65); transform: scale(.96);
  transition: transform .22s, opacity .22s, filter .22s, box-shadow .22s;
}
.diff-card canvas { display: block; width: 100%; height: clamp(90px, 24vh, 170px); }
.diff-text { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 10px 12px; }
.diff-paws { display: inline-flex; gap: 2px; color: var(--accent); }
.diff-paws svg { width: 17px; height: 17px; }
.diff-name { font-size: 22px; font-weight: 700; line-height: 1.1; }
.diff-label { font-size: 13px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
.diff-desc { font-size: 13.5px; line-height: 1.3; opacity: .9; margin-top: 4px; }
.diff-card.sel { opacity: 1; filter: none; transform: scale(1.03); box-shadow: inset 0 0 0 3px var(--accent), 0 0 24px var(--glow), 0 10px 26px rgba(10, 8, 40, 0.4); }
.diff-card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.diff-check {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; color: #241c3a; background: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); transform: scale(0); transition: transform .25s cubic-bezier(.2, 1.6, .4, 1);
}
.diff-card.sel .diff-check { transform: scale(1); }
/* portrait: wide cards stacked, the picture on the left */
@media (orientation: portrait) {
  .diff-row { flex-direction: column; gap: 10px; }
  .diff-card { flex: none; flex-direction: row; transform: scale(.98); }
  .diff-card.sel { transform: scale(1.02); }
  .diff-card canvas { width: 42%; height: auto; min-height: 104px; flex: none; }
  .diff-text { flex: 1; min-width: 0; align-items: flex-start; justify-content: center; text-align: left; padding: 8px 12px; }
  .diff-check { top: 6px; right: 6px; width: 24px; height: 24px; }
}
@media (orientation: landscape) and (max-height: 460px) {
  .diff-row { gap: 10px; padding: 6px 8px 8px; }
  .diff-card canvas { height: clamp(64px, 26vh, 120px); }
  .diff-text { padding: 6px 8px 8px; }
  .diff-name { font-size: 19px; }
  .diff-desc { font-size: 12px; }
}
/* phones in landscape with the browser bars: the paws and the label say it, the line goes */
@media (orientation: landscape) and (max-height: 380px) {
  .diff-desc { display: none; }
  .diff-card canvas { height: clamp(60px, 22vh, 100px); }
}
@media (orientation: landscape) and (max-height: 330px) {
  .diff-row { padding: 4px 8px 6px; }
  .diff-card canvas { height: 54px; }
  .diff-text { padding: 3px 6px 6px; gap: 0; }
  .diff-paws svg { width: 13px; height: 13px; }
  .diff-name { font-size: 17px; }
}
@media (orientation: portrait) and (max-height: 620px) {
  .panel.lobby { gap: 8px; }
  .room .qr { width: clamp(120px, 22vh, 230px); }
  .diff-name { font-size: 19px; }
  .diff-desc { font-size: 12.5px; line-height: 1.25; }
  .diff-card canvas { min-height: 88px; }
}
/* the mode as a small badge (map, room, menus) */
.diff-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; white-space: nowrap; }
.diff-badge small { font-size: .78em; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; }
.diff-badge .diff-paws svg { width: 13px; height: 13px; }
.room-diff, .menu-diff { font-size: 15px; opacity: .95; }
.panel p.menu-diff { margin: 2px 0; }
.btn.menu-diff { gap: 6px; }
@media (prefers-reduced-motion: reduce) { .diff-card, .diff-check { transition: none; } }

/* ------------------------------------------------------------------ Churu power badge (ui/churu-hud.js) */
.hud-churu { position: relative; width: 36px; height: 36px; padding: 0; gap: 0; justify-content: center; border-color: var(--churu, var(--line)); box-shadow: 0 4px 18px rgba(0,0,0,0.18), 0 0 10px var(--churu, transparent); }
.hud-churu .ch-ring { position: absolute; inset: 1px; width: calc(100% - 2px); height: calc(100% - 2px); transform: rotate(-90deg); }
.hud-churu .ch-ring circle { fill: none; stroke-width: 3.4; }
.hud-churu .ch-ring .bg { stroke: rgba(255,255,255,0.2); }
.hud-churu .ch-ring .fg { stroke: var(--churu, #fff); stroke-linecap: round; transition: stroke-dashoffset .15s linear; }
.hud-churu .ch-ico { display: flex; width: 27px; height: 27px; }
.hud-churu .ch-ico svg { width: 100%; height: 100%; }
.hud-churu.warn { animation: churuWarn .5s ease-in-out infinite; }
@keyframes churuWarn { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.toast .toast-churu { width: 1.7em; height: 1.7em; vertical-align: -0.5em; margin-right: 2px; }
.stat .churu-svg { width: 30px; height: 30px; }
@container hud (max-width: 760px) { .hud-churu { width: 31px; height: 31px; } .hud-churu .ch-ico { width: 23px; height: 23px; } }
@container hud (max-width: 620px) { .hud-churu { width: 28px; height: 28px; } .hud-churu .ch-ico { width: 21px; height: 21px; } }
