/* ==========================================================================
   OPLike UI v2 — design system + round-1 screens (captain select, recruit,
   treasure, shop, map, header). Loaded after style.css; overrides it.
   Rules: one primary action per screen (straw), secondary = paper, danger = red.
   Spacing scale 4/8/12/16/24. Radius 6. Hard ink shadows, no soft blur on UI.
   ========================================================================== */
:root {
  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --bg1: #2b86c8; --bg2: #0f4a80; --bg3: #061f3b; --glow: rgba(140, 210, 255, .18);
  --focus: 0 0 0 3px #fff, 0 0 0 6px var(--ink);
}

/* ---------- Page background: deep sea per arc (no tiled pattern) ---------- */
body, body.theme-eastblue, body.theme-arabasta, body.theme-enieslobby, body.theme-marineford {
  background: radial-gradient(120% 70% at 50% -10%, var(--bg1) 0%, var(--bg2) 45%, var(--bg3) 100%) fixed;
}
body.theme-arabasta { --bg1: #e5a24c; --bg2: #8f4c22; --bg3: #2c1408; --glow: rgba(255, 210, 140, .18); }
body.theme-enieslobby { --bg1: #5b6fb8; --bg2: #2a3470; --bg3: #0c1028; --glow: rgba(190, 200, 255, .16); }
body.theme-marineford { --bg1: #b4452e; --bg2: #4a2333; --bg3: #0e1220; --glow: rgba(255, 170, 130, .16); }
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    repeating-linear-gradient(115deg, transparent 0 120px, var(--glow) 120px 160px, transparent 160px 300px),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, .45), transparent 60%);
  -webkit-mask: linear-gradient(180deg, #000, transparent 75%); mask: linear-gradient(180deg, #000, transparent 75%); opacity: .7; }
#app { max-width: 1120px; }

/* ---------- Buttons: clear hierarchy + states ---------- */
.btn { border-radius: var(--r); transition: transform .08s, box-shadow .08s, filter .12s, background .12s; }
.btn:focus-visible, .seg:focus-visible, .ros:focus-visible, .tab:focus-visible, .note:focus-visible, .bag-tile:focus-visible, .card.pick:focus-visible {
  outline: none; box-shadow: var(--focus); }
.btn.ghost { background: var(--paper); }
.btn.ghost:hover { background: #fff; }
.btn:disabled { filter: none; opacity: .6; background: #d8d2c4; color: #5b5346; box-shadow: 2px 2px 0 rgba(20, 20, 20, .5); }

/* ---------- Panels ---------- */
.panel, .card, .modal { border-radius: var(--r); }
.card.pick { transition: transform .12s, box-shadow .12s; cursor: pointer; }
.card.pick:hover { transform: translate(-2px, -3px); box-shadow: 8px 9px 0 var(--ink); }
.card.pick:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* ---------- Toasts: top, out of the way ---------- */
#toast { top: 14px; bottom: auto; left: auto; right: 16px; transform: none; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#toast .t { animation: toastIn .22s cubic-bezier(.2, 1.3, .4, 1) both; max-width: 340px; }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } }
@media (max-width: 760px) { #toast { right: 8px; left: 8px; align-items: center; } }

/* ---------- Game header ---------- */
.topbar { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center; padding: 8px 12px; border-radius: var(--r); }
.tb-arc { display: flex; flex-direction: column; gap: 2px; line-height: 1; }
.tb-arc .arc { font-size: 1.75rem; }
.tb-dots { display: flex; gap: 5px; }
.tb-dots i { width: 22px; height: 6px; border-radius: 3px; background: #d8ccb0; border: 1.5px solid var(--ink); }
.tb-dots i.done { background: var(--straw); } .tb-dots i.cur { background: var(--red); }
.tb-res { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tb-res .pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: #fff; }
.tb-res .pill b { font-family: var(--display); font-weight: 400; font-size: 1rem; letter-spacing: .3px; }
.tb-res .pill .ico { width: 18px; height: 18px; }
.tb-res .skulls { font-style: normal; color: var(--red); }
.tb-res .pill.buff { background: #fff3c4; } .tb-res .pill.diff { background: #2a1416; color: #ffd27a; }
.tb-nav { display: flex; gap: 6px; align-items: center; }
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; row-gap: 6px; padding: 6px 8px; }
  .tb-arc .arc { font-size: 1.3rem; }
  .tb-res { grid-column: 1 / -1; grid-row: 2; }
  .tb-nav { grid-column: 2; grid-row: 1; }
  .tb-nav .btn.small { padding: 4px 7px 3px; font-size: .8rem; }
  .tb-nav [data-act=types] { display: none; }
}

/* ---------- Node screens: header + action bar ---------- */
.node-head { display: flex; align-items: center; gap: var(--s3); margin: var(--s2) 0 var(--s4); }
.node-head h2 { margin: 0; }
.nh-ico { width: 54px; height: 54px; flex: none; background: var(--paper); border: 3px solid var(--ink); border-radius: 50%; display: grid; place-items: center;
  box-shadow: 3px 3px 0 var(--ink); }
.nh-ico .ico { width: 36px; height: 36px; }
.nh-sub { color: #dbe8f3; font-size: .95rem; margin-top: 4px; }
.nh-sub b { color: #fff; } .nh-sub .berries { color: var(--straw); font-family: var(--display); font-weight: 400; font-size: 1.15rem; }
.nh-sub .warn { color: #ffd27a; }
.action-bar { position: sticky; bottom: 0; z-index: 6; display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s4);
  padding: var(--s3) 0 calc(var(--s3) + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, rgba(4, 18, 36, .55) 40%); }
.cards.pick3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: stretch; }

/* ---------- Stat bars ---------- */
.sbars { display: grid; gap: 4px; margin: var(--s2) 0; }
.sbar { display: grid; grid-template-columns: 18px 30px 1fr 38px; align-items: center; gap: 6px; font-size: .78rem; font-weight: 900; }
.sbar-ico .ico, .sbar-ico svg { width: 18px; height: 18px; display: block; }
.sbar-l { color: var(--muted); letter-spacing: .5px; }
.sbar-track { height: 10px; background: #e7dcc3; border: 2px solid var(--ink); border-radius: 5px; overflow: hidden; }
.sbar-track i { display: block; height: 100%; border-radius: 3px 0 0 3px; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4); }
.sb-hp { background: #3fbf5f; } .sb-atk { background: #e0503a; } .sb-def { background: #3d8ee0; } .sb-spd { background: #f0b52a; }
.sbar b { font-family: var(--display); font-weight: 400; font-size: 1rem; text-align: right; }

/* ---------- Recruit cards ---------- */
.recruit-card { display: flex; flex-direction: column; text-align: left; padding: 0 0 var(--s3); overflow: hidden; }
.recruit-card > :not(.rc-top) { margin-left: var(--s3); margin-right: var(--s3); }
.rc-top { position: relative; display: flex; justify-content: center; padding: var(--s3) 0 var(--s1); border-bottom: 3px solid var(--ink);
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--tc) 35%, #fff), color-mix(in srgb, var(--tc) 12%, var(--paper)) 70%); }
.rc-top .sprite.lg { width: 150px; height: 150px; }
.rc-lv { position: absolute; top: 8px; right: 8px; font-family: var(--display); background: var(--ink); color: #fff; padding: 2px 9px; border-radius: 12px; font-size: .95rem; }
.recruit-card h3 { margin: var(--s2) 0 2px; font-size: 1.5rem; }
.rc-types { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 2px; }
.rc-syn { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.syn-chip { font-size: .72rem; font-weight: 900; padding: 2px 8px; border-radius: 10px; border: 2px solid var(--ink); background: #fff; }
.syn-chip.on { background: var(--straw); animation: synPulse 1.4s ease-in-out infinite; }
@keyframes synPulse { 50% { transform: scale(1.06); } }
.recruit-card .evo-hint, .recruit-card .skill.muted { margin-top: auto; padding-top: 6px; font-size: .78rem; }

/* ---------- Item cards (treasure / shop) ---------- */
.item-card { display: flex; flex-direction: column; text-align: center; }
.item-card .skill { flex: 1; }
.item-card .item-art { width: 84px; height: 84px; margin: 8px auto 4px; }
.item-card .item-art svg { width: 100%; height: 100%; }
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-items: stretch; }
.ic-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: var(--s2); }
.ic-foot .price { display: none; }
.item-card.sold { filter: grayscale(.7); opacity: .75; }
.sold-stamp { font-family: var(--display); color: var(--red); border: 3px solid var(--red); padding: 2px 12px; transform: rotate(-8deg); letter-spacing: 2px; }

/* ---------- Captain select ---------- */
.cap-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: var(--s4); align-items: start; }
.cap-detail { position: sticky; top: 64px; padding: 0; overflow: hidden; }
.cd-hero { display: flex; justify-content: center; padding: var(--s4) 0 var(--s2); border-bottom: 3px solid var(--ink);
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--tc, #9aa4ad) 40%, #fff), color-mix(in srgb, var(--tc, #9aa4ad) 14%, var(--paper)) 72%); }
.cd-hero .sprite.lg { width: 200px; height: 200px; }
.cd-body { padding: var(--s3) var(--s4) var(--s4); }
.cd-name { font-size: 1.8rem; margin: 0 0 4px; }
.cd-go { width: 100%; margin-top: var(--s3); font-size: 1.5rem; }
.cd-lock { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--muted); }
.cd-lock .ico { width: 34px; height: 34px; flex: none; }
.cap-detail.locked .cd-hero { background: #cfc6b3; }
.cap-side { display: grid; gap: var(--s3); min-width: 0; }
.diffbar { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; padding: 10px 12px; margin: 0; }
.db-l { font-family: var(--display); font-size: 1.1rem; }
.segs { display: flex; flex-wrap: wrap; gap: 4px; }
.seg { font-family: var(--display); font-size: .95rem; min-width: 38px; height: 32px; padding: 0 10px; border: 2px solid var(--ink); border-radius: 16px; background: #fff; cursor: pointer; }
.seg.on { background: var(--red); color: #fff; }
.seg:disabled { opacity: .4; cursor: not-allowed; }
.db-desc { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }
.roster { padding: 10px 12px 12px; }
.roster-h { font-family: var(--display); font-size: 1.15rem; margin-bottom: 8px; }
.ros-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ros { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 5px; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 22%, #fff), #fff 70%); border: 2.5px solid var(--ink); border-radius: var(--r);
  box-shadow: 2px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.ros:hover { transform: translateY(-2px); box-shadow: 3px 5px 0 var(--ink); }
.ros .sprite.sm { width: 62px; height: 62px; }
.ros-n { font-family: var(--display); font-size: .82rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ros.sel { outline: 3px solid var(--red); outline-offset: 2px; background: #fff3c4; }
.ros.locked { background: #d9d2c2; }
.ros.locked .sprite img { filter: brightness(0) opacity(.45); }
.ros.locked .ros-n { color: #7a7060; }
@media (max-width: 760px) {
  .cap-layout { grid-template-columns: 1fr; }
  .cap-detail { position: static; display: grid; grid-template-columns: 130px 1fr; }
  .cd-hero { border-bottom: 0; border-right: 3px solid var(--ink); align-items: center; padding: 8px 0; }
  .cd-hero .sprite.lg { width: 120px; height: 120px; }
  .cd-body { padding: 10px; }
  .cd-name { font-size: 1.35rem; }
  .cd-go { font-size: 1.15rem; padding: 8px 10px; }
  .ros-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
  .ros .sprite.sm { width: 50px; height: 50px; }
}

/* ---------- Map ---------- */
.chart-prog { position: absolute; top: 10px; right: 10px; font-family: var(--display); font-size: .95rem; background: var(--paper); border: 2px solid var(--ink);
  border-radius: 14px; padding: 2px 10px; box-shadow: 2px 2px 0 var(--ink); color: var(--parch-ink); z-index: 4; }
.chart-prog b { font-weight: 400; color: var(--red); }
.node.picked .node-art { transform: scale(1.22); }
.node.picked::after { content: ''; position: absolute; inset: -14%; border: 3px dashed var(--red); border-radius: 50%; animation: spin 6s linear infinite; pointer-events: none; }
.map-side { gap: var(--s3); }
.side-sec { background: rgba(4, 20, 40, .35); border: 2px solid rgba(255, 255, 255, .12); border-radius: var(--r); padding: 8px; }
.side-h { display: flex; gap: 6px; align-items: baseline; color: #fff; margin: 0 2px 6px; }
.side-h b { font-family: var(--display); font-weight: 400; font-size: 1.2rem; letter-spacing: .5px; }
.side-h .muted { color: #b9cde0; }
.side-hint { font-size: .72rem; color: #b9cde0; }
.team-grid { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.team-grid .crew-chip { width: auto !important; max-width: none; min-width: 0; padding: 5px 6px; gap: 6px; }
.team-grid .crew-chip .sprite.sm { width: 46px; height: 46px; }
.team-grid .crew-chip .info { font-size: .74rem; min-width: 0; }
.team-grid .crew-chip .info b { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; max-width: 100%; vertical-align: bottom; }
.crew-chip.empty-slot { border-style: dashed; border-color: rgba(255, 255, 255, .35); background: transparent; box-shadow: none; justify-content: center; min-height: 58px; cursor: default; }
.crew-chip.empty-slot span { color: rgba(255, 255, 255, .45); font-weight: 900; font-size: .8rem; }
.crew-chip.empty-slot:hover { transform: none; box-shadow: none; }
.side-tabs { padding: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 3px solid var(--ink); background: var(--paper-2); }
.tab { flex: 1; font-family: var(--display); font-size: .95rem; padding: 8px 6px 6px; border: 0; border-right: 2px solid var(--ink); background: transparent; cursor: pointer; color: var(--muted); }
.tab:last-child { border-right: 0; }
.tab.on { background: var(--paper); color: var(--ink); box-shadow: inset 0 -4px 0 var(--red); }
.tab-body { padding: 10px; }
.tab-body .panel { border: 0; box-shadow: none; padding: 0; background: none; }
.tab-body .relic-strip { margin-top: 8px; }
.tab-body .legend { color: var(--ink); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 0; font-size: .8rem; }
.tab-empty { font-size: .82rem; }
@media (max-width: 760px) {
  .team-grid { grid-template-columns: 1fr 1fr; }
  .map-side .crewbar.team-grid { overflow: visible; flex-direction: unset; }
  .map-side .team-grid .crew-chip { min-width: 0; }
}

/* ---------- Menu header ---------- */
.page-head { background: linear-gradient(180deg, rgba(4, 18, 36, .6), transparent); margin: -8px -8px 6px; padding: 8px; }

/* ---------- Team grid chips: compact, order badge on the portrait ---------- */
.team-grid .crew-chip { position: relative; }
.team-grid .crew-chip .front-tag, .team-grid .crew-chip .back-tag { position: absolute; top: -7px; left: -7px; z-index: 2; font-size: .62rem; padding: 0 5px;
  border-radius: 9px; line-height: 1.5; }
.team-grid .crew-chip .front-tag { font-size: 0; padding: 0; width: 22px; height: 18px; display: grid; place-items: center; }
.team-grid .crew-chip .front-tag::after { content: '1º'; font-size: .66rem; }
.team-grid .crew-chip .info { line-height: 1.2; }
.team-grid .crew-chip .info br { display: none; }
.team-grid .crew-chip .info b + .muted { display: block; font-size: .7rem; }
.action-bar { background: none; }
@media (max-width: 760px) {
  .cap-detail { grid-template-columns: 112px 1fr; }
  .cd-hero .sprite.lg { width: 104px; height: 104px; }
  .cd-go { white-space: nowrap; font-size: 1.05rem; }
  .team-grid .crew-chip .chip-gear { flex-direction: column; }
}
@media (max-width: 760px) {
  /* Item choices as compact rows: icon left, text right, button under the text. */
  .cards.pick3 .item-card, .shop-grid .item-card { display: grid; grid-template-columns: 68px 1fr; grid-template-rows: auto auto 1fr auto; column-gap: 10px;
    text-align: left; padding: 30px 12px 10px; }
  .cards.pick3 .item-card .item-art, .shop-grid .item-card .item-art { grid-row: 1 / 4; width: 64px; height: 64px; margin: 0; }
  .cards.pick3 .item-card h3, .shop-grid .item-card h3 { margin: 0; font-size: 1.15rem; }
  .cards.pick3 .item-card .skill, .shop-grid .item-card .skill { font-size: .8rem; }
  .shop-grid .ic-foot { grid-column: 2; justify-content: flex-start; margin-top: 4px; }
  .shop-grid { grid-template-columns: 1fr; }
}

/* ---------- Title screen v2: logo + clean menu over the sunset ---------- */
.title2 { min-height: calc(100dvh - 32px); align-items: stretch; }
.t2-front { justify-content: center; min-height: calc(100dvh - 32px); padding: 4vh 0 8vh; gap: 2.5vh; }
.t2-logo { width: min(560px, 86vw); }
.tmenu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 82vw); }
.tmenu-btn { font-family: var(--display); font-size: 1.45rem; letter-spacing: .6px; color: var(--ink); background: rgba(251, 245, 230, .94);
  border: 3px solid var(--ink); border-radius: var(--r); padding: 10px 18px 8px; cursor: pointer; box-shadow: 4px 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .12s; animation: tmIn .45s cubic-bezier(.2, 1.3, .4, 1) both; animation-delay: calc(.25s + var(--i) * 60ms); }
.tmenu-btn.main { background: var(--straw); font-size: 1.7rem; padding: 12px 18px 10px; }
.tmenu-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); background: #fff; }
.tmenu-btn.main:hover { background: #ffd54a; }
.tmenu-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tmenu-btn:focus-visible { outline: none; box-shadow: var(--focus); }
@keyframes tmIn { from { transform: translateY(14px); opacity: 0; } }
.title2 .disclaimer { position: fixed; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; z-index: 2; opacity: .8; }
.ts-ship { left: 4vw; top: calc(var(--hz) - 20vmin); }
@media (max-width: 760px) {
  .t2-front { padding: 6vh 0 12vh; gap: 3vh; }
  .tmenu-btn { font-size: 1.3rem; } .tmenu-btn.main { font-size: 1.5rem; }
  .title2 .disclaimer { background: none; font-size: .66rem; padding: 0 12px; }
  .ts-scene { --hz: 52%; }
}
@media (prefers-reduced-motion: reduce) { .tmenu-btn { animation: none; } }
html.reduce-motion .tmenu-btn { animation: none; }

/* ==========================================================================
   Round 2 — battle, result, gallery, achievements, options, end screen
   ========================================================================== */

/* ---------- Battle ---------- */
.battle-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
.battle-head h2 { margin: 0; flex: 1; min-width: 0; }
.battle-controls { display: flex; gap: 8px; align-items: center; margin: 0; flex-wrap: nowrap; }
.battle-controls .seg.anim b { font-weight: 400; }
.seg.anim { background: #fff; } .seg.anim.on { background: var(--straw); color: var(--ink); }
.arena { border-radius: var(--r); border-width: 3px; height: 460px; }
.arena::before { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; box-shadow: inset 0 0 70px rgba(0, 0, 0, .35); }
.round { font-family: var(--display); border-radius: 14px; padding: 2px 12px; }
/* Nameplates: name + level chip, HP with label, thin energy bar */
.fighter .hud { border-radius: var(--r); padding: 6px 10px 7px; min-width: 210px; }
.hud-top b { font-size: 1.1rem; }
.hud-top span { background: var(--ink); color: #fff; border-radius: 10px; padding: 0 8px; font-size: .85rem; line-height: 1.5; }
.fighter .hud .bar.hp { height: 12px; border-radius: 6px; position: relative; }
.fighter .hud .bar.hp::before { content: "PV"; position: absolute; left: 4px; top: -1px; font-family: var(--display); font-size: .6rem; color: #fff; z-index: 2;
  text-shadow: 1px 1px 0 var(--ink); }
.fighter .hud .bar.hp > i, .fighter .hud .bar.hp > .trail { border-radius: 4px 0 0 4px; }
.fighter .hud .bar.en { height: 6px; border-radius: 3px; margin-top: 4px; }
.hpnum { text-align: right; font-family: var(--display); font-size: .82rem; }
/* Benches as two labelled team strips */
.benches { margin-top: 10px; background: rgba(4, 20, 40, .35); border: 2px solid rgba(255, 255, 255, .12); border-radius: var(--r); padding: 8px 10px; }
.bench-wrap { flex: 1; min-width: 0; }
.bench-wrap.e { text-align: right; }
.bench-l { display: block; font-family: var(--display); color: #dbe8f3; font-size: .85rem; letter-spacing: .5px; margin-bottom: 4px; }
.bench-wrap.e .bench { justify-content: flex-end; }
.mini { border-radius: var(--r); }
/* Log: compact ticker, newest line highlighted */
.battle-log { max-height: 116px; overflow: auto; border-radius: var(--r); border: 3px solid var(--ink); background: var(--paper); box-shadow: 4px 4px 0 var(--ink);
  padding: 6px 10px; margin-top: 10px; font-size: .86rem; line-height: 1.45; }
.battle-log > div { padding: 1px 0 1px 10px; border-left: 3px solid transparent; color: #4b4136; }
.battle-log > div:last-child { border-left-color: var(--red); color: var(--ink); font-weight: 700; }
@media (max-width: 760px) {
  .battle-head { flex-wrap: wrap; }
  .battle-head h2 { font-size: 1.45rem; }
  .arena { height: 330px; }
  .fighter .hud { min-width: 0; }
  .bench-l { font-size: .72rem; }
}

/* ---------- Battle result ---------- */
.result-panel .result { max-width: 640px; margin: 0 auto; text-align: center; padding: 16px 18px 14px; }
.rw-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.rw { display: inline-flex; align-items: center; gap: 4px; font-family: var(--display); font-size: 1.05rem; background: #fff; border: 2px solid var(--ink);
  border-radius: 14px; padding: 2px 12px; box-shadow: 2px 2px 0 var(--ink); }
.rw .ico { width: 18px; height: 18px; }
.lvls { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; text-align: left; margin: 8px 0 4px; }
.lv-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: var(--r);
  padding: 3px 8px 3px 4px; font-size: .82rem; }
.lv-row .sprite.xs { width: 32px; height: 32px; }
.lv-row .lv-n { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-row .lvl { font-family: var(--display); color: var(--red); white-space: nowrap; } .lv-row .lvl b { font-weight: 400; font-size: .7rem; }
.lv-row.ko { opacity: .6; }
.evo-chip { grid-column: 1 / -1; justify-self: start; background: var(--straw); border: 2px solid var(--ink); border-radius: 10px; padding: 0 8px; font-size: .72rem; }
.result-go { margin-top: 10px; }
.result-go .btn.big { font-size: 1.5rem; padding: 8px 36px 6px; }

/* ---------- Gallery ---------- */
.gal-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 4px 0 8px; }
.gal-tabs { border: 3px solid var(--ink); border-radius: var(--r); overflow: hidden; flex: 1; max-width: 460px; box-shadow: 3px 3px 0 var(--ink); }
.gal-tabs .tab small { font-family: var(--body); font-weight: 900; font-size: .72rem; opacity: .7; }
.gal-prog { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; margin-bottom: 14px; }
.gal-prog i { display: block; height: 100%; background: var(--straw); }
.gal-empty { color: #fbe9c4; text-align: center; padding: 30px 0; }
.wgrid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 16px 12px; }

/* ---------- Achievements ---------- */
.ach-wall .cards.ach { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ach-card { position: relative; display: grid; grid-template-columns: 46px 1fr; gap: 10px; align-items: start; padding: 10px 12px; }
.ach-card .ach-seal { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); display: grid; place-items: center; background: #fff3c4; }
.ach-card .ach-seal .ico { width: 30px; height: 30px; }
.ach-card.locked { background: #e4dccb; }
.ach-card.locked .ach-seal { background: #d0c7b4; filter: grayscale(1); }
.ach-txt b { font-family: var(--display); font-weight: 400; font-size: 1.1rem; }
.ach-rw { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .8rem; background: rgba(215, 38, 46, .08); border-radius: var(--r); padding: 3px 6px; }
.ach-rw .sprite.xs { width: 30px; height: 30px; }
.ach-ok { position: absolute; top: 6px; right: 8px; font-family: var(--display); color: #1f8a3a; font-size: 1.3rem; }

/* ---------- Options ---------- */
.modal.settings { max-width: 560px; padding: 16px 18px; }
.set-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.set-head h2 { margin: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 2px dashed rgba(20, 20, 20, .15); }
.set-l { display: flex; flex-direction: column; gap: 2px; }
.set-l b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; }
.set-l span { font-size: .8rem; color: var(--muted); }
.set-c { display: flex; align-items: center; gap: 8px; flex: none; }
.set-c input[type=range] { width: 150px; accent-color: var(--red); }
.set-c output { font-family: var(--display); min-width: 42px; text-align: right; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; font-family: var(--display); font-size: 1rem; }
.switch i { width: 48px; height: 26px; border-radius: 13px; border: 3px solid var(--ink); background: #d8d2c4; position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform .15s; }
.switch.on i { background: var(--straw); } .switch.on i::after { transform: translateX(22px); }
.switch:focus-visible { outline: none; } .switch:focus-visible i { box-shadow: var(--focus); }
@media (max-width: 760px) { .set-row { flex-direction: column; align-items: flex-start; } .set-c input[type=range] { width: 200px; } }

/* ---------- End screen ---------- */
.end-layout { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 24px; align-items: start; padding-top: 8px; }
.end-poster { position: sticky; top: 16px; }
.end-poster .poster-custom, .end-poster .poster { width: 100%; }
.end-kicker { display: inline-block; font-family: var(--display); font-size: .95rem; letter-spacing: 2px; text-transform: uppercase; padding: 2px 12px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); }
.end-kicker.win { background: var(--straw); } .end-kicker.lose { background: var(--red); color: #fff; }
.end-side h2 { margin: 8px 0 4px; font-size: 2.6rem; }
.end-side .end-stats { color: #dbe8f3; margin: 0 0 12px; }
.unlocks { padding: 10px 12px; margin-bottom: 12px; }
.unl-h { font-family: var(--display); font-size: 1.2rem; color: var(--red); margin-bottom: 6px; }
.unl-list { display: flex; flex-wrap: wrap; gap: 8px; }
.unl { display: flex; align-items: center; gap: 6px; background: #fff3c4; border: 2px solid var(--ink); border-radius: var(--r); padding: 2px 10px 2px 2px; }
.unl .sprite.sm { width: 44px; height: 44px; }
.end-side .summary { margin: 0 0 14px; }
.end-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.end-actions .btn.big { font-size: 1.5rem; }
.end-actions kbd { font-size: .8rem; margin-left: 6px; }
@media (max-width: 860px) {
  .end-layout { grid-template-columns: 1fr; }
  .end-poster { position: static; max-width: 340px; margin: 0 auto; }
  .end-side { text-align: center; } .end-actions { align-items: stretch; } .end-actions .row { justify-content: center; }
  .end-side h2 { font-size: 2rem; }
}

.wall .page-head { background: none; margin: 0 0 6px; padding: 0; position: static; }
@media (max-width: 860px) { .end-poster { width: 100%; } }
.modal.settings { text-align: left; }
.modal.settings .set-row { flex-direction: row; align-items: center; text-align: left; }
.modal.settings .set-l { align-items: flex-start; }
@media (max-width: 760px) { .modal.settings .set-row { flex-direction: column; align-items: flex-start; } }

/* ---------- Saga select ---------- */
.saga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 8px; }
.saga-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 14px 16px; cursor: pointer; text-align: center;
  background: linear-gradient(180deg, #fff6d8, var(--paper) 55%); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: 5px 5px 0 var(--ink); transition: transform .1s, box-shadow .1s; font-family: var(--body); }
.saga-card:hover { transform: translate(-2px, -3px); box-shadow: 8px 9px 0 var(--ink); }
.saga-card:focus-visible { outline: none; box-shadow: var(--focus); }
.saga-card.locked { cursor: not-allowed; background: #d9d2c2; }
.saga-card.locked:hover { transform: none; box-shadow: 5px 5px 0 var(--ink); }
.saga-card.locked .sprite img { filter: brightness(0) opacity(.45); }
.sg-num { font-family: var(--display); font-size: .95rem; letter-spacing: 2px; text-transform: uppercase; color: #fff; background: var(--red);
  border: 2px solid var(--ink); border-radius: 12px; padding: 1px 12px; }
.sg-art .sprite.lg { width: 150px; height: 150px; }
.sg-name { font-family: var(--display); font-size: 2rem; line-height: 1; }
.sg-sub { font-size: .9rem; color: var(--muted); font-weight: 700; }
.sg-meta { font-size: .8rem; font-weight: 900; }
.sg-st { margin-top: 6px; font-family: var(--display); font-size: .95rem; padding: 2px 12px; border-radius: 12px; border: 2px solid var(--ink); }
.sg-st.new { background: var(--straw); } .sg-st.done { background: #3fbf5f; color: #fff; } .sg-st.lock, .sg-st.soon { background: #fff; color: var(--muted); }

/* ---------- Map nodes with enemy sprites ---------- */
.node.k-combat, .node.k-rival { width: 12.5%; }
.node.k-rival .node-shadow { background: rgba(215, 38, 46, .3); }

/* ---------- Island map art behind the chart ---------- */
.chart-wrap.has-art { background-color: #1f6fb2; background-position: center; background-size: cover; background-repeat: no-repeat; }
.chart-wrap.has-art::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .28), transparent 18%, transparent 82%, rgba(0, 0, 0, .25)), radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, .3)); }
.chart-wrap.has-art svg.chart { z-index: 1; }
.chart-wrap.has-art .chart .isle, .chart-wrap.has-art .chart .seaking { display: none; }
.chart-wrap.has-art .chart .route { stroke: #fff; opacity: .85; stroke-width: 3; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .9)); }
.chart-wrap.has-art .chart .route.on { stroke: var(--straw); opacity: 1; stroke-width: 4; }
.chart-wrap.has-art .chart .route.ahead { stroke: #9fe0ff; opacity: 1; }
.chart-wrap.has-art .chart .label { fill: #fff; stroke: var(--ink); stroke-width: 6px; paint-order: stroke; }
/* Readability over busy island art: every node sits on a cream token with a coloured ring
   (colour = node kind) and its art gets a white sticker outline, so it never blends in. */
.chart-wrap.has-art .node { --nk: #fff; }
.chart-wrap.has-art .node.k-rival, .chart-wrap.has-art .node.k-elite, .chart-wrap.has-art .node.k-boss { --nk: var(--red); }
.chart-wrap.has-art .node.k-shop, .chart-wrap.has-art .node.k-treasure { --nk: #f2b51d; }
.chart-wrap.has-art .node.k-rest { --nk: #3fbf5f; }
.chart-wrap.has-art .node.k-event { --nk: #3a8de0; }
.chart-wrap.has-art .node.k-recruit { --nk: #b25ad6; }
.chart-wrap.has-art .node:not(.start)::before { content: ''; position: absolute; z-index: 0; left: 7%; right: 7%; top: 14%; bottom: -4%; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(255, 251, 238, .96), rgba(240, 226, 196, .9) 72%);
  border: 2.5px solid var(--ink); box-shadow: 0 0 0 2.5px var(--nk), 0 3px 0 2.5px rgba(0, 0, 0, .5); pointer-events: none; }
.chart-wrap.has-art .node-art { z-index: 1; }
.chart-wrap.has-art .node-shadow { display: none; }
.chart-wrap.has-art .node-art img { filter: drop-shadow(1.5px 0 0 #fff) drop-shadow(-1.5px 0 0 #fff) drop-shadow(0 1.5px 0 #fff) drop-shadow(0 -1.5px 0 #fff)
  drop-shadow(1px 2px 0 rgba(20, 20, 20, .55)); }
.chart-wrap.has-art .node.avail::before { box-shadow: 0 0 0 3px var(--straw), 0 0 14px 4px var(--straw), 0 3px 0 3px rgba(0, 0, 0, .5); }
.chart-wrap.has-art .node.visited::before { opacity: .45; }
.chart-wrap.has-art .node.visited .node-art { filter: grayscale(.9) brightness(.8) opacity(.65); }
/* Node art images (chest, berries, meat, treasure map) */
.node-art img.node-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(2px 3px 0 rgba(20, 20, 20, .55)); }
/* Recruit teaser: silhouette + "?" */
.node.k-recruit .sprite.unknown img { filter: brightness(0) opacity(.75) drop-shadow(0 0 3px #fff); }
.node-q { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); z-index: 3; font-family: var(--display); font-size: 6cqw; color: var(--straw);
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; pointer-events: none; }

/* ---------- Ships ---------- */
.ship-img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(2px 3px 0 rgba(20, 20, 20, .45)); }
.node-ship { position: absolute; width: 95%; aspect-ratio: 1; right: -78%; top: 0; z-index: 4; pointer-events: none; animation: sway 2.4s ease-in-out infinite; }
.node.start .node-ship { right: auto; left: -20%; top: -40%; width: 160%; }
.sailer .node-ship { position: static; width: 100%; }
.sailer { width: 7%; aspect-ratio: 1; transform: translate(-50%, -70%); }
.ship-panel { padding: 10px 12px; }
.ship-row { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.ship-row .sp-art { width: 86px; height: 70px; flex: none; }
.sp-txt { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.sp-txt b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; color: var(--ink); }
.sp-up { font-size: .78rem; font-weight: 900; }
.ship-pick { padding: 10px 12px; display: grid; gap: 6px; }
.sp-list { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-opt { width: 62px; height: 52px; padding: 3px; border: 2.5px solid var(--ink); border-radius: var(--r); background: linear-gradient(180deg, #d9efff, #fff); cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink); transition: transform .08s; }
.sp-opt:hover { transform: translateY(-2px); }
.sp-opt.sel { outline: 3px solid var(--red); outline-offset: 2px; background: #fff3c4; }
.sp-opt.locked { background: #d9d2c2; cursor: not-allowed; }
.sp-opt.locked .ship-img { filter: brightness(0) opacity(.4); }

.item-img { object-fit: contain; display: block; }
.ico.item-img { width: 100%; height: 100%; }

/* ---------- Full illustrations (portraits) ---------- */
.portrait { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.portrait img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); }
.cd-hero .portrait { height: 230px; }
.rc-top .portrait { height: 170px; }
.pc-photo .portrait { position: relative; height: 98%; }
.pc-photo .portrait img { filter: sepia(.12) contrast(1.05) drop-shadow(0 3px 4px rgba(40, 25, 10, .4)); }
.cutin-face .portrait { height: 100%; }
.cutin.enemy .cutin-face .portrait img { transform: scaleX(-1); }
@media (max-width: 760px) { .cd-hero .portrait { height: 120px; } .rc-top .portrait { height: 140px; } }

/* ---------- Portraits in place of sprites (OP.Sprite.art) ---------- */
/* Small boxes show the upper body; big ones the whole illustration. */
.sprite.has-portrait img { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35)); }
.sprite.has-portrait.sm img, .sprite.has-portrait.xs img { width: 100%; height: 100%; max-width: none; max-height: none;
  object-fit: cover; object-position: 50% 6%; border-radius: 6px; filter: none; }
.wcard.tpl .wc-photo .sprite.has-portrait img { border-radius: 0; }
.sprite.has-portrait.unknown img { filter: brightness(0) opacity(.35); }
/* Item artwork in inline spots (ship upgrade pips, map shortcut): same size as the drawn icons. */
.pip .ico { width: 18px; height: 18px; flex: none; }
.map-fab .ico.item-img { width: 30px; height: 30px; }

/* ---------- Post-battle level rows: centred cards with breathing room ---------- */
/* (style.css's `.lvls > div { padding: 2px 0 }` used to win and glue the level to the right border) */
.lvls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.lvls > .lv-row { flex: 0 1 220px; min-width: 0; padding: 5px 14px 5px 5px; gap: 8px; box-shadow: 2px 2px 0 var(--ink); }
.lv-row .lv-n { text-align: left; }
.lv-row .lvl, .lv-row .muted { justify-self: end; }

/* ---------- Gallery: ships ---------- */
.gal-note { margin: 6px 0 10px; color: #f3e7c9; font-size: .9rem; }
.ship-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ship-card { display: flex; gap: 10px; align-items: center; background: var(--paper, #fbf5e6); border: 3px solid var(--ink); border-radius: var(--r);
  box-shadow: 4px 4px 0 var(--ink); padding: 10px 12px; }
.ship-card .sc-art { width: 96px; height: 80px; flex: none; }
.ship-card.locked .sc-art .ship-img { filter: brightness(0) opacity(.4); }
.sc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sc-name { font-family: var(--display); font-size: 1.1rem; line-height: 1.1; }
.sc-tag { align-self: flex-start; font-size: .68rem; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; border: 2px solid var(--ink);
  border-radius: 10px; padding: 0 7px; background: #fff; }
.sc-tag.story { background: #9fd3ff; } .sc-tag.ach { background: var(--straw); }
.sc-desc { font-size: .8rem; }
.sc-how { font-size: .76rem; color: var(--muted); }
.sp-hint { margin-top: 6px; font-size: .76rem; color: var(--muted); }
.ach-ship-img { width: 40px; height: 32px; display: inline-block; flex: none; }
.ach-card.locked .ach-ship-img .ship-img { filter: brightness(0) opacity(.4); }

/* ---------- Main enemy type of an encounter (route choice by type) ---------- */
.node-type { position: absolute; left: 50%; bottom: -12%; transform: translateX(-50%); z-index: 3; pointer-events: none;
  font-family: var(--display); font-size: 2.3cqw; line-height: 1; letter-spacing: .5px; color: #fff; background: var(--tc);
  border: 2px solid var(--ink); border-radius: 8px; padding: 2px 5px 1px; box-shadow: 1px 2px 0 rgba(0, 0, 0, .5); white-space: nowrap; }
.node.k-boss .node-type { bottom: -6%; }
.ni-dom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0 8px; border-bottom: 2px dashed rgba(20, 20, 20, .15); margin-bottom: 4px; font-weight: 900; font-size: .85rem; }
.ni-dom .ni-n { color: var(--muted); font-weight: 700; }
.ni-match { flex-basis: 100%; display: flex; gap: 10px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.ni-match .up { color: #2f8f46; } .ni-match .down { color: var(--red); }
