@font-face { font-family: 'CinzelD'; src: url(../fonts/CinzelDecorative.ttf) format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Cinzel'; src: url(../fonts/Cinzel.ttf) format('truetype'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url(../fonts/Nunito.ttf) format('truetype'); font-weight: 200 1000; font-display: swap; }
:root { --ink: #2a211c; --paper: #fffaf0; --bg: #efe4cf; --red: #c8452f; --red2: #9d2f1f; --gold: #d9a441; --teal: #2f7f7a; --soft: #7a6a5a;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font-family: 'Nunito', system-ui, sans-serif; color: var(--ink); background: var(--bg); user-select: none; -webkit-user-select: none; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,.35) 0 50%, rgba(120,80,40,.06) 50% 100%),
    linear-gradient(45deg, rgba(255,255,255,0) 0 50%, rgba(120,80,40,.05) 50% 100%),
    var(--noise, none); background-size: 100% 100%, 100% 100%, 180px 180px; }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: linear-gradient(90deg, transparent calc(50% - 1px), rgba(120,80,40,.10) 50%, rgba(255,255,255,.4) calc(50% + 1px), transparent calc(50% + 2px)),
              linear-gradient(0deg, transparent calc(50% - 1px), rgba(120,80,40,.08) 50%, rgba(255,255,255,.35) calc(50% + 1px), transparent calc(50% + 2px)); }
