/* LOOMLIGHT — felt-and-thread UI. Portrait-first, 390x800 target, fits 360x640. */
:root {
  --bg: #1b1838; --bg2: #24204a; --bg3: #2e2960; --ink: #f3ecdc; --dim: #b4accb; --faint: #7d76a0;
  --c: #e05a5a; --i: #5a78e0; --o: #e0b45a; --x: #8a8696; --good: #7fd18b; --bad: #ff6b6b; --pad: #8fb4ff;
  --stitch: rgba(243, 236, 220, 0.35); --r: 12px;
  --step: 110ms;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; max-width: 560px; margin: 0 auto;
  background-color: var(--bg); background-size: 160px 160px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#screen { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
#fx { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; z-index: 60; }
.hidden { display: none !important; }
.shake1 { animation: shake1 220ms; } .shake2 { animation: shake2 360ms; }
@keyframes shake1 { 0%,100% { transform: none } 25% { transform: translate(-3px, 1px) } 50% { transform: translate(3px, -2px) } 75% { transform: translate(-2px, 2px) } }
@keyframes shake2 { 0%,100% { transform: none } 20% { transform: translate(-7px, 3px) } 40% { transform: translate(6px, -4px) } 60% { transform: translate(-5px, 4px) } 80% { transform: translate(4px, -2px) } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
.no-anim *, .no-anim *::before, .no-anim *::after { animation: none !important; transition: none !important; }

/* ---------- generic ---------- */
.btn { min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: var(--r); border: 2px dashed var(--stitch); background: var(--bg3); color: var(--ink);
  font-weight: 650; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.primary { background: linear-gradient(#e7b95c, #c8913a); color: #2a1a08; border-color: rgba(60, 30, 0, 0.45); }
.btn.danger { background: #7a2b3a; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 18px; padding: 0 24px; }
.btn[disabled], .btn.disabled { opacity: 0.45; pointer-events: none; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--dim); }
.small { font-size: 13px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.panel { background: rgba(46, 41, 96, 0.85); border: 2px dashed var(--stitch); border-radius: 16px; padding: 12px; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: 0.3px; }
h2 { font-size: 22px; } h3 { font-size: 17px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,0.1); white-space: nowrap; cursor: pointer; min-height: 22px; }
.chip.kw { background: rgba(224, 180, 90, 0.22); color: #ffe2a6; border: 1px solid rgba(224,180,90,0.45); }
.chip.pad { background: rgba(90, 120, 224, 0.35); color: #dbe5ff; }
.chip.sharp { background: rgba(224, 90, 90, 0.3); color: #ffd6d6; }
.chip.tangled { background: rgba(160, 150, 200, 0.3); }
.chip.unravel { background: rgba(127, 209, 139, 0.25); color: #d6ffdc; }
.chip.prickle { background: rgba(127, 179, 160, 0.3); }
.chip.aff { background: rgba(224, 180, 90, 0.3); color: #ffe7b8; }
.tag-c { color: var(--c); } .tag-i { color: #8ea6ff; } .tag-o { color: var(--o); }
.toast { background: rgba(20, 16, 40, 0.94); border: 2px dashed var(--stitch); border-radius: 12px; padding: 8px 14px; font-weight: 650; font-size: 14px; animation: toastIn 2.4s forwards; max-width: 90%; text-align: center; }
#toasts { position: absolute; left: 0; right: 0; top: 54px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 80; }
@keyframes toastIn { 0% { opacity: 0; transform: translateY(-8px) } 8% { opacity: 1; transform: none } 85% { opacity: 1 } 100% { opacity: 0 } }

/* ---------- top bar ---------- */
.topbar { height: 44px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; background: rgba(15, 12, 34, 0.7); border-bottom: 2px dashed rgba(243,236,220,0.15); font-weight: 700; font-size: 14px; }
.hpbox { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; cursor: pointer; min-height: 44px; }
.hpbar { position: relative; flex: 1; max-width: 120px; height: 10px; background: #3a2140; border-radius: 6px; overflow: hidden; }
.hpbar > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #e05a5a, #ff8a7a); border-radius: 6px; transition: width 200ms; }
.hpbar > b { position: absolute; top: 0; bottom: 0; background: #ffd0d0; opacity: 0.9; animation: pulse 0.9s infinite alternate; }
@keyframes pulse { from { opacity: 0.35 } to { opacity: 0.95 } }
.topstat { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.iconbtn { min-width: 44px; height: 44px; border: none; background: none; font-size: 20px; cursor: pointer; border-radius: 10px; }
.iconbtn:active { background: rgba(255,255,255,0.08); }

/* ---------- title ---------- */
.title-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.logo { font-size: 44px; font-weight: 900; letter-spacing: 4px; color: #ffe9b8; text-shadow: 0 0 18px rgba(224, 180, 90, 0.55), 0 2px 0 #6b4a18; }
.logo-sub { color: var(--dim); font-size: 14px; text-align: center; max-width: 300px; }
.title-loom { width: 240px; height: 70px; position: relative; margin: 8px 0 10px; }
.title-loom span { position: absolute; top: 8px; bottom: 8px; width: 6px; border-radius: 3px; animation: glowthread 2.4s infinite ease-in-out; }
@keyframes glowthread { 0%,100% { opacity: 0.45; transform: scaleY(0.85) } 50% { opacity: 1; transform: none } }
.title-btns { display: flex; flex-direction: column; gap: 10px; width: min(300px, 88%); }
.title-btns .btn { width: 100%; }
.version { position: absolute; bottom: 8px; right: 12px; font-size: 12px; color: var(--faint); }

/* ---------- setup ---------- */
.setup { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.setup-body { flex: 1; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 12px; }
.carousel { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 8px; }
.idcard { flex: 0 0 78%; scroll-snap-align: center; border-radius: 18px; padding: 12px; background: var(--bg2); border: 2px dashed var(--stitch); display: flex; flex-direction: column; gap: 6px; cursor: pointer; position: relative; }
.idcard.sel { border-color: #ffe2a6; box-shadow: 0 0 0 2px rgba(224,180,90,0.45), 0 0 22px rgba(224,180,90,0.25); }
.idcard.locked { opacity: 0.55; }
.idcard .portrait { width: 84px; height: 84px; align-self: center; }
.idcard .name { font-weight: 800; font-size: 18px; text-align: center; }
.minideck { display: flex; flex-wrap: wrap; gap: 3px; }
.minideck span { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,0.08); }
.heirlooms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hchip { min-height: 52px; padding: 6px 8px; border-radius: 12px; background: var(--bg2); border: 2px dashed var(--stitch); cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 13px; }
.hchip.sel { border-color: #ffe2a6; background: #3a3170; }
.hchip.locked { opacity: 0.45; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .val { font-size: 22px; font-weight: 800; min-width: 28px; text-align: center; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 10px; cursor: pointer; }
.switch { width: 50px; height: 28px; border-radius: 14px; background: #4a4470; position: relative; flex: none; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: left 120ms; }
.switch.on { background: #7fae5a; } .switch.on::after { left: 25px; }
input[type=text], textarea { font: inherit; background: #120f2a; color: var(--ink); border: 2px dashed var(--stitch); border-radius: 10px; padding: 10px; width: 100%; min-height: 44px; user-select: text; -webkit-user-select: text; }
input[type=range] { width: 100%; height: 32px; accent-color: #e0b45a; }
.footerbar { flex: none; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(15,12,34,0.7); border-top: 2px dashed rgba(243,236,220,0.15); display: flex; gap: 10px; }

/* ---------- map ---------- */
.map-scroll { flex: 1; overflow-y: auto; position: relative; }
.map-inner { position: relative; margin: 0 auto; width: 100%; max-width: 420px; }
.map-inner svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.node { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: #2e2960; border: 2px dashed rgba(243,236,220,0.3); cursor: pointer; transition: transform 120ms; }
.node.visited { background: #1f1b40; opacity: 0.55; }
.node.reach { border: 3px solid #ffe2a6; animation: nodepulse 1.4s infinite; background: #3d3478; }
.node.here { box-shadow: 0 0 0 4px rgba(255,226,166,0.6); opacity: 1; }
.node.sel { transform: scale(1.15); background: #57489e; }
.node.dim { opacity: 0.4; }
.node.boss { width: 78px; height: 78px; margin: -39px 0 0 -39px; font-size: 38px; background: #3b1f4a; }
.node .badge { position: absolute; right: -6px; top: -6px; font-size: 12px; background: #e0b45a; color: #2a1a08; border-radius: 9px; padding: 0 5px; font-weight: 800; }
@keyframes nodepulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,226,166,0.5) } 50% { box-shadow: 0 0 0 8px rgba(255,226,166,0) } }
.map-info { flex: none; min-height: 64px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; background: rgba(15,12,34,0.8); border-top: 2px dashed rgba(243,236,220,0.15); }
.acthead { position: absolute; top: 6px; left: 10px; right: 10px; font-weight: 800; color: var(--dim); font-size: 13px; text-align: center; }

/* ---------- combat ---------- */
.combat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.enemyzone { flex: 1; min-height: 150px; position: relative; display: flex; align-items: flex-end; justify-content: space-around; padding: 6px 4px 4px; gap: 2px; }
.enemy { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; max-width: 190px; cursor: pointer; padding: 4px 2px; border-radius: 14px; }
.enemy.target { background: radial-gradient(ellipse at 50% 60%, rgba(224,180,90,0.16), transparent 70%); }
.enemy .reticle { position: absolute; left: 50%; top: 46%; width: 70%; aspect-ratio: 1; transform: translate(-50%, -50%); border: 2px dashed rgba(255,226,166,0.7); border-radius: 50%; pointer-events: none; animation: spin 9s linear infinite; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg) } }
.intent { display: flex; align-items: center; gap: 3px; padding: 2px 9px; min-height: 34px; border-radius: 14px; background: #f3ecdc; color: #241c3c; font-weight: 900; font-size: 22px; line-height: 1; box-shadow: 0 2px 0 rgba(0,0,0,0.35); white-space: nowrap; max-width: 100%; }
.intent .ic { font-size: 18px; }
.intent .nt { font-size: 11px; font-weight: 700; color: #6a5a80; }
.intent.atk { background: #ffd9d4; } .intent.def { background: #d9e3ff; } .intent.loom { background: #ffe7b8; }
.sprite { position: relative; width: 100%; max-width: 120px; aspect-ratio: 1; }
.sprite { animation: bob 2.6s infinite ease-in-out; }
.sprite img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sprite img.wings { animation: flap 0.9s infinite ease-in-out; transform-origin: 50% 55%; }
@keyframes bob { 0%,100% { translate: 0 0 } 50% { translate: 0 -4px } }
@keyframes flap { 0%,100% { transform: scaleX(1) } 50% { transform: scaleX(0.82) } }
.enemy.hitflash .sprite { filter: brightness(2.6) saturate(0.2); }
.enemy.lunge .sprite { animation: lunge 260ms; }
@keyframes lunge { 50% { transform: translateY(14px) scale(1.08) } }
.enemy.dying { animation: dying 420ms forwards; }
@keyframes dying { to { opacity: 0; transform: scale(0.6) } }
.enemy .ename { font-size: 12px; font-weight: 700; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ehp { position: relative; width: 92%; height: 14px; background: #3a2140; border-radius: 7px; overflow: hidden; }
.ehp > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #d9534f, #ff8a7a); transition: width 160ms; }
.ehp > b { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(255,240,220,0.85) 0 4px, rgba(255,200,190,0.55) 4px 8px); animation: pulse 0.9s infinite alternate; }
.ehp > u { position: absolute; right: 0; top: 0; bottom: 0; background: rgba(143,180,255,0.65); text-decoration: none; }
.ehpt { font-size: 12px; font-weight: 800; white-space: nowrap; }
.ehpt .skull { font-size: 14px; }
.statuses { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-height: 22px; }
.nameplate-rule { font-size: 11px; color: #ffe2a6; text-align: center; max-width: 100%; line-height: 1.2; }
.dirarrow { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font-size: 13px; font-weight: 800; color: #ffe2a6; background: rgba(60,40,90,0.8); padding: 2px 10px; border-radius: 10px; }

.forecast { flex: none; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: rgba(15,12,34,0.65); border-top: 2px dashed rgba(243,236,220,0.13); border-bottom: 2px dashed rgba(243,236,220,0.13); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.forecast.lethal { background: rgba(120, 20, 30, 0.75); color: #ffd6d6; animation: pulse 0.8s infinite alternate; }
.forecast.win { background: rgba(40, 90, 50, 0.7); }
.forecast .more { margin-left: auto; color: var(--dim); }
.pstatus { flex: none; height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 13px; }
.spool { display: flex; gap: 4px; align-items: center; margin-left: auto; font-weight: 700; }
.pip { width: 16px; height: 16px; border-radius: 50%; background: #e0b45a; box-shadow: 0 0 8px rgba(224,180,90,0.7); border: 2px solid #ffe2a6; }
.pip.empty { background: transparent; box-shadow: none; border: 2px dashed rgba(224,180,90,0.5); }

.loomwrap { flex: none; position: relative; padding: 6px 4px 8px; }
.loom { display: flex; gap: 4px; justify-content: center; padding: 6px 4px; border-radius: 14px; background: linear-gradient(#3b2a1a, #2c1f13); border: 3px solid #5a4028; box-shadow: inset 0 0 0 2px rgba(255,220,160,0.12); animation: loombob 5s infinite ease-in-out; }
@keyframes loombob { 0%,100% { transform: none } 50% { transform: translateY(-1px) } }
.slot { position: relative; flex: 1 1 0; max-width: 72px; min-width: 0; height: 100px; border-radius: 10px; border: 2px dashed rgba(255,220,160,0.28); background: rgba(0,0,0,0.25); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; cursor: pointer; }
.slot .num { position: absolute; bottom: 2px; left: 4px; font-size: 11px; color: rgba(255,220,160,0.45); font-weight: 800; }
.slot.glow { border: 2px solid #ffe2a6; background: rgba(255,226,166,0.12); box-shadow: 0 0 12px rgba(255,226,166,0.35); }
.slot.glow.over { background: rgba(255,226,166,0.3); }
.slot.locked { background: repeating-linear-gradient(45deg, rgba(0,0,0,0.45) 0 6px, rgba(60,50,90,0.45) 6px 12px); }
.slot.active { transform: translateY(-6px) scale(1.06); box-shadow: 0 0 18px rgba(255,226,166,0.8); transition: transform 80ms; }
.slot.snapping .thread { animation: snapdrop 360ms forwards; }
@keyframes snapdrop { 30% { transform: rotate(-8deg) } 100% { transform: translateY(40px) rotate(14deg); opacity: 0 } }
.slot.marked { box-shadow: inset 0 0 0 2px rgba(255,107,107,0.8); }
.slot .marks { position: absolute; top: -12px; right: -4px; font-size: 16px; z-index: 3; filter: drop-shadow(0 1px 1px #000); }
.slot .lockicon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; z-index: 2; pointer-events: none; }
.thread { position: absolute; inset: 2px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; padding: 3px 2px 0; overflow: hidden; background: var(--bg2); }
.thread.C { background: linear-gradient(180deg, #5a2434, #3a1a2a); box-shadow: 0 0 10px rgba(224,90,90,0.35); }
.thread.I { background: linear-gradient(180deg, #273a7a, #1c2650); box-shadow: 0 0 10px rgba(90,120,224,0.35); }
.thread.O { background: linear-gradient(180deg, #6a4f22, #3e2e14); box-shadow: 0 0 10px rgba(224,180,90,0.35); }
.thread.X { background: #3a3744; }
.thread .ti { font-size: 22px; line-height: 1.1; margin-top: 8px; }
.thread .tn { font-size: 10.5px; font-weight: 700; text-align: center; line-height: 1.05; max-height: 23px; overflow: hidden; padding: 0 1px; }
.thread .fray { position: absolute; top: 3px; left: 4px; display: flex; gap: 2px; }
.fray i { width: 6px; height: 6px; border-radius: 50%; background: #ffe2a6; display: block; }
.fray .knot { font-size: 12px; line-height: 6px; color: #ffe2a6; font-style: normal; }
.thread .stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 9px; }
.out { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: #f3ecdc; color: #241c3c; border-radius: 9px; padding: 0 5px; font-size: 12px; font-weight: 900; white-space: nowrap; z-index: 4; box-shadow: 0 1px 0 rgba(0,0,0,0.4); }
.out.dmg { background: #ffd9d4; } .out.padb { background: #d9e3ff; } .out.none { background: #8a8696; color: #eee; }
.trigx { position: absolute; top: 20px; right: 2px; font-size: 11px; font-weight: 900; color: #ffe2a6; z-index: 3; }
.shuttle { position: absolute; top: 50%; width: 30px; height: 12px; margin: -6px 0 0 -15px; border-radius: 50%; background: radial-gradient(#ffe9b8, #b07a2e); box-shadow: 0 0 16px #ffd36b; z-index: 8; pointer-events: none; transition: left var(--step) ease-out; }
.loomdir { position: absolute; right: 10px; top: -6px; font-size: 12px; font-weight: 800; color: #ffe2a6; z-index: 5; }

.hand { flex: none; height: 150px; position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 0 6px 6px; }
.card { position: relative; width: 76px; height: 118px; flex: none; border-radius: 10px; background: #f3ecdc; color: #241c3c; display: flex; flex-direction: column; align-items: center; padding: 15px 4px 9px; cursor: pointer;
  border: 2px dashed rgba(36,28,60,0.35); box-shadow: 0 3px 0 rgba(0,0,0,0.35); transition: transform 120ms, margin 120ms; touch-action: none; }
.card .cost { position: absolute; top: -6px; left: -6px; width: 26px; height: 26px; border-radius: 50%; background: #e0b45a; color: #2a1a08; font-weight: 900; font-size: 15px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff3cf; }
.card .cost.free { background: #7fd18b; }
.card .fray { position: absolute; top: 5px; right: 5px; }
.card .fray i { background: #6a5a80; }
.card .fray .knot { color: #6a5a80; }
.card .ci { font-size: 20px; line-height: 1.1; }
.card .cn { font-size: 11.5px; font-weight: 800; text-align: center; line-height: 1.05; margin: 1px 0 2px; }
.card .ct { font-size: 10.5px; line-height: 1.15; text-align: center; color: #3a3058; overflow: hidden; }
.card .ct b.live { color: #c0392b; }
.card .ct b.livep { color: #2f55c8; }
.card .stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-radius: 0 0 8px 8px; }
.card.snip { background: #fff7e0; }
.card.snip::after { content: 'SNIP'; position: absolute; top: 4px; font-size: 9px; font-weight: 900; color: #a08040; letter-spacing: 1px; }
.card.lint { background: #c9c5d2; }
.card.up .cn { color: #2a7a3a; }
.card.sel { transform: translateY(-22px); box-shadow: 0 0 0 3px #ffe2a6, 0 8px 18px rgba(0,0,0,0.5); z-index: 10; }
.card.cant { filter: grayscale(0.6) brightness(0.8); }
.card.dragging { opacity: 0.35; }
.card.big { width: 104px; height: 156px; padding-top: 22px; }
.card.big .ci { font-size: 30px; } .card.big .cn { font-size: 13.5px; } .card.big .ct { font-size: 12px; }
.card.rare { box-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 0 0 2px #e0b45a; overflow: hidden; }
.card.rare::before { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,240,200,0.65) 50%, transparent 70%); background-size: 250% 100%; animation: shimmer 2.8s infinite; pointer-events: none; border-radius: 8px; }
@keyframes shimmer { from { background-position: 150% 0 } to { background-position: -100% 0 } }
.rar { position: absolute; bottom: 10px; right: 4px; font-size: 9px; font-weight: 900; color: #a08040; }
.dragghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -60%) rotate(-4deg) scale(1.05); }
.playbtn { position: absolute; left: 50%; top: -58px; transform: translateX(-50%); z-index: 20; }
.prompt { position: absolute; left: 50%; top: -30px; font-size: 13px !important; padding: 3px 10px !important; transform: translateX(-50%); z-index: 20; background: rgba(20,16,40,0.92); border: 2px dashed #ffe2a6; border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }

.bottombar { flex: none; height: 64px; display: flex; align-items: center; gap: 4px; padding: 0 6px calc(env(safe-area-inset-bottom)); background: rgba(15,12,34,0.8); border-top: 2px dashed rgba(243,236,220,0.15); }
.bottombar .sm { min-width: 46px; padding: 0 4px; font-size: 13px; flex-direction: column; gap: 0; line-height: 1.1; height: 52px; }
.bottombar .sm .ic { font-size: 17px; }
.pocket { width: 46px; height: 52px; border-radius: 10px; border: 2px dashed rgba(224,180,90,0.6); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--dim); cursor: pointer; flex: none; position: relative; flex-direction: column; line-height: 1.1; }
.pocket.has { background: #f3ecdc; color: #241c3c; font-weight: 800; }
.pocket.glow { border: 2px solid #ffe2a6; box-shadow: 0 0 10px rgba(255,226,166,0.5); }
.weave { margin-left: auto; min-width: 128px; flex: 1; max-width: 180px; height: 56px; font-size: 19px; font-weight: 900; letter-spacing: 1.5px; border-radius: 16px; border: 2px solid #fff3cf; background: linear-gradient(#f0c56a, #c8913a); color: #2a1a08; cursor: pointer; box-shadow: 0 3px 0 #6b4a18, 0 0 18px rgba(224,180,90,0.35); }
.weave:active { transform: translateY(2px); box-shadow: 0 1px 0 #6b4a18; }
.weave.lethal { background: linear-gradient(#e05a5a, #9a2a2a); color: #fff; border-color: #ffd6d6; box-shadow: 0 3px 0 #4a1010, 0 0 18px rgba(224,90,90,0.6); }
.weave.armed { animation: pulse 0.5s infinite alternate; font-size: 14px; letter-spacing: 0.5px; }
.weave.busy { opacity: 0.6; }
.pile { min-width: 36px; height: 52px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--dim); background: none; border: none; cursor: pointer; }
.pile .ic { font-size: 17px; }

.pop { position: absolute; z-index: 70; font-weight: 900; pointer-events: none; text-shadow: 0 2px 0 #000, 0 0 8px rgba(0,0,0,0.6); animation: pop 800ms forwards; white-space: nowrap; transform: translate(-50%, -50%); }
.pop.dmg { color: #fff1e0; } .pop.blk { color: #a9c4ff; } .pop.heal { color: #9effa9; } .pop.gold { color: #ffe2a6; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6) } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15) } 70% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%, -140%) scale(1) } }
.banner { position: absolute; left: 0; right: 0; top: 38%; text-align: center; z-index: 75; pointer-events: none; font-size: 26px; font-weight: 900; color: #ffe9b8; text-shadow: 0 0 18px rgba(224,180,90,0.7), 0 2px 0 #000; animation: banner 1.2s forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(0.7) } 15% { opacity: 1; transform: scale(1.05) } 80% { opacity: 1 } 100% { opacity: 0 } }
.ambush { position: absolute; inset: 0; z-index: 50; background: rgba(15,10,30,0.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }

/* ---------- sheet ---------- */
#sheet-wrap { position: absolute; inset: 0; z-index: 85; }
#sheet-backdrop { position: absolute; inset: 0; background: rgba(5,3,15,0.55); }
#sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 82%; display: flex; flex-direction: column; background: #262150; border-top: 3px dashed rgba(255,226,166,0.45); border-radius: 20px 20px 0 0; padding: 6px 14px calc(14px + env(safe-area-inset-bottom)); animation: sheetin 180ms ease-out; }
@keyframes sheetin { from { transform: translateY(40%); opacity: 0 } }
.sheet-grip { width: 48px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.3); margin: 4px auto 8px; flex: none; }
#sheet-body { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.4; }
.sheet-title { display: flex; align-items: center; gap: 10px; }
.sheet-title .big { font-size: 34px; }
.cyc { display: flex; flex-direction: column; gap: 4px; }
.cyc > div { padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,0.05); font-size: 14px; }
.cyc > div.cur { background: rgba(224,180,90,0.22); border: 1px solid rgba(224,180,90,0.6); }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }
.tabs .btn.on { background: #57489e; border-color: #ffe2a6; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 12px 8px; justify-items: center; padding: 8px 4px; }
.cardgrid .card { transform: none; }
.charmrow { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,0.05); cursor: pointer; min-height: 52px; }
.charmrow .ic { font-size: 26px; width: 34px; text-align: center; }
.charmrow.sel { background: rgba(224,180,90,0.22); outline: 2px solid #ffe2a6; }
.charms-strip { display: flex; gap: 4px; overflow-x: auto; }
.charm-mini { font-size: 18px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255,255,255,0.06); cursor: pointer; flex: none; }

/* ---------- reward / shop / hearth / event ---------- */
.page { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page-body { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.offer { display: flex; justify-content: center; gap: 10px; padding-top: 6px; }
.offer .card.picked { box-shadow: 0 0 0 3px #7fd18b; transform: translateY(-6px); }
.offer .card.chosen { box-shadow: 0 0 0 3px #ffe2a6, 0 8px 18px rgba(0,0,0,0.5); transform: translateY(-8px); }
.offer.done .card:not(.picked) { opacity: 0.35; }
.goldline { font-size: 18px; font-weight: 800; color: #ffe2a6; text-align: center; }
.shopgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 8px; justify-items: center; }
.price { margin-top: 6px; font-weight: 800; color: #ffe2a6; font-size: 14px; text-align: center; min-height: 20px; }
.price.no { color: var(--faint); }
.sold { opacity: 0.25; pointer-events: none; }
.services { display: flex; flex-direction: column; gap: 8px; }
.services .btn { justify-content: space-between; width: 100%; }
.tiles { display: flex; flex-direction: column; gap: 12px; }
.tile { min-height: 84px; border-radius: 18px; padding: 12px 14px; background: var(--bg2); border: 2px dashed var(--stitch); display: flex; align-items: center; gap: 14px; cursor: pointer; text-align: left; width: 100%; }
.tile .ic { font-size: 36px; }
.tile .t { font-weight: 800; font-size: 18px; }
.tile:active { transform: scale(0.99); }
.event-art { font-size: 72px; text-align: center; margin-top: 8px; animation: bob 3s infinite ease-in-out; }
.evopt { width: 100%; min-height: 56px; text-align: left; justify-content: flex-start; flex-direction: column; align-items: flex-start; padding: 8px 14px; gap: 2px; }
.evopt .d { font-size: 13px; font-weight: 500; color: var(--dim); }
.acttitle { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; animation: fadein 500ms ease-out; cursor: pointer; }
@keyframes fadein { from { opacity: 0; transform: scale(0.96) } }
.acttitle .n { font-size: 18px; color: var(--dim); letter-spacing: 4px; font-weight: 800; }
.acttitle .t { font-size: 34px; font-weight: 900; color: #ffe9b8; text-shadow: 0 0 18px rgba(224,180,90,0.6); text-align: center; }
.summary h2 { font-size: 28px; text-align: center; }
.stat { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px dashed rgba(255,255,255,0.1); font-size: 15px; }
.feat { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(255,255,255,0.05); }
.feat.got { background: rgba(127,209,139,0.15); }
.coach { pointer-events: none; position: absolute; z-index: 70; background: #fff3cf; color: #2a1a08; border-radius: 14px; padding: 10px 12px; font-weight: 650; font-size: 14px; max-width: 250px; box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
.coach .row { margin-top: 6px; justify-content: flex-end; }
.coach .btn { pointer-events: auto; min-height: 36px; font-size: 13px; padding: 0 10px; background: #e0b45a; color: #2a1a08; border-color: rgba(60,30,0,0.4); }

/* colour-blind patterns on stripes */
.stripe.C { background: repeating-linear-gradient(90deg, var(--c) 0 6px, #b03a3a 6px 9px); }
.stripe.I { background: radial-gradient(circle, #c7d3ff 1.6px, transparent 2px) 0 0 / 7px 7px, var(--i); }
.stripe.O { background: linear-gradient(135deg, #b8862e 25%, transparent 25%) -4px 0 / 8px 8px, linear-gradient(225deg, #b8862e 25%, transparent 25%) -4px 0 / 8px 8px, var(--o); }
.stripe.X { background: var(--x); }
.nocb .stripe.C { background: var(--c); } .nocb .stripe.I { background: var(--i); } .nocb .stripe.O { background: var(--o); }

@media (max-height: 700px) {
  .hand { height: 132px; }
  .card { width: 70px; height: 108px; padding-top: 16px; }
  .slot { height: 88px; }
  .enemyzone { min-height: 120px; }
  .sprite { max-width: 90px; }
}
@media (max-width: 370px) {
  .card { width: 68px; }
  .weave { min-width: 104px; font-size: 16px; }
}
.setup-body > *, .page-body > * { flex: none; }
