:root {
  --ink: #FFFFFF;
  --muted: #AEB6E8;
  --bg: #0E1233;
  --panel: #151B47;
  --panel-2: #1A2154;
  --soft: #1F2766;
  --line: #3A4494;
  --gold: #FFD447;
  --gold-shadow: #B8901A;
  --purple: #6B4FD8;
  --green: #2E7D5B;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --body: 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.row .btn-play { flex: 1; }
html, body { margin: 0; height: 100%; background: #070A22; color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
body { display: flex; justify-content: center; }
#app { width: 100%; max-width: 480px; height: 100dvh; background: var(--bg); position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); overflow-y: auto; }
.screen[hidden] { display: none; }

/* text */
.h-pixel { font-family: var(--pixel); font-size: 14px; line-height: 1.4; color: var(--gold); margin: 0; }
.h-pixel.purple { color: var(--purple); }
.fine { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; margin: 0; }
.fine.dark { color: #4A527F; }
.note { font-size: 12px; font-weight: 700; color: #DDE2FF; margin: 0; line-height: 1.35; }
.say { font-size: 16px; font-weight: 900; margin: 0; color: #F1E6FF; }
.say::before { content: '🔊 '; font-size: 13px; }
.say:empty { display: none; }

/* buttons */
.btn { font-family: var(--body); font-weight: 900; font-size: 17px; color: var(--ink); background: var(--soft); border: 3px solid var(--line); border-radius: 16px; min-height: 60px; padding: 0 16px; cursor: pointer; touch-action: manipulation; user-select: none; }
.btn:active { transform: translateY(2px); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-play { background: var(--gold); color: var(--bg); border: 0; box-shadow: 0 7px 0 var(--gold-shadow); font-family: var(--pixel); font-size: 18px; min-height: 72px; }
.btn-play.small { min-height: 56px; font-size: 13px; }
.btn-soft { flex: 1; }
.btn-soft.dark { background: #E8EAF6; color: var(--bg); border-color: #C5CAE9; }
.btn-icon { width: 60px; padding: 0; display: grid; place-items: center; }
.btn-back { width: 52px; min-height: 52px; padding: 0; font-size: 28px; line-height: 1; }
.row { display: flex; gap: 10px; }
.row.bottom { margin-top: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.bar { display: flex; align-items: center; gap: 12px; }
.pill { margin-left: auto; background: var(--soft); border-radius: 999px; padding: 8px 14px; font-family: var(--pixel); font-size: 11px; }

/* title */
#s-title { align-items: center; justify-content: center; gap: 16px; }
.logo { font-family: var(--pixel); font-size: clamp(26px, 8.6vw, 38px); line-height: 1.15; text-align: center; color: var(--gold); text-shadow: 4px 4px 0 #FF7AC6, 8px 8px 0 #2A1E6B; letter-spacing: 2px; }
.tagline { margin: 0; font-size: 20px; font-weight: 800; color: #DDE2FF; }
#s-title .btn-play { width: 280px; }
#s-title .row { width: 100%; max-width: 340px; }
canvas.preview { image-rendering: pixelated; }

/* trio badge: number | symbol | name */
.trio { display: inline-flex; border-radius: 10px; overflow: hidden; border: 3px solid var(--c, #fff); align-self: flex-start; font-family: var(--pixel); }
.trio span { padding: 8px 6px; font-size: 11px; }
.trio .n { background: var(--c); color: var(--bg); }
.trio .s { background: var(--bg); color: #fff; }
.trio .w { background: #fff; color: var(--bg); font-size: 9px; padding-top: 9px; }
.trio-sm span { padding: 5px 5px; font-size: 9px; }
.trio-sm .w { font-size: 8px; padding-top: 6px; }

/* select */
.table-card { background: var(--panel); border-radius: 16px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mini-table { position: relative; width: 358px; height: 186px; max-width: 100%; transform-origin: top center; }
.mini-table i { position: absolute; width: 18px; height: 18px; border-radius: 3px; background: #262E6E; }
.mini-table i.zoom { background: transparent; border: 2px solid var(--gold); border-radius: 6px; }
.mini-caption { margin: 0; font-size: 13px; font-weight: 800; color: var(--muted); }
.mini-caption.left { text-align: left; }
.card { background: var(--panel-2); border: 3px solid var(--c, var(--line)); border-radius: 20px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.card-top { display: flex; gap: 12px; align-items: center; }
.card-info { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 13px; font-weight: 900; }
.chip::before { content: ''; width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
.fact { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 15px; font-weight: 800; line-height: 1.3; }
.tag { flex: none; border-radius: 6px; padding: 3px 6px; font-size: 11px; font-weight: 900; margin-top: 1px; color: #fff; }
.tag-real { background: var(--green); }
.tag-game { background: var(--purple); }
.tag-art { background: #B8476E; }
.pick-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
#s-select { gap: 8px; }
#s-select .card { padding: 10px; gap: 6px; }
#s-select .fact { font-size: 14px; }
.pick { min-height: 46px; border-radius: 12px; border: 3px solid var(--c); background: var(--c); color: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; cursor: pointer; font-family: var(--pixel); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.pick small { font-size: 7px; }
.pick b { font-size: 14px; font-weight: 400; }
.pick[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px #fff; }
.pick .gold { position: absolute; }
#select-go { margin-top: auto; }

/* versus */
#s-versus { padding: 0; gap: 0; background: linear-gradient(170deg, #3A1D55 0 44%, #13315C 44% 100%); }
.vs-top { position: relative; padding: 18px 18px 0; min-height: 250px; display: flex; flex-direction: column; gap: 8px; }
.vs-top canvas { position: absolute; right: 30px; top: 50px; }
.vs-badge { align-self: center; width: 76px; height: 76px; border-radius: 50%; background: var(--gold); color: var(--bg); display: grid; place-items: center; font-family: var(--pixel); font-size: 20px; box-shadow: 0 6px 0 var(--gold-shadow), 0 0 0 6px var(--bg); z-index: 2; margin-top: -20px; }
.vs-bottom { display: flex; align-items: flex-end; gap: 10px; padding: 0 18px; min-height: 170px; margin-top: -30px; }
.vs-opp-info { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-left: auto; padding-bottom: 30px; }
.sheet { margin-top: auto; background: #fff; color: var(--bg); border-radius: 28px 28px 0 0; padding: 18px 18px max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet .h-pixel { font-size: 16px; }
.sheet p { margin: 0; font-size: 18px; font-weight: 900; line-height: 1.3; }
.sym-chip { font-family: var(--pixel); font-size: 15px; background: var(--bg); color: #fff; border-radius: 6px; padding: 3px 6px; }
.choice { min-height: 60px; border-radius: 14px; border: 3px solid var(--bg); background: #F2F4FF; color: var(--bg); font-family: var(--pixel); font-size: 14px; box-shadow: 0 5px 0 var(--bg); cursor: pointer; }

/* fight */
.screen-fight { padding: max(10px, env(safe-area-inset-top)) 0 0; gap: 0; }
.hud { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 12px 8px; }
.hud-side { display: flex; flex-direction: column; gap: 6px; }
.hud-side.right { align-items: flex-end; }
.hp { width: 100%; height: 18px; background: #262E6E; border: 2px solid #fff; border-radius: 6px; overflow: hidden; display: flex; }
.hud-side.right .hp { justify-content: flex-end; }
.hp-fill { height: 100%; background: var(--c); transition: width .2s; }
.arena { position: relative; flex: 1; min-height: 220px; background: #161D52; overflow: hidden; }
#arena-canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); image-rendering: pixelated; }
.caption { position: absolute; left: 0; right: 0; top: 10px; margin: 0; text-align: center; font-family: var(--pixel); font-size: 13px; line-height: 1.5; color: var(--gold); text-shadow: 3px 3px 0 var(--bg); padding: 0 12px; pointer-events: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; }
.overlay[hidden] { display: none; }
.smash-card { background: #fff; color: var(--bg); border-radius: 24px; padding: 18px 14px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 8px 0 var(--purple); width: 100%; max-width: 360px; }
.smash-card p { margin: 0; font-size: 18px; font-weight: 900; }
.bubbles { display: flex; gap: 14px; }
.bubble { width: 86px; height: 86px; border-radius: 50%; border: 4px solid var(--bg); background: #F2F4FF; color: var(--bg); font-family: var(--pixel); font-size: 22px; box-shadow: 0 6px 0 var(--bg); cursor: pointer; }
.ko-text { font-family: var(--pixel); font-size: 44px; color: var(--gold); text-shadow: 5px 5px 0 #FF7AC6, 9px 9px 0 var(--bg); text-align: center; line-height: 1.3; }
.controls { background: var(--panel); padding: 12px 14px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-label { font-family: var(--pixel); font-size: 9px; color: var(--gold); }
.meter { flex: 1; height: 16px; background: #262E6E; border: 2px solid var(--gold); border-radius: 6px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.pad { display: flex; justify-content: space-between; align-items: flex-end; }
.pad-left { display: grid; grid-template-columns: repeat(2, 64px); gap: 8px; }
.pad-left .btn-pad { width: 64px; min-height: 64px; }
.pad-right { display: grid; grid-template-columns: 78px 106px; gap: 10px; align-items: end; }
.btn-pad { width: 72px; min-height: 72px; padding: 0; font-size: 24px; }
.btn-special { grid-column: 1 / span 2; min-height: 56px; font-family: var(--pixel); font-size: 13px; background: #262E6E; color: var(--muted); border: 3px dashed var(--line); }
.btn-special:not([disabled]) { background: var(--gold); color: var(--bg); border: 4px solid var(--bg); box-shadow: 0 6px 0 var(--gold-shadow); animation: pulse .9s ease-in-out infinite; }
.btn-kick { width: 78px; height: 78px; min-height: 0; border-radius: 50%; padding: 0; border: 4px solid var(--bg); background: #8FD3FF; color: var(--bg); font-family: var(--pixel); font-size: 10px; box-shadow: 0 6px 0 #4FA6DB; }
.chain { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-family: var(--pixel); font-size: 11px; color: #fff; text-shadow: 2px 2px 0 var(--bg); pointer-events: none; }
.level-tag { position: absolute; left: 10px; top: 40px; margin: 0; font-family: var(--pixel); font-size: 8px; line-height: 1.6; color: var(--muted); pointer-events: none; }

/* difficulty choice */
.mode-hero { display: flex; gap: 12px; align-items: center; background: var(--panel); border-radius: 18px; padding: 10px; }
.mode-list { display: flex; flex-direction: column; gap: 12px; }
.mode { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 18px; border: 3px solid var(--c); background: var(--panel-2); color: #fff; cursor: pointer; min-height: 90px; }
.mode b { font-family: var(--pixel); font-weight: 400; font-size: 16px; color: var(--c); }
.mode span { font-size: 15px; font-weight: 800; }
.mode.current { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--c); }

/* road map */
.map-info { display: flex; align-items: center; gap: 10px; }
.link-btn { margin-left: auto; background: none; border: 0; color: var(--muted); font-weight: 800; font-size: 14px; text-decoration: underline; min-height: 44px; cursor: pointer; }
.road { flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); border-radius: 18px; padding: 14px 10px; display: flex; flex-direction: column-reverse; gap: 6px; }
.zone { text-align: center; font-family: var(--pixel); font-size: 9px; line-height: 1.7; color: var(--muted); padding: 10px 0 4px; }
.node-row { display: flex; }
.node { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--line); background: #262E6E; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-family: var(--pixel); font-size: 10px; cursor: pointer; padding: 0; position: relative; }
.node small { font-size: 7px; }
.node.done { background: var(--green); border-color: #fff; color: #fff; }
.node.now { background: var(--gold); border-color: var(--bg); color: var(--bg); box-shadow: 0 0 0 4px var(--gold); animation: pulse 1s ease-in-out infinite; }
.node.locked { opacity: .55; cursor: default; }
.node.boss { border-radius: 14px; border-color: #FF7AC6; }
.node .badge { position: absolute; top: -8px; right: -8px; font-size: 7px; background: #FF7AC6; color: var(--bg); border-radius: 6px; padding: 3px 4px; }
.node .badge.twist { background: #8FD3FF; }
.map-next { background: var(--panel-2); border-radius: 16px; padding: 10px 14px; font-weight: 800; font-size: 15px; line-height: 1.35; }
.map-next b { font-family: var(--pixel); font-weight: 400; font-size: 11px; color: var(--gold); }
.btn-strike { width: 106px; height: 106px; min-height: 0; border-radius: 50%; padding: 0; border: 4px solid var(--bg); background: #FF7AC6; color: var(--bg); font-family: var(--pixel); font-size: 12px; box-shadow: 0 7px 0 #B8467F; }
.btn-guard.on { background: #FF7AC6; color: var(--bg); }

/* result */
#s-result { align-items: center; background: #2A1240; }
.result-title { font-family: var(--pixel); font-size: 26px; line-height: 1.3; text-align: center; color: var(--gold); text-shadow: 4px 4px 0 var(--c, #FF7AC6), 7px 7px 0 var(--bg); margin-top: 18px; }
.coin-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--gold); color: var(--bg); border-radius: 999px; padding: 6px 14px; font-family: var(--pixel); font-size: 11px; }
.coin-pill::before, .coins::before { content: ''; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 4px var(--gold), inset 0 0 0 6px var(--bg); display: inline-block; vertical-align: middle; margin-right: 6px; }
#res-trio { align-self: center; }
#s-result .stack { width: 100%; }
.sticker-card, .prompt-card { width: 100%; display: flex; align-items: center; gap: 14px; background: #fff; color: var(--bg); border-radius: 18px; padding: 12px 14px; }
.sticker { width: 60px; height: 70px; flex: none; background: var(--c); border: 4px solid var(--bg); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-family: var(--pixel); box-shadow: 0 5px 0 var(--bg); transform: rotate(-5deg); }
.sticker small { font-size: 8px; } .sticker b { font-size: 17px; font-weight: 400; }
.sticker-card p, .prompt-card p { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.3; }
.sticker-card .h-pixel, .prompt-card .h-pixel { font-size: 11px; color: var(--purple); }

/* album */
.zoom-grid { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: 3px; }
.zoom-grid > * { min-height: 58px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-family: var(--pixel); }
.slot { background: var(--panel); color: var(--muted); border: 3px dashed var(--line); font-size: 10px; cursor: pointer; padding: 0; }
.slot.hint { border-color: var(--c); background: #3A1D55; color: #fff; animation: pulse .8s ease-in-out infinite; }
.filled { background: var(--c); color: var(--bg); border: 3px solid var(--bg); }
.filled small { font-size: 7px; } .filled b { font-size: 13px; font-weight: 400; }
.filled.new { border-color: var(--gold); }
.gold-card { background: var(--panel-2); border: 3px solid var(--gold); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.gold-card[hidden] { display: none; }
.gold-card p { margin: 0; font-size: 16px; font-weight: 800; }
.marks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.marks span { border-radius: 10px; padding: 8px 4px; text-align: center; font-size: 13px; font-weight: 900; background: #262E6E; color: var(--muted); }
.marks span.ok { background: var(--green); color: #fff; }

/* armory */
.armory-stage { background: var(--panel); border-radius: 20px; display: flex; flex-direction: column; align-items: center; padding: 6px 0 10px; }
.armory-stage .trio { align-self: center; }
.gear-list { display: flex; flex-direction: column; gap: 8px; }
.gear { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 3px solid var(--line); border-radius: 16px; padding: 8px 10px; }
.gear.on { border-color: var(--gold); }
.gear .tile { width: 50px; height: 58px; flex: none; background: #8E9BB5; color: var(--bg); border: 3px solid var(--bg); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-family: var(--pixel); }
.gear .tile small { font-size: 7px; } .gear .tile b { font-size: 14px; font-weight: 400; }
.gear .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.gear .info b { font-family: var(--pixel); font-size: 10px; font-weight: 400; line-height: 1.3; }
.gear .info span { font-size: 13px; font-weight: 800; line-height: 1.25; }
.gear button { width: 80px; min-height: 56px; flex: none; font-family: var(--pixel); font-size: 9px; padding: 0; }
.gear button.buy { background: var(--gold); color: var(--bg); border: 3px solid var(--bg); box-shadow: 0 4px 0 var(--gold-shadow); }
.gear button.wear-on { background: var(--green); border-color: #fff; }
.gear button[disabled] { border-style: dashed; color: var(--muted); background: #262E6E; cursor: default; }
.toast { min-height: 18px; margin: 0; text-align: center; font-family: var(--pixel); font-size: 10px; color: var(--gold); }

/* dialog */
dialog { border: 0; border-radius: 20px; padding: 20px; max-width: 360px; width: calc(100% - 32px); color: var(--bg); }
dialog .h-pixel { color: var(--purple); margin-bottom: 12px; }
dialog::backdrop { background: rgba(5, 7, 26, .7); }
.toggle { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 16px; margin: 10px 0; }
.toggle input { width: 24px; height: 24px; }
.gate-q { font-size: 18px; font-weight: 900; margin: 0 0 12px; }
#set-sources { word-break: break-word; text-align: left; margin: 8px 0 14px; }

/* ---------- responsive: small phones, landscape phones, tablets, laptops ---------- */
canvas.preview { max-width: 100%; height: auto !important; }
/* the main action stays reachable when a menu has to scroll */
#select-go, #map-go, #s-armory > .btn-play, #s-album .row.bottom, #s-result .stack {
  position: sticky; bottom: 0; z-index: 5;
}
#s-album .row.bottom, #s-result .stack { background: linear-gradient(transparent, var(--bg) 30%); padding-top: 14px; }
#s-result .stack { background: linear-gradient(transparent, #2A1240 30%); }
.sheet { position: sticky; bottom: 0; z-index: 5; }

@media (orientation: landscape) {
  #app { max-width: 1280px; }
  /* menus stay a comfortable column in the middle */
  .screen:not(.screen-fight):not(#s-versus) { padding-left: max(16px, calc((100% - 540px) / 2)); padding-right: max(16px, calc((100% - 540px) / 2)); }
  /* fight: arena in the middle, movement pad left, attacks right */
  .screen-fight {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(0, 3fr) minmax(230px, 1fr);
    overflow-x: hidden;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "hud hud hud" "left arena right" "left meter right";
  }
  .screen-fight .controls, .screen-fight .pad { display: contents; }
  .screen-fight .hud { grid-area: hud; }
  .screen-fight .arena { grid-area: arena; min-height: 0; }
  .screen-fight .meter-row { grid-area: meter; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); background: var(--panel); }
  .screen-fight .pad-left { grid-area: left; align-self: end; justify-self: center; padding: 12px; }
  .screen-fight .pad-right { grid-area: right; align-self: end; justify-self: center; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
  /* versus: fighters on the left, Call It on the right */
  #s-versus { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 440px); grid-template-rows: auto auto auto 1fr; overflow-y: auto; }
  #s-versus .vs-top, #s-versus .vs-badge, #s-versus .vs-bottom { grid-column: 1; }
  #s-versus .sheet { grid-column: 2; grid-row: 1 / span 4; align-self: center; margin: 16px; border-radius: 28px; position: static; }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* short landscape phones: shrink the decorative pieces so the real content fits */
  canvas.preview { max-height: 30vh; width: auto !important; }
  .logo { font-size: 26px; }
  #s-title { gap: 8px; }
  .btn-play { min-height: 56px; font-size: 15px; }
  .screen-fight .hud { padding-bottom: 4px; }
  .screen-fight .btn-pad { width: 56px; min-height: 56px; }
  .screen-fight .pad-left { grid-template-columns: repeat(2, 56px); }
  .screen-fight .pad-right { grid-template-columns: 70px 92px; }
  .screen-fight .btn-kick { width: 70px; height: 70px; }
  .screen-fight .btn-strike { width: 92px; height: 92px; }
  .screen-fight .btn-special { min-height: 48px; }
  .vs-top { min-height: 0; padding-top: 10px; }
  .vs-top canvas { position: static; align-self: flex-end; margin-top: -40px; }
  .vs-bottom { min-height: 0; margin-top: -20px; }
}

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 481px) { #app { border-left: 2px solid #1F2766; border-right: 2px solid #1F2766; } }
