/* Jumping Notes — identidade Pianisy: 2D Soft Flat Cartoon */
/* Fonte musical (SMuFL) para as figuras rítmicas. Leland © MuseScore, SIL Open Font License 1.1. */
@font-face { font-family: 'Leland'; src: url('../assets/fonts/Leland.otf') format('opentype'); font-display: block; }

:root {
  --purple: #8b5cf6;
  --purple-d: #6d3fe0;
  --purple-dd: #3b2470;
  --ink: #2e1a47;
  --yellow: #facc15;
  --yellow-d: #d9a90a;
  --pink: #f9a8b8;
  --grass: #5ec27a;
  --danger: #ef5b6b;
  --gold: #ffc533;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", system-ui, sans-serif;
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; overflow: hidden; background: #bfe6ff; color: var(--ink);
  font-family: var(--font); user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; overscroll-behavior: none; touch-action: manipulation;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { display: block; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }
.sky { background: linear-gradient(#b6e3ff 0%, #d6f0ff 60%, #effaff 100%); }   /* azul claro: a Nisy roxa se destaca */

/* ---------- Botões ---------- */
.btn {
  --shadow: rgba(0,0,0,.15);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .5em 1.5em; border-radius: 999px;
  font-weight: 900; font-size: clamp(15px, 3.6vh, 22px); letter-spacing: .03em;
  box-shadow: 0 5px 0 var(--shadow), 0 10px 22px rgba(59,36,112,.18);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow), 0 4px 10px rgba(59,36,112,.18); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--yellow); color: var(--purple-dd); --shadow: var(--yellow-d); }
.btn-secondary { background: #fff; color: var(--purple-d); --shadow: #d6c8ff; }
.btn-danger { background: #fff0f2; color: #c43547; --shadow: #f6c7cf; }
.btn-xl { font-size: clamp(20px, 6vh, 34px); padding: .45em 2.2em; min-height: 56px; }
.btn-small { font-size: 14px; min-height: 40px; padding: .4em 1.1em; }

.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  background: rgba(255,255,255,.92); color: var(--purple-d);
  display: grid; place-items: center; box-shadow: 0 4px 0 #d6c8ff, 0 8px 16px rgba(59,36,112,.12);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d6c8ff; }
.icon-btn svg { width: 24px; height: 24px; }
.corner-tr { position: absolute; top: calc(14px + var(--st)); right: calc(16px + var(--sr)); }

/* ---------- Nuvens decorativas ---------- */
.clouds { position: absolute; inset: 0; pointer-events: none; }
.cloud {
  position: absolute; width: 140px; height: 44px; border-radius: 50px; background: rgba(255,255,255,.9);
  animation: drift 60s linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 64px; height: 64px; top: -32px; left: 22px; }
.cloud::after { width: 48px; height: 48px; top: -22px; left: 72px; }
.c1 { top: 18%; left: 6%; }
.c2 { top: 9%; left: 58%; transform: scale(.7); animation-duration: 80s; }
.c3 { top: 30%; left: 80%; transform: scale(.85); animation-duration: 70s; }
@keyframes drift { from { translate: 0 0; } 50% { translate: -40px 0; } to { translate: 0 0; } }

/* ---------- Tela inicial ---------- */
/* Capa da tela inicial: a arte do aparelho, inteira na tela (cover = preenche sem distorcer; as artes já têm a
   proporção de cada aparelho, então o corte é mínimo). O <html data-device> é definido antes do primeiro quadro. */
#screen-home { background: #8fd3ff; }
.home-cover { position: absolute; inset: 0; background: center / cover no-repeat; }
/* Áreas de toque sobre os botões desenhados na capa (posição calculada em js/main.js, com a mesma escala da capa). */
#screen-home .home-actions { position: absolute; inset: 0; display: block; pointer-events: none; }
.cover-hit {
  position: absolute; pointer-events: auto; border: 0; padding: 0; background: transparent; cursor: pointer;
  border-radius: 999px; -webkit-tap-highlight-color: transparent; transition: transform .14s, background .14s;
}
.cover-hit:active { transform: scale(.96); background: rgba(255,255,255,.22); }
.cover-hit:focus-visible { outline: 4px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 7px rgba(91,33,182,.6); }
html[data-device="iphone"] .home-cover { background-image: url(../assets/capa/capa-iphone.png); }
html[data-device="ipad"] .home-cover { background-image: url(../assets/capa/capa-ipad-reino.png); }
/* Plataforma v6 (1024×1024, desenho na faixa central): recorta só a faixa com conteúdo. */
.plat-crop { aspect-ratio: 976 / 432; object-fit: cover; object-position: 50% 50%; }
.img-btn { padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; border-radius: 999px; }
.img-btn img { height: clamp(46px, 13vh, 84px); width: auto; display: block; filter: drop-shadow(0 6px 10px rgba(59,36,112,.25)); }
.img-btn-xl img { height: clamp(56px, 17vh, 110px); }
.img-btn:active img { transform: translateY(3px) scale(.98); }
.img-btn:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
.img-btn-round img { height: 52px; }
.img-btn:disabled { opacity: .35; pointer-events: none; }
.lock-img { position: absolute; top: 3%; width: 9vh; min-width: 44px; height: auto; filter: drop-shadow(0 4px 6px rgba(59,36,112,.35)); }
.home-actions {
  position: absolute; left: 0; right: 0; bottom: calc(4vh + var(--sb));
  display: flex; justify-content: center; align-items: center; gap: 18px;
}
@keyframes float { 50% { translate: var(--tx, 0) -6px; } }
@keyframes hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 40% { transform: translateY(-10%) scale(.97, 1.03); } 55% { transform: translateY(0) scale(1.04, .96); } }

/* Entrada ao abrir o app: o logotipo surge (95% → 100%, 600 ms) e fica parado; depois os botões aparecem. */
@keyframes coverIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.preintro .home-cover, .preintro .home-actions { opacity: 0; }
.intro .home-cover { animation: coverIn .6s ease-out both; }
.intro .home-actions { animation: fadeUp .45s ease-out .5s both; }

@media (prefers-reduced-motion: reduce) {
  .intro .home-cover, .intro .home-actions { animation: none; }
}

/* ---------- Mapa ---------- */
.bar {
  position: absolute; top: calc(12px + var(--st)); left: calc(16px + var(--sl)); right: calc(16px + var(--sr));
  display: flex; align-items: center; justify-content: space-between; z-index: 2;
}
.bar h2 {
  font-size: clamp(20px, 6vh, 34px); font-weight: 900; color: var(--purple-d);
  text-shadow: 0 2px 0 rgba(255,255,255,.8);
}
.map-track {
  position: absolute; left: calc(5vw + var(--sl)); right: calc(5vw + var(--sr)); top: 16vh; bottom: 18vh;
  display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; gap: 2vw;
}
.map-track::before {
  content: ""; position: absolute; left: 14%; right: 14%; top: 50%; border-top: 5px dashed rgba(255,255,255,.85);
}
.map-track.two { grid-template-columns: repeat(2, 1fr); }
.map-track.one { grid-template-columns: 1fr; justify-items: center; }
.map-track.one::before { display: none; }
.stage {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .3vh;
  transition: transform .15s; z-index: 1;
}
.stage:nth-child(2) { translate: 0 -7vh; }
.stage:nth-child(3) { translate: 0 4vh; }
.stage:active { transform: scale(.95); }
.stage-island { width: min(42vh, 24vw); filter: drop-shadow(0 10px 12px rgba(59,36,112,.2)); animation: float 5s ease-in-out infinite; }
.stage:nth-child(2) .stage-island { animation-delay: -1.5s; }
.stage:nth-child(3) .stage-island { animation-delay: -3s; }
.stage-num {
  position: absolute; top: 3%; width: 7vh; height: 7vh; min-width: 38px; min-height: 38px;
  border-radius: 50%; display: grid; place-items: center; background: var(--purple); color: #fff;
  font-weight: 900; font-size: clamp(18px, 4.6vh, 30px); box-shadow: 0 4px 0 var(--purple-d); border: 3px solid #fff;
}
.stage-name {
  font-weight: 900; font-size: clamp(13px, 3.4vh, 20px); background: rgba(255,255,255,.95);
  padding: .2em .9em; border-radius: 999px; color: var(--purple-dd); box-shadow: 0 3px 0 #d6c8ff;
}
.stage-carrots { display: flex; gap: 2px; }
.stage-carrots img, .stage-carrots svg { width: clamp(20px, 5vh, 30px); height: clamp(20px, 5vh, 30px); }
.stage.locked .stage-num, .stage.soon .stage-num { display: none; }
.stage .lock {
  position: absolute; top: 3%; width: 8vh; height: 8vh; min-width: 40px; min-height: 40px; border: 3px solid #fff;
  border-radius: 50%; background: rgba(59,36,112,.82); color: #fff; display: grid; place-items: center;
}
.stage .lock svg { width: 50%; height: 50%; }
.stage.locked .stage-island, .stage.soon .stage-island { filter: grayscale(.7) brightness(1.05) drop-shadow(0 10px 12px rgba(59,36,112,.15)); }
.stage.locked .stage-num, .stage.soon .stage-num { background: #a99bc9; box-shadow: 0 4px 0 #8577a8; }
.stage.current .stage-num { animation: pulse 1.4s ease-in-out infinite; }
.stage.castle .stage-island { width: min(52vh, 30vw); }
@keyframes pulse { 50% { box-shadow: 0 4px 0 var(--purple-d), 0 0 0 8px rgba(250,204,21,.6); } }

.map-nav {
  position: absolute; left: 0; right: 0; bottom: calc(3vh + var(--sb));
  display: flex; align-items: center; justify-content: center; gap: 22px;
}
.map-nav .icon-btn:disabled { opacity: .35; }
.map-dots { display: flex; gap: 10px; }
.map-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.6); }
.map-dots i.on { background: var(--purple); width: 30px; border-radius: 6px; }

/* Cenouras */
.carrot { --body: #ff8a1f; --leaf: #4caf50; }
.carrot.gold { filter: drop-shadow(0 0 6px rgba(255,197,51,.7)); }
.carrot.empty { filter: grayscale(1) opacity(.3); }
img.carrot { object-fit: contain; }

/* ---------- Jogo ---------- */
#screen-game.active { display: flex; flex-direction: column; }
.game-wrap { position: relative; flex: 1; min-height: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud {
  position: absolute; top: calc(10px + var(--st)); left: calc(14px + var(--sl)); right: calc(14px + var(--sr));
  display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-title { display: flex; flex-direction: column; align-items: center; color: var(--purple-dd); text-align: center; }
.hud-title span { font-size: 12px; font-weight: 800; opacity: .7; letter-spacing: .08em; text-transform: uppercase; }
.hud-title b { font-size: clamp(15px, 4vh, 22px); font-weight: 900; }
/* Laterais em tamanho fixo; o título usa o espaço que sobra e, se não couber, termina em "…" numa linha só. */
.hud-left, .hud-right { flex: none; }
.hud-title { flex: 1 1 auto; min-width: 0; }
.hud-title b { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.hud-right .chip { white-space: nowrap; }
.chip {
  font-size: 13px; font-weight: 800; padding: .35em .8em; border-radius: 999px;
  background: rgba(255,255,255,.9); color: var(--purple-d);
}
/* Cesto das telas de resultado/derrota: cesto de vime com 0–3 cenouras */
.basket-show { position: relative; width: clamp(110px, 26vh, 170px); height: clamp(80px, 19vh, 124px); margin: 0 auto 6px; }
.basket-show .b-carrot { position: absolute; bottom: 38%; width: 30%; height: auto; transform-origin: bottom center; }
.basket-show svg { position: absolute; inset: auto 0 0 0; width: 100%; height: 62%; }
.basket-show .b-back { z-index: 0; } .basket-show .b-carrot { z-index: 1; } .basket-show .b-front { z-index: 2; }

/* Vidas: três corações, separados das cenouras */
.hearts { display: inline-flex; gap: 3px; padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.94); box-shadow: 0 3px 0 rgba(59,36,112,.25); }
.hearts svg { width: 28px; height: 26px; transition: transform .2s; }
.hearts svg.empty { --heart-fill: #f3eefc; --heart-line: #b9a8e6; --heart-shine: transparent; }
.hearts svg.breaking { animation: heartbreak .6s ease-out; }
@keyframes heartbreak { 0% { transform: scale(1); } 25% { transform: scale(1.35) rotate(-8deg); } 50% { transform: scale(.85) rotate(8deg); } 100% { transform: scale(1); } }

/* Contador de desempenho: 🥕 Cenouras: N */
.hud-left { display: flex; align-items: center; gap: 10px; }
.score {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,.94); color: var(--purple-dd); font-weight: 900; font-size: clamp(14px, 3.6vh, 20px);
  box-shadow: 0 3px 0 rgba(59,36,112,.25);
}
.score img, .score svg { width: 30px; height: 30px; }
.score b { min-width: 1.4em; text-align: center; font-size: 1.15em; }
.score.pulse { animation: scorepulse .35s ease-out; }
@keyframes scorepulse { 40% { transform: scale(1.18); box-shadow: 0 0 0 6px rgba(255,210,63,.6); } }
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.fly-carrot { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; will-change: transform; filter: drop-shadow(0 0 6px rgba(255,210,63,.9)); }
.fly-carrot img { width: 100%; height: 100%; object-fit: contain; }
.skip { position: absolute; right: calc(14px + var(--sr)); top: calc(64px + var(--st)); z-index: 5; min-height: 40px; font-size: 15px; padding: .3em 1.1em; }
.hud-title { transition: opacity .3s; }
.game-wrap.finale .hud-title { opacity: 0; }
.hud-title { color: var(--purple-dd) !important; text-shadow: 0 1px 0 rgba(255,255,255,.7); }
.chip-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border: 2px solid transparent; min-height: 34px; }
.chip-btn .music { font-family: 'Leland'; font-size: 22px; line-height: 0; position: relative; top: 4px; }
.chip-btn[aria-pressed="true"] { background: var(--yellow); color: var(--purple-dd); border-color: var(--yellow-d); }
.speed-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,.9); box-shadow: 0 3px 0 rgba(59,36,112,.18); }
.speed-seg button { display: inline-flex; align-items: center; gap: 3px; min-height: 36px; padding: 0 .65em; border-radius: 999px; font-size: 13px; font-weight: 800; color: #6b5a8a; cursor: pointer; }
.speed-seg .ic { width: 16px; height: 16px; }
.speed-seg button[aria-pressed="true"] .ic { --accent: #ffd23f; color: #fff; }
.speed-seg button[aria-pressed="true"] { background: var(--purple-d); color: #fff; box-shadow: 0 2px 0 var(--purple-dd); }
/* Telas estreitas (celular deitado): some o selo do modo e os ícones, para caber o seletor. */
/* Ícones SVG próprios dentro de textos e botões */
.ic { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; color: var(--purple-d); }
.ic-xl { width: 54px; height: 54px; }
.chip-ic { display: inline-flex; align-items: center; gap: 5px; }
.btn .ic { color: currentColor; }
.segmented .ic { width: 20px; height: 20px; vertical-align: -0.28em; }
.skip { display: inline-flex; align-items: center; gap: 6px; }
.result-carrots .result-note .ic { width: 1.3em; height: 1.3em; vertical-align: -0.3em; animation: none; }
.toast .ic { width: 1.2em; height: 1.2em; vertical-align: -0.25em; margin-right: 4px; color: #fff; --accent: #ffd23f; }
.carrots { display: flex; gap: 2px; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,.9); }
.carrots svg { width: 34px; height: 34px; transition: transform .3s, opacity .3s, filter .3s; }
.carrots svg.lost { opacity: .3; filter: grayscale(1); transform: scale(.8) rotate(-20deg); }
.carrots svg.losing { animation: lose .6s ease; }
@keyframes lose { 30% { transform: scale(1.4) rotate(15deg); } 60% { transform: scale(.7) rotate(-20deg); } }

.feedback {
  position: absolute; translate: -50% -100%; pointer-events: none; opacity: 0; white-space: nowrap;
  font-size: clamp(18px, 5.6vh, 34px); font-weight: 900; letter-spacing: .03em; color: #fff;
  paint-order: stroke; -webkit-text-stroke: 6px var(--purple-dd);
}
.feedback.show { animation: pop .9s ease-out forwards; }
.feedback.perfect { color: var(--yellow); }
.feedback.early { color: #7fd0ff; }
.feedback.late { color: #ffb36b; }
.feedback.miss { color: #ff8b98; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.5); }
  20% { opacity: 1; transform: scale(1.15); }
  35% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-24px); }
}

.countin {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: clamp(60px, 26vh, 180px); font-weight: 900; color: #fff;
  paint-order: stroke; -webkit-text-stroke: 10px var(--purple); opacity: 0;
}
.countin.show { animation: count .6s ease-out; }
@keyframes count { 0% { opacity: 0; transform: scale(1.6); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.9); } }

.bubble {
  position: absolute; left: 50%; top: calc(66px + var(--st)); translate: -50% 0; max-width: 80%;
  padding: .45em 1.1em; border-radius: 18px; background: #fff; color: var(--purple-dd);
  font-weight: 900; font-size: clamp(14px, 4vh, 22px); box-shadow: 0 4px 0 #d6c8ff;
  opacity: 0; transition: opacity .2s, transform .2s; transform: translateY(-6px); pointer-events: none; text-align: center;
}
.bubble.show { opacity: 1; transform: translateY(0); }

/* ---------- Teclado ---------- */
.keyboard {
  position: relative; flex: none; height: clamp(110px, 38vh, 300px);
  padding: 8px calc(12px + var(--sr)) calc(10px + var(--sb)) calc(12px + var(--sl));
  background: linear-gradient(#7a4ff0, #5b34c9); border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 18px rgba(59,36,112,.25); touch-action: none;
}
body[data-input="midi"] .keyboard { height: clamp(70px, 22vh, 170px); }
.kb-inner {
  --black-w: calc(100% / var(--whites) * .58);
  position: relative; height: 100%; margin: 0 auto; display: flex;
  max-width: calc(var(--whites) * 190px);
}
.key { position: relative; touch-action: none; }
.key.white {
  flex: 1; margin: 0 3px; border-radius: 6px 6px 18px 18px;
  background: linear-gradient(#fff, #f6f2ff); box-shadow: inset 0 -9px 0 #ddd3f5, 0 3px 0 rgba(0,0,0,.12);
  transition: transform .05s, background .1s;
}
.key.black {
  position: absolute; top: 0; z-index: 2; width: var(--black-w); height: 58%;
  border-radius: 4px 4px 12px 12px; background: linear-gradient(#4b3474, #2e1a47);
  box-shadow: inset 0 -7px 0 #1b0f2e, 0 3px 4px rgba(0,0,0,.25);
}
.key-stripe { position: absolute; left: 10%; right: 10%; top: 8px; height: 6px; border-radius: 3px; background: var(--note); opacity: .9; }
.key.black .key-stripe { top: 6px; height: 4px; }
.key-label {
  position: absolute; left: 0; right: 0; bottom: 18%; text-align: center; font-weight: 900;
  font-size: clamp(14px, 4.4vh, 28px); color: var(--ink); opacity: 0; transition: opacity .2s;
}
.key.black .key-label { color: #fff; font-size: clamp(10px, 2.6vh, 16px); bottom: 14%; }
.keyboard.names .key-label { opacity: 1; }
.key.white.down { background: linear-gradient(#efe8ff, #e5dcff); box-shadow: inset 0 -3px 0 #ddd3f5; transform: translateY(3px); }
.key.black.down { background: #5a3f8a; box-shadow: inset 0 -2px 0 #1b0f2e; }
.key.white.good { background: #d6f5df; }
.key.white.wrong, .key.black.wrong { background: #ffd5da; animation: keyshake .3s; }
.key.hint { animation: hint 1s ease-in-out infinite; z-index: 3; }
.key.white.hint { background: linear-gradient(#fff9d9, #fff1a8); }
@keyframes hint { 50% { box-shadow: 0 0 0 4px var(--yellow), 0 0 26px 8px rgba(250,204,21,.85); } }
@keyframes keyshake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

/* ---------- Modais ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center;
  padding: max(12px, var(--st)) max(16px, var(--sr)) max(12px, var(--sb)) max(16px, var(--sl));
  background: rgba(46,26,71,.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal.open { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card {
  position: relative; width: min(560px, 100%); max-height: 100%; overflow: auto;
  background: #fff; border-radius: 28px; padding: 22px 26px; box-shadow: 0 8px 0 #d6c8ff, 0 20px 50px rgba(46,26,71,.3);
  animation: rise .25s ease-out;
}
.card-wide { width: min(820px, 100%); }
.card-center { text-align: center; }
@keyframes rise { from { transform: translateY(16px) scale(.97); } }
.card h2 { font-size: clamp(20px, 5.6vh, 30px); font-weight: 900; color: var(--purple-d); text-align: center; margin: 0 40px 14px; }
.card p { color: #5c4a7a; font-weight: 700; margin-bottom: 14px; }
.card-close { position: absolute; top: 14px; left: 14px; width: 40px; height: 40px; box-shadow: 0 3px 0 #e6ddff; background: #f4efff; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: stretch; max-width: 320px; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* Escolha de modo e velocidade: dois grupos de botões-ícone (estilo de ícone de app, Pianisy). */
.ctl-groups { display: flex; justify-content: center; align-items: flex-start; gap: clamp(16px, 4vw, 40px); flex-wrap: wrap; }
.ctl-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ctl-group h3 { font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #6b5a8a; }
.ctl-row { display: flex; gap: clamp(8px, 1.6vw, 14px); }
.ctl-hint { min-height: 1.3em; font-size: 13px; font-weight: 700; color: #5c4a7a; text-align: center; max-width: 34ch; }
.ctl-tile {
  --tile: clamp(78px, 15vh, 122px);
  width: var(--tile); height: calc(var(--tile) * 1.04); padding: 7% 6% 6%; border-radius: 26%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; cursor: pointer;
  background: linear-gradient(#f5f0ff, #e2d7fd); box-shadow: 0 5px 0 #cdbcf8, 0 8px 16px rgba(59,36,112,.12), inset 0 2px 0 #fff;
  border: 3px solid transparent; transition: transform .16s cubic-bezier(.3,1.6,.5,1), background .2s, box-shadow .2s;
}
.ctl-tile .tile-art { width: 108%; height: calc(var(--tile) * .66); flex: none; margin: -4% -4% 0; }
.ctl-tile .tile-label {
  width: 100%; padding: .22em 0; border-radius: 999px; background: linear-gradient(#fffdf8, #f6f0ff);
  box-shadow: inset 0 -2px 0 rgba(108,79,200,.16); font-weight: 900; color: var(--purple-dd);
  font-size: calc(var(--tile) * .17); line-height: 1.15;
}
/* Pressionado: encolhe um pouco e volta com mola suave. */
.ctl-tile:active { transform: scale(.93); }
.ctl-tile:focus-visible { outline: 4px solid var(--purple); outline-offset: 3px; }
/* Selecionado: Treino e velocidades em roxo; Aventura em amarelo. */
.ctl-tile[aria-checked="true"] { background: linear-gradient(#9a6bff, #6a35e0); box-shadow: 0 5px 0 #4c22a8, 0 10px 18px rgba(76,34,168,.3), inset 0 2px 0 rgba(255,255,255,.35); border-color: #fff; }
.tile-speed[aria-checked="true"] {
  background: linear-gradient(#fbf8ff, #ece4ff); border-color: var(--purple-d);
  box-shadow: 0 5px 0 #4c22a8, 0 0 0 4px rgba(139,92,246,.25), 0 10px 18px rgba(76,34,168,.25), inset 0 2px 0 #fff;
}
.tile-speed[aria-checked="true"] .tile-label { background: linear-gradient(#8b5cf6, #6a35e0); color: #fff; box-shadow: none; }
.tile-adventure[aria-checked="true"] { background: linear-gradient(#ffe25a, #ffc21a); box-shadow: 0 5px 0 #e2a400, 0 10px 18px rgba(226,164,0,.3), inset 0 2px 0 rgba(255,255,255,.5); }
.ctl-start { margin-top: 16px; min-width: 220px; }
/* Menu de pausa: opções da partida (velocidade, Figuras, régua) à esquerda e as ações à direita. */
.pause-card { width: min(720px, 100%); }
.pause-song { margin: -4px 0 14px; color: #5c4a7a; font-weight: 700; font-size: 15px; }
.pause-song b { color: var(--purple-dd); }
.pause-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: 22px; align-items: center; text-align: left; }
.pause-opts { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pause-chips, .pause-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.pause-chips .chip { background: #f1ecff; }
.pause-row { display: flex; flex-direction: column; gap: 6px; }
.pause-label { font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #6b5a8a; }
.pause-card .speed-seg { background: #f1ecff; box-shadow: none; align-self: flex-start; }
.pause-card .speed-seg button { min-height: 44px; padding: 0 .9em; font-size: 15px; }
.pause-card .chip-btn { min-height: 44px; padding: .35em 1em; font-size: 15px; background: #f1ecff; }
.pause-card .chip-btn[aria-pressed="true"] { background: var(--yellow); }
.pause-card .stack { max-width: none; margin: 0; }
@media (max-width: 560px) { .pause-grid { grid-template-columns: 1fr; } }
@media (max-height: 500px) { .pause-song { margin-bottom: 8px; font-size: 13px; } .pause-opts { gap: 8px; } .pause-card .stack { gap: 8px; } }
#modal-mode .card { text-align: center; width: min(820px, 100%); }
.ctl-groups { flex-wrap: nowrap; }
.ic-gauge { width: 1.35em; height: 1em; }
#hud-mode .ic { width: 1.45em; height: 1.05em; }
@media (max-height: 500px) {
  .ctl-tile { --tile: clamp(64px, 21vh, 86px); }
  .ctl-group h3 { font-size: 11px; } .ctl-hint { font-size: 11px; min-height: 1.2em; max-width: 26ch; } .ctl-start { margin-top: 8px; }
  #modal-mode .card h2 { margin-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) { .ctl-tile { transition: none; } .ctl-tile:active { transform: none; } }

.howto { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: center; margin-bottom: 16px; }
.video-box { position: relative; aspect-ratio: 16/9; border-radius: 18px; overflow: hidden; background: #efe8ff; }
.video-box video { width: 100%; height: 100%; display: block; background: #000; }
.video-missing { display: none; position: absolute; inset: 0; place-items: center; text-align: center; font-weight: 800; color: var(--purple-d); font-size: 15px; line-height: 1.4; }
.video-box.missing video { display: none; }
.video-box.missing .video-missing { display: grid; }
.howto-steps { padding-left: 1.2em; display: grid; gap: 8px; font-weight: 700; color: #4b3a66; font-size: 15px; }
.howto-steps b { color: var(--purple-d); }
#btn-tutorial { display: flex; margin: 0 auto; }
#btn-tutorial.glow { animation: pulse 1.2s infinite; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 2px solid #f1ecff; font-weight: 800; }
.setting:first-of-type { border-top: 0; }
.setting-col { flex-direction: column; align-items: stretch; }
.switch { width: 62px; height: 36px; border-radius: 999px; background: #d9d1ea; position: relative; transition: background .2s; flex: none; }
.switch i { position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--purple); }
.switch[aria-checked="true"] i { left: 30px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 16px; background: #f1ecff; }
.segmented.three { grid-template-columns: 1fr 1fr 1fr; }
.segmented button { min-height: 44px; border-radius: 12px; font-weight: 800; color: #6b5a8a; }
.segmented button.on { background: #fff; color: var(--purple-d); box-shadow: 0 2px 0 #d6c8ff; }
.gate { display: flex; gap: 10px; justify-content: center; }
.gate input {
  width: 110px; min-height: 48px; border-radius: 14px; border: 3px solid #e6ddff; text-align: center;
  font: 900 22px var(--font); color: var(--purple-dd);
}
.gate input.bad { border-color: var(--danger); animation: keyshake .3s; }
.card .credits { font-size: 12px; font-weight: 600; color: #8a7aa6; text-align: center; margin: 6px 0 0; }
.midi-status { font-weight: 700; color: #6b5a8a; min-height: 1.2em; }

.result-nisy { height: clamp(90px, 28vh, 180px); animation: hop 1s ease-in-out infinite; }
/* Derrota: a Nisy acena ao lado do cesto vazio, incentivando a tentar de novo (sem pular). */
.fail-art { display: flex; align-items: flex-end; justify-content: center; gap: 10px; }
.fail-art .basket-show { margin: 0 0 6px; }
.fail-nisy { height: clamp(80px, 22vh, 150px); width: auto; }
/* Mapa: a Nisy acena no canto, fora dos caminhos das etapas. */
.map-nisy { position: absolute; left: calc(10px + var(--sl)); bottom: calc(6px + var(--sb)); height: clamp(90px, 24vh, 200px); width: auto; pointer-events: none; z-index: 1; filter: drop-shadow(0 6px 8px rgba(59,36,112,.18)); }
.result h2 { margin-top: 6px; }
.result-carrots .result-note { width: 100%; font-weight: 800; color: var(--purple-d); margin-bottom: 4px; }
.result-carrots { flex-wrap: wrap; display: flex; justify-content: center; gap: 10px; margin-bottom: 16px; }
.result-carrots > img, .result-carrots > svg { width: clamp(44px, 12vh, 70px); height: clamp(44px, 12vh, 70px); animation: rise .5s backwards; }
.result-carrots svg:nth-child(2) { animation-delay: .15s; }
.result-carrots svg:nth-child(3) { animation-delay: .3s; }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(18px + var(--sb)); translate: -50% 20px;
  padding: .6em 1.3em; border-radius: 999px; background: var(--purple-dd); color: #fff;
  font-weight: 900; font-size: 16px; box-shadow: 0 8px 24px rgba(46,26,71,.35);
  opacity: 0; transition: opacity .25s, translate .25s; pointer-events: none;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Somente horizontal ---------- */
.rotate {
  position: fixed; inset: 0; z-index: 50; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: linear-gradient(#8b5cf6, #6d3fe0); color: #fff; font-weight: 900; font-size: 22px; text-align: center;
}
.rotate-phone { width: 84px; height: 84px; color: #fff; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 40%, 60% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 1024px) { .rotate { display: flex; } }

@media (max-height: 420px) {
  .card { padding: 14px 18px; border-radius: 22px; }
  .card h2 { margin-bottom: 8px; }
  .howto-steps { font-size: 13px; gap: 4px; }
  .setting { padding: 8px 0; }
  .result { width: min(680px, 100%); }
  .result-nisy { height: 17vh; }
  .result h2 { font-size: 20px; margin: 2px 30px 4px; }
  .result p { font-size: 13px; margin-bottom: 6px; }
  .result-carrots { margin-bottom: 10px; }
  .result-carrots > img, .result-carrots > svg { width: 40px; height: 40px; }
  .row { flex-wrap: nowrap; gap: 8px; }
  .row .btn { font-size: 13px; min-height: 44px; padding: .4em 1em; }
}

/* Controles da nova capa de iPad, que não contém botões na imagem. */
.cover-hit span { display: none; }
html[data-device="ipad"] #screen-home .home-actions { inset: auto 0 max(5vh, env(safe-area-inset-bottom)) 0; display: flex; gap: clamp(12px, 2vw, 24px); justify-content: center; }
html[data-device="ipad"] .cover-hit { position: relative; width: clamp(140px, 23vw, 250px); height: clamp(52px, 8vh, 76px); border: 3px solid #c5a3ff; background: linear-gradient(#a76aff, #6533dc); color: #ffe947; box-shadow: inset 0 3px 0 #ffffff66, 0 5px 0 #48219a, 0 8px 16px #24134d55; font: 900 clamp(19px, 2.7vw, 30px)/1 system-ui, sans-serif; text-shadow: 0 2px 1px #4d2599; }
html[data-device="ipad"] .cover-hit span { display: inline; }
html[data-device="ipad"] #btn-howto { background: linear-gradient(#fff173, #ffc526); border-color: #fff3a4; color: #6130bc; text-shadow: none; box-shadow: inset 0 3px 0 #ffffff88, 0 5px 0 #c7881b, 0 8px 16px #24134d55; }

/* Configurações do iPad: aproveitar a largura em vez de empilhar controles. */
@media (min-width: 700px) {
  #modal-settings .card { width: min(1080px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; padding: 18px 24px; }
  #modal-settings h2,
  #modal-settings .credits { grid-column: 1 / -1; }
  #modal-settings h2 { margin-bottom: 8px; }
  #modal-settings .setting { min-width: 0; padding: 10px 0; gap: 10px; font-size: 15px; }
  #modal-settings .setting-col { gap: 6px; }
  #modal-settings .segmented button { padding: 6px; }
  #modal-settings .midi-status { font-size: 12px; line-height: 1.3; }
  #modal-settings .midi-status:empty { display: none; }
  #modal-settings .switch { min-height: 44px; }
  #modal-settings .switch i { top: 8px; }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  #btn-play:hover, #btn-howto:hover, .ctl-start:hover { filter: brightness(1.08); }
}