#app { position: relative; z-index: 1; height: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: calc(var(--safe-t) + 10px) 14px calc(var(--safe-b) + 12px); animation: unfold .32s ease-out; }
@keyframes unfold { from { opacity: 0; transform: perspective(900px) rotateX(8deg) translateY(12px); } to { opacity: 1; transform: none; } }
h1, h2, h3 { font-family: 'Cinzel', serif; margin: 0; letter-spacing: .02em; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.topbar h2 { flex: 1; text-align: center; font-size: 20px; font-weight: 800; }
.topbar .sp { width: 44px; }
.ib { width: 44px; height: 44px; border-radius: 12px; border: 2.5px solid var(--ink); background: var(--paper); font-size: 20px; font-weight: 900; color: var(--ink); display: grid; place-items: center; box-shadow: 0 3px 0 var(--ink); padding: 0; }
.ib:active, .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ib:disabled { opacity: .35; }
.ib svg { width: 22px; height: 22px; }
.btn { font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 17px; border: 2.5px solid var(--ink); border-radius: 14px; padding: 13px 18px; background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink); position: relative; overflow: hidden; }
.btn.pri { background: var(--red); color: #fff; }
.btn.gold { background: var(--gold); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.sm { font-size: 14px; padding: 9px 12px; border-radius: 11px; box-shadow: 0 3px 0 var(--ink); }
.btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.22) 0 50%, rgba(0,0,0,.06) 50%); pointer-events: none; }
.btn:disabled { opacity: .45; }
.paper { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 rgba(42,33,28,.85); position: relative; background-image: linear-gradient(135deg, rgba(255,255,255,.5) 0 50%, rgba(120,80,40,.05) 50%), var(--noise, none); background-size: 100% 100%, 180px 180px; }
.fold::before { content: ''; position: absolute; top: -2.5px; right: -2.5px; width: 26px; height: 26px; background: linear-gradient(225deg, var(--bg) 0 50%, #e6d6b8 50%); border-left: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); border-radius: 0 14px 0 6px; }

/* title */
.s-title { justify-content: space-between; align-items: center; text-align: center; overflow-y: auto; }
.s-title .logo { margin-top: 2vh; width: 100%; }
.s-title .sword { width: 64%; max-width: 260px; margin: 0 auto; display: block; filter: drop-shadow(0 6px 0 rgba(42,33,28,.18)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(1deg); } }
.s-title .kicker { font-family: 'Cinzel', serif; font-weight: 800; letter-spacing: .3em; font-size: 13px; color: var(--red2); margin-top: 6px; }
.s-title h1 { font-family: 'CinzelD', 'Cinzel', serif; font-size: clamp(30px, 9.5vw, 44px); line-height: 1.02; margin-top: 4px; color: var(--ink); text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(200,69,47,.35); }
.s-title h1 small { display: block; font-size: .5em; letter-spacing: .12em; }
.s-title .sub { color: var(--soft); font-weight: 700; margin: 10px 18px 0; font-size: 15px; }
.menu { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 330px; margin: 18px auto 0; }
.menu .btn { font-size: 19px; padding: 15px; }
.foot { font-size: 12px; color: var(--soft); margin-top: 12px; font-weight: 700; }
.foot b { color: var(--ink); letter-spacing: .06em; }
.crane { position: absolute; width: 54px; opacity: .9; pointer-events: none; }

/* class select */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 6px 14px 20px; }
.hint { text-align: center; color: var(--soft); font-weight: 800; font-size: 14px; margin: 2px 0 8px; }
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ccard { padding: 8px 8px 10px; text-align: center; cursor: pointer; }
.ccard .art { height: 150px; display: flex; justify-content: center; }
.ccard .art svg { height: 100%; }
.ccard h3 { font-size: 16px; font-weight: 900; margin-top: 2px; }
.ccard p { margin: 3px 0 0; font-size: 12.5px; line-height: 1.25; color: #5a4b3e; font-weight: 700; }
.ccard:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(42,33,28,.85); }

/* gender */
.ggrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }
.gcard { padding: 10px; text-align: center; cursor: pointer; }
.gcard .art svg { width: 100%; height: auto; display: block; }
.gcard h3 { font-size: 20px; margin: 4px 0 2px; }
.ctitle { text-align: center; margin: 4px 0 4px; }
.ctitle h3 { font-size: 26px; font-weight: 900; }
.ctitle p { margin: 4px 0 0; color: #5a4b3e; font-weight: 700; }

/* coloring */
.s-color .stage { flex: 1; min-height: 0; position: relative; margin: 4px 0 6px; padding: 0; overflow: hidden; }
.stage .zoomer { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; }
.stage .zoomer svg { height: 100%; width: 100%; margin: auto; display: block; touch-action: manipulation; }
.stage.z2 .zoomer svg { height: 200%; width: 200%; flex: none; }
.stage.z3 .zoomer svg { height: 300%; width: 300%; flex: none; }
.stage .rg { cursor: pointer; transition: fill .18s; }
.stage .rg.flash { animation: flash .45s; }
@keyframes flash { 30% { stroke-width: 6px; } }
.stage .tag { position: absolute; left: 10px; top: 8px; font-weight: 900; font-size: 13px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px; pointer-events: none; opacity: 0; transition: opacity .2s; }
.stage .tag.on { opacity: 1; }
.stage .zbtn { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; font-size: 15px; }
.stage .prog { position: absolute; left: 10px; bottom: 10px; font-weight: 900; font-size: 12px; color: var(--soft); pointer-events: none; }
.parts { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -14px; padding-left: 14px; scrollbar-width: none; }
.parts::-webkit-scrollbar, .presets::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; padding: 6px 10px 6px 6px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); white-space: nowrap; }
.chip i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); display: block; }
.chip.sel { background: var(--ink); color: #fff; }
.pal { padding: 8px 8px 8px; border-radius: 14px; }
.modes { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.seg { display: flex; border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden; flex: none; background: #fff; }
.seg button { display: flex; align-items: center; gap: 5px; border: 0; background: #fff; color: var(--ink); font: 900 13px 'Nunito', sans-serif; padding: 5px 12px; }
.seg button + button { border-left: 2.5px solid var(--ink); }
.seg button.sel { background: var(--red); color: #fff; }
.sizes { display: none; gap: 5px; margin-left: auto; }
.pal.brushmode .sizes { display: flex; }
.sizes button { width: 34px; height: 34px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; display: grid; place-items: center; padding: 0; }
.sizes button i { display: block; border-radius: 50%; background: var(--ink); }
.sizes button.sel { background: var(--gold); }
.stage.brush { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.stage.brush .zoomer { touch-action: none; overscroll-behavior: contain; }
.stage.brush .zoomer svg { touch-action: none; cursor: crosshair; }
.stage.brush .rg { cursor: crosshair; }
.presets { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.presets button { flex: none; font: 800 12.5px 'Nunito', sans-serif; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 10px; background: #fff; color: var(--ink); }
.presets button.sel { background: var(--red); color: #fff; }
.sw { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.sw button { aspect-ratio: 1; border: 2.5px solid var(--ink); border-radius: 9px; padding: 0; position: relative; box-shadow: inset -3px -3px 0 rgba(0,0,0,.12); }
.sw button.sel { transform: scale(1.12); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5.5px var(--ink); z-index: 1; }
.tools { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.tools .cur { width: 44px; height: 44px; border-radius: 12px; border: 2.5px solid var(--ink); flex: none; position: relative; overflow: hidden; }
.tools .cur input { position: absolute; inset: -10px; width: 70px; height: 70px; opacity: 0; }
.tools .cur span { position: absolute; right: 1px; bottom: 0; font-size: 13px; font-weight: 900; background: #fff; border-radius: 6px 0 0 0; padding: 0 3px; border-left: 2px solid var(--ink); border-top: 2px solid var(--ink); }
.tools .ib { width: 42px; height: 42px; flex: none; }
.tools .ib.on { background: var(--gold); }
.tools .grow { flex: 1; }
.tools .btn { flex: 1; padding: 10px 8px; font-size: 16px; }
.lbl { font-size: 10px; font-weight: 900; display: block; line-height: 1; margin-top: 1px; }
.ib.wide { width: auto; padding: 0 8px; display: flex; gap: 4px; }

/* name */
.namebox { padding: 14px; margin-top: 8px; }
.namebox label { font-weight: 900; font-size: 14px; color: var(--soft); }
.namerow { display: flex; gap: 8px; margin-top: 6px; }
.namerow input { flex: 1; min-width: 0; font: 900 22px 'Nunito', sans-serif; border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--ink); user-select: text; -webkit-user-select: text; }
.nprev { flex: 1; min-height: 0; display: flex; justify-content: center; margin: 10px 0; }
.nprev svg { height: 100%; }

/* hero card */
.card { margin: 6px auto 0; width: 100%; max-width: 360px; padding: 12px 12px 14px; text-align: center; background: #fffdf6; overflow: hidden; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card .band { height: 10px; margin: -12px -12px 8px; background: repeating-linear-gradient(135deg, var(--red) 0 12px, var(--red2) 12px 24px); border-bottom: 2.5px solid var(--ink); }
.card .portrait { flex: 1; min-height: 0; border: 2.5px solid var(--ink); border-radius: 12px; display: flex; justify-content: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--c1, #f6e7c8) 0 50%, var(--c2, #ecd8b2) 50%), #f6e7c8; }
.card .portrait::before { content: ''; position: absolute; inset: 0; background: linear-gradient(45deg, rgba(255,255,255,.25) 0 50%, rgba(0,0,0,.04) 50%); }
.card .portrait svg { height: 100%; position: relative; }
.card h2 { font-family: 'CinzelD', 'Cinzel', serif; font-size: 28px; margin-top: 10px; overflow-wrap: anywhere; }
.card .cls { font-weight: 900; color: var(--red2); letter-spacing: .14em; font-size: 13px; text-transform: uppercase; margin-top: 2px; }
.card .meta { font-size: 12px; color: var(--soft); font-weight: 800; margin-top: 4px; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1; padding: 12px 6px; font-size: 15px; }

/* heroes */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot { padding: 8px; text-align: center; min-height: 196px; display: flex; flex-direction: column; cursor: pointer; }
.slot .art { flex: 1; height: 136px; display: flex; justify-content: center; }
.slot .art svg { height: 136px; }
.slot h3 { font-size: 15px; font-weight: 900; font-family: 'Nunito', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot p { margin: 0; font-size: 12px; color: var(--soft); font-weight: 800; }
.slot.empty { border-style: dashed; background: rgba(255,250,240,.55); justify-content: center; align-items: center; color: var(--soft); font-weight: 900; box-shadow: none; }
.slot.empty b { font-size: 40px; line-height: 1; }
.codebox { padding: 12px; margin-top: 14px; font-size: 13.5px; font-weight: 700; }
.codebox .code { font: 900 22px 'Nunito', monospace; letter-spacing: .12em; margin: 4px 0; }
.codebox input { font: 900 16px 'Nunito', sans-serif; border: 2px solid var(--ink); border-radius: 10px; padding: 8px; width: 130px; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.sync { font-size: 12px; font-weight: 800; color: var(--soft); }

#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 64px); transform: translateX(-50%) translateY(-20px); background: var(--ink); color: #fff; font-weight: 800; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 50; pointer-events: none; max-width: 90%; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
.modal { position: fixed; inset: 0; background: rgba(42,33,28,.45); z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal .paper { padding: 18px; max-width: 340px; width: 100%; text-align: center; }
.modal h3 { font-size: 20px; }
.modal p { font-weight: 700; color: #5a4b3e; }
@media (max-height: 700px) { .ccard .art { height: 120px; } .sw { gap: 4px; } }

.s-title .lineup { display: flex; justify-content: center; gap: 0; margin: 8px 0 0; height: 17vh; max-height: 150px; }
.s-title .lineup div { height: 100%; margin: 0 -10px; }
.s-title .lineup svg { height: 100%; }

/* v4 smooth cut-paper sprites */
svg.sprite.cut { shape-rendering: geometricPrecision; }
.backup .brow { display: flex; gap: 8px; margin-top: 8px; }
.backup .brow .btn { flex: 1; }
.modal textarea.stext { width: 100%; height: 110px; margin: 6px 0 10px; font: 600 12px monospace; border: 2px solid var(--ink); border-radius: 10px; padding: 8px; resize: none; user-select: text; -webkit-user-select: text; word-break: break-all; box-sizing: border-box; }

/* stat distribution */
.stathead { display: flex; gap: 10px; padding: 8px 10px; margin-top: 4px; align-items: stretch; }
.stathead .spic { width: 104px; flex: none; height: 142px; border: 2.5px solid var(--ink); border-radius: 12px; overflow: hidden; display: flex; justify-content: center; background: linear-gradient(135deg, var(--c1, #f6e7c8) 0 50%, var(--c2, #ecd8b2) 50%); }
.stathead .spic svg { height: 100%; }
.stathead .sinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.scls { font-weight: 900; color: var(--red2); letter-spacing: .12em; font-size: 12px; text-transform: uppercase; }
.pts { display: flex; align-items: baseline; gap: 6px; }
.pts b { font: 900 38px/1 'CinzelD', 'Cinzel', serif; color: var(--red); text-shadow: 2px 2px 0 #fff; min-width: 38px; }
.pts span { font-weight: 900; font-size: 12.5px; color: var(--soft); }
.pts.zero b { color: var(--teal); }
.live label { font-weight: 900; font-size: 11px; color: var(--soft); letter-spacing: .1em; text-transform: uppercase; }
#hearts, .chearts { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-height: 22px; }
.hearts { display: inline-flex; flex-wrap: wrap; gap: 1px; }
.h { position: relative; width: 20px; height: 20px; display: inline-block; }
.h svg { width: 100%; height: 100%; display: block; }
.h.half .fillh { position: absolute; left: 0; top: 0; width: 50%; height: 100%; overflow: hidden; }
.h.half .fillh svg { width: 20px; height: 20px; }
.hn { font-weight: 900; font-size: 13px; margin-left: 5px; }
.live2 { display: flex; gap: 6px; flex-wrap: wrap; }
.live2 span { font-weight: 900; font-size: 12px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 8px; }
.legend { font-weight: 800; font-size: 11.5px; color: var(--soft); text-align: center; margin: 9px 0 2px; }
.cost { display: inline-block; font-weight: 900; font-size: 12px; min-width: 24px; text-align: center; padding: 2px 7px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; flex: none; }
.cost.c1 { background: var(--gold); box-shadow: 0 0 0 2px #fff0c4; }
.srows { padding-top: 6px; }
.srow { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px 8px 6px; margin-bottom: 7px; box-shadow: 0 3px 0 rgba(42,33,28,.8); }
.srow.pro { background: #fff3cf; border-color: #7a5a10; }
.srow .top { display: flex; align-items: center; gap: 7px; }
.sico { width: 30px; height: 30px; flex: none; }
.srow .nm { flex: 1; min-width: 0; font-weight: 900; font-size: 15.5px; line-height: 1.05; display: flex; flex-direction: column; }
.grow { font-style: normal; font-weight: 800; font-size: 10.5px; color: var(--teal); letter-spacing: .02em; }
.pm { width: 38px; height: 36px; border-radius: 10px; border: 2.5px solid var(--ink); background: var(--paper); font: 900 24px/1 'Nunito', sans-serif; color: var(--ink); padding: 0; box-shadow: 0 3px 0 var(--ink); flex: none; }
.pm[data-act=plus] { background: var(--teal); color: #fff; }
.pm:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.pm:disabled { opacity: .3; box-shadow: none; transform: none; }
.srow .val { font: 900 22px 'Nunito', sans-serif; min-width: 26px; text-align: center; }
.srow .desc { font-weight: 700; font-size: 11.5px; color: var(--soft); margin: 2px 0 0 37px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sfoot { margin-top: 6px; }
.sfoot .btn { padding: 11px 4px; font-size: 14px; }
.sfoot .btn:nth-child(2) { flex: 1.5; }
/* card stats */
.cstats { margin-top: 8px; border-top: 2px dashed rgba(42,33,28,.35); padding-top: 7px; }
.chearts { justify-content: center; }
.cgrid8 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 6px; }
.cs { display: flex; align-items: center; gap: 3px; background: #fff; border: 2px solid var(--ink); border-radius: 9px; padding: 2px 4px; font-weight: 900; font-size: 10.5px; }
.cs .sico { width: 17px; height: 17px; }
.cs span { flex: 1; text-align: left; letter-spacing: -.01em; }
.cs b { font-size: 14px; }
.cs.pro { background: #fff3cf; border-color: #7a5a10; }
.cextra { font-weight: 800; font-size: 11.5px; color: var(--soft); margin-top: 6px; }
.cextra em { color: var(--red2); font-style: normal; }

/* ---------- battle cards + training ---------- */
.btn.purple { background: #6b4fa8; color: #fff; }
.s-title .menu .btn.teal { margin-top: 2px; }
.tfilter { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.tfilter .chip { flex: none; padding: 6px 12px; }
.cardgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 2px 2px 10px; }
.gcard, .hcard { border: 0; background: none; padding: 0; position: relative; aspect-ratio: 47.6 / 66.4; border-radius: 6px; }
.gcard.hide { display: none; }
.gcard .cslot, .hcard .cslot { width: 100%; height: 100%; }
.gcard:not(.ready) .cslot, .hcard:not(.ready) .cslot { background: repeating-linear-gradient(45deg, #f4ead6 0 6px, #efe2c8 6px 12px); border: 2px dashed #c9b48e; border-radius: 6px; }
.gcard svg, .hcard svg { width: 100%; height: 100%; display: block; }
.gcard:active { transform: scale(.97); }
.dummybox { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 4px 2px 16px; cursor: pointer; }
.dummybox .dart { width: 92px; flex: none; }
.dummybox .dart svg { width: 100%; display: block; }
.dummybox h3 { font-size: 18px; }
.dummybox p { margin: 4px 0 0; font-size: 14px; }
.stage.k-card .zoomer svg { max-height: 100%; }
.s-deck .scroll { padding-top: 10px; }
.tset { display: none; padding: 10px 12px; }
.tset.on { display: block; }
.tsrow { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; font-weight: 800; font-size: 15px; }
.tsrow label { display: flex; align-items: center; gap: 6px; }
.tsrow .sico { width: 20px; height: 20px; }
.pmr { display: flex; align-items: center; gap: 8px; }
.pmr b { min-width: 26px; text-align: center; font-size: 17px; }
.tog { font: 900 14px Nunito, sans-serif; border: 2.5px solid var(--ink); border-radius: 999px; padding: 5px 14px; background: #fffdf8; min-width: 62px; }
.tog.on { background: var(--teal); color: #fff; }
.tsnote { font-size: 12.5px; opacity: .75; margin: 6px 0 8px; }
.ll { padding: 2px 0; border-bottom: 1px dashed rgba(42,33,28,.15); }
.ll.k-round { font-weight: 900; color: #6b4fa8; margin-top: 4px; }
.ll.k-play { font-weight: 800; }
.ll.k-dmg { color: #9a2a1d; } .ll.k-heal { color: #2f7a40; } .ll.k-miss { color: #666; font-style: italic; } .ll.k-sys, .ll.k-ko { font-weight: 900; }

/* ---------- v9: deck builder + paper-diorama battle stage ---------- */
.modal .row { flex-wrap: wrap; }
.modal .row .btn { flex: 1 1 40%; }
.modal .row .btn small { font-weight: 700; opacity: .75; }
.sheetcard { width: 150px; margin: 8px auto 10px; }
.sheetcard svg { width: 100%; display: block; }
.modal .paper p { max-height: 60vh; overflow-y: auto; }
.dkbtn { padding: 8px 12px; }
.btn small { font-weight: 800; opacity: .8; font-size: 12px; }
.dkhead { display: flex; gap: 10px; padding: 8px 10px; background: linear-gradient(180deg, var(--c1, #f6e1c4), var(--c2, #ecd0a8)); align-items: center; }
.dkpic { width: 74px; flex: none; }
.dkpic svg { width: 100%; display: block; }
.dkinfo { flex: 1; min-width: 0; }
.dkname { font: 900 16px Nunito, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dkname span { font-weight: 700; font-size: 12px; opacity: .7; margin-left: 4px; }
.dkcount { font: 900 30px 'Cinzel', serif; line-height: 1.05; }
.dkcount b { font-size: 34px; }
.dkcount.full { color: #2f8f5a; }
.dkbar { height: 8px; border: 2px solid var(--ink); border-radius: 6px; background: #fffdf8; overflow: hidden; margin: 2px 0 6px; }
.dkbar i { display: block; height: 100%; background: var(--teal); transition: width .2s; }
.dkrow { display: flex; gap: 6px; }
.dkrow .btn { flex: 1; padding: 7px 4px; font-size: 13px; }
.dktabs { display: flex; gap: 6px; margin: 8px 0 4px; }
.dktabs button { flex: 1; font: 900 14px Nunito, sans-serif; border: 2.5px solid var(--ink); border-radius: 12px; padding: 7px 4px; background: var(--paper); }
.dktabs button.on { background: var(--ink); color: #fff; }
.dktabs small { opacity: .75; font-weight: 800; }
.dgrid { gap: 10px 8px; }
.dcard { position: relative; }
.dcard.hide { display: none; }
.dcard .dart { display: block; width: 100%; aspect-ratio: 47.6 / 66.4; border: 0; padding: 0; background: none; position: relative; -webkit-touch-callout: none; }
.dcard .dart svg { width: 100%; height: 100%; display: block; }
.dcard .cslot { width: 100%; height: 100%; }
.dcard:not(.ready) .cslot { background: repeating-linear-gradient(45deg, #f4ead6 0 6px, #efe2c8 6px 12px); border: 2px dashed #c9b48e; border-radius: 6px; }
.dcard:not(.in) .dart { opacity: .8; }
.dcard.in .dart::after { content: ''; position: absolute; inset: -2px; border: 3px solid var(--teal); border-radius: 8px; pointer-events: none; }
.dbadge { position: absolute; top: -5px; right: -4px; font: 900 13px Nunito, sans-serif; background: var(--teal); color: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 0 6px; font-style: normal; z-index: 2; }
.dbadge:empty { display: none; }
.dctl { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.dctl .pm { width: 34px; height: 30px; font-size: 20px; }
.dctl .dn { font: 900 13px Nunito, sans-serif; }
.dctl .pm:disabled { opacity: .35; }
.dkempty { text-align: center; padding: 20px; }
.tsrow.col { flex-direction: column; align-items: stretch; gap: 4px; }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; font: 900 12px Nunito, sans-serif; border: 2.5px solid var(--ink); border-radius: 10px; padding: 6px 2px; background: #fffdf8; }
.seg button.on { background: var(--teal); color: #fff; }
/* the stage: a 16:9 paper diorama, hero left, enemies right */
.abg, .abg svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
@keyframes bob { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-2.5%) scaleY(1.015); } }
.ll.k-reshuffle { background: #ffeeb8; border: 2px solid #c9972b; border-radius: 8px; padding: 3px 8px; font-weight: 900; color: #7a4d00; margin: 4px 0; }

/* =====================================================================================================================
   v10: LANDSCAPE. The game is played with the phone tilted (manifest: landscape). Portrait shows a "rotate" card.
   ===================================================================================================================== */
:root { --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }
html, body { -webkit-touch-callout: none; }
#rotate { display: none; position: fixed; inset: 0; z-index: 100; place-items: center; padding: 24px; background: var(--bg); }
#rotate .paper { padding: 22px 24px 20px; max-width: 320px; text-align: center; }
#rotate svg { width: 120px; height: 120px; display: block; margin: 0 auto 6px; }
#rotate .ph { transform-origin: 50% 50%; animation: tilt 2.6s ease-in-out infinite; }
@keyframes tilt { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
#rotate h2 { font-size: 24px; font-family: 'CinzelD', 'Cinzel', serif; }
#rotate p { margin: 8px 0 0; font-weight: 800; color: #5a4b3e; line-height: 1.35; }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: grid; } #app, #toast, .modal { visibility: hidden; } }
.fsbtn { position: absolute; right: calc(var(--safe-r) + 10px); top: calc(var(--safe-t) + 8px); z-index: 3; }
.ico { width: 20px; height: 20px; }

/* ---- battle UI (all sizes) ---- */
.s-train { padding: 0 !important; position: relative; overflow: hidden; animation: none; }
.arena { position: absolute; inset: 0; overflow: hidden; background: #8fd3f2; touch-action: manipulation; --uh: clamp(60px, 26vh, 138px); --cw: clamp(58px, 19vh, 94px); --ch: calc(var(--cw) * 1.395); }
.abg, .abg svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.drift { animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateX(-16px); } to { transform: translateX(16px); } }
.units { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.unit { position: absolute; transform: translate(-50%, -100%); text-align: center; pointer-events: auto; }
.unit .uart svg { height: calc(var(--uh) * var(--k, 1)); width: auto; display: block; margin: 0 auto; animation: ubob 2.8s ease-in-out infinite; transform-origin: 50% 100%; }
.unit.u-foe .uart svg { animation-duration: 3.5s; animation-delay: -1.1s; }
@keyframes ubob { 0%, 100% { transform: translateY(0) scaleY(1); } 50% { transform: translateY(-2.5%) scaleY(1.015); } }
.unit.ko .uart svg { animation: none; opacity: .45; filter: grayscale(.8); transform: rotate(-8deg); }
.unit.ko .ulabel .uchips { display: none; }
.unit.u-foe { cursor: pointer; }
.unit.hurt .uart svg { animation: hurt .4s linear; }
@keyframes hurt { 20% { transform: translateX(-4px); filter: brightness(1.5); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }
.ulabel { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 1px; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 124px; pointer-events: none; }
.uname { font: 900 10.5px/1.1 Nunito, sans-serif; color: var(--ink); background: rgba(255,250,240,.92); border: 1.6px solid var(--ink); border-radius: 7px; padding: 0 6px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ebar { position: relative; width: 70px; height: 12px; border: 2px solid var(--ink); border-radius: 7px; background: #fffdf8; overflow: hidden; }
.ebar i { display: block; height: 100%; background: #e0533a; transition: width .35s; }
.u-hero .ebar i { background: #3f9d52; }
.ebar .hpn { position: absolute; inset: 0; display: grid; place-items: center; font: 900 9px/1 Nunito, sans-serif; color: #fff; -webkit-text-stroke: 2.4px var(--ink); paint-order: stroke fill; }
.uchips { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.st { font: 900 9px Nunito, sans-serif; border: 1.5px solid var(--ink); border-radius: 6px; padding: 0 4px; background: #fff; white-space: nowrap; }
.st i { font-style: normal; margin-left: 3px; background: var(--ink); color: #fff; border-radius: 5px; padding: 0 3px; }
.st-bleed, .st-rage, .st-rageArmed { background: #f2b3a8; } .st-stun, .st-immobilize, .st-sleep { background: #f6dc8c; }
.st-guard, .st-dodge, .st-stealth { background: #bcd8ef; } .st-bless, .st-rally, .st-agility, .st-pp, .st-prep { background: #c9e6b9; }
.st-weaken, .st-blind, .st-slow, .st-undead { background: #d6c9ec; }
.scan { font: 800 9px Nunito, sans-serif; background: #fffdf8; border: 1.5px dashed var(--ink); border-radius: 6px; padding: 1px 4px; white-space: nowrap; }
.tmark { position: absolute; left: 50%; bottom: calc(100% + 40px); width: 0; height: 0; margin-left: -9px; border: 9px solid transparent; border-top: 13px solid #e0533a; border-bottom: 0; filter: drop-shadow(0 1.5px 0 var(--ink)); display: none; animation: pt .8s ease-in-out infinite; }
.unit.tgt .tmark { display: block; }
@keyframes pt { 50% { transform: translateY(4px); } }
.unit.tgt .uname { background: #ffe58a; }
.fnum { position: absolute; left: 50%; top: 5%; transform: translateX(-50%); font: 900 26px 'Nunito', sans-serif; color: #c8261b; -webkit-text-stroke: 5px #fff; paint-order: stroke fill; text-shadow: 0 2px 0 rgba(0,0,0,.3); pointer-events: none; opacity: 0; animation: fnum 1.4s ease-out forwards; z-index: 5; white-space: nowrap; }
.fnum.heal { color: #2f9a4a; } .fnum.miss { color: #555; font-size: 18px; }
@keyframes fnum { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -46px) scale(1); } }

/* floating HUD */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 5px) calc(var(--safe-r) + 8px) 0 calc(var(--safe-l) + 8px); pointer-events: none; z-index: 6; }
.hud > * { pointer-events: auto; }
.hud .hdeck { margin: 0 auto; }
.pill { background: rgba(255,250,240,.92); border: 2px solid var(--ink); border-radius: 10px; padding: 1px 7px; font: 900 11px Nunito, sans-serif; display: flex; align-items: center; gap: 4px; white-space: nowrap; box-shadow: 0 2px 0 rgba(42,33,28,.6); }
.ib.mini { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); flex: none; background: rgba(255,250,240,.92); }
.ib.mini svg { width: 18px; height: 18px; }
.hud .hearts { display: inline-flex; gap: 1px; }
.hud .hearts .h { width: 14px; height: 14px; }
.hud .hearts .h.half .fillh svg { width: 14px; height: 14px; }
.hud .hpn { font: 900 11px Nunito, sans-serif; opacity: .85; }
.hud .hcoin .sico { width: 15px; height: 15px; }
.hdeck .dn, .hdeck .dd { font-weight: 900; }
.turn { position: absolute; left: 50%; top: calc(var(--safe-t) + 44px); transform: translateX(-50%); z-index: 5; pointer-events: none; font-size: 11.5px; }
.turn.win { color: #2f8f5a; } .turn.lose { color: var(--red2); }
.cinfo { position: absolute; left: 50%; top: calc(var(--safe-t) + 68px); transform: translateX(-50%); z-index: 5; max-width: 62%; text-align: center; font: 800 11.5px/1.25 Nunito, sans-serif; background: rgba(255,250,240,.88); border: 2px solid var(--ink); border-radius: 9px; padding: 1px 8px; pointer-events: none; }
.cinfo:empty { display: none; }
.cinfo .why { color: var(--red2); font-weight: 900; }
.banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 12; background: #ffeeb8; border: 3px solid #c9972b; border-radius: 12px; padding: 8px 16px; font: 900 15px Nunito, sans-serif; color: #7a4d00; box-shadow: 0 4px 0 rgba(42,33,28,.5); animation: banner 3.2s ease-out forwards; pointer-events: none; text-align: center; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
/* compact floating action buttons on the right edge */
.tact { position: absolute; right: calc(var(--safe-r) + 8px); top: 50%; transform: translateY(-46%); display: flex; flex-direction: column; gap: 7px; z-index: 6; width: 76px; }
.tact .btn { padding: 7px 4px; font-size: 14px; border-radius: 11px; box-shadow: 0 3px 0 var(--ink); }
.tact .btn[data-act=play] { padding: 11px 4px; font-size: 16px; }
.tact .btn:disabled { opacity: .6; filter: saturate(.7); }
/* panels: settings + battle log float over the stage */
.arena .tset, .arena .tlog { position: absolute; top: calc(var(--safe-t) + 44px); right: calc(var(--safe-r) + 8px); z-index: 9; margin: 0; display: none; overflow-y: auto; }
.arena .tset { width: min(560px, calc(100% - 16px - var(--safe-l) - var(--safe-r))); max-height: calc(100% - var(--safe-t) - 52px); padding: 8px 12px; }
.arena .tset.on { display: block; }
.tset .tcols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.tset .tsrow { padding: 2px 0; font-size: 13px; }
.tset .tsnote { margin: 4px 0 6px; font-size: 11px; }
.tset .row { margin-top: 4px; }
.tset .row .btn { padding: 6px 8px; font-size: 13px; }
.tset .pm { width: 28px; height: 28px; }
.arena .tlog { width: min(380px, 52%); max-height: calc(100% - var(--safe-t) - 52px); padding: 7px 10px; }
.arena .tlog.on { display: block; }
.tlh { font: 900 13px 'Cinzel', serif; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.tlh span { font: 700 11px Nunito, sans-serif; opacity: .7; }
.tlog .lines { max-height: calc(100vh - 110px); overflow-y: auto; font-size: 12px; line-height: 1.3; }
.seg.n3 button { min-width: 34px; padding: 3px 8px; }
/* the hand: fanned along the bottom edge, only the top half shows */
.hand { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--ch) + 16px); overflow-x: auto; overflow-y: hidden; pointer-events: none; z-index: 8; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hand::-webkit-scrollbar { display: none; }
.hfan { position: relative; height: 100%; min-width: 100%; }
.hcard { position: absolute; bottom: 0; width: var(--cw); pointer-events: auto; --ty: 53%; --rot: 0deg; --dy: 0px; transform: translateY(calc(var(--ty) + var(--dy))) rotate(var(--rot)); transform-origin: 50% 130%; transition: transform .16s ease-out; touch-action: pan-x; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; filter: drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.hcard.sel { --ty: 4%; z-index: 30; filter: drop-shadow(0 0 0 #e0533a) drop-shadow(0 0 5px rgba(224,83,58,.9)) drop-shadow(0 4px 4px rgba(0,0,0,.3)); }
.hcard svg, .hcard .cslot { pointer-events: none; -webkit-user-drag: none; }
/* press-and-hold detail popup */
.detail { position: absolute; inset: 0; z-index: 20; background: rgba(30,22,16,.62); display: flex; align-items: center; justify-content: center; gap: 18px; padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 20px) 10px calc(var(--safe-l) + 20px); }
.detail[hidden] { display: none; }
.detail .dbig { height: min(88%, 340px); aspect-ratio: 47.6 / 66.4; filter: drop-shadow(0 6px 8px rgba(0,0,0,.5)); animation: pop .16s ease-out; }
.detail .dbig svg { width: 100%; height: 100%; display: block; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.detail .dinfo { width: min(330px, 52%); max-height: 92%; overflow: hidden; padding: 12px 14px; text-align: left; animation: pop .16s ease-out; }
.detail h3 { font-size: 22px; margin: 2px 0 4px; }
.detail .ddesc { margin: 0 0 6px; font-weight: 700; font-size: 13.5px; line-height: 1.3; color: #3d3027; }
.detail .dtype { display: inline-block; font: 900 10.5px Nunito, sans-serif; letter-spacing: .12em; text-transform: uppercase; background: var(--ink); color: #fff; border-radius: 999px; padding: 1px 9px; }
.detail .dtype.t-weapon { background: #b8352a; } .detail .dtype.t-defense { background: #2f5fa8; } .detail .dtype.t-spell { background: #6b4fa8; } .detail .dtype.t-prayer { background: #b98a10; } .detail .dtype.t-buff { background: #2f8f5a; } .detail .dtype.t-enhancer { background: #2f7f7a; } .detail .dtype.t-combo { background: #7a5a3a; }
.detail .dmath { background: #fff; border: 2px dashed var(--ink); border-radius: 10px; padding: 5px 8px; font: 700 12px/1.3 Nunito, sans-serif; }
.detail .dmath b { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); margin-bottom: 1px; }
.detail .dtotal { font: 900 26px 'Cinzel', serif; color: var(--red2); margin-top: 3px; }
.detail .dhint { font: 800 11px Nunito, sans-serif; color: var(--soft); margin-top: 2px; }

/* ---- landscape layouts for every screen ---- */
@media (orientation: landscape) {
  #app { max-width: none; }
  .screen { padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 14px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 14px); }
  .topbar { min-height: 42px; }
  .topbar h2 { font-size: 18px; }
  .topbar .sp { width: 40px; }
  .ib { width: 40px; height: 40px; }
  .btn { padding: 9px 14px; font-size: 15px; }
  .row { margin-top: 8px; }
  .row .btn { padding: 9px 6px; font-size: 14px; }
  .hint { margin: 0 0 4px; font-size: 13px; }
  .scroll { margin: 0 calc(-14px - var(--safe-r)) 0 -14px; padding: 4px calc(14px + var(--safe-r)) 14px 14px; }
  .chip { padding: 5px 9px 5px 5px; font-size: 12.5px; }
  /* title: logo + lineup left, menu right */
  .s-title { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto; grid-template-areas: "logo menu" "lineup menu" "lineup foot"; column-gap: 24px; align-items: center; text-align: left; overflow: hidden; }
  .s-title .logo { grid-area: logo; display: grid; grid-template-columns: 84px 1fr; column-gap: 14px; align-items: center; margin: 0; align-self: end; }
  .s-title .logo .sword { grid-row: 1 / 5; width: 84px; margin: 0; }
  .s-title .logo .kicker { margin: 0; font-size: 11px; }
  .s-title .logo h1 { font-size: clamp(26px, 8.4vh, 40px); margin-top: 2px; }
  .s-title .logo .sub { margin: 6px 0 0; font-size: 13px; }
  .s-title .lineup { grid-area: lineup; height: 100%; max-height: 150px; margin: 0; align-self: center; justify-content: flex-start; }
  .s-title .menu { grid-area: menu; margin: 0; max-width: none; gap: 9px; align-self: center; }
  .s-title .menu .btn { font-size: 17px; padding: 11px; }
  .s-title .foot { grid-area: foot; margin: 6px 0 0; text-align: center; align-self: end; }
  .crane { width: 44px; }
  /* class + look select */
  .cgrid { grid-template-columns: repeat(4, 1fr); gap: 9px; }
  .ccard .art { height: clamp(78px, 24vh, 112px); }
  .ccard p { font-size: 11.5px; }
  .ctitle { margin: 0 0 2px; } .ctitle h3 { font-size: 20px; } .ctitle p { margin: 2px 0 0; font-size: 13px; }
  .ggrid { grid-template-columns: repeat(2, minmax(0, 210px)); justify-content: center; gap: 18px; margin-top: 2px; }
  .gcard .art svg { height: 31vh; width: auto; margin: 0 auto; }
  .gcard h3 { font-size: 17px; margin: 2px 0 0; }
  .s-gender .hint { margin-top: 6px !important; }
  /* coloring: art left, parts + palette right */
  .s-color { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.3fr); grid-template-rows: auto auto 1fr; grid-template-areas: "top top" "stage parts" "stage pal"; column-gap: 12px; row-gap: 5px; }
  .s-color .topbar { grid-area: top; } .s-color .stage { grid-area: stage; margin: 0; } .s-color .parts { grid-area: parts; margin: 0; padding: 0 0 4px; } .s-color .pal { grid-area: pal; align-self: start; overflow: auto; max-height: 100%; }
  .s-color .pal { padding: 6px; } .presets { margin-bottom: 5px; } .tools { margin-top: 6px; } .tools .ib { width: 38px; height: 38px; } .tools .cur { width: 40px; height: 40px; } .tools .btn { padding: 8px; }
  .sw { gap: 4px; } .sw button { border-radius: 8px; border-width: 2px; }
  .modes { margin-bottom: 4px; } .seg button { padding: 3px 10px; } .sizes button { width: 30px; height: 30px; }
  /* stats: hero + totals left, stat rows right */
  .s-stats { display: grid; grid-template-columns: minmax(0, 285px) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; grid-template-areas: "top top" "head rows" "legend rows" "foot rows"; column-gap: 14px; }
  .s-stats .topbar { grid-area: top; } .s-stats .stathead { grid-area: head; margin: 0; } .s-stats .legend { grid-area: legend; margin: 6px 0 0; } .s-stats .srows { grid-area: rows; margin: 0; } .s-stats .sfoot { grid-area: foot; align-self: end; flex-wrap: wrap; margin: 6px 0 0; }
  .s-stats .sfoot { flex-wrap: nowrap; gap: 5px; } .s-stats .sfoot .btn { flex: 1 1 auto; padding: 8px 5px; font-size: 12.5px; white-space: nowrap; } .s-stats .sfoot .btn:nth-child(2) { flex: 1.4; }
  .screen > * { min-width: 0; }
  .stathead .spic { width: 82px; height: 118px; }
  .srows { padding-top: 0; } .srow { padding: 4px 8px; margin-bottom: 5px; } .srow .desc { white-space: normal; }
  /* name */
  .s-name { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "top top" "prev box" "prev ok"; column-gap: 18px; }
  .s-name .topbar { grid-area: top; } .s-name .nprev { grid-area: prev; margin: 4px 0; } .s-name .namebox { grid-area: box; margin: 0; align-self: center; } .s-name > .btn { grid-area: ok; align-self: start; margin-top: 10px; }
  /* hero card */
  .s-card { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; grid-template-areas: "top top" "card r1" "card r2" "card r3"; column-gap: 14px; }
  .s-card .topbar { grid-area: top; } .s-card .card { grid-area: card; margin: 0; max-width: none; flex-direction: row; text-align: left; align-items: stretch; gap: 12px; padding: 10px 12px; grid-row: 2 / 6; }
  .s-card .card .band { position: absolute; left: 0; right: 0; top: 0; margin: 0; }
  .s-card .card .portrait { flex: none; width: 38%; margin-top: 10px; }
  .s-card .cinf { flex: 1; min-width: 0; overflow-y: auto; margin-top: 8px; }
  .s-card .card h2 { font-size: 22px; margin-top: 0; }
  .s-card > .row { grid-column: 2; margin: 0 0 8px; flex-wrap: wrap; }
  .s-card > .row .btn { flex: 1 1 42%; }
  .s-card > .row { margin-top: 0 !important; } .s-card > .ra { grid-row: 2; } .s-card > .rb { grid-row: 3; } .s-card > .rc { grid-row: 4; align-self: start; }
  .s-card .cgrid8 { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
  /* heroes */
  .slots { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .slot { min-height: 150px; } .slot .art, .slot .art svg { height: 98px; flex: none; } .slot h3 { font-size: 13px; } .slot p { font-size: 11px; } .slot.empty b { font-size: 30px; }
  /* card gallery + deck builder: filters/summary left, card grid right */
  .s-gallery, .s-deck { display: grid; grid-template-columns: minmax(0, 230px) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; column-gap: 14px; }
  .s-gallery .topbar, .s-deck .topbar { grid-column: 1 / 3; }
  .s-gallery .hint { grid-column: 1; grid-row: 2; text-align: left; } .s-gallery .tfilter { grid-column: 1; grid-row: 3 / 5; } .s-gallery .scroll { grid-column: 2; grid-row: 2 / 5; }
  .s-deck .dkhead { grid-column: 1; grid-row: 2; } .s-deck .dktabs { grid-column: 1; grid-row: 3; margin: 6px 0 0; } .s-deck .tfilter { grid-column: 1; grid-row: 4; } .s-deck .scroll { grid-column: 2; grid-row: 2 / 5; }
  .s-gallery .tfilter, .s-deck .tfilter { flex-wrap: wrap; overflow: visible; align-content: flex-start; padding: 6px 0 0; }
  .cardgrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .dgrid { gap: 8px; }
  .dkpic { width: 54px; } .dkcount { font-size: 24px; } .dkhead { padding: 6px 8px; } .dkrow .btn { padding: 6px 4px; font-size: 12px; white-space: nowrap; }
  .dktabs button { padding: 6px 4px; font-size: 12.5px; }
  .dummybox { margin-top: 10px; }
  /* sheets / modals */
  .modal { padding: 10px calc(var(--safe-r) + 10px) 10px calc(var(--safe-l) + 10px); }
  .modal .paper { max-width: 440px; max-height: calc(100% - 4px); overflow-y: auto; padding: 12px 16px; }
  .modal p { margin: 6px 0; }
  .modal p:has(.sheetcard) { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; text-align: left; max-height: none; }
  .sheetcard { width: min(112px, 26vh); margin: 0; }
  #toast { top: calc(var(--safe-t) + 50px); }
}
@media (orientation: landscape) and (max-height: 420px) {
  .stathead .spic { width: 74px; height: 100px; } .s-stats .legend { font-size: 10.5px; margin-top: 4px; } .stathead { padding: 6px 8px; }
  .s-title .logo .sub { display: none; }
  .s-title .lineup { max-height: 110px; }
}
@media (prefers-reduced-motion: reduce) { .unit .uart svg, .drift, #rotate .ph { animation: none !important; } }
/* the look-select cards share the class name .gcard with the card gallery: give them their paper back */
.s-gender .gcard { border: 2.5px solid var(--ink); border-radius: 16px; background-color: var(--paper); padding: 10px; aspect-ratio: auto; position: relative; }

/* ================= Slime Pond ================= */
.btn.green { background: #3f9d52; color: #fff; }
.s-pond, .s-pbattle { padding: 0 !important; position: relative; overflow: hidden; animation: none; }
.s-pbattle .pov, .pond .pov { position: absolute; inset: 0; z-index: 40; display: none; place-items: center; background: rgba(20,12,6,.45); }
.pov.on { display: grid; }
.ppanel { max-width: min(560px, 92%); max-height: 92%; overflow: auto; padding: 12px 16px 14px; text-align: center; }
.ppanel h2 { font-size: 22px; margin: 0 0 4px; } .ppanel h3 { font-size: 17px; margin: 0 0 3px; } .ppanel p { margin: 3px 0 8px; font: 800 13px/1.3 Nunito, sans-serif; color: #4a3b30; }
.ppanel .btn { margin-top: 4px; } .ppanel .row { display: flex; gap: 8px; justify-content: center; } .ppanel .ok { color: #2f8f5a; }
.ppanel .hrow { display: flex; gap: 12px; align-items: center; text-align: left; margin-bottom: 4px; } .ppanel .hrow small { font: 900 11px Nunito, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.hbig { flex: none; width: 74px; height: 74px; display: grid; place-items: center; background: #f1e6cf; border: 2.5px solid var(--ink); border-radius: 14px; } .hbig svg { width: 62px; height: 62px; } .hbig.tk svg { width: 66px; height: 66px; }
.icell { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%; } .icell svg { width: 34px; height: 34px; } .icell span { font: 900 9.5px/1.05 Nunito, sans-serif; text-align: center; max-width: 100%; }
.icon.coin, .pg svg, .pcount svg, .gpill svg, .loot svg, .hcoin svg { width: 16px; height: 16px; vertical-align: -3px; }
.pcount svg { width: 20px; height: 20px; }
/* party select */
.s-pondParty .hint { margin-bottom: 4px; }
.pgrid { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; padding: 4px 2px 8px; align-content: start; }
.pcard { border: 2.5px solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); padding: 5px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-family: Nunito, sans-serif; color: var(--ink); }
.pcard.sel { background: #d9f0cf; outline: 3px solid #3f9d52; } .pcard .pcart svg { height: 82px; width: auto; display: block; } .pcard b { font-size: 14px; } .pcard small { font: 800 10.5px Nunito, sans-serif; color: var(--soft); } .pcard .pg { color: var(--ink); }
.pnone { padding: 18px; font-weight: 800; }
.s-pondParty .row { margin-top: 6px; } .s-pondParty .row .btn { flex: 1; }
/* map */
.pond { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 55%, #2f7a3f 0, #1d5a30 55%, #123d22 100%); touch-action: manipulation; }
.pcv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pbanner { position: absolute; left: calc(var(--safe-l) + 8px); top: calc(var(--safe-t) + 6px); z-index: 6; min-width: 150px; padding: 5px 12px 6px 42px; color: #4b2d12; background: linear-gradient(180deg, #f6e4b4, #e8cf93); border: 3px solid #7a4f22; border-radius: 10px 22px 10px 22px; box-shadow: 0 3px 0 rgba(30,15,5,.55), inset 0 0 0 2px #f9edc7; }
.pbanner h3 { font: 900 17px 'CinzelD', 'Cinzel', serif; letter-spacing: .02em; line-height: 1.05; color: #4b2d12; text-shadow: 0 1px 0 #fff3cf; }
.pbanner .pback { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 9px; } .pbanner .pback svg { width: 16px; height: 16px; }
.pcount { display: flex; gap: 10px; margin-top: 2px; font: 900 13px Nunito, sans-serif; } .pcount span { display: inline-flex; align-items: center; gap: 2px; }
.ptools { position: absolute; right: calc(var(--safe-r) + 8px); top: calc(var(--safe-t) + 6px); z-index: 6; display: flex; gap: 6px; }
.ptools .ib.mini { width: 38px; height: 38px; } .ptools svg { width: 26px; height: 26px; }
.phud { position: absolute; left: calc(var(--safe-l) + 8px); bottom: calc(var(--safe-b) + 6px); z-index: 6; display: flex; flex-direction: column-reverse; gap: 4px; max-height: 58%; }
.ph { display: flex; gap: 5px; align-items: center; width: 150px; padding: 3px 6px 3px 3px; background: rgba(255,250,240,.93); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 2px 0 rgba(30,15,5,.6); position: relative; }
.ph.act { outline: 3px solid #5ac8ff; box-shadow: 0 0 12px #5ac8ff; } .ph.out { opacity: .55; filter: grayscale(.8); }
.ph .phart { width: 34px; height: 44px; flex: none; } .ph .phart svg { width: 100%; height: 100%; display: block; }
.ph .phi { min-width: 0; flex: 1; } .ph b { font: 900 12px/1 Nunito, sans-serif; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phbar { position: relative; height: 11px; margin: 2px 0; border: 1.8px solid var(--ink); border-radius: 6px; background: #fffdf8; overflow: hidden; } .phbar i { display: block; height: 100%; background: #3f9d52; } .phbar span { position: absolute; inset: 0; display: grid; place-items: center; font: 900 8.5px Nunito, sans-serif; color: #fff; -webkit-text-stroke: 2.2px var(--ink); paint-order: stroke fill; }
.pdice-row { display: flex; gap: 3px; } .pdice-row u { width: 9px; height: 9px; border: 1.6px solid var(--ink); border-radius: 2.5px; background: #fffdf8; } .pdice-row u.on { background: #e0533a; }
.phg { font: 800 10px Nunito, sans-serif; display: flex; align-items: center; gap: 2px; margin-top: 1px; } .phg svg { width: 12px; height: 12px; }
.ph em { position: absolute; right: 4px; top: 3px; font: 900 9px Nunito, sans-serif; font-style: normal; background: #c8452f; color: #fff; border-radius: 6px; padding: 0 4px; }
.pround { position: absolute; right: calc(var(--safe-r) + 96px); top: calc(var(--safe-t) + 12px); z-index: 5; font: 900 11px Nunito, sans-serif; background: rgba(255,250,240,.9); border: 2px solid var(--ink); border-radius: 9px; padding: 1px 8px; }
.phint { position: absolute; right: calc(var(--safe-r) + 104px); bottom: calc(var(--safe-b) + 18px); z-index: 6; max-width: 250px; text-align: right; font: 800 12.5px/1.25 Nunito, sans-serif; background: rgba(255,250,240,.94); border: 2.2px solid var(--ink); border-radius: 11px; padding: 3px 9px; box-shadow: 0 2px 0 rgba(30,15,5,.55); } .phint:empty { display: none; }
.pgo { position: absolute; right: calc(var(--safe-r) + 104px); bottom: calc(var(--safe-b) + 62px); z-index: 7; padding: 8px 20px; font-size: 18px; } .pstay { position: absolute; right: calc(var(--safe-r) + 104px); bottom: calc(var(--safe-b) + 62px); z-index: 7; }
.pgo[hidden], .pstay[hidden] { display: none; }
.pdie { position: absolute; right: calc(var(--safe-r) + 12px); bottom: calc(var(--safe-b) + 8px); z-index: 7; width: 84px; height: 92px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; padding: 0; font: 900 12px Nunito, sans-serif; color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 4px var(--ink); }
.pdie:disabled { opacity: .95; } .pdie.ready .die3d { animation: dieidle 1.1s ease-in-out infinite; } .pdie span { margin-top: 5px; } .pdie.ready span { font-size: 14px; }
@keyframes dieidle { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-7px) rotate(3deg); } }
.die3d { width: 54px; height: 54px; perspective: 420px; flex: none; } .die3d .cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(30deg); }
.die3d .f { position: absolute; inset: 0; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 15%; background: #fffaf0; border: 2.5px solid var(--ink); border-radius: 22%; backface-visibility: hidden; box-shadow: inset 0 -5px 0 rgba(120,80,40,.14); }
.die3d .f s { border-radius: 50%; margin: 9%; } .die3d .f s.on { background: var(--ink); }
.die3d .f1 { transform: translateZ(27px); } .die3d .f6 { transform: rotateY(180deg) translateZ(27px); } .die3d .f2 { transform: rotateY(90deg) translateZ(27px); } .die3d .f5 { transform: rotateY(-90deg) translateZ(27px); } .die3d .f3 { transform: rotateX(90deg) translateZ(27px); } .die3d .f4 { transform: rotateX(-90deg) translateZ(27px); }
.die3d .f2 s.on, .die3d .f3 s.on, .die3d .f5 s.on { background: var(--ink); } .die3d .f1 s.on { background: #c8452f; }
.pdice { position: absolute; inset: 0; z-index: 30; display: none; place-items: center; background: rgba(10,25,12,.38); pointer-events: none; } .pdice.on { display: grid; }
.pdice .die3d.big { width: 120px; height: 120px; perspective: 700px; } .pdice .die3d.big .f { transform-origin: center; } .pdice .die3d.big .f1 { transform: translateZ(60px); } .pdice .die3d.big .f6 { transform: rotateY(180deg) translateZ(60px); } .pdice .die3d.big .f2 { transform: rotateY(90deg) translateZ(60px); } .pdice .die3d.big .f5 { transform: rotateY(-90deg) translateZ(60px); } .pdice .die3d.big .f3 { transform: rotateX(90deg) translateZ(60px); } .pdice .die3d.big .f4 { transform: rotateX(-90deg) translateZ(60px); }
.pdice .die3d.toss { animation: toss 1.15s ease-out; } @keyframes toss { 0% { transform: translateY(-120px) scale(.6); } 35% { transform: translateY(18px) scale(1.05); } 52% { transform: translateY(-34px) scale(1); } 70% { transform: translateY(6px); } 85% { transform: translateY(-8px); } 100% { transform: none; } }
.pdice .dnum { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 54px); font: 900 44px 'Cinzel', serif; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: dnum .6s ease-out; } @keyframes dnum { from { opacity: 0; transform: translate(-50%, 80px) scale(.5); } }
.plog { position: absolute; left: calc(var(--safe-l) + 8px); top: calc(var(--safe-t) + 64px); z-index: 9; width: min(320px, 50%); max-height: 55%; overflow: auto; padding: 6px 10px; font: 700 11.5px/1.35 Nunito, sans-serif; display: none; } .plog.on { display: block; }
/* panels */
.shopp { max-width: min(700px, 96%); } .shophead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; } .shophead h3 { display: flex; gap: 6px; align-items: center; margin: 0; } .shophead svg { width: 26px; height: 26px; }
.shopgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 6px; } .shopitem { border: 2.2px solid var(--ink); border-radius: 12px; background: #fffdf5; padding: 5px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; } .shopitem.sold { opacity: .45; }
.shopitem .sic svg { width: 40px; height: 40px; } .shopitem b { font: 900 11.5px/1.05 Nunito, sans-serif; } .shopitem small { font: 700 9px/1.15 Nunito, sans-serif; color: #5a4b3e; min-height: 31px; } .shopitem .btn { padding: 4px 6px; margin: 0; font-size: 13px; display: inline-flex; gap: 3px; align-items: center; } .shopitem .btn svg { width: 14px; height: 14px; }
.bagrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0; } .slot { border: 2.2px solid var(--ink); border-radius: 10px; background: #fffdf5; min-height: 58px; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); } .slot small { font: 700 8.5px/1.1 Nunito, sans-serif; color: #5a4b3e; } .slot:not(.has) { background: rgba(255,253,245,.5); }
.erows { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 6px; } .erow { display: flex; gap: 6px; align-items: center; text-align: left; font: 800 12px Nunito, sans-serif; } .erow svg:first-child { height: 52px; width: auto; } .erow .up, .up { color: #2f8f5a; font-weight: 900; }
.eg { font: 800 13px Nunito, sans-serif; margin-bottom: 4px; } .loot { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; margin: 6px 0 8px; font: 900 14px Nunito, sans-serif; } .loot div { display: flex; align-items: center; gap: 3px; } .loot .icon:not(.coin) { width: 24px; height: 24px; } .loot .warn { color: var(--red2); }
/* battle extras */
.s-pbattle .unit .morphed svg { height: calc(var(--uh) * 1.1); width: auto; } .unit.fled { opacity: .3; } .u-pet .uart svg { height: calc(var(--uh) * var(--k, 1) * .62); }
.u-foe .uart svg { height: calc(var(--uh) * var(--k, 1) * .9); }
.hcard .scard, .dbig .scard { width: 100%; height: auto; display: block; }
.st-poison { background: #bfe29a; } .st-morph { background: #a6e08a; }
/* character sheet */
.s-sheet { overflow: hidden; } .sheet { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1.2fr .85fr; gap: 8px; }
.sh-eq { display: flex; gap: 4px; min-height: 0; justify-content: center; } .eqcol { display: flex; flex-direction: column; gap: 4px; width: 60px; } .sfig { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; } .sfig svg { max-height: calc(100% - 22px); width: auto; max-width: 100%; display: block; } .sdef { font: 900 12px Nunito, sans-serif; display: flex; gap: 3px; align-items: center; } .sdef svg { width: 18px; height: 18px; }
.eqs { flex: 1; min-height: 0; border: 2.2px solid var(--ink); border-radius: 10px; background: #fffdf5; padding: 1px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; color: var(--ink); } .eqs small { position: absolute; top: 1px; left: 3px; font: 900 8px Nunito, sans-serif; color: var(--soft); } .eqs:not(.has) { background: rgba(255,253,245,.55); border-style: dashed; } .eqs .icell svg { width: 28px; height: 28px; } .eqs .icell span { font-size: 8px; }
.eqs .petart svg { height: 34px; width: auto; } .eqs.pets span { font: 900 8.5px Nunito, sans-serif; }
.sh-st { padding: 6px 9px; display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: auto; } .lvl { display: flex; justify-content: space-between; font: 900 14px Nunito, sans-serif; } .lvl span { font-size: 11px; color: var(--soft); }
.xpbar { height: 12px; border: 2px solid var(--ink); border-radius: 7px; background: #fffdf8; overflow: hidden; } .xpbar i { display: block; height: 100%; background: linear-gradient(180deg, #7fd0ff, #3f8fd8); }
.s-sheet .xpts { font: 800 11px/1.25 Nunito, sans-serif; } .s-sheet .xpts small { display: block; color: var(--soft); font-size: 9.5px; }
.srows { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; padding-right: 2px; } .srow { display: flex; align-items: center; gap: 4px; font: 900 12px Nunito, sans-serif; } .srow .sn { flex: 1; display: flex; gap: 3px; align-items: center; } .srow .sv em { color: #2f8f5a; font-style: normal; font-size: 10px; margin-left: 2px; }
.srow .pm { width: 26px; height: 26px; flex: none; border: 2px solid var(--ink); border-radius: 7px; background: #fffdf5; font-weight: 900; font-size: 15px; line-height: 1; padding: 0; } .srow .pm:disabled { opacity: .25; } .srow .pm:not(:disabled) { background: #bfe6a4; }
.sder { font: 800 11px Nunito, sans-serif; margin-top: auto; }
.sh-inv { padding: 6px; display: flex; flex-direction: column; min-height: 0; } .ivh { font: 900 13px Nunito, sans-serif; margin-bottom: 3px; } .ivgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(5, 1fr); gap: 4px; grid-auto-flow: column; } .ivgrid .slot { min-height: 0; } .ivgrid .icell svg { width: 26px; height: 26px; } .ivgrid .icell span { font-size: 8.5px; }
.spop { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 8px); transform: translateX(-50%); z-index: 20; width: min(560px, 94%); padding: 6px 10px; display: flex; gap: 10px; align-items: center; } .spop[hidden] { display: none; }
.spop .pico { width: 52px; height: 52px; flex: none; display: grid; place-items: center; background: #f1e6cf; border: 2.2px solid var(--ink); border-radius: 12px; } .spop .pico svg { width: 42px; height: 42px; } .spop .pico.petart svg { height: 46px; width: auto; }
.spop .ptxt { flex: 1; min-width: 0; } .spop .ptxt b { font-size: 14px; } .spop .ptxt p { margin: 1px 0 0; font: 700 11.5px/1.25 Nunito, sans-serif; } .spop .pbtns { display: flex; flex-direction: column; gap: 3px; } .spop .pbtns .btn { padding: 4px 10px; font-size: 13px; }
.gpill { font-size: 14px; } .gpill svg { width: 18px; height: 18px; }
.row.rb { flex-wrap: wrap; }

/* map camera buttons: zoom + / − / center on hero / whole map */
.pcam { position: absolute; right: calc(var(--safe-r) + 8px); top: calc(var(--safe-t) + 52px); z-index: 6; display: flex; flex-direction: column; gap: 5px; }
.pcam .ib.mini { width: 40px; height: 40px; font-size: 22px; } .pcam svg { width: 24px; height: 24px; } .pcam .lit { background: #bfe6a4; box-shadow: 0 0 10px #8fe06a; }
.pond .pcv { touch-action: none; }
/* v8 sticker art: the wolf is drawn facing right, so as an enemy (they stand on the right) it is mirrored to face the heroes */
.flipx { transform: scaleX(-1); } .flipx svg { display: block; }
.unit .uart svg.sprite { filter: drop-shadow(0 2px 2px rgba(20, 10, 4, .35)); }
