/* Cinderwick battle mockup. Phone portrait first; on desktop the same column sits centred. */
@font-face { font-family: "Jersey 15"; src: url("../assets/fonts/jersey-15-latin-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Jersey 10"; src: url("../assets/fonts/jersey-10-latin-400-normal.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #0b0914;
  --panel: #151126;
  --panel-2: #1e1836;
  --line: #352a5a;
  --line-2: #4c3d80;
  --text: #f1ebff;
  --muted: #9a8fbd;
  --ember: #ff8a2a;
  --gold: #ffd166;
  --hp: #e0362c;
  --mp: #3aa0ff;
  --xp: #b46cff;
  --ok: #4ad66d;
  --icons: none;
  --col: min(100vw, 480px, calc(var(--app-h, 100dvh) * 0.6));
  color-scheme: dark; /* one committed look: night */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The page never scrolls: it is exactly the screen. --app-h is the real screen height (src/shell.js); on an iPhone
   home-screen app 100% / 100vh come out short and leave a strip at the bottom. */
html { height: 100%; overflow: hidden; background: #05040a; }
body { position: fixed; inset: 0; height: var(--app-h, 100dvh); margin: 0; overflow: hidden; background: #05040a; color: var(--text); overscroll-behavior: none; }
@media (pointer: coarse) { html, body { background: var(--panel); } }
body { font-family: "Jersey 15", ui-monospace, "Courier New", monospace; font-size: 15px; line-height: 1; font-weight: 400; display: flex; justify-content: center; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: relative; width: var(--col); height: 100%; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }

/* icons: one 32px sheet from PixelLab, shown at whole multiples where the screen allows */
.ico { --s: 32px; flex: none; display: inline-block; width: var(--s); height: var(--s); background-image: var(--icons); background-repeat: no-repeat; background-size: calc(var(--s) * var(--icon-n, 24)) var(--s); background-position: calc(var(--i) * var(--s) * -1) 0; image-rendering: pixelated; }
.ico.sm { --s: 16px; }
.ico.lg { --s: 48px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: var(--panel); border-bottom: 2px solid var(--line); }
.spacer { flex: 1; }
.chip { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; background: var(--panel-2); border: 2px solid var(--line); border-radius: 6px; }
.chip.who { padding-left: 2px; gap: 4px; }
.chip.who b { display: block; font-size: 15px; letter-spacing: 0.3px; }
.chip.who span { display: block; font-size: 15px; color: var(--gold); }
.chip.coin b { font-size: 15px; min-width: 18px; text-align: right; }
.chip.coin.bump { animation: bump 0.32s ease-out; border-color: var(--gold); }
.chip.iconbtn { padding: 0 8px; }
.spk { display: block; color: var(--text); image-rendering: pixelated; }
.spk .off { display: none; color: var(--ember); }
#sound.muted .spk { color: var(--muted); }
#sound.muted .spk .on { display: none; }
#sound.muted .spk .off { display: block; }
@keyframes bump { 0% { transform: translateY(0) scale(1); } 35% { transform: translateY(-3px) scale(1.08); } 100% { transform: none; } }

/* battle scene */
.stage { position: relative; width: 100%; aspect-ratio: 620 / 464; background: #05040a; overflow: hidden; flex: none; border-bottom: 2px solid var(--line); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shade { position: absolute; inset: 0 0 auto 0; height: 22%; background: linear-gradient(#07060dcc, #07060d00); pointer-events: none; }
.banner { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 5px 14px 6px; background: #0e0b1ad9; border: 2px solid var(--line-2); border-radius: 6px; }
.banner .zone { font-size: 15px; letter-spacing: 1.2px; text-transform: uppercase; white-space: nowrap; }
.dots { display: flex; align-items: center; gap: 0; }
.dots i { width: 6px; height: 6px; background: #2a2146; border: 2px solid var(--line-2); border-radius: 50%; }
.dots i.done { background: var(--gold); border-color: #b9862a; }
.dots i.now { background: var(--ember); border-color: #fff0c8; box-shadow: 0 0 8px var(--ember); }
.dots i.gate { border-radius: 2px; transform: rotate(45deg); margin-left: 2px; }
.dots s { width: 6px; height: 2px; background: var(--line-2); }
.dots s.done { background: #b9862a; }
.bossbar { position: absolute; left: 50%; top: 56px; width: 74%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.bossbar.on { opacity: 1; }
.bossbar b { font-size: 18px; letter-spacing: 1.5px; text-transform: uppercase; color: #ffd9c8; text-shadow: 0 2px 0 #000, 0 0 8px #000; white-space: nowrap; }
.bosstrack { position: relative; width: 100%; height: 12px; background: #1a0c12; border: 2px solid #0b0812; outline: 2px solid #6a2030; border-radius: 3px; overflow: hidden; }
.bosstrack div { position: absolute; inset: 0 auto 0 0; }
#bossLag { background: #fff3e0; transition: width 0.5s ease-out; }
#bossFill { background: linear-gradient(#ff7a5a 0 40%, #e0362c 40%); }
.taphint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); padding: 3px 10px; font-size: 15px; color: #ffe9a8; background: #0e0b1ad9; border: 2px solid #b9862a; border-radius: 6px; pointer-events: none; opacity: 0; white-space: nowrap; }
.taphint.on { animation: taphint 4s ease-out both; }
@keyframes taphint { 0% { opacity: 0; } 8% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.titlecard { position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; opacity: 0; }
.titlecard small { display: block; font-size: 15px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); }
.titlecard b { display: block; font-size: 30px; letter-spacing: 2px; text-transform: uppercase; text-shadow: 0 2px 0 #000, 0 0 18px #000; }
.titlecard.show { animation: card 2.4s ease-out both; }
@keyframes card { 0% { opacity: 0; transform: translateY(8px); } 18% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.soundhint { position: absolute; right: 6px; bottom: 6px; padding: 3px 8px; font-size: 15px; color: var(--muted); background: #0e0b1ad9; border: 2px solid var(--line); border-radius: 6px; pointer-events: none; transition: opacity 0.3s; }
.soundhint.gone { opacity: 0; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: #05040a; }
.loading.gone { display: none; }

/* spell bar */
.spellbar { display: flex; align-items: stretch; justify-content: center; gap: 5px; padding: 5px 8px; background: var(--panel); border-bottom: 2px solid var(--line); }
.auto { flex: none; width: 44px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: #1a1626; border: 2px solid var(--line); border-radius: 6px; color: var(--muted); }
.auto small { font: 10px "Jersey 10", monospace; letter-spacing: 1.5px; }
.auto b { font-size: 15px; }
.auto.on { background: #12301e; border-color: #2f8a4a; color: #b9ffcb; }
.auto:active, .slot:active { transform: translateY(1px); }
.slots { flex: none; display: grid; grid-template-columns: repeat(var(--n, 5), 44px); gap: 5px; }
.slot { position: relative; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; background: var(--panel-2); border: 2px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.slot.ready { border-color: #ffd98a; box-shadow: inset 0 0 0 1px #ffb24a66; }
.slot.cast { animation: cast 0.28s ease-out; }
@keyframes cast { 0% { transform: scale(0.92); border-color: #fff; } 100% { transform: none; } }
.slot .sweep { position: absolute; inset: 0; background: conic-gradient(#07060dc4 calc(var(--p, 0) * 1turn), #0000 0); pointer-events: none; }
.slot .secs { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; text-shadow: 0 1px 0 #000, 0 0 6px #000; }
.slot .cost { position: absolute; right: 3px; bottom: 2px; font: 10px "Jersey 10", monospace; color: #9fd2ff; text-shadow: 0 1px 0 #000; }
.slot .name { display: none; position: absolute; left: 0; right: 0; top: 2px; font: 10px "Jersey 10", monospace; letter-spacing: 0.3px; color: #d9cfff; text-align: center; text-shadow: 0 1px 0 #000; white-space: nowrap; }
.slot.low .ico { filter: saturate(0.2) brightness(0.7); }
.slot.locked { background: #120f1f; border-color: var(--line); }
.slot.locked .ico.spell { opacity: 0.22; filter: grayscale(1); }
.slot.locked .lock { position: absolute; }
.slot.locked .cost { color: var(--muted); left: 0; right: 0; text-align: center; }
.slot.learned { animation: learned 1.2s ease-out; }
@keyframes learned { 0% { border-color: #fff; box-shadow: 0 0 0 3px #ffd98a, 0 0 18px #ffb24a; transform: scale(1.12); } 100% { transform: none; } }
.slot.locked::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, #0000 40%, #ffffff14 50%, #0000 60%); background-size: 300% 100%; animation: shimmer 4.5s linear infinite; }
@keyframes shimmer { 0% { background-position: 120% 0; } 60%, 100% { background-position: -60% 0; } }

/* lower panel: the other activities, at a glance */
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--bg); overflow: hidden; }
.pane { display: contents; }
.pane[hidden] { display: none; }
.wardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex: none; }
.wardhead b { font-size: 18px; letter-spacing: 0.5px; }
.wardhead span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.looks { flex: none; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* gear: what he wears, his numbers, the bag */
.pane.gearpane:not([hidden]), .pane.craftpane:not([hidden]) { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.gi { flex: none; display: block; width: 48px; height: 48px; background-image: var(--gear); background-repeat: no-repeat; background-position: calc(var(--gx) * -48px) calc(var(--gy) * -48px); image-rendering: pixelated; }
.geartop { flex: none; display: flex; gap: 8px; align-items: stretch; }
.portrait { --c: #aab0b8; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; width: 132px; padding: 4px 4px 5px; background: linear-gradient(color-mix(in srgb, var(--c) 18%, var(--panel)), var(--panel) 70%); border: 2px solid color-mix(in srgb, var(--c) 65%, var(--line)); border-radius: 6px; text-align: center; overflow: hidden; }
.portrait canvas { display: block; width: 124px; height: 198px; margin: -18px 0 0; image-rendering: pixelated; }
.portrait b { color: var(--c); font-size: 15px; white-space: nowrap; }
.portrait span { font: 10px "Jersey 10", monospace; color: var(--muted); white-space: nowrap; }
.portrait.bump { animation: newlook 0.7s ease-out; }
@keyframes newlook { 0% { filter: brightness(2.4); transform: scale(1.04); } 100% { filter: none; transform: none; } }
.gearside { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.worn { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.cell { --c: var(--line); position: relative; display: grid; place-items: center; height: 56px; padding: 0; background: color-mix(in srgb, var(--c) 14%, var(--panel)); border: 2px solid color-mix(in srgb, var(--c) 70%, var(--line)); border-radius: 6px; overflow: hidden; }
.cell.empty { background: #0f0c1c; border-color: var(--line); border-style: dashed; opacity: 0.6; }
.cell.picked { border-color: #fff; box-shadow: 0 0 0 1px #fff8, inset 0 0 10px color-mix(in srgb, var(--c) 50%, #0000); }
.cell.worn { height: 66px; align-content: start; padding-top: 1px; }
.cell small { position: absolute; left: 0; right: 0; bottom: 2px; font: 10px "Jersey 10", monospace; color: var(--muted); text-align: center; }
.cell .better { position: absolute; right: 3px; top: 3px; width: 0; height: 0; border: 5px solid #0000; border-bottom: 7px solid var(--ok); border-top: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; padding: 5px 7px; background: var(--panel); border: 2px solid var(--line); border-radius: 6px; }
.stat { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.stat span { color: var(--muted); flex: 1; }
.stat em, .detail em { font-style: normal; font: 10px "Jersey 10", monospace; margin-left: 4px; color: var(--muted); }
.stat em.up, .detail em.up { color: var(--ok); }
.stat em.down, .detail em.down { color: #ff6a52; }
.stat.changed b { animation: statpop 0.6s ease-out; }
@keyframes statpop { 0% { color: #fff; transform: scale(1.35); } 100% { transform: none; } }
.detail { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 5px 7px; background: #0f0c1c; border: 2px solid var(--line); border-radius: 6px; min-height: 64px; }
.detail p { margin: 0; }
.detail .hint { color: var(--muted); line-height: 1.15; }
.dhead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dhead .gi { margin: -8px -6px; transform-origin: center; }
.dhead b { display: block; color: var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dhead span { display: block; font: 10px "Jersey 10", monospace; color: var(--muted); margin-top: 2px; }
.dhead > div { min-width: 0; }
.acts { display: flex; gap: 5px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: 1; height: 28px; padding: 0 8px; background: var(--panel-2); border: 2px solid var(--line-2); border-radius: 6px; white-space: nowrap; }
.btn.go { background: #12301e; border-color: #2f8a4a; color: #b9ffcb; }
.btn:active { transform: translateY(1px); }
.btn.off { opacity: 0.45; }
.bag { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }

/* brew: the cauldron under the battle */
.brewbox { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; background: linear-gradient(#1a1430, var(--panel)); border: 2px solid var(--line); border-radius: 6px; }
.cauldronbtn { position: relative; flex: none; width: 124px; height: 112px; padding: 0; background: radial-gradient(closest-side, #2a1f4a, #0000); border: 0; border-radius: 8px; overflow: visible; }
.cauldronbtn canvas { display: block; width: 96px; height: 96px; margin: 2px auto 0; image-rendering: pixelated; transform-origin: 50% 90%; }
.cauldronbtn:active canvas { transform: scale(1.04, 0.94); }
.cauldronbtn.kick canvas { animation: kick 0.5s cubic-bezier(.3,1.6,.5,1); }
@keyframes kick { 0% { transform: scale(1.14, 0.8); } 35% { transform: scale(0.9, 1.16) translateY(-5px); } 65% { transform: scale(1.05, 0.96); } 100% { transform: none; } }
.cauldronbtn.poor canvas { filter: saturate(0.45) brightness(0.8); }
.brewcost { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; font-size: 15px; color: var(--gold); background: #0e0b1ae6; border: 2px solid #b9862a; border-radius: 6px; white-space: nowrap; }
.brewside { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.brewhead { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; white-space: nowrap; }
.brewhead b { font-size: 18px; letter-spacing: 0.5px; }
.brewhead span { font: 10px "Jersey 10", monospace; color: var(--muted); }
.brewx { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.xbtn { height: 28px; padding: 0; background: var(--panel-2); border: 2px solid var(--line-2); border-radius: 6px; font-size: 15px; white-space: nowrap; }
.xbtn.on { background: #12301e; border-color: #2f8a4a; color: #b9ffcb; }
.xbtn.locked { color: var(--muted); border-color: var(--line); background: #120f1f; font: 10px "Jersey 10", monospace; }
.brewodds { display: flex; gap: 8px; font: 10px "Jersey 10", monospace; white-space: nowrap; }
.brewodds span, .oddsfull span { color: var(--c); }
.brewout { flex: none; display: flex; gap: 5px; min-height: 60px; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.brewout:empty::before { content: "What you brew lands here. Tap a piece to open it in Gear."; align-self: center; color: var(--muted); font: 10px "Jersey 10", monospace; padding-left: 4px; }
.cell.out { flex: none; width: 56px; }
.cell.out.shiny { box-shadow: 0 0 10px color-mix(in srgb, var(--c) 70%, #0000), inset 0 0 8px color-mix(in srgb, var(--c) 45%, #0000); }
.brewinfo { padding: 8px 10px; background: var(--panel); border: 2px solid var(--line); border-radius: 6px; line-height: 1.2; }
.brewinfo h3 { margin: 0 0 6px; font: inherit; font-size: 18px; }
.brewinfo p { margin: 0 0 8px; color: var(--muted); }
.oddsfull { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; margin-bottom: 8px; }
.card.tap { cursor: pointer; }
.card.ready { border-color: #2f8a4a; }
.tab.alert::after { content: ""; position: absolute; top: 5px; right: 22%; width: 8px; height: 8px; background: var(--ember); border: 2px solid #fff0c8; border-radius: 50%; }
.tab { position: relative; }
.look { --c: #9aa0a8; flex: none; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; width: calc(var(--cw) * 2 + 26px); padding: 6px 8px 7px; background: linear-gradient(color-mix(in srgb, var(--c) 16%, var(--panel)), var(--panel) 62%); border: 2px solid color-mix(in srgb, var(--c) 65%, var(--line)); border-radius: 6px; text-align: center; }
.look h3 { margin: 0; font: inherit; font-size: 20px; letter-spacing: 1px; text-transform: uppercase; color: var(--c); white-space: nowrap; }
.look h3 small { margin-left: 6px; font-size: 15px; letter-spacing: 0.4px; text-transform: none; color: var(--text); -webkit-text-fill-color: var(--text); }
.look .views { display: flex; align-items: flex-end; justify-content: center; }
.look .views i { display: block; width: var(--cw); height: var(--ch); background-image: var(--looks); background-repeat: no-repeat; background-position: calc(var(--v) * var(--cw) * -1) calc(var(--r) * var(--ch) * -1); image-rendering: pixelated; }
.look p { margin: 0; color: var(--muted); line-height: 1.12; text-wrap: balance; }
.look.ascendant h3 { background: linear-gradient(90deg, #5ff0d0, #ff7ad9, #ffd166); -webkit-background-clip: text; background-clip: text; color: transparent; }
.look.ascendant { border-image: linear-gradient(120deg, #5ff0d0, #ff7ad9, #ffd166) 1; border-radius: 0; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 6px 6px; background: var(--panel); border: 2px solid var(--line); border-radius: 6px; text-align: center; }
.card > div { width: 100%; }
.card b { display: block; font-size: 15px; letter-spacing: 0.4px; }
.card span { display: block; font: 10px "Jersey 10", monospace; color: var(--muted); margin: 1px 0 4px; white-space: nowrap; }
.card em { display: block; font-style: normal; font: 10px "Jersey 10", monospace; color: var(--gold); margin-top: 3px; }
.mini { height: 6px; background: #0a0814; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.mini > div { height: 100%; width: 0; background: var(--ok); }
.mini.key > div { background: var(--gold); }
.mini.cinder > div { background: var(--ember); }
.quest { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px; background: var(--panel); border: 2px solid var(--line); border-radius: 6px; }
.quest > div { flex: 1; }
.quest b { display: block; font-weight: 400; margin-bottom: 5px; }
.quest em { font-style: normal; color: var(--gold); }
.quest.done { border-color: #b9862a; }
.log { flex: 1; min-height: 0; margin: 0; padding: 6px 8px; list-style: none; background: #0f0c1c; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; font-size: 15px; color: var(--muted); }
.log li { display: flex; align-items: center; gap: 6px; animation: logIn 0.25s ease-out; white-space: nowrap; }
.log li b { color: var(--text); }
.log li.gold b { color: var(--gold); }
.log li.up b { color: #d9a8ff; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }

/* tabs */
.tabs { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--panel); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0 5px; background: none; border: 0; border-top: 3px solid #0000; color: var(--muted); font: 10px "Jersey 10", monospace; letter-spacing: 0.3px; }
.tab .ico { opacity: 0.6; }
.tab.on { color: var(--text); border-top-color: var(--ember); background: linear-gradient(#ff8a2a1f, #0000); }
.tab.on .ico { opacity: 1; }

.toast { position: absolute; left: 50%; bottom: 76px; transform: translate(-50%, 8px); padding: 7px 12px; background: #0e0b1af2; border: 2px solid var(--line-2); border-radius: 6px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .slot.locked::after, .titlecard.show, .chip.coin.bump { animation: none; }
}

/* ---- v12: the lower screen. Pixel panels: square, stepped corners, a dark line outside and a coloured one inside. */
.px { --edge: #3b2f66; border: 0; border-radius: 0; background: var(--panel); box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px var(--edge), inset 0 6px 0 0 #ffffff0d;
  clip-path: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px)); }
.spellbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; background: #120e22; border-bottom: 2px solid #07060d; box-shadow: inset 0 -2px 0 #b9862a55; }
.auto { flex: none; width: auto; height: 38px; padding: 0 14px; display: grid; place-items: center; --edge: #3a3550; background: #1a1626; color: var(--muted); }
.auto b { font-size: 18px; letter-spacing: 1.5px; }
.auto.on { --edge: #2f8a4a; background: #12301e; color: #b9ffcb; }
.slots { flex: none; display: flex; gap: 6px; }
.slot { position: relative; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; --edge: #4c3d80; background: #1e1836; overflow: hidden; }
.slot.ready { --edge: #ffd98a; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px var(--edge), inset 0 6px 0 0 #ffffff0d; }
.slot.locked { --edge: #2a2440; background: #120f1f; }
.slot.locked::after { content: none; }
.slot.locked .lock { position: static; opacity: 0.8; }
.slot .secs { font-size: 18px; }

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 8px; background: #0d0a18; overflow: hidden; }
.pane.mainpane:not([hidden]) { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; overflow-y: auto; scrollbar-width: none; }
.slotgrid { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
/* a piece of gear in its frame: the rarity's own backdrop, its colour as the border, the level on a plate */
.gslot { --c: #3b2f66; --bg: none; position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: #151126 var(--bg) center / cover; image-rendering: pixelated;
  box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 5px var(--c), inset 0 0 0 7px #07060d99; overflow: hidden;
  clip-path: polygon(0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px)); }
.gslot .gi { width: 72px; height: 72px; background-size: 576px 576px; background-position: calc(var(--gx) * -72px) calc(var(--gy) * -72px); filter: drop-shadow(0 2px 0 #07060d88); }
.gslot em { position: absolute; left: 7px; bottom: 7px; padding: 1px 4px 0; font-style: normal; font-size: 15px; letter-spacing: 0.5px; color: #f1ebff; background: #07060dd9; box-shadow: 0 0 0 1px #ffffff22; }
.gslot:active { transform: translateY(1px); }
.gslot.empty { background: #0f0c1c; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #241d40; }
.gslot .better { position: absolute; right: 8px; top: 8px; width: 0; height: 0; border: 6px solid #0000; border-bottom: 8px solid var(--ok); border-top: 0; filter: drop-shadow(0 1px 0 #000); }
.gslot.big { flex: none; width: 96px; }
@media (max-height: 760px) { .slotgrid .gslot { aspect-ratio: 1.2; } .slotgrid .gslot .gi { width: 48px; height: 48px; background-size: 384px 384px; background-position: calc(var(--gx) * -48px) calc(var(--gy) * -48px); } }

.brewrow { flex: none; display: grid; grid-template-columns: 1.55fr 1fr; gap: 8px; }
.cauldronbox { position: relative; height: 150px; --edge: #6a4fb0; background: radial-gradient(ellipse at 50% 62%, #2c1f58, #150f2c 72%); }
.saved { position: absolute; left: 10px; top: 10px; z-index: 2; padding: 2px 8px 1px; font-size: 15px; letter-spacing: 1px; color: var(--muted); background: #0e0b1a; border: 2px solid #b9862a; border-radius: 0; }
.saved b { color: var(--text); font-weight: 400; margin-left: 2px; }
.saved.has { border-color: var(--ok); }
.saved.has b { color: var(--ok); }
.cauldronbtn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); width: 128px; height: 112px; padding: 0; background: none; border: 0; }
.cauldronbtn canvas { display: block; width: 128px; height: 112px; margin: 0; image-rendering: pixelated; transform-origin: 50% 88%; }
.brewcost { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 2; pointer-events: none; }
.pops { position: absolute; inset: 0; pointer-events: none; }
.pop { --c: #aab0b8; position: absolute; width: 48px; height: 48px; padding: 0; background: none; border: 0; pointer-events: auto; filter: drop-shadow(0 0 5px var(--c)) drop-shadow(0 2px 0 #07060d); }
.pop.shiny { filter: drop-shadow(0 0 8px var(--c)) drop-shadow(0 0 2px #fff) drop-shadow(0 2px 0 #07060d); }
.pop.gone { pointer-events: none; }
.pop em { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); padding: 0 4px; font-style: normal; font: 10px "Jersey 10", monospace; color: #b9ffcb; background: #12301e; border: 1px solid #2f8a4a; white-space: nowrap; }
.pop em.s { color: var(--gold); background: #2a1c06; border-color: #b9862a; }
.pop .better { position: absolute; right: 0; top: 0; width: 0; height: 0; border: 6px solid #0000; border-bottom: 8px solid var(--ok); border-top: 0; }
.brewside { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.autobrew { flex: 1; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 10px; --edge: #2f8a4a; background: #10261c; }
.autobrew.locked { --edge: #2a2440; background: #120f1f; }
.autobrew.locked b { color: var(--muted); }
.autolabel { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.autolabel b { font-size: 15px; letter-spacing: 1.5px; color: #b9ffcb; font-weight: 400; white-space: nowrap; }
.switch { position: relative; width: 44px; height: 20px; padding: 0; background: #0b0914; border: 2px solid #3a3550; border-radius: 0; }
.switch i { position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; background: #6a6480; transition: left 0.12s steps(3); }
.switch.on { background: #1f6a38; border-color: #4ad66d; }
.switch.on i { left: 26px; background: #eafff0; }
.cogbtn { flex: none; width: 38px; height: 100%; display: grid; place-items: center; padding: 0; background: none; border: 0; border-left: 2px solid #ffffff1a; }
.tier { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px; --edge: #6a4fb0; background: #1c1440; color: var(--text); }
.tier b { font-size: 20px; letter-spacing: 2px; font-weight: 400; }
.tier span { display: inline-flex; align-items: center; gap: 3px; font-size: 15px; color: var(--muted); white-space: nowrap; }
.tier.ready { --edge: #ffd166; }
.tier.ready span { color: var(--gold); }

/* the Gear screen */
.geartop { flex: none; display: flex; gap: 8px; align-items: stretch; }
.portrait { flex: none; width: 132px; display: grid; place-items: end center; padding: 0 4px 6px; background: radial-gradient(ellipse at 50% 70%, #2c1f58, #150f2c 75%); --edge: #6a4fb0; overflow: hidden; border: 0; }
.portrait canvas { margin: -14px 0 0; }
.stats { flex: 1; display: grid; grid-template-columns: 1fr; align-content: center; gap: 5px; padding: 10px 12px; border: 0; }
.stat em { margin-left: 6px; }
.bag { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.bag .gslot .gi { width: 48px; height: 48px; background-size: 384px 384px; background-position: calc(var(--gx) * -48px) calc(var(--gy) * -48px); }
.bag .gslot em { left: 4px; bottom: 4px; font: 10px "Jersey 10", monospace; padding: 0 3px; }
.bag .gslot .better { right: 5px; top: 5px; }

/* sheets */
.sheet { position: absolute; inset: 0; z-index: 20; display: grid; place-items: end center; padding: 10px 10px calc(70px + env(safe-area-inset-bottom)); background: #05040acc; }
.sheet[hidden] { display: none; }
.sheetbox { position: relative; width: 100%; max-width: 420px; padding: 16px 14px 14px; --edge: #6a4fb0; background: #171230; animation: sheetIn 0.16s steps(4); }
@keyframes sheetIn { from { transform: translateY(16px); opacity: 0; } }
.sheetbox .x { position: absolute; right: 8px; top: 8px; width: 28px; height: 28px; padding: 0; font-size: 18px; color: var(--muted); background: #0e0b1a; border: 2px solid #3b2f66; border-radius: 0; }
.sheetbox h3 { margin: 0 0 10px; font: inherit; font-size: 20px; letter-spacing: 1px; }
.sheetbox label { display: block; margin: 10px 0 5px; color: var(--muted); }
.sheetbox .row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.sheetbox .row.five { grid-template-columns: repeat(5, 1fr); }
.sheetbox .fine { margin: 10px 0 0; color: var(--muted); line-height: 1.2; }
.sheetbox .acts { margin-top: 12px; }
.ihead { display: flex; gap: 12px; align-items: center; padding-right: 30px; }
.ihead b { display: block; font-size: 20px; font-weight: 400; }
.ihead span { display: block; color: var(--muted); margin: 3px 0 8px; }
.ihead p { margin: 0; font-size: 18px; }
.ihead p em { font-style: normal; font-size: 15px; margin-left: 8px; color: var(--muted); }
.ihead p em.up { color: var(--ok); }
.ihead p em.down { color: #ff6a52; }
.btn { height: 36px; font-size: 18px; border: 0; }
.btn.go { --edge: #2f8a4a; background: #12301e; }
.xbtn { height: 32px; border: 0; --edge: #4c3d80; background: #1e1836; color: var(--text); font-size: 15px; }
.xbtn.on { --edge: #4ad66d; background: #12301e; color: #b9ffcb; }
.xbtn[style] { color: var(--c); }
.xbtn.locked { --edge: #2a2440; background: #120f1f; color: var(--muted); font: 10px "Jersey 10", monospace; }
.oddsgrid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 4px 10px; font-size: 15px; }
.oddsgrid.max { grid-template-columns: 1.4fr 1fr; }
.oddsgrid i { font-style: normal; font: 10px "Jersey 10", monospace; color: var(--muted); }
.oddsgrid b { font-weight: 400; text-align: right; }
.oddsgrid em { font-style: normal; text-align: right; color: var(--ok); }
.oddsgrid i:nth-child(n+2) { text-align: right; }

.tabs { grid-template-columns: repeat(5, 1fr); background: #120e22; border-top: 2px solid #07060d; box-shadow: inset 0 2px 0 #b9862a55; }
.tab { padding: 4px 0 4px; }
.toast { z-index: 30; }
.toast { top: calc(var(--col) * 0.62); bottom: auto; }

/* ---- v13: round spells, the review, the tier and settings sheets, Magic */
.slot { width: 42px; height: 42px; border-radius: 50%; clip-path: none; background: #0e0b1a; border: 0; box-shadow: 0 0 0 2px #07060d, 0 0 0 4px #4c3d80, 0 0 0 6px #07060d; margin: 4px 5px; overflow: hidden; }
.slot .ico.spell { --s: 32px; width: 42px; height: 42px; background-size: calc(42px * var(--icon-n, 24)) 42px; background-position: calc(var(--i) * -42px) 0; }
.slot.ready { box-shadow: 0 0 0 2px #07060d, 0 0 0 4px #ffd98a, 0 0 0 6px #07060d, 0 0 10px 4px #ffb24a66; }
.slot.locked { background: #120f1f; box-shadow: 0 0 0 2px #07060d, 0 0 0 4px #2a2440, 0 0 0 6px #07060d; }
.slot .sweep { border-radius: 50%; }
.slots { gap: 2px; }
.gi.sm { width: 32px; height: 32px; background-size: 256px 256px; background-position: calc(var(--gx) * -32px) calc(var(--gy) * -32px); flex: none; }

.cauldronbox { height: 158px; }
.cauldronbtn { top: 44%; transform: translate(-50%, -50%); }
.sheet { place-items: center; padding: 10px; overflow-y: auto; }
.sheetbox { max-height: calc(100% - 20px); overflow-y: auto; scrollbar-width: none; background: linear-gradient(#221a48, #151030); }
.sheetbox h3.gold, .gold { color: #ffd166; }
.sheetbox h3 { text-align: center; letter-spacing: 2px; }
.sheetbox h3.big { font-size: 24px; letter-spacing: 1px; margin: 4px 0 10px; }
.rsub { margin: -6px 0 10px; text-align: center; color: #b9a8e8; }
.rhead { font-size: 26px !important; letter-spacing: 4px !important; text-shadow: 0 2px 0 #07060d, 0 0 12px currentColor; margin-bottom: 8px !important; }
.versus { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vs { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 2; width: 30px; height: 30px; display: grid; place-items: center; font-style: normal; font-size: 15px; color: #2a1c06; background: #ffd166; box-shadow: 0 0 0 2px #07060d; border-radius: 50%; }
.rcard { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0 6px 8px; background: #120e26; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #3b2f66; text-align: center; min-width: 0; }
.rcard.new { box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px var(--c), 0 0 14px color-mix(in srgb, var(--c) 45%, #0000); }
.rtitle { align-self: stretch; margin: 4px 4px 4px; padding: 3px 0 2px; font-style: normal; font-size: 15px; letter-spacing: 2px; color: var(--muted); background: #1c1640; }
.rcard.new .rtitle { color: #07060d; background: var(--c); }
.rcard .gslot.big { width: 84px; }
.rcard > b { font-size: 18px; font-weight: 400; line-height: 1.05; min-height: 38px; display: grid; place-items: center; }
.rrar { display: inline-flex; align-items: center; gap: 5px; color: var(--c); font-size: 15px; white-space: nowrap; }
.rrar u { width: 10px; height: 10px; background: var(--c); }
.rstat { align-self: stretch; display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; padding: 6px 8px; background: #0b0918; text-align: left; }
.rstat i { grid-column: 1 / -1; font-style: normal; font: 10px "Jersey 10", monospace; letter-spacing: 1px; color: var(--muted); }
.rstat b { font-size: 20px; font-weight: 400; }
.rstat em, .ifeq em { font-style: normal; font-size: 15px; align-self: center; color: var(--muted); }
em.up { color: var(--ok) !important; }
em.down { color: #ff6a52 !important; }
.ifeq { margin-top: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #10261c; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #2f8a4a; }
.ifeq.down { background: #2a1216; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #8a2f3a; }
.ifeq i { font-style: normal; font: 10px "Jersey 10", monospace; letter-spacing: 2px; color: #b9ffcb; }
.ifeq b { font-size: 22px; font-weight: 400; }
.acts.two { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.acts.two .btn { height: 48px; flex-direction: column; gap: 0; }
.btn.sal { --edge: #6a2f4a; background: #2a1420; font-size: 15px; }
.btn small { font: 10px "Jersey 10", monospace; color: var(--gold); display: inline-flex; align-items: center; gap: 3px; }
.btn.later { width: 100%; margin-top: 8px; --edge: #cbbf9a; background: #f1e6c8; color: #2a1c06; }
.btn.up { height: 54px; flex-direction: column; gap: 2px; }
.btn.up b { font-size: 20px; letter-spacing: 3px; font-weight: 400; }
.btn.up small { font-size: 15px; font-family: inherit; }
.group { margin-top: 10px; padding: 8px; background: #120e26; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #3b2f66; }
.group label { display: flex; justify-content: space-between; margin: 0 0 8px; color: #ffd166; letter-spacing: 2px; }
.group label i { font-style: normal; letter-spacing: 0; color: #b9a8e8; font: 10px "Jersey 10", monospace; align-self: center; }
.bbtn { height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; --edge: #4c3d80; background: #1e1836; color: var(--text); border: 0; padding: 0; }
.bbtn b { font-size: 20px; font-weight: 400; }
.bbtn small { display: inline-flex; align-items: center; gap: 2px; font: 10px "Jersey 10", monospace; color: #b9a8e8; }
.bbtn.on { --edge: #ffe9a8; background: #e0a82e; color: #2a1c06; }
.bbtn.on small { color: #2a1c06; }
.bbtn.locked { --edge: #2a2440; background: #120f1f; color: var(--muted); }
.notice { margin: 0 0 8px; padding: 8px; line-height: 1.2; background: #10261c; box-shadow: inset 0 0 0 2px #2f8a4a; }
.notice b { color: #7dffa3; font-weight: 400; }
.rhd { display: grid; grid-template-columns: 1fr auto 56px; gap: 8px; padding: 2px 10px 4px; font: 10px "Jersey 10", monospace; letter-spacing: 1px; color: #b9a8e8; }
.rhd i { font-style: normal; text-align: right; }
.rhd i:first-child { text-align: left; }
.rlist { display: flex; flex-direction: column; gap: 5px; }
.rbar { --c: #aab0b8; width: 100%; display: flex; align-items: center; gap: 8px; height: 40px; margin-bottom: 5px; padding: 0 10px 0 6px; border: 0; color: #f1ebff; text-align: left;
  background: linear-gradient(color-mix(in srgb, var(--c) 22%, #151030), color-mix(in srgb, var(--c) 10%, #100c24)); box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 3px color-mix(in srgb, var(--c) 35%, #07060d); }
.rbar.on { background: linear-gradient(color-mix(in srgb, var(--c) 78%, #fff 0%), color-mix(in srgb, var(--c) 52%, #151030)); box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px color-mix(in srgb, var(--c) 80%, #fff), inset 0 6px 0 #ffffff2e; text-shadow: 0 1px 0 #07060dcc; }
.rlist .rbar { margin: 0; }
.rbar b { flex: 1; font-size: 18px; font-weight: 400; }
.rbar:not(.on) b { color: #b9b0d8; }
.rbar em { font-style: normal; font-size: 20px; }
.rbar em.from { font-size: 15px; color: #b9b0d8; }
.rbar .chip { min-width: 62px; padding: 2px 6px 1px; text-decoration: none; text-align: center; font-size: 15px; background: #07060dcc; text-shadow: none; }
.rbar .chip.up { color: #7dffa3; }
.rbar .chip.down { color: #ff8a8a; }
.tick { width: 24px; height: 24px; margin-left: 14px; background: #07060d99; box-shadow: inset 0 0 0 2px #ffffff66; text-decoration: none; display: grid; place-items: center; }
.tick.on { background: #1f8a44; box-shadow: inset 0 0 0 2px #b9ffcb; }
.tick.on::after { content: ""; width: 10px; height: 5px; border-left: 3px solid #fff; border-bottom: 3px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.potpic { display: block; width: 96px; height: 96px; margin: -6px auto -4px; background: center / 96px 96px no-repeat; image-rendering: pixelated; }

.pane.magicpane:not([hidden]) { display: flex; flex-direction: column; gap: 6px; min-height: 0; flex: 1; overflow-y: auto; scrollbar-width: none; }
.spelllist { display: flex; flex-direction: column; gap: 5px; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; background: #151126; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #3b2f66; }
.mrow > div { flex: 1; min-width: 0; }
.mrow b { display: block; font-size: 18px; font-weight: 400; }
.mrow span:not(.slot) { display: block; color: var(--muted); line-height: 1.1; }
.mrow em { font-style: normal; color: var(--gold); white-space: nowrap; }
.mrow.locked b, .mrow.locked em { color: var(--muted); }
.mrow .slot { flex: none; }
.complist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.comp { --c: #aab0b8; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 6px 8px; text-align: center; background: #151126; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px color-mix(in srgb, var(--c) 70%, #07060d); }
.comp.on { box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px var(--c), 0 0 12px color-mix(in srgb, var(--c) 50%, #0000); }
.cpic { display: grid; place-items: center; width: 100%; height: 72px; background: var(--bg) center / cover; image-rendering: pixelated; box-shadow: inset 0 0 0 2px #07060d; }
.cpic u { width: 64px; height: 64px; background: var(--comps) calc(var(--n) * -64px) 0 / auto 64px no-repeat; filter: drop-shadow(0 2px 0 #07060d88); }
.comp b { font-size: 18px; font-weight: 400; color: var(--c); }
.comp span { font: 10px "Jersey 10", monospace; color: var(--muted); }
.comp em { font-style: normal; color: #b9ffcb; }
.comp .btn { width: 100%; height: 30px; font-size: 15px; margin-top: 3px; }
.comp .btn.on { --edge: #ffd166; background: #3a2c0a; color: #ffe9a8; }

/* ---- v14: a smaller spell strip, flat and living rarity frames, the wider cauldron, Magic as a screen */
.spellbar { padding: 4px 8px; }
.auto { height: 30px; padding: 0 10px; }
.auto b { font-size: 15px; letter-spacing: 1px; }
/* a spell is its own round emblem, shown pixel for pixel: no ring round it */
.slot, .slot.ready, .slot.locked { width: 32px; height: 32px; margin: 1px 4px; background: none; box-shadow: none; border-radius: 50%; overflow: visible; }
.slot .ico.spell { --s: 32px; width: 32px; height: 32px; background-size: calc(32px * var(--icon-n, 24)) 32px; background-position: calc(var(--i) * -32px) 0; }
.slot.ready .ico.spell { filter: drop-shadow(0 0 3px #ffd98a) drop-shadow(0 0 1px #ffb24a); }
.slot .sweep { inset: 2px; border-radius: 50%; }
.slot .secs { font-size: 15px; }
.slot.locked .lock { opacity: 0.7; }

/* rarity: one flat colour for the lower four, a living canvas inside the frame for the upper four */
.gslot { background: var(--fill, #151126); }
.rfx { position: absolute; left: 5px; top: 5px; width: calc(100% - 10px); height: calc(100% - 10px); image-rendering: pixelated; pointer-events: none; }
.gslot .gi { position: relative; }
.gslot em, .gslot .better { z-index: 1; }
.rbar { position: relative; background: color-mix(in srgb, var(--c) 14%, #100c24); }
.rbar.on { background: color-mix(in srgb, var(--c) 56%, #0e0b1a); box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px color-mix(in srgb, var(--c) 85%, #fff); }
.rbar .rfx { left: 4px; top: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
.rbar:not(.on) .rfx { opacity: 0.5; }
.rbar > :not(.rfx) { position: relative; }
.rbar b, .rbar em { text-shadow: 1px 0 #07060d, -1px 0 #07060d, 0 1px #07060d, 0 -1px #07060d, 0 2px #07060d; }
.rbar:not(.on) b, .rbar em.from { color: #e6dcff; }

.cauldronbtn { width: 220px; height: 150px; top: 50%; transform: translate(-50%, -50%); }
.cauldronbtn canvas { width: 220px; height: 150px; }
.cauldronbtn.kick canvas { animation: none; }

.tab { position: relative; }
.tab.alert::after { content: ""; position: absolute; left: calc(50% + 10px); top: 5px; width: 8px; height: 8px; background: #ffd166; box-shadow: 0 0 0 2px #07060d; }

.magic { position: absolute; left: 0; right: 0; top: 0; bottom: 56px; z-index: 15; display: flex; flex-direction: column; background: #0d0a18; }
.magic[hidden] { display: none; }
.mhead { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; background: linear-gradient(#2a1d5c, #1a1238); border-bottom: 2px solid #07060d; box-shadow: inset 0 -2px 0 #b9862a; }
.mback { flex: none; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; --edge: #b9862a; background: #1e1640; color: #ffd166; }
.mhead b { display: block; font-size: 26px; letter-spacing: 3px; color: #ffd166; font-weight: 400; margin-bottom: 3px; }
.mhead span { color: #b9a8e8; }
.seg { flex: none; display: grid; grid-template-columns: 1fr 1fr; margin: 8px 10px 0; padding: 4px; background: #07060d; box-shadow: inset 0 0 0 2px #3b2f66; }
.seg button { height: 36px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 18px; letter-spacing: 1px; }
.seg button.on { background: #e0a82e; color: #2a1c06; box-shadow: inset 0 0 0 2px #ffe9a8, inset 0 -5px 0 #b9862a; }
.mbody { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 14px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: none; }
.mbody > * { flex: none; }

.cpic { position: relative; flex: none; display: grid; place-items: center; width: 68px; height: 68px; background: var(--fill, #151126); box-shadow: inset 0 0 0 2px #07060d; }
.cpic .rfx { left: 2px; top: 2px; width: calc(100% - 4px); height: calc(100% - 4px); }
.cpic u { position: relative; width: 64px; height: 64px; background: var(--comps) calc(var(--n) * -64px) 0 / auto 64px no-repeat; image-rendering: pixelated; filter: drop-shadow(0 2px 0 #07060d88); }
.cpic.big { width: 136px; height: 136px; }
.cpic.big u { width: 128px; height: 128px; background-size: auto 128px; background-position: calc(var(--n) * -128px) 0; }
.cpic.bare { background: none; box-shadow: none; }
.cpic.dark { background: #120f1f; }
.cpic.dark u { filter: brightness(0) opacity(0.5); }

.feat { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px; min-height: 156px; background: var(--fill, #151126); box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 5px var(--c, #3b2f66); }
.feat > :not(.rfx) { position: relative; }
.feat .cpic.big { width: 128px; height: 128px; }
.finfo { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px; background: #07060dd9; }
.finfo > b { font-size: 22px; font-weight: 400; line-height: 1; }
.pill { padding: 2px 8px 1px; font-style: normal; color: #07060d; background: var(--c); letter-spacing: 1px; }
.flv { color: var(--muted); } .flv b { font-size: 20px; font-weight: 400; color: #ffd166; }
.fgift { color: #7dffa3; font-size: 18px; }
.fhit { color: #ffd166; }
.finfo p { margin: 2px 0 0; color: #cfc6ea; line-height: 1.15; }
.feat.none { min-height: 0; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #3b2f66; }
.feat.none .finfo { background: none; padding: 4px; }

.tokens { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #1c1440; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #6a4fb0; }
.tinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tinfo span { color: #b9a8e8; white-space: nowrap; }
.tinfo span b { font-size: 22px; font-weight: 400; color: #f1ebff; margin-right: 3px; }
.tbar { height: 8px; background: #07060d; box-shadow: inset 0 0 0 1px #6a4fb0; }
.tbar i { display: block; height: 100%; background: #b06cff; box-shadow: inset 0 2px 0 #d8b0ff; }
.tinfo em { font-style: normal; color: #c8a8ff; }
.tokens .btn { flex: none; height: 42px; padding: 0 12px; }
.tokens .btn:not(.go) { --edge: #4c3d80; background: #1e1836; color: var(--text); }

.chances { padding: 10px; background: #151126; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #3b2f66; }
.chances > b { display: block; font-size: 18px; font-weight: 400; color: #ffd166; margin-bottom: 3px; }
.chances > span { color: #b9a8e8; }
.crow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 8px 0; }
.cchip { padding: 5px 0 4px; text-align: center; background: color-mix(in srgb, var(--c) 20%, #0e0b1a); box-shadow: inset 0 0 0 2px var(--c); min-width: 0; }
.cchip i { display: block; margin-bottom: 3px; font-style: normal; font: 10px "Jersey 10", monospace; letter-spacing: 0.5px; color: var(--c); }
.cchip b { font-size: 18px; font-weight: 400; }
.chances p { margin: 0; color: var(--muted); line-height: 1.15; }

.colhead, .rankhead { display: flex; justify-content: space-between; align-items: baseline; }
.colhead { margin-top: 4px; }
.colhead b { font-size: 22px; font-weight: 400; color: #ffe9a8; }
.colhead span, .rankhead span { color: var(--muted); }
.rankhead b { font-size: 18px; font-weight: 400; color: var(--c); }
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ccard { --c: #3b2f66; display: flex; align-items: center; gap: 7px; min-width: 0; padding: 5px 6px 5px 5px; border: 0; border-radius: 0; text-align: left; color: var(--text); background: #151126; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px color-mix(in srgb, var(--c) 75%, #07060d); }
.ccard > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ccard b { font-weight: 400; line-height: 1.05; }
.ccard span { font: 10px "Jersey 10", monospace; color: #b9ffcb; letter-spacing: 0.3px; }
.ccard em { font-style: normal; font: 10px "Jersey 10", monospace; letter-spacing: 1px; color: #ffd166; }
.ccard.none { box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #2a2440; }
.ccard.none b, .ccard.none span { color: var(--muted); }
.ccard.on { box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px #ffd166, 0 0 10px #ffd16655; }
.ccard:active { transform: translateY(1px); }

.sgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sres { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 8px 4px; text-align: center; background: #120e26; box-shadow: inset 0 0 0 2px #07060d, inset 0 0 0 4px var(--c); }
.sres b { font-weight: 400; line-height: 1.05; }
.sres span { font: 10px "Jersey 10", monospace; letter-spacing: 1px; color: var(--c); }
.sres em { font-style: normal; color: #7dffa3; }
.sres.big { padding: 12px; gap: 6px; }
.sres.big b { font-size: 24px; }
.sres.big span { font-size: 15px; font-family: inherit; }
.sres.big em { font-size: 20px; }
.spelllist .mrow { padding: 6px 10px 6px 6px; }

/* ---- v15: everything on one screen, no scrolling. The scene gives up sky first, then the column narrows;
   the gear slots take whatever height is left. --rest: the height of everything that is not the scene. */
:root { --rest: calc(452px + env(safe-area-inset-top) + env(safe-area-inset-bottom)); --col: min(100vw, 480px, calc((var(--app-h, 100dvh) - var(--rest)) / 0.5)); --scene: calc(var(--col) * 464 / 620); }
.stage { aspect-ratio: auto; height: min(var(--scene), max(calc(var(--col) * 0.5), calc(var(--app-h, 100dvh) - var(--rest)))); }
#view { inset: auto 0 0 0; height: var(--scene); }
.pane.mainpane:not([hidden]) { overflow: hidden; }
.slotgrid { flex: 1 1 0; min-height: 118px; grid-template-rows: 1fr 1fr; container-type: size; }
.slotgrid .gslot { aspect-ratio: auto; min-height: 0; }
.slotgrid .gslot .gi { width: 48px; height: 48px; background-size: 384px 384px; background-position: calc(var(--gx) * -48px) calc(var(--gy) * -48px); }
@container (min-height: 180px) { .slotgrid .gslot .gi { width: 72px; height: 72px; background-size: 576px 576px; background-position: calc(var(--gx) * -72px) calc(var(--gy) * -72px); } }
.cauldronbox { height: 152px; }
.tabs { padding-bottom: env(safe-area-inset-bottom); }
