.menu {
  position: absolute;
  inset: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(15px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  color: #fff1dc;
  background: radial-gradient(ellipse at 47% 18%, #263235 0%, transparent 68%), #0c131a;
}
.menu-shell { max-width: 980px; margin: 0 auto; display: grid; gap: 15px; }
.menu-header, .menu-brand, .team-title { display: flex; align-items: center; }
.menu-header { justify-content: space-between; gap: 10px; }
.menu-brand { gap: 10px; min-width: 0; }
.menu-brand h1 {
  margin: 0;
  font: 600 clamp(.81rem, 2.9vw, 1.03rem)/1.2 system-ui, sans-serif;
  color: #edd6b3;
  text-shadow: 0 2px 8px #000;
}
.menu-brand h1 span {
  display: block;
  color: #ffe2b1;
  font: 700 clamp(1.22rem, 4.75vw, 2.1rem)/1 Georgia, serif;
  letter-spacing: -.045em;
}
.menu-insignia {
  display: grid;
  place-items: center;
  width: clamp(40px, 13vw, 57px);
  aspect-ratio: 1;
  flex: none;
  border: 1px solid #a87a45;
  border-radius: 13px;
  background: radial-gradient(#69412b, #261d1e 75%);
  box-shadow: inset 0 0 0 2px #14151b, 0 5px 17px #0008;
}
.menu-icon {
  display: inline-block;
  width: var(--menu-icon-size, 30px);
  aspect-ratio: 1;
  flex: none;
  background: url('./assets/menu-icons.webp') var(--icon-x, 0) var(--icon-y, 0) / 400% 400% no-repeat;
}
.icon-crest { --menu-icon-size: clamp(35px, 11vw, 51px); }
.icon-map { --icon-x: 33.3333%; }
.icon-book { --icon-x: 66.6667%; }
.icon-hunt { --icon-x: 100%; }
.icon-booster { --icon-y: 33.3333%; }
.icon-armor { --icon-x: 33.3333%; --icon-y: 33.3333%; }
.icon-shop { --icon-x: 66.6667%; --icon-y: 33.3333%; }
.icon-help { --icon-x: 100%; --icon-y: 33.3333%; }
.icon-quest { --icon-y: 66.6667%; }
.icon-enemies { --icon-x: 33.3333%; --icon-y: 66.6667%; }
.icon-evolution { --icon-x: 66.6667%; --icon-y: 66.6667%; }
.icon-attack { --icon-y: 100%; }
.install-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #595047;
  border-radius: 11px;
  background: linear-gradient(#263038, #131c24);
  color: #e0bf92;
  font-size: 1.55rem;
}
.install-button:hover { border-color: #ba8b59; }
.install-symbol { position: relative; display: block; width: 17px; height: 17px; border-bottom: 2px solid currentColor; }
.install-symbol::before { content: ''; position: absolute; top: 0; left: 8px; height: 10px; border-left: 2px solid currentColor; }
.install-symbol::after { content: ''; position: absolute; top: 4px; left: 5px; width: 8px; height: 8px; border-bottom: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); }
.menu-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); align-items: end; gap: 15px; }
.mission {
  overflow: hidden;
  border: 1px solid #986d44;
  border-radius: 20px;
  background: #151a21;
  box-shadow: 0 12px 30px #0006, inset 0 1px #ffdcab37;
}
.mission-art {
  isolation: isolate;
  position: relative;
  display: grid;
  align-items: end;
  min-height: clamp(245px, 43vh, 390px);
  overflow: hidden;
  background: #23262a var(--mission-cover, url('./assets/menu-hero.webp')) center 52% / cover no-repeat;
}
.mission-art[data-keyart="true"] { background-position: 64% 50%; }
.mission-art::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg,#13171e 1%,#13171ed4 21%,transparent 58%);
  pointer-events: none;
}
.mission-monster {
  position: absolute;
  z-index: -1;
  width: min(76%, 390px);
  height: 98%;
  right: 0;
  top: -1%;
  object-fit: contain;
  filter: var(--skin-filter, brightness(1)) drop-shadow(0 12px 15px #0a0a14);
}
.mission-art[data-keyart="true"] .mission-monster { visibility: hidden; }
.mission-intro { padding: 16px 17px 10px; }
.mission-type {
  display: inline-block;
  color: var(--chapter-color, #ffc384);
  font-size: .8rem;
  font-weight: 800;
  text-shadow: 0 2px 6px #000;
}
.mission-intro h2 {
  margin: 5px 0 11px;
  color: #fff2db;
  font: 700 clamp(2.07rem, 9vw, 3.55rem)/.99 Georgia, serif;
  letter-spacing: -.045em;
  text-shadow: 0 4px 13px #000;
}
.mission-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.mission-tags > * {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 35px;
  padding: 2px 8px;
  border: 1px solid #9b79586e;
  border-radius: 8px;
  background: #17191fe8;
  color: #f4dfbd;
  font-size: .77rem;
  font-weight: 740;
}
.mission-tags button:hover { border-color: #e7b786; }
.mission-tags .menu-icon, #starter-tag .item-sprite { --menu-icon-size: 20px; --icon-size: 19px; }
.mission-controls { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 8px; padding: 4px 12px 12px; }
.hunt-button, .campaign-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 54px;
  padding: 5px 8px;
  border-radius: 11px;
  font-size: .9rem;
  font-weight: 850;
  line-height: 1.16;
}
.hunt-button {
  border: 1px solid #ffe1aa;
  background: linear-gradient(#ffd997, #e99a55);
  color: #30180e;
  box-shadow: inset 0 1px #fff8dd, 0 3px 0 #8c522d, 0 6px 13px #0006;
}
.hunt-button:hover { background: linear-gradient(#ffe8b5, #f1a764); }
.hunt-button:active { transform: translateY(2px); }
.hunt-button:disabled { opacity: .7; cursor: wait; }
.campaign-link {
  justify-content: start;
  text-align: start;
  color: #f4dec0;
  border: 1px solid #98806a;
  background: linear-gradient(#2b3032, #1b222a);
}
.campaign-link:hover { border-color: #efc393; background: #393632; }
.campaign-link small { display: block; margin-top: 3px; color: #d5c4af; font-size: .7rem; font-weight: 600; }
#loading { grid-column: 1/-1; margin: 3px 0 0; color: #e4d4bc; font-size: .82rem; text-align: center; }
.mission-embers { position: absolute; inset: 0; pointer-events: none; }
.mission-embers i {
  position: absolute;
  left: var(--x, 14%);
  bottom: var(--y, 26%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffc67a;
  box-shadow: 0 0 8px 2px #e67a3f;
  animation: menu-ember 4s linear infinite both;
  animation-delay: var(--delay, 0s);
}
.mission-embers i:nth-child(2) { --x: 33%; --y: 50%; --delay: -2s; }
.mission-embers i:nth-child(3) { --x: 43%; --y: 30%; --delay: -1s; }
.mission-embers i:nth-child(4) { --x: 69%; --y: 32%; --delay: -3s; }
.mission-embers i:nth-child(5) { --x: 82%; --y: 65%; --delay: -1.2s; }
.mission-embers i:nth-child(6) { --x: 90%; --y: 24%; --delay: -2.6s; }
@keyframes menu-ember { 0% { opacity: 0; } 35% { opacity: .9; } 100% { opacity: 0; transform: translate(13px,-46px); } }
.menu-team { min-width: 0; display: grid; gap: 8px; }
.team-title { justify-content: space-between; padding-inline: 2px; }
.team-title h2 { margin: 0; font: 700 1.11rem/1.2 Georgia, serif; }
#menu-count { color: #d3bb9f; font-size: .78rem; font-weight: 750; }
.monster-select {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid #6e6253;
  border-radius: 13px;
  background: linear-gradient(100deg,#242f35,#181d24);
  text-align: start;
}
.monster-select:hover { border-color: var(--monster-accent, #ffc47a); }
.monster-avatar {
  display: block;
  width: 61px;
  aspect-ratio: 1;
  border: 1px solid #6f5f49;
  border-radius: 10px;
  background: radial-gradient(#4c3c31,#1c242c);
  overflow: hidden;
}
.monster-avatar img { width: 100%; height: 100%; object-fit: contain; filter: var(--skin-filter,brightness(1)); }
.monster-info { display: grid; gap: 2px; color: #e5d7c3; }
.monster-info strong { color: #ffe8c6; font-size: 1.01rem; line-height: 1.15; overflow-wrap: anywhere; }
.monster-info > span { font-size: .75rem; }
.monster-info b { color: var(--monster-accent,#ffc47a); }
#hero-progress { width: 100%; height: 7px; accent-color: var(--monster-accent, #ffc47a); }
.monster-select-label { color: #e8c49a; font-size: .74rem; font-weight: 750; }
.menu-team .evolution-entry { display: flex; align-items: center; gap: 8px; text-align: start; }
.evolution-entry > span { display: grid; gap: 2px; }
.menu-nav {
  display: grid;
  grid-template-columns: repeat(6,minmax(0,1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid #695a4c;
  border-radius: 14px;
  background: #171d24;
}
.menu-nav button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  min-height: 59px;
  min-width: 0;
  padding: 3px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #e6cfb3;
  font-size: .76rem;
  font-weight: 750;
}
.menu-nav button:hover, .menu-nav button[aria-current="page"] { border-color: #9d7752; background: radial-gradient(#67462b, #2b2426); color: #fff1d4; }
.menu-nav .menu-icon { --menu-icon-size: 34px; filter: drop-shadow(0 1px 2px #090a10); }
@media (max-width: 700px) {
  .menu { padding-block-start: max(12px,env(safe-area-inset-top)); }
  .menu-shell { max-width: 500px; gap: 11px; }
  .menu-grid { grid-template-columns: minmax(0,1fr); gap: 11px; }
  .mission-art { min-height: clamp(230px,40dvh,340px); }
  .install-button { width: 40px; height: 44px; }
}
@media (max-width: 360px) {
  .menu { padding-inline: 10px; }
  .menu-nav button { font-size: .65rem; }
  .mission-controls { padding-inline: 8px; }
  .menu-nav .menu-icon { --menu-icon-size: 30px; }
}
@media (prefers-reduced-motion: reduce) { .mission-embers i { animation: none; opacity: .5; } }

#panel[data-kind="dex"], #panel[data-kind="help"], #panel[data-kind="install"] {
  background: linear-gradient(155deg, #203744, #13242f 52%, #101e29);
  border-color: #78919a;
}
#panel[data-kind="dex"] { width: min(677px, calc(100% - 28px)); }
.dex { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.dex-entry {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 10px;
  text-align: center;
  border: 1px solid #516f78;
  border-radius: 11px;
  background: #101f29;
}
.dex-entry:hover:not(:disabled) { background: #24404b; }
.dex-entry.selected { border-color: #f3bc81; background: linear-gradient(155deg, #51362c, #172631 74%); }
.dex-entry:disabled { cursor: default; }
.dex-entry img { width: min(100%, 130px); height: 100px; object-fit: contain; }
.dex-entry:disabled img { opacity: .55; filter: contrast(.75) saturate(.35); }
.dex-info { display: grid; gap: 3px; }
.dex-info strong { overflow-wrap: anywhere; font-size: 1rem; line-height: 1.12; }
.dex-info small { font-size: .8rem; color: #bdcfd4; line-height: 1.3; }
.dex-info .dex-status { color: #ffcd97; font-weight: 800; }
.help-list { display: grid; gap: 8px; padding: 0; margin: 16px 0 0; list-style: none; }
.help-list li { padding: 9px 12px; border: 1px solid #53707c; border-radius: 9px; background: #152731; color: #dbe5e7; }
.help-list strong { display: block; margin-bottom: 3px; color: #ffe0b4; }

@media (max-width: 480px) {
  .dex { grid-template-columns: 1fr; }
  .dex-entry { grid-template-columns: 66px 1fr; align-items: center; justify-items: start; gap: 12px; text-align: left; min-height: 76px; }
  .dex-entry img { width: 66px; height: 58px; }
}
#open-attacks[data-ready="true"] { border-color: #dfa66d; }
#starter-tag { border-color: #d9a579; color: #fff0d8; }
#panel[data-kind="attacks"] { width: min(720px,calc(100vw - 24px)); border-color: #aa8462; }
.hunt-progress { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid #aa8462; border-radius: 9px; background: #382c25; color: #ffdcaa; }
.hunt-progress div { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.hunt-progress span { font-size: .86rem; }
.hunt-progress progress { width: 100%; height: 9px; accent-color: #efab66; }
.hunt-info { margin: 10px 0; }
.hunt-form-status { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin-top: 8px; padding: 7px 10px; border: 1px solid #786450; border-radius: 8px; background: #242923; color: #ebcfaa; font-size: .8rem; }
.hunt-move-group { margin-top: 15px; }
.hunt-move-group > h3 { margin: 0 0 7px; font-size: .94rem; color: #eedcc1; }
.evolution-card .evolution-moves,.evolution-unlock .evolution-moves { color: #ffcf8d; }
.hunt-moves { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.hunt-move { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 10px; border: 1px solid #527583; border-radius: 9px; background: #142630; }
.hunt-move.starter { background: #322920; border-color: #d7a774; }
.hunt-move header { display: flex; align-items: center; gap: 8px; }
.hunt-move-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 7px; background: #203642; }
.hunt-move h3 { margin: 0; font-size: .95rem; line-height: 1.15; overflow-wrap: anywhere; }
.hunt-move header small { display: block; margin-top: 2px; color: #a9cfdb; font-size: .75rem; }
.hunt-move p { margin: 0; font-size: .83rem; line-height: 1.3; }
.hunt-move button { min-height: 38px; padding: 3px 6px; color: #fbead2; background: #2b4350; border: 1px solid #77929d; border-radius: 6px; font-size: .805rem; font-weight: 800; }
.hunt-move button[data-action="unlock"]:enabled { color: #3d2113; background: #ffd397; border-color: #ffe1b5; }
.hunt-move button:disabled { opacity: .73; cursor: default; }
.hunt-rewards { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 8px 0 13px; }
.hunt-xp-reward { color: #c5edfa; background: #192d3a; border: 1px solid #7295a4; border-radius: 8px; padding: 4px 9px; font-size: .86rem; font-weight: 800; }
@media(max-width:510px) {
  #panel[data-kind="attacks"] { padding: 15px; }
  #panel[data-kind="attacks"] #close { position: sticky; top: 0; right: auto; z-index: 2; float: right; margin: 0 0 4px 6px; }
  .hunt-info { font-size: .9rem; line-height: 1.4; }
  .hunt-moves { grid-template-columns: 1fr; }
  .hunt-move { align-items: center; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: auto auto; padding: 8px; }
  .hunt-move p { grid-column: 1/-1; grid-row: 2; }
  .hunt-move button { grid-column: 2; grid-row: 1; max-width: 110px; font-size: .75rem; }
}
@media(max-width:360px) {
  .menu-nav button { font-size: .69rem; padding-inline: 1px; }
  .hunt-move-icon { width: 28px; height: 28px; }
  .hunt-move header { gap: 5px; }
  .hunt-move button { max-width: 94px; }
}
.hunter-chapter + .hunter-chapter { margin-top: 17px; }
#panel[data-kind="hunters"] #close { position:sticky; top:0; right:auto; z-index:1; float:right; margin:0 0 4px 6px; }
.hunter-chapter h3 { margin: 0 0 6px; font-size: .92rem; color: var(--chapter-color,#b9d6dc); }
.hunter-roster { display:grid; gap:7px; margin:0; padding:0; list-style:none; }
.hunter-roster li {
  display:grid; grid-template-columns:60px minmax(0,1fr); gap:12px; align-items:center;
  padding:6px 10px 6px 6px; background:#142630; border:1px solid #516b76; border-radius:8px;
}
.hunter-portrait {
  display:block; width:60px; aspect-ratio:1; border-radius:5px;
  background:var(--hunter-art) 0 0 / 400% var(--hunter-rows,400%) no-repeat,radial-gradient(#263e51,#14212c);
  box-shadow:inset 0 -2px var(--hunter-color);
}
.hunter-roster .hunter-boss { border-color:var(--chapter-color); background:linear-gradient(120deg,#283038,#182630); }
.hunter-roster h4,.hunter-roster p { margin:0; }
.hunter-roster h4 { font-size:1rem; }
.hunter-roster p,.hunter-roster small { font-size:.8rem; }
.hunter-roster small { color:#eed0ac; }
#open-quests[data-cleared="true"] { color:#b1ffe0; border-color:#6db795; background:#17322ee8; }
