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

:root {
  --ink: #4a3377;
  --ink-soft: #8672b3;
  --mint: #7fe3bf; --mint-d: #36b48a; --mint-dd: #27916e;
  --pink: #ff93bd; --pink-d: #e5568f; --pink-dd: #bf3b72;
  --lav: #b3a6ff; --lav-d: #7565e8; --lav-dd: #5646c4;
  --peach: #ffcb7a; --peach-d: #ee8f2f; --peach-dd: #c26f14;
  --panel: rgba(255, 255, 255, 0.84);
  --shadow: 0 6px 0 rgba(120, 92, 190, 0.2), 0 14px 28px rgba(90, 60, 160, 0.18);
  --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: #bfe9ff; touch-action: none; user-select: none; -webkit-user-select: none; }
body { font-family: 'Fredoka', 'Arial Rounded MT Bold', 'Trebuchet MS', sans-serif; color: var(--ink); font-weight: 500; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#hud, .card, #title .title-wrap { zoom: var(--ui, 1); }
.hidden { display: none !important; }
button { font-family: inherit; }
kbd {
  display: inline-block; min-width: 28px; padding: 3px 8px 5px; text-align: center; font: 600 13px 'Fredoka', sans-serif;
  background: #fff; color: var(--ink); border-radius: 9px; border: 2px solid #d9cffa; box-shadow: 0 3px 0 #cbbdf5;
}

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel); border: 3px solid #fff; border-radius: 22px; box-shadow: var(--shadow);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.label { font-size: 11px; letter-spacing: 0.14em; font-weight: 700; color: var(--ink-soft); }

#hud { position: absolute; inset: 0; }
.hud-left { position: absolute; left: calc(88px); top: calc(14px + var(--safe-t)); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.score-panel { padding: 8px 18px 10px; min-width: 150px; position: relative; }
.score-panel .big { font-size: 40px; line-height: 1; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; transform-origin: left center; }
.score-panel .big.pop { animation: scorePop 0.35s ease-out; }
@keyframes scorePop { 0% { transform: scale(1); } 35% { transform: scale(1.22); color: var(--pink-d); } 100% { transform: scale(1); } }
.chip { display: inline-block; margin-top: 6px; padding: 3px 11px 4px; border-radius: 99px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; color: #fff; }
.chip b { font-size: 16px; }
.chip.combo { background: linear-gradient(#ff9cc4, #ff6aa6); box-shadow: 0 3px 0 var(--pink-dd); animation: chipWob 0.6s ease-in-out infinite; }
@keyframes chipWob { 50% { transform: rotate(-3deg) scale(1.06); } }
.height-panel { padding: 6px 16px 8px; display: flex; align-items: baseline; gap: 6px; }
.height-panel .ico { width: 18px; height: 18px; color: var(--mint-d); align-self: center; }
.height-panel .num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.height-panel .unit { font-size: 16px; color: var(--ink-soft); font-weight: 600; }
.zen-panel { padding: 8px 16px; font-size: 16px; }
.zen-panel b { color: var(--lav-d); margin-right: 8px; letter-spacing: 0.1em; }

.lives { display: flex; gap: 6px; padding-left: 4px; }
.lives svg { width: 34px; height: 34px; filter: drop-shadow(0 3px 0 rgba(120, 92, 190, 0.25)); transition: transform 0.2s; }
.lives svg.lost { animation: lifeLost 0.7s forwards; }
@keyframes lifeLost { 0% { transform: scale(1.2) rotate(0); } 40% { transform: scale(1.35) rotate(-14deg); } 100% { transform: scale(0.8) rotate(8deg); filter: grayscale(1) opacity(0.35); } }

.hud-right { position: absolute; right: calc(14px + env(safe-area-inset-right, 0px)); top: calc(14px + var(--safe-t)); }
.top-row { display: flex; gap: 10px; align-items: flex-start; }
.next-panel { padding: 6px 10px 8px; width: 112px; text-align: center; position: relative; }
.next-panel canvas#next0 { width: 80px; height: 80px; display: block; margin: 0 auto; }
.next-panel canvas.small { position: absolute; right: -4px; bottom: -14px; width: 40px; height: 40px; background: var(--panel); border: 3px solid #fff; border-radius: 16px; box-shadow: 0 4px 0 rgba(120, 92, 190, 0.2); opacity: 0.9; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.icon-btn {
  pointer-events: auto; width: 46px; height: 46px; padding: 9px; border-radius: 16px; border: 3px solid #fff; cursor: pointer;
  background: linear-gradient(#d4cbff, #b3a6ff); color: var(--lav-dd); box-shadow: 0 5px 0 var(--lav-d), 0 10px 18px rgba(90, 60, 160, 0.18);
  transition: transform 0.08s, box-shadow 0.08s;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--lav-d); }
.icon-btn:hover { filter: brightness(1.05); }

.stability { position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); padding: 7px 18px 9px; display: flex; align-items: center; gap: 12px; }
.stability .bar { width: 150px; height: 14px; border-radius: 99px; background: rgba(120, 92, 190, 0.16); overflow: hidden; box-shadow: inset 0 2px 3px rgba(80, 50, 140, 0.18); }
.stability .bar i { display: block; height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(#a8f5d2, #4fcf9f); transition: width 0.15s, background 0.3s; }
.stability.warn .bar i { background: linear-gradient(#ffb3a0, #ff6a63); }
.stability.warn { animation: warnShake 0.25s infinite; }
.stab-text { font-size: 14px; font-weight: 700; min-width: 58px; color: var(--mint-dd); }
.stability.warn .stab-text { color: #e04852; }
.stability.mid .bar i { background: linear-gradient(#ffe29a, #ffb24d); }
.stability.mid .stab-text { color: var(--peach-dd); }
@keyframes warnShake { 25% { transform: translateX(calc(-50% - 2px)); } 75% { transform: translateX(calc(-50% + 2px)); } }

.hint { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); max-width: 46vw; text-align: center; line-height: 1.25; padding: 7px 16px; border-radius: 99px; font-size: 14px; background: rgba(255, 255, 255, 0.7); color: var(--ink); transition: opacity 0.6s; border-radius: 20px; }
.hint.gone { opacity: 0; }
.hint kbd { padding: 1px 6px 3px; min-width: 0; font-size: 12px; }

.zen-types { position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 10px; pointer-events: auto; }
.zen-types button { position: relative; width: 74px; height: 74px; border-radius: 22px; border: 3px solid #fff; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; padding: 2px; transition: transform 0.1s; }
.zen-types button:hover { transform: translateY(-3px); }
.zen-types button.sel { border-color: var(--lav-d); background: #fff; }
.zen-types canvas { width: 100%; height: 100%; display: block; }
.zen-types span { position: absolute; top: 2px; left: 7px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }

/* ---------------------------------------------------------------- banners */
#banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; }
#banner .b {
  display: inline-block; font-weight: 700; font-size: clamp(30px, 6.6vw, 58px); letter-spacing: 0.02em; color: var(--c, #36b48a);
  -webkit-text-stroke: 11px #fff; paint-order: stroke fill; text-shadow: 0 7px 0 rgba(90, 60, 150, 0.25);
  animation: bannerIn 1.9s cubic-bezier(.2, 1.4, .4, 1) forwards; white-space: nowrap;
}
#banner .b.nice { --c: #2fb98a; }
#banner .b.perfect { --c: #ff8a1f; font-size: clamp(34px, 7.4vw, 66px); }
#banner .b.combo { --c: #ff4f9a; }
#banner .b.warn { --c: #ff5a5a; animation: bannerWarn 1.9s forwards; }
#banner .b.milestone { --c: #8f6cff; font-size: clamp(36px, 8vw, 76px); }
@keyframes bannerIn {
  0% { transform: scale(0.2) rotate(-6deg); opacity: 0; }
  14% { transform: scale(1.18) rotate(2deg); opacity: 1; }
  24% { transform: scale(0.97) rotate(-1deg); }
  34% { transform: scale(1) rotate(0); }
  80% { opacity: 1; transform: translateY(-6px); }
  100% { opacity: 0; transform: translateY(-34px) scale(0.96); }
}
@keyframes bannerWarn {
  0% { transform: scale(0.4); opacity: 0; }
  10% { transform: scale(1.1); opacity: 1; }
  20%, 40%, 60% { transform: translateX(-7px) rotate(-1.5deg); }
  30%, 50%, 70% { transform: translateX(7px) rotate(1.5deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* ---------------------------------------------------------------- screens */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.screen.modal { background: rgba(120, 100, 190, 0.28); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fadeIn 0.25s; }
@keyframes fadeIn { from { opacity: 0; } }
#title { justify-content: flex-start; background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0)); padding-left: clamp(18px, 8vw, 120px); }
.title-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 520px; }

.logo { margin: 0; font-size: clamp(76px, 13vw, 150px); line-height: 0.86; font-weight: 700; display: flex; flex-direction: column; transform: rotate(-3deg); }
.logo .row { display: flex; }
.logo .row.r2 { margin-left: 0.5em; }
.logo .row span {
  display: inline-block; color: var(--c); -webkit-text-stroke: 0.14em #fff; paint-order: stroke fill;
  text-shadow: 0 0.06em 0 rgba(255, 255, 255, 0.9), 0 0.1em 0 rgba(90, 60, 150, 0.22);
  animation: letterBob 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * -0.28s); transform-origin: 50% 90%;
}
@keyframes letterBob { 0%, 100% { transform: translateY(0) scale(1, 1); } 25% { transform: translateY(-0.07em) scale(0.96, 1.07); } 50% { transform: translateY(0) scale(1.07, 0.93); } 62% { transform: translateY(0.01em) scale(1.02, 0.98); } }
.tagline { margin: 6px 0 14px 6px; font-size: clamp(16px, 2.2vw, 22px); color: var(--ink); font-weight: 600; text-shadow: 0 2px 0 #fff, 0 0 8px #fff; }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: stretch; width: min(360px, 84vw); }
.row-btns { display: flex; gap: 12px; }
.row-btns .btn { flex: 1; padding-left: 10px; padding-right: 10px; font-size: 17px; }

.btn {
  pointer-events: auto; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; border: 3px solid #fff; border-radius: 22px;
  padding: 13px 22px 15px; font-size: 20px; font-weight: 700; letter-spacing: 0.01em; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; position: relative; white-space: nowrap;
}
.btn svg { width: 24px; height: 24px; flex: none; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.14)); }
.btn.big { font-size: 26px; padding: 18px 26px 20px; border-radius: 26px; }
.btn.big svg { width: 30px; height: 30px; }
.btn.small { font-size: 14px; padding: 7px 14px 9px; border-radius: 16px; }
.btn:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn:active { transform: translateY(4px); }
.btn.primary { background: linear-gradient(#a8f1d3, var(--mint-d)); box-shadow: 0 6px 0 var(--mint-dd), 0 14px 22px rgba(30, 140, 100, 0.25); }
.btn.primary:active { box-shadow: 0 2px 0 var(--mint-dd); }
.btn.pink { background: linear-gradient(#ffc0d9, var(--pink-d)); box-shadow: 0 6px 0 var(--pink-dd), 0 14px 22px rgba(190, 60, 110, 0.22); }
.btn.lav { background: linear-gradient(#cfc6ff, var(--lav-d)); box-shadow: 0 6px 0 var(--lav-dd), 0 14px 22px rgba(86, 70, 196, 0.24); }
.btn.peach { background: linear-gradient(#ffdca3, var(--peach-d)); box-shadow: 0 6px 0 var(--peach-dd), 0 14px 22px rgba(194, 111, 20, 0.22); }
.btn.danger { background: linear-gradient(#ffb0b0, #e65a68); box-shadow: 0 4px 0 #b53c4a; }
.btn.pink:active, .btn.lav:active, .btn.peach:active { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }

.badges { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.badge { display: grid; grid-template-columns: 26px auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 8px 16px 9px 12px; background: var(--panel); border: 3px solid #fff; border-radius: 20px; box-shadow: var(--shadow); }
.badge svg { grid-row: 1 / 3; width: 26px; height: 26px; }
.badge span { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }
.badge b { font-size: 22px; line-height: 1; }

.title-jellies { position: absolute; right: clamp(10px, 6vw, 110px); bottom: 3vh; display: flex; align-items: flex-end; gap: 0; pointer-events: none; }
.title-jellies canvas { margin: 0 -6px; }
.title-jellies canvas:nth-child(1) { width: 104px; height: 104px; }
.title-jellies canvas:nth-child(2) { width: 130px; height: 130px; }
.title-jellies canvas:nth-child(3) { width: 160px; height: 160px; }

/* cards */
.card {
  position: relative; width: min(480px, 92vw); max-height: 92vh; overflow: auto; padding: 22px 28px 26px; text-align: center;
  background: linear-gradient(#ffffff, #f5efff); border: 4px solid #fff; border-radius: 34px; box-shadow: 0 10px 0 rgba(120, 92, 190, 0.28), 0 30px 60px rgba(70, 40, 140, 0.3);
  animation: cardIn 0.4s cubic-bezier(.2, 1.5, .4, 1);
}
.card.wide { width: min(860px, 94vw); }
.card.narrow { width: min(360px, 90vw); }
@keyframes cardIn { from { transform: scale(0.7) translateY(30px); opacity: 0; } }
.card h2 { margin: 0 0 14px; font-size: 38px; color: var(--lav-d); text-shadow: 0 3px 0 #e9e2ff; }
.card h3 { margin: 6px 0 8px; font-size: 18px; color: var(--ink); text-align: left; }
.card p { text-align: left; font-size: 16px; line-height: 1.4; margin: 0 0 8px; color: #5d4a88; }
.card-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.card-actions .btn { min-width: 150px; }
.stack-btns { display: flex; flex-direction: column; gap: 12px; }

.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; text-align: left; }
.keys { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 9px; }
.keys li { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.kbd-group { min-width: 150px; display: flex; gap: 5px; flex-wrap: wrap; }
.roster { display: flex; flex-direction: column; gap: 10px; }
.roster .r { display: flex; align-items: center; gap: 12px; padding: 6px 12px 6px 6px; background: #fff; border-radius: 22px; border: 2px solid #ece6ff; }
.roster canvas { width: 76px; height: 70px; flex: none; }
.roster b { display: block; font-size: 17px; }
.roster small { font-size: 13.5px; color: var(--ink-soft); line-height: 1.25; display: block; }

.row-setting { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 4px; border-bottom: 2px dashed #e4dcff; font-size: 18px; font-weight: 600; }
.row-setting > span { display: flex; align-items: center; gap: 10px; }
.row-setting svg { width: 24px; height: 24px; color: var(--lav-d); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 180px; height: 16px; border-radius: 99px; background: linear-gradient(90deg, var(--mint) var(--p, 50%), #e4dcff var(--p, 50%)); outline: none; cursor: pointer; border: 2px solid #fff; box-shadow: inset 0 2px 3px rgba(80, 50, 140, 0.18); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--mint) 45%, var(--mint-d)); border: 3px solid #fff; box-shadow: 0 3px 0 var(--mint-dd); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--mint); border: 3px solid #fff; box-shadow: 0 3px 0 var(--mint-dd); }
.seg { display: flex; background: #e9e2ff; border-radius: 16px; padding: 3px; border: 2px solid #fff; }
.seg button { border: 0; background: transparent; border-radius: 13px; padding: 6px 14px; font-size: 15px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.seg button.on { background: linear-gradient(#cfc6ff, var(--lav-d)); color: #fff; box-shadow: 0 3px 0 var(--lav-dd); }
.switch { -webkit-appearance: none; appearance: none; width: 58px; height: 32px; border-radius: 99px; background: #ddd4fa; position: relative; cursor: pointer; border: 3px solid #fff; box-shadow: inset 0 2px 3px rgba(80, 50, 140, 0.18); transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 1px; left: 1px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 #b9aae9; transition: transform 0.2s cubic-bezier(.3, 1.6, .5, 1); }
.switch:checked { background: var(--mint); }
.switch:checked::after { transform: translateX(26px); }

.ribbon { position: absolute; top: -20px; left: 50%; transform: translateX(-50%) rotate(-3deg); padding: 6px 26px 9px; border-radius: 99px; background: linear-gradient(#ffe38a, #ffb338); color: #fff; font-size: 22px; font-weight: 700; letter-spacing: 0.06em; border: 3px solid #fff; box-shadow: 0 5px 0 var(--peach-dd); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); animation: ribbonPop 0.9s cubic-bezier(.2, 1.6, .4, 1) 0.25s backwards, chipWob 1.2s ease-in-out 1.2s infinite; }
@keyframes ribbonPop { from { transform: translateX(-50%) scale(0) rotate(-20deg); } }
.over-score { margin: 4px 0 14px; }
.over-score span { display: block; font-size: 12px; letter-spacing: 0.16em; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; }
.over-score b { font-size: 68px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.over-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.over-stats > div { background: #fff; border-radius: 20px; border: 2px solid #ece6ff; padding: 10px 6px 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.over-stats svg { width: 22px; height: 22px; color: var(--mint-d); }
.over-stats span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--ink-soft); }
.over-stats b { font-size: 24px; }
.over-best { margin-top: 14px; font-size: 15px; color: var(--ink-soft); }
.over-best b { color: var(--ink); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .hud-left { left: 78px; gap: 6px; }
  .score-panel { padding: 5px 12px 7px; min-width: 110px; }
  .score-panel .big { font-size: 28px; }
  .height-panel .num { font-size: 20px; }
  .lives svg { width: 26px; height: 26px; }
  .next-panel { width: 84px; padding: 4px 6px 6px; }
  .next-panel canvas#next0 { width: 58px; height: 58px; }
  .icon-btn { width: 40px; height: 40px; padding: 7px; }
  .stability .bar { width: 100px; }
  .how-grid { grid-template-columns: 1fr; }
  .card { padding: 18px 16px 20px; }
  .card h2 { font-size: 30px; }
  .kbd-group { min-width: 120px; }
  .hint { display: none; }
  .title-jellies { right: 50%; transform: translateX(50%); bottom: 2vh; opacity: 0.95; }
  #title { justify-content: center; padding-left: 0; align-items: flex-start; padding-top: 5vh; }
  .title-wrap { align-items: center; }
  .logo { align-items: center; }
  .menu { width: min(320px, 84vw); }
  .badges { justify-content: center; }
}
@media (max-height: 560px) and (min-width: 761px) {
  .logo { font-size: 84px; }
  .tagline { margin-bottom: 8px; }
  .btn.big { padding: 12px 22px 14px; font-size: 22px; }
  .btn { padding: 9px 18px 11px; }
  .badges { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo .row span, .chip.combo, .ribbon { animation: none; }
}

/* zen / dim states */
#hud.zen .score-panel, #hud.zen .lives, #hud.zen .stability, #hud.zen .next-panel { display: none; }
#hud.dim .stability, #hud.dim .hint { opacity: 0; }
#hud.dim { transition: opacity 0.4s; }
.ribbon { top: 10px; z-index: 2; }
.card:has(.ribbon:not(.hidden)) h2 { margin-top: 34px; }

/* modes, awards, toasts, info pill */
.info-pill { padding: 6px 16px 8px; font-size: 22px; font-weight: 700; color: var(--lav-d); font-variant-numeric: tabular-nums; }
.info-pill.urgent { color: #e04852; animation: chipWob 0.5s ease-in-out infinite; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-card { pointer-events: auto; cursor: pointer; text-align: left; border: 3px solid #fff; border-radius: 24px; padding: 14px 16px 16px; color: var(--ink); box-shadow: 0 6px 0 rgba(120, 92, 190, 0.22); transition: transform 0.1s; position: relative; overflow: hidden; }
.mode-card:hover { transform: translateY(-3px) rotate(-0.5deg); }
.mode-card:active { transform: translateY(3px); }
.mode-card h3 { margin: 0 0 4px; font-size: 22px; color: inherit; }
.mode-card p { margin: 0 0 8px; font-size: 14px; line-height: 1.3; color: rgba(60, 40, 100, 0.78); }
.mode-card .best { font-size: 13px; font-weight: 700; color: rgba(60, 40, 100, 0.6); }
.mode-card canvas { position: absolute; right: -6px; bottom: -8px; width: 74px; height: 74px; opacity: 0.95; pointer-events: none; }
.mode-card.classic { background: linear-gradient(#e6fff4, #b6f1d7); }
.mode-card.endless { background: linear-gradient(#fff2f8, #ffc7de); }
.mode-card.time { background: linear-gradient(#fff6df, #ffdca3); }
.mode-card.zen { background: linear-gradient(#f0edff, #cfc6ff); }
.award-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.award { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 20px; background: #fff; border: 2px solid #ece6ff; }
.award svg { width: 38px; height: 38px; flex: none; }
.award b { display: block; font-size: 16px; }
.award small { font-size: 13px; color: var(--ink-soft); line-height: 1.2; display: block; }
.award.locked { opacity: 0.55; filter: grayscale(0.8); }
.card h2 small { font-size: 16px; color: var(--ink-soft); font-weight: 600; margin-left: 6px; }
#toasts { position: absolute; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 5; }
.toast { display: flex; align-items: center; gap: 12px; padding: 8px 20px 10px 10px; border-radius: 99px; background: linear-gradient(#fff, #fff4d6); border: 3px solid #fff; box-shadow: 0 6px 0 var(--peach-dd), 0 14px 24px rgba(120, 70, 10, 0.25); animation: toastIn 4s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.toast svg { width: 40px; height: 40px; }
.toast small { display: block; font-size: 11px; letter-spacing: 0.12em; font-weight: 700; color: var(--peach-dd); text-transform: uppercase; }
.toast b { font-size: 18px; }
@keyframes toastIn { 0% { transform: translateY(-80px) scale(0.7); opacity: 0; } 10% { transform: translateY(0) scale(1.05); opacity: 1; } 16% { transform: scale(1); } 88% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-40px); } }
.over-mode { font-size: 12px; letter-spacing: 0.16em; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 2px; }
.zen-types { gap: 6px; max-width: 94vw; flex-wrap: nowrap; }
.zen-types button { width: 58px; height: 58px; border-radius: 18px; flex: none; }
.roster { max-height: 46vh; overflow: auto; padding-right: 4px; }
.row-btns .btn { padding-left: 8px; padding-right: 8px; font-size: 16px; gap: 6px; }
.row-btns .btn svg { width: 20px; height: 20px; }
@media (max-width: 760px) { .mode-grid, .award-grid { grid-template-columns: 1fr; } .mode-card canvas { width: 60px; height: 60px; } .zen-types button { width: 44px; height: 44px; border-radius: 14px; } .zen-types span { display: none; } }

/* collection */
.tabs { display: flex; gap: 8px; justify-content: center; margin: -4px 0 14px; flex-wrap: wrap; }
.tabs button { pointer-events: auto; cursor: pointer; border: 3px solid #fff; border-radius: 16px; padding: 7px 16px 9px; font-size: 16px; font-weight: 700; color: var(--ink-soft); background: #ece6ff; box-shadow: 0 3px 0 rgba(120, 92, 190, 0.2); }
.tabs button.on { background: linear-gradient(#cfc6ff, var(--lav-d)); color: #fff; box-shadow: 0 3px 0 var(--lav-dd); }
.tabs small { font-size: 12px; margin-left: 2px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; max-height: 50vh; overflow: auto; padding: 4px; }
.item { pointer-events: auto; cursor: pointer; background: #fff; border: 3px solid #ece6ff; border-radius: 22px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; color: var(--ink); transition: transform 0.08s; }
.item:hover { transform: translateY(-2px); }
.item canvas { width: 96px; height: 84px; }
.item .nm { font-size: 14px; }
.item .st { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 4px; }
.item.on { border-color: var(--mint-d); background: linear-gradient(#fff, #e8fff5); }
.item.on .st { color: var(--mint-dd); }
.item.locked .st { color: var(--peach-dd); }
.item.cant { animation: warnShake 0.3s; }
.coin { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3a8, #ffc933 60%, #e8941a); border: 1.5px solid #c8780a; display: inline-block; }
.coins-line { color: var(--peach-dd) !important; font-weight: 700; margin-top: 6px; }

#hud.zen .abilities { bottom: calc(88px + var(--safe-b)); }
@media (max-width: 760px) { #hud.zen .abilities { bottom: calc(76px + var(--safe-b) + 54px); } }

/* puzzle UI */
#hud.puzzle .score-panel { display: none; }
#info-pill { white-space: pre-line; line-height: 1.15; }
#hud.puzzle .info-pill { font-size: 15px; font-weight: 600; max-width: 300px; color: var(--ink); }
#hud.puzzle .info-pill::first-line { font-weight: 700; color: var(--lav-d); }
.abilities { position: absolute; left: calc(88px); bottom: calc(16px + var(--safe-b)); display: flex; gap: 8px; pointer-events: auto; }
.ab { position: relative; width: 56px; height: 56px; border-radius: 20px; border: 3px solid #fff; cursor: pointer; background: linear-gradient(#fff, #efe8ff); box-shadow: 0 5px 0 rgba(120, 92, 190, 0.3), 0 10px 18px rgba(80, 50, 150, 0.15); color: var(--lav-d); padding: 8px; transition: transform 0.08s; }
.ab svg { width: 100%; height: 100%; }
.ab:hover { transform: translateY(-2px); }
.ab:active { transform: translateY(3px); }
.ab .cnt { position: absolute; right: -6px; top: -8px; min-width: 22px; height: 22px; border-radius: 99px; background: var(--pink-d); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; padding: 0 4px; }
.ab .key { position: absolute; left: 5px; bottom: 1px; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.ab.empty { opacity: 0.4; filter: grayscale(0.7); pointer-events: none; }
.ab.armed { background: linear-gradient(#e2fff3, #9ee9c8); color: var(--mint-dd); animation: chipWob 0.7s ease-in-out infinite; }
.ab[data-id=freeze] { color: #3a8fd8; }
.ab[data-id=balance] { color: var(--mint-dd); }
.ab[data-id=sticky] { color: #8eaa14; }
.ab[data-id=gentle] { color: var(--pink-d); }
.world-list { display: flex; flex-direction: column; gap: 12px; max-height: 62vh; overflow: auto; padding: 4px; text-align: left; }
.world { border-radius: 24px; padding: 12px 16px 14px; border: 3px solid #fff; box-shadow: 0 5px 0 rgba(120, 92, 190, 0.18); }
.world h3 { margin: 0; font-size: 20px; display: flex; justify-content: space-between; gap: 10px; }
.world h3 span { font-size: 14px; color: rgba(60, 40, 100, 0.65); font-weight: 600; }
.world p { margin: 2px 0 8px; font-size: 13.5px; }
.levels { display: flex; flex-wrap: wrap; gap: 10px; }
.lvl { pointer-events: auto; cursor: pointer; width: 60px; border: 3px solid #fff; border-radius: 18px; padding: 6px 0 5px; background: #fff; color: var(--ink); font-size: 20px; font-weight: 700; box-shadow: 0 4px 0 rgba(120, 92, 190, 0.25); text-align: center; transition: transform 0.08s; }
.lvl:hover { transform: translateY(-2px); }
.lvl:active { transform: translateY(3px); }
.lvl .st { display: flex; justify-content: center; gap: 1px; height: 14px; }
.lvl .st svg { width: 14px; height: 14px; }
.lvl.locked { opacity: 0.5; filter: grayscale(0.8); cursor: default; pointer-events: none; }
.lvl.done { background: linear-gradient(#fff, #fff7dc); }
.stars { display: flex; justify-content: center; gap: 8px; margin: 2px 0 10px; }
.stars svg { width: 64px; height: 64px; animation: starIn 0.6s cubic-bezier(.2, 1.8, .4, 1) backwards; filter: drop-shadow(0 4px 0 rgba(120, 92, 190, 0.25)); }
.stars svg:nth-child(2) { animation-delay: 0.25s; margin-top: -10px; } .stars svg:nth-child(3) { animation-delay: 0.5s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.star-rules { list-style: none; padding: 0; margin: 0 0 6px; font-size: 15px; text-align: left; display: flex; flex-direction: column; gap: 5px; }
.star-rules li { display: flex; align-items: center; gap: 10px; }
.star-rules li svg { width: 22px; height: 22px; flex: none; }
.star-rules li.no { opacity: 0.5; }
.card.narrow-ish { width: min(400px, 92vw); }
.card-actions.col { flex-direction: column; }
.mode-card.puzzle { grid-column: 1 / -1; background: linear-gradient(#fff3d6, #ffd9b0, #ffc2dc); }
.mode-card.puzzle h3 { font-size: 26px; }
@media (max-width: 760px) { .abilities { left: 12px; bottom: calc(76px + var(--safe-b)); } .ab { width: 46px; height: 46px; padding: 6px; border-radius: 16px; } }

/* keyboard focus */
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 7px var(--lav-d) !important; }

/* wind gauge: bar grows left or right from the centre mark */
.wind { display: flex; align-items: center; gap: 10px; padding: 6px 14px 7px; margin-top: 6px; }
.wind .wl { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: var(--lav-d); }
.wind .wtrack { position: relative; width: 132px; height: 12px; border-radius: 8px; background: rgba(120, 100, 200, 0.18); box-shadow: inset 0 1px 3px rgba(60, 35, 100, 0.25); overflow: hidden; }
.wind .wtrack::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(60, 35, 100, 0.35); }
.wind #wbar { position: absolute; top: 1px; bottom: 1px; left: 50%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #7fd8ff, #b9a1ff); transition: left 0.12s linear, width 0.12s linear; }

/* very short embeds (e.g. a small itch.io frame): shrink the menu and HUD so nothing is cut off */
@media (max-height: 520px) {
  #title .title-wrap { zoom: calc(var(--ui, 1) * 0.62); }
  #title { padding-top: 2vh; }
  #hud { zoom: calc(var(--ui, 1) * 0.8); }
  .card { zoom: calc(var(--ui, 1) * 0.78); max-height: 125vh; overflow-y: auto; }
}
.credits { margin: 12px 0 0; font-size: 12px; text-align: center; color: var(--ink-soft); opacity: 0.8; }
