/* One dark-fantasy look for every screen: deep violet panels, thin gold edges, serif headings, ember accents.
   The canvas view (battle/view/canvas.js) uses the same colours. */
:root {
  --bg: #120c18;
  --panel: #1f1729;
  --panel2: #2a2036;
  --edge: #463857;
  --edge-hi: #6a5584;
  --gold: #e3b65a;
  --gold-dk: #9c7a32;
  --text: #f1e6cf;
  --muted: #b8a98f;
  --dim: #85789a;
  --ember: #e0703a;
  --blood: #b8383a;
  --relic: #a65bff;
  --upgrade: #5ad1ff;
  --effect: #6ee7a0;
  --active: #ffb040;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.35 system-ui, sans-serif; overflow: hidden; }
body { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
.screen { max-width: 520px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; padding: 12px 12px 10px; gap: 10px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: 0.3px; }
h1 { margin: 0; font-size: 26px; color: var(--gold); }
h2 { margin: 0; font-size: 22px; color: var(--gold); }
p { margin: 4px 0 0; color: var(--muted); }

button { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--edge); border-radius: 10px; padding: 10px 14px; min-height: 44px; }
button:disabled { opacity: 0.45; }
button.primary { background: linear-gradient(#ecc46a, #c99a3e); color: #1a1024; font-weight: 800; border: 1px solid #f5d98f; box-shadow: 0 3px 0 var(--gold-dk); }
button.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gold-dk); }
button.danger { background: var(--blood); color: #fff; border-color: #e06a5a; }

/* ---- Deck screen ---- */
#deck { overflow-y: auto; background: radial-gradient(ellipse at 50% -10%, #3a2550 0%, var(--bg) 60%); max-width: none; }
#deck > * { width: 100%; max-width: 496px; margin: 0 auto; }
#deck header { text-align: center; padding: 4px 0 2px; }
#deck header::after { content: ""; display: block; height: 1px; margin: 10px 20% 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
#classBlurb { font-size: 14px; }
.towers { display: flex; flex-direction: column; gap: 7px; }
.tower { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 8px 10px; }
.tower.off { opacity: 0.45; }
.tower .chip { flex: none; width: 44px; height: 44px; }
.tower > div { flex: 1; min-width: 0; }
.tower h3 { margin: 0; font-size: 17px; }
.tower h3 small { display: block; font-family: system-ui, sans-serif; color: var(--dim); font-weight: 400; font-size: 12px; letter-spacing: 0; }
.tower p { margin: 2px 0 0; font-size: 13.5px; }
.tower details { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tower summary { color: var(--gold); cursor: pointer; font-size: 12.5px; }
.tower .tick { margin: 12px 0 0 auto; flex: none; width: 20px; height: 20px; accent-color: var(--gold); }
.switches { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
select { font: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--edge); border-radius: 8px; padding: 8px; min-height: 40px; }
.seg { display: flex; }
.seg button { border-radius: 0; margin: 0; padding: 8px 10px; border-left-width: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; border-left-width: 1px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--gold); color: #1a1024; font-weight: 700; border-color: var(--gold); }
footer { padding-bottom: 6px; }
footer button { width: 100%; font-family: var(--serif); font-size: 19px; }
#deckNote { text-align: center; font-size: 13px; }

/* ---- Battle: one thin HUD row, the map edge to edge, a bottom tray ---- */
#battle { padding: 0; gap: 0; max-width: none; position: relative; background: var(--bg); }
.hud { height: 44px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 8px; padding-top: env(safe-area-inset-top); background: linear-gradient(#251b31, #18111f); border-bottom: 1px solid var(--gold-dk); }
.hud .stat { flex: 1; text-align: center; white-space: nowrap; font-weight: 700; font-size: 15px; transition: transform 0.15s; }
#wave { font-family: var(--serif); color: var(--text); }
.hud .lives { color: #ff8f80; }
.hud .lives::before { content: "\2665 "; }
.hud .lives.jolt { transform: scale(1.4); color: #ff5a4a; }
.hud .gold { color: #ffd870; }
.hud .gold::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff1b8, #e3b65a 55%, #9c7a32); vertical-align: -1px; }
.hud .gold.pulse { transform: scale(1.15); }
.hud button { min-height: 32px; height: 32px; padding: 0 10px; font-weight: 700; border-radius: 8px; }
.hud .icon { width: 34px; padding: 0; letter-spacing: 1px; font-family: var(--serif); color: var(--gold); }
#speedBtn { color: var(--gold); }
.stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; position: relative; background: #1a1322; }
#board { height: 100%; max-width: 100%; aspect-ratio: 420 / 700; touch-action: none; display: block; }
.toast { position: absolute; left: 8px; right: 8px; bottom: 8px; background: rgba(20, 12, 28, 0.95); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; z-index: 2; pointer-events: none; }
.toast b { color: var(--gold); }
.toast.hint { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(227, 182, 90, 0.25), 0 4px 14px rgba(0, 0, 0, 0.5); }
.tray { flex: none; background: linear-gradient(#18111f, #120c18); border-top: 1px solid var(--gold-dk); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.trayrow { display: flex; gap: 10px; align-items: center; }
.summon { flex: 1; height: 60px; background: linear-gradient(#ecc46a, #c99a3e); color: #1a1024; font-family: var(--serif); font-weight: 800; font-size: 21px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; border: 1px solid #f5d98f; box-shadow: 0 4px 0 var(--gold-dk); }
.summon .cost { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; opacity: 0.8; }
.summon:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--gold-dk); }
.round { flex: none; width: 66px; height: 66px; border-radius: 50%; padding: 4px; background: radial-gradient(circle at 40% 30%, #9a3f2c, #5a1e1c); color: #fff; font-weight: 700; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; border: 2px solid var(--ember); }
.round small { font-size: 11px; color: #ffe7a0; }
.heldrow { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; align-items: center; }
.heldrow .empty { color: var(--dim); font-size: 12px; }
.hchip { min-height: 28px; height: 28px; padding: 0 10px; border-radius: 14px; font-size: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--edge-hi); color: var(--text); }
.hchip.relic { border-color: var(--relic); box-shadow: inset 3px 0 0 var(--relic); }
.hchip.upgrade { border-color: var(--upgrade); box-shadow: inset 3px 0 0 var(--upgrade); }

.meter { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.pips { display: flex; gap: 6px; }
.pip { width: 14px; height: 14px; transform: rotate(45deg); border-radius: 3px; border: 2px solid var(--edge-hi); background: transparent; }
.pip.full { background: var(--relic); border-color: #d6a8ff; }
.meter.next { color: #ffe7a0; }
.meter.next .pip { border-color: #ffd870; }
.meter.next .pip.full { background: #ffd870; animation: beat 0.7s infinite; }
@keyframes beat { 50% { transform: rotate(45deg) scale(1.25); } }

/* ---- Cards: stops, guide, pause, end ---- */
.overlay { position: absolute; inset: 0; background: rgba(8, 4, 12, 0.82); display: grid; place-items: center; padding: 16px; z-index: 5; }
.card { background: linear-gradient(#251b31, var(--panel)); border: 1px solid var(--gold-dk); border-radius: 14px; padding: 16px; width: 100%; max-width: 380px; max-height: 90dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.card h2 { text-align: center; }
.card h2 + p { text-align: center; margin-top: -4px; font-size: 13.5px; }
.card h3 { margin: 8px 0 0; font-size: 15px; color: var(--gold); }
.card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.card td { padding: 3px 0; border-bottom: 1px solid rgba(70, 56, 87, 0.5); }
.card td:last-child { text-align: right; font-weight: 700; }
.confirm { background: var(--panel2); border: 1px solid var(--edge); border-radius: 8px; padding: 8px; }
.two { display: flex; gap: 8px; }
.two button { flex: 1; }
.stamps { display: flex; gap: 8px; justify-content: space-between; }
.stamp { flex: 1; text-align: center; font-family: var(--serif); font-size: 12px; font-weight: 800; border: 2px solid var(--edge); color: var(--dim); border-radius: 10px; padding: 8px 2px; transform: scale(1); opacity: 0.5; }
.stamp.got { border-color: var(--gold); color: var(--gold); opacity: 1; animation: stamp 0.35s ease-out; transform: rotate(-4deg); }
@keyframes stamp { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(-4deg); opacity: 1; } }
.guide { font-size: 13.5px; color: var(--muted); }
.guide h3 { color: var(--gold); }
.guide p { margin: 4px 0; }
.guide b { color: var(--text); }

.card.wide { max-width: 420px; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.offer { text-align: left; display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--edge); border-left: 4px solid var(--edge-hi); border-radius: 10px; padding: 8px 10px; min-height: 56px; width: 100%; }
.offer .body { flex: 1; }
.offer b { display: block; font-family: var(--serif); font-size: 15.5px; }
.offer small { color: var(--muted); font-size: 12.5px; }
.offer .price { flex: none; min-width: 44px; text-align: center; background: linear-gradient(#ecc46a, #c99a3e); color: #1a1024; border-radius: 8px; font-weight: 800; padding: 6px 8px; }
.offer .tier { color: #ffd870; font-weight: 700; font-family: system-ui, sans-serif; font-size: 12.5px; }
.offer.sold { opacity: 0.4; }
.offer.cant .price { background: #4a3d5c; color: var(--muted); }
.offer.relic { border-left-color: var(--relic); }
.offer.upgrade { border-left-color: var(--upgrade); }
.offer.effect { border-left-color: var(--effect); }
.offer.active { border-left-color: var(--active); }
.held { font-size: 13px; color: var(--muted); }
.held b { color: var(--text); }
.held ul { margin: 2px 0 6px; padding-left: 18px; }
