/* Menu de jogo: tela de título, menu principal, personagens e fases.
   Todas as medidas usam cqh/cqw (relativas ao quadro do jogo), então tudo escala junto. */

.masthead, .mission, .side-panel { display: none !important; }
html, body { height: 100%; overflow: hidden; background: #03070a; overscroll-behavior: none; }
.game-shell, .game-panel { width: 100%; height: 100dvh; margin: 0; padding: 0; }

.game-frame.expanded {
  position: fixed; inset: 0; z-index: 10; border: 0; border-radius: 0; overflow: auto;
  background: radial-gradient(ellipse at center, #0b1512 0%, #020504 80%);
  box-shadow: none;
}
.game-frame.expanded .screen { container-type: size; border-radius: 0; }
.game-frame.expanded[data-mode='menu'] .screen { width: min(100vw, calc(100dvh * 16 / 9)); }
.game-frame.expanded[data-mode='menu'] .game-toolbar { display: none; }
.game-frame.expanded[data-mode='editor'] .screen { width: min(100%, calc((100dvh - 260px) * 16 / 9)); }

.cover { container-type: size; display: block; overflow: hidden; background: #03070a; }
.cover::before { display: none; }
.cover[hidden], .menu-screen[hidden] { display: none !important; }

/* ---------- Cenário ---------- */
.stage-bg {
  position: absolute; inset: -4%;
  background: var(--stage, none) 58% center / cover no-repeat;
  animation: stage-drift 32s ease-in-out infinite alternate;
}
@keyframes stage-drift {
  from { transform: scale(1.04) translateX(-1.2%); }
  to { transform: scale(1.13) translateX(1.2%); }
}
.stage-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 42%, transparent 28%, #02060bd0 100%),
    linear-gradient(0deg, #02060bf2 0%, #02060b66 30%, transparent 56%),
    linear-gradient(180deg, #02060b99, transparent 26%);
  transition: background .5s;
}
.stage-shade::after {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .6s;
  background: linear-gradient(90deg, #02060bf5 0%, #02060bd0 32%, #02060b55 54%, transparent 72%);
}
.cover[data-screen='main'] .stage-shade::after { opacity: 1; }
.cover:is([data-screen='characters'], [data-screen='levels']) .stage-shade { background: #02060be0; backdrop-filter: blur(5px); }
.stage-fx { mix-blend-mode: screen; pointer-events: none; }
.stage-fog {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30cqh; pointer-events: none;
  background: linear-gradient(0deg, #0a1a16aa, transparent); animation: fog 9s ease-in-out infinite alternate;
}
@keyframes fog { from { opacity: .55; } to { opacity: 1; } }

.stage-hero {
  position: absolute; bottom: 2cqh; height: 66cqh; width: auto; max-width: 42cqw;
  object-fit: contain; object-position: bottom; pointer-events: none; user-select: none;
  filter: drop-shadow(0 2cqh 2.5cqh #000b) drop-shadow(0 0 4cqh #f5d78030);
  animation: hero-idle 4.2s ease-in-out infinite;
  transition: left .7s cubic-bezier(.2, .8, .2, 1), right .7s cubic-bezier(.2, .8, .2, 1), height .7s, opacity .5s;
}
@keyframes hero-idle { 50% { translate: 0 -1.3cqh; } }
.hero-main { left: 4cqw; }
.hero-companion { right: 4cqw; transform: scaleX(-1); animation-delay: -2.1s; }
.cover[data-screen='main'] .hero-main { left: 56cqw; height: 82cqh; }
.cover[data-screen='main'] .hero-companion { opacity: 0; right: -12cqw; }
.cover:is([data-screen='characters'], [data-screen='levels']) .stage-hero { opacity: 0; }

/* ---------- Estrutura das telas ---------- */
.menu-screen { position: absolute; inset: 0; z-index: 2; }
.menu-screen.enter { animation: screen-in .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(2cqh); } to { opacity: 1; transform: none; } }

.corner-buttons { position: absolute; z-index: 5; top: 3cqh; right: 2.4cqw; display: flex; gap: 1.4cqh; }
.round-button {
  display: grid; place-items: center; width: max(40px, 6.4cqh); height: max(40px, 6.4cqh);
  border: 1px solid #ffffff33; border-radius: 50%; background: #0b1512bb; color: #e8efe4;
  cursor: pointer; backdrop-filter: blur(4px); transition: border-color .15s, background .15s;
}
.round-button:hover, .round-button:focus-visible { border-color: var(--gold); background: #2a2415cc; outline: none; }
.round-button .icon { width: 52%; height: 52%; }

/* ---------- Tela de título ---------- */
.screen-title { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8cqh; }
.logo-emblem {
  display: inline-grid; place-items: center; width: 6.6cqh; height: 6.6cqh; flex: 0 0 auto;
  border: 1px solid #f5d78099; border-radius: 28%; transform: rotate(45deg);
  color: var(--gold-light); background: #0b1512aa; box-shadow: 0 0 3cqh #f1bc6966;
}
.logo-emblem .icon { width: 56%; height: 56%; transform: rotate(-45deg); }
.logo h1 { margin: 2cqh 0 0; font-family: var(--heading); text-transform: uppercase; line-height: .95; font-weight: 800; }
.logo-top {
  display: block; font-size: min(14cqh, 10cqw); letter-spacing: .05em;
  background: linear-gradient(180deg, #fff7da 0%, #ffd98a 46%, #d99a3c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 .7cqh 0 #5a3410) drop-shadow(0 0 3.4cqh #f1bc6988);
  animation: logo-glow 4s ease-in-out infinite alternate;
}
@keyframes logo-glow { from { filter: drop-shadow(0 .7cqh 0 #5a3410) drop-shadow(0 0 2cqh #f1bc6955); } to { filter: drop-shadow(0 .7cqh 0 #5a3410) drop-shadow(0 0 4.6cqh #f1bc69cc); } }
.logo-bottom {
  display: block; margin-top: 1cqh; font-size: min(7.6cqh, 6cqw); font-style: italic; letter-spacing: .32em;
  color: #ffe8b4; text-shadow: 0 0 2cqh #f1bc69aa, 0 .4cqh .8cqh #000a;
}
.logo-tag {
  display: flex; align-items: center; gap: 1.8cqw; margin: 2.6cqh 0 0; color: #ffd595;
  font-size: min(2.7cqh, 3.2cqw); font-weight: 700; letter-spacing: .36em; text-transform: uppercase;
}
.logo-tag i { width: 8cqw; height: 1px; background: linear-gradient(90deg, transparent, #ffd595b0); }
.logo-tag i:last-child { transform: scaleX(-1); }
.press-start {
  position: absolute; left: 50%; bottom: 14cqh; translate: -50% 0; border: 0; background: none; cursor: pointer;
  color: #fff4d4; font-size: min(3cqh, 4cqw); font-weight: 700; letter-spacing: .32em; text-transform: uppercase;
  text-shadow: 0 0 2cqh #f1bc69, 0 .3cqh .6cqh #000b; white-space: nowrap; animation: blink 1.7s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .22; } }
.title-foot { position: absolute; left: 0; right: 0; bottom: 4.5cqh; margin: 0; color: #a9b8acb0; font-size: min(2cqh, 2.6cqw); letter-spacing: .14em; }

/* ---------- Menu principal ---------- */
.screen-main { padding: 6cqh 0 0 6cqw; }
.main-logo { display: flex; align-items: center; gap: 2cqh; }
.main-logo .logo-emblem { width: 6cqh; height: 6cqh; }
.main-logo-text b {
  display: block; font-family: var(--heading); font-size: min(5.4cqh, 5cqw); letter-spacing: .06em; text-transform: uppercase; line-height: 1;
  background: linear-gradient(180deg, #fff7da, #e9b45c); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.main-logo-text em { display: block; margin-top: .6cqh; color: #ffe1a8; font-size: min(3cqh, 3.4cqw); letter-spacing: .24em; text-transform: uppercase; }
.menu-list { display: grid; gap: 1.2cqh; width: min(62cqh, 88cqw); margin-top: 5cqh; }
.menu-item {
  display: flex; align-items: center; gap: 2cqh; height: 8.4cqh; padding: 0 3cqh 0 2.2cqh;
  border: 0; border-left: .6cqh solid #ffffff22; color: #e8efe4; text-align: left; cursor: pointer;
  background: linear-gradient(90deg, #0b1512e0, #0b151299);
  clip-path: polygon(0 0, 100% 0, 96.5% 100%, 0 100%);
  transition: background .18s, color .18s, border-color .18s, transform .18s;
  animation: item-in .55s cubic-bezier(.2, .8, .2, 1) both;
}
.menu-item:nth-child(1) { animation-delay: .1s; } .menu-item:nth-child(2) { animation-delay: .16s; }
.menu-item:nth-child(3) { animation-delay: .22s; } .menu-item:nth-child(4) { animation-delay: .28s; }
.menu-item:nth-child(5) { animation-delay: .34s; } .menu-item:nth-child(6) { animation-delay: .4s; }
@keyframes item-in { from { opacity: 0; transform: translateX(-5cqw); } to { opacity: 1; transform: none; } }
.menu-item.primary { border-left-color: var(--gold); background: linear-gradient(90deg, #3a2f18e8, #1f1a0fb0); }
.menu-item:hover, .menu-item:focus-visible {
  outline: none; transform: translateX(1.6cqh); color: #271a06; border-left-color: #fff3c4;
  background: linear-gradient(90deg, #ffd98af2, #e5a94ad0 70%, #e5a94a66);
}
.mi-icon { display: grid; place-items: center; width: 4.6cqh; height: 4.6cqh; flex: 0 0 auto; color: var(--gold-light); font-size: 3.2cqh; }
.mi-icon .icon { width: 100%; height: 100%; }
.menu-item:hover .mi-icon, .menu-item:focus-visible .mi-icon { color: #271a06; }
.mi-text strong { display: block; font-size: 3.1cqh; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; line-height: 1.1; }
.mi-text small { display: block; margin-top: .3cqh; font-size: 1.9cqh; opacity: .75; }
.screen-main .current-chapter { position: absolute; left: 6cqw; bottom: 8cqh; margin: 0; font-size: min(2cqh, 2.6cqw); }
.screen-main .cover-best { position: absolute; left: 6cqw; bottom: 4.2cqh; margin: 0; color: #ffd595; font-size: min(2cqh, 2.6cqw); letter-spacing: .06em; }

/* ---------- Subtelas ---------- */
.sub-head { display: flex; align-items: center; gap: 2cqw; padding: 5.5cqh 14cqw 0 5cqw; }
.sub-head h2 {
  margin: 0; font-family: var(--heading); font-size: min(6cqh, 6cqw); letter-spacing: .08em; text-transform: uppercase; color: #fff1cc;
  text-shadow: 0 0 2cqh #f1bc6955;
}
.sub-count { margin-left: auto; white-space: nowrap; color: #ffd595; font-size: min(2.3cqh, 3cqw); letter-spacing: .08em; }
.back-button {
  height: 5.8cqh; min-height: 34px; padding: 0 2.4cqh; border: 1px solid #ffffff44; border-radius: 999px; background: #0b1512cc;
  color: #ffe8b4; font-size: min(2.3cqh, 3cqw); font-weight: 700; letter-spacing: .08em; cursor: pointer; transition: border-color .15s, background .15s;
}
.back-button:hover, .back-button:focus-visible { border-color: var(--gold); background: #2a2415dd; outline: none; }

.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3cqw; padding: 4.5cqh 8cqw 0; }
.char-card {
  position: relative; display: flex; align-items: flex-end; gap: 1.6cqw; height: 58cqh; padding: 2.4cqh 2.4cqh 2.4cqh 1.6cqh;
  border: 2px solid #ffffff26; border-radius: 2cqh; overflow: hidden; color: #e8efe4; text-align: left; cursor: pointer;
  background: linear-gradient(160deg, #162722f0, #0a1411f0); transition: border-color .2s, transform .2s, box-shadow .2s;
}
.char-card:hover, .char-card:focus-visible { outline: none; transform: translateY(-.8cqh); border-color: #ffffff66; }
.char-card[aria-pressed='true'] { border-color: var(--gold); box-shadow: 0 0 4cqh #f1bc6944, inset 0 0 6cqh #f1bc6918; }
.char-card img { flex: 0 0 50%; width: 50%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 1.5cqh 2cqh #000a); animation: hero-idle 4.2s ease-in-out infinite; }
.char-info { display: grid; gap: 1.2cqh; flex: 1; align-self: center; min-width: 0; }
.char-info strong { font-family: var(--heading); font-size: min(5.2cqh, 5cqw); line-height: 1; }
.char-info em { margin-top: -.6cqh; color: #ffd595; font-size: min(2.3cqh, 3cqw); font-style: italic; }
.stat { display: grid; grid-template-columns: 11.5cqh 1fr; align-items: center; gap: 1cqh; }
.stat small { color: #a9b8ac; font-size: min(1.9cqh, 2.6cqw); }
.stat i { height: 1.1cqh; border-radius: 9px; background: linear-gradient(90deg, #f1bc69 var(--v), #ffffff1c var(--v)); }
.char-power { color: #d6e0d3; font-size: min(1.95cqh, 2.6cqw); line-height: 1.4; }
.char-power b { display: block; color: var(--gold-light); font-size: min(2.2cqh, 2.9cqw); }
.char-pick { position: absolute; top: 2cqh; right: 2cqh; padding: .8cqh 1.8cqh; border-radius: 999px; background: #ffffff1a; font-size: min(1.7cqh, 2.4cqw); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.char-card[aria-pressed='true'] .char-pick { background: var(--gold); color: #271a06; }
.screen-chars .download-button { width: max-content; position: absolute; left: 50%; bottom: 4cqh; translate: -50% 0; min-height: 34px; height: 5cqh; padding: 0 2cqh; font-size: min(2cqh, 2.8cqw); }

.screen-levels .chapter-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.4cqw; margin: 4.5cqh 7cqw 0; padding: 0; list-style: none; }
.screen-levels .chapter-button {
  position: relative; display: block; width: 100%; height: 31cqh; padding: 0; border: 2px solid #ffffff2a; border-radius: 1.8cqh; overflow: hidden;
  background: #0b1512; text-align: left; cursor: pointer; transition: border-color .2s, transform .2s, box-shadow .2s;
}
.screen-levels .chapter-image { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 0; object-fit: cover; transition: transform .6s, filter .3s; }
.screen-levels .chapter-button::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, #02060bf2, #02060b40 62%, transparent); }
.screen-levels .chapter-text { position: absolute; z-index: 1; left: 2cqh; right: 2cqh; bottom: 2cqh; }
.screen-levels .chapter-text small { margin: 0 0 .4cqh; color: #ffd595; font-size: min(2cqh, 2.6cqw); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.screen-levels .chapter-text strong { color: #fff4d4; font-family: var(--heading); font-size: min(3cqh, 3.6cqw); line-height: 1.1; }
.screen-levels .chapter-button > .icon { position: absolute; z-index: 1; top: 1.6cqh; right: 1.6cqh; width: 4.4cqh; height: 4.4cqh; padding: 1cqh; border-radius: 50%; background: #0b1512d0; color: #ffd595; }
.screen-levels .chapter-button:hover:not(:disabled), .screen-levels .chapter-button:focus-visible { outline: none; transform: translateY(-.8cqh); border-color: var(--gold); box-shadow: 0 0 3.5cqh #f1bc6955; background: #0b1512; }
.screen-levels .chapter-button:hover:not(:disabled) .chapter-image { transform: scale(1.07); }
.screen-levels .chapter-button[aria-current='step'] { border-color: #d7ad66; }
.screen-levels .chapter-button:disabled { cursor: not-allowed; background: #0b1512; }
.screen-levels .chapter-button:disabled .chapter-image { filter: grayscale(1) brightness(.35); opacity: 1; }
.screen-levels .save-note { position: absolute; left: 0; right: 0; bottom: 3cqh; margin: 0; text-align: center; color: #a9b8acb0; font-size: min(2cqh, 2.6cqw); }

/* ---------- Cartão de abertura da fase ---------- */
.level-card { position: absolute; z-index: 6; left: 0; right: 0; top: 24cqh; display: flex; flex-direction: column; align-items: center; text-align: center; pointer-events: none; opacity: 0; }
.level-card::before { content: ''; width: 30cqw; height: 1px; margin-bottom: 2cqh; background: linear-gradient(90deg, transparent, #ffd595, transparent); }
.level-card.show { animation: level-card 3.2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes level-card {
  0% { opacity: 0; transform: translateX(-6cqw); }
  12% { opacity: 1; transform: none; }
  76% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateX(6cqw); }
}
.level-card small { color: #ffd595; font-size: min(3cqh, 3cqw); font-weight: 800; letter-spacing: .5em; text-transform: uppercase; text-shadow: 0 .3cqh .8cqh #000c; }
.level-card strong { font-family: var(--heading); font-size: min(10cqh, 8cqw); letter-spacing: .06em; text-transform: uppercase; color: #fff4d4; text-shadow: 0 0 3cqh #f1bc69aa, 0 .6cqh 0 #0009; }
.level-card em { margin-top: 1.6cqh; color: #e1e6d9; font-size: min(2.6cqh, 3cqw); font-style: normal; letter-spacing: .06em; text-shadow: 0 .3cqh .8cqh #000c; }

/* ---------- Celular em pé ---------- */
@media (orientation: portrait) {
  .game-frame.expanded[data-mode='menu'] .screen { width: 100vw; height: 100dvh; aspect-ratio: auto; }
  .stage-hero { display: none; }
  .screen-main { display: flex; flex-direction: column; align-items: center; padding: 8cqh 4cqw 0; }
  .menu-list { margin-top: 4cqh; }
  .char-grid { grid-template-columns: 1fr; gap: 2cqh; padding: 3cqh 5cqw 0; }
  .char-card { height: 31cqh; }
  .screen-levels .chapter-list { grid-template-columns: repeat(2, 1fr); gap: 3cqw; margin-inline: 5cqw; }
  .screen-levels .chapter-button { height: 17cqh; }
  .sub-head { padding: 5cqh 4cqw 0; flex-wrap: wrap; }
  .screen-chars .download-button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-bg, .stage-hero, .stage-fog, .logo-top, .press-start, .char-card img, .menu-item, .menu-screen.enter { animation: none !important; }
  .level-card.show { animation-duration: 3.2s; }
}
