/* Spirehold — dark stone and parchment, gold accents. Phone first; a side sheet on wide screens. */
:root {
  --bg: #120e0a; --panel: rgba(26, 20, 14, 0.94); --panel2: rgba(38, 30, 22, 0.96); --line: #4a3c2a; --ink: #f0e6d0; --dim: #b8a888;
  --gold: #ffcf5a; --lore: #8fc8ff; --shard: #d8a0ff; --red: #ff6a5a; --green: #8aea7a; --blue: #8fd8ff;
  --font: 'Spectral', Georgia, serif; --head: 'Cinzel', Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --sheetW: 400px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
button { font: inherit; font-weight: 600; color: var(--ink); background: linear-gradient(#4a3a26, #2e2418); border: 1px solid #7a6040; border-radius: 7px; padding: 7px 12px; cursor: pointer; min-height: 40px; }
button:hover:not(:disabled) { border-color: var(--gold); box-shadow: 0 0 8px rgba(255, 200, 90, 0.25); }
button:disabled { opacity: 0.45; cursor: default; }
button.big { font-size: 1.15rem; padding: 11px 20px; min-height: 48px; font-family: var(--head); }
button.primary { background: linear-gradient(#8a6a2a, #5a4216); border-color: #e0b050; }
button.good { background: linear-gradient(#3a6a2a, #22421a); border-color: #7ac060; }
button.danger { background: linear-gradient(#7a2a20, #4a1810); border-color: #c05040; }
button.small { min-height: 32px; padding: 3px 9px; font-size: 0.9rem; }
button.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
button.pad-focus, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input, select, textarea { font: inherit; background: #1a140e; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.center { justify-content: center; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.hint { color: var(--dim); font-size: 0.9rem; margin: 4px 0; }
h1, h2, h3, h4 { font-family: var(--head); margin: 0; letter-spacing: 0.03em; }
.goldc { color: var(--gold); } .lorec { color: var(--lore); } .shardc { color: var(--shard); } .bad { color: var(--red); } .good { color: var(--green); }

/* title */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30; background: radial-gradient(ellipse at 50% 40%, rgba(60, 40, 10, 0.25), rgba(0, 0, 0, 0.6)); }
.title-card { text-align: center; padding: 24px; max-width: 480px; width: 100%; }
.title-card h1 { font-size: clamp(2.6rem, 12vw, 4.6rem); font-weight: 900; letter-spacing: 0.12em; color: #ffd98a; text-shadow: 0 0 24px rgba(255, 170, 60, 0.5), 0 3px 0 #5a3a10; }
.title-card .tag { color: var(--dim); margin: 6px 0 22px; font-size: 1.1rem; font-style: italic; }
#title-buttons button { width: 100%; }
#title-extra { margin-top: 14px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#hud > #toasts, #hud > .banner, #hud > .bars, #hud > .bossbar { pointer-events: none; }
.topbar { position: absolute; top: calc(6px + var(--safe-t)); left: calc(6px + var(--safe-l)); right: calc(6px + var(--safe-r)); display: flex; gap: 6px; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.icon-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 1.3rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; font-weight: 700; font-family: var(--head); white-space: nowrap; font-size: 0.95rem; }
.stat.gold { color: var(--gold); } .stat.gold::before { content: '◉ '; }
.stat.lore { color: var(--lore); } .stat.lore::before { content: '✎ '; }
.stat.shard { color: var(--shard); } .stat.shard::before { content: '✦ '; }
.row2 { position: absolute; top: calc(56px + var(--safe-t)); left: calc(6px + var(--safe-l)); display: flex; gap: 6px; align-items: stretch; }
.wavebox { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px 5px; min-width: 128px; position: relative; }
.wavebox b { font-family: var(--head); display: block; font-size: 0.95rem; }
.wavebox span { font-size: 0.78rem; color: var(--dim); display: block; line-height: 1.1; }
.wprog { display: block; height: 4px; background: #2a2218; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.wprog i { display: block; height: 100%; width: 0; background: var(--gold); }
.bars { position: absolute; top: calc(108px + var(--safe-t)); left: calc(6px + var(--safe-l)); width: min(220px, 52vw); display: flex; flex-direction: column; gap: 4px; }
.bar { position: relative; height: 17px; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { position: absolute; inset: 0; width: 100%; transform-origin: left; }
.bar span { position: relative; font-size: 0.75rem; font-weight: 700; padding-left: 5px; line-height: 15px; display: block; text-shadow: 0 1px 2px #000; }
.bar.wall > i { background: linear-gradient(90deg, #8a7a5a, #d8c8a0); }
.bar.mana > i { background: linear-gradient(90deg, #3a5aff, #8fd0ff); }
/* under the wall and mana bars, never over them (owner 2026-11-09) */
.bossbar { position: absolute; top: calc(154px + var(--safe-t)); left: calc(6px + var(--safe-l)); width: min(340px, calc(100vw - 12px)); text-align: left; }
.bossbar b { font-family: var(--head); color: #ffd070; text-shadow: 0 1px 3px #000; font-size: 0.95rem; }
.bossbar > i { display: block; height: 8px; background: rgba(0, 0, 0, 0.6); border: 1px solid #7a3020; border-radius: 4px; overflow: hidden; }
.bossbar > i > i { display: block; height: 100%; background: linear-gradient(90deg, #c03020, #ff9040); }

/* spells */
.spells { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(66px + var(--safe-b)); display: flex; gap: 6px; flex-wrap: nowrap; max-width: calc(100vw - 12px); overflow: hidden; }
.spell { position: relative; width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 10px; font-size: 1.4rem; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.spell .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.spell .k { position: absolute; top: 1px; left: 4px; font-size: 0.65rem; color: var(--dim); }
.spell .m { position: absolute; bottom: 1px; right: 4px; font-size: 0.65rem; color: var(--lore); font-weight: 700; }
.spell .auto { position: absolute; top: 1px; right: 3px; font-size: 0.6rem; color: var(--green); font-weight: 700; }
.spell.aiming { border-color: var(--gold); box-shadow: 0 0 12px rgba(255, 200, 90, 0.7); }
.spell.nomana { filter: saturate(0.3) brightness(0.7); }

/* tabs + sheet */
.tabs { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px calc(4px + var(--safe-r)) calc(4px + var(--safe-b)) calc(4px + var(--safe-l)); display: flex; gap: 3px; background: linear-gradient(transparent, rgba(10, 8, 6, 0.85) 30%); }
.tabs button { flex: 1; min-width: 0; padding: 2px 2px; display: flex; flex-direction: column; align-items: center; line-height: 1.05; min-height: 54px; font-size: 0.72rem; position: relative; }
.tabs button .ic { font-size: 1.25rem; }
.tabs button.on { background: linear-gradient(#8a6a2a, #5a4216); border-color: var(--gold); }
.tabs button .dot { position: absolute; top: 4px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }
.sheet { position: absolute; left: 0; right: 0; bottom: calc(62px + var(--safe-b)); height: 56vh; background: var(--panel); border-top: 2px solid #7a6040; display: flex; flex-direction: column; z-index: 5; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.05rem; color: #ffd98a; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px 10px 16px; touch-action: pan-y; overscroll-behavior: contain; }
body.sheet-open .spells { bottom: calc(56vh + 70px + var(--safe-b)); }
.sheet .subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
@media (min-width: 900px) {
  .sheet { left: auto; right: calc(6px + var(--safe-r)); top: calc(6px + var(--safe-t)); bottom: calc(64px + var(--safe-b)); height: auto; width: var(--sheetW); border: 1px solid #7a6040; border-radius: 10px; }
  body.sheet-open .spells { left: calc((100vw - var(--sheetW)) / 2); bottom: calc(10px + var(--safe-b)); }
  .tabs { left: auto; right: calc(6px + var(--safe-r)); width: var(--sheetW); background: none; padding-bottom: calc(6px + var(--safe-b)); }
  .spells { bottom: calc(10px + var(--safe-b)); }
  .spell { width: 58px; height: 58px; }
}

/* cards inside the sheet */
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; }
.card h3 { font-size: 0.98rem; color: #ffe0a0; }
.card .meta { color: var(--dim); font-size: 0.85rem; }
.card .row { flex-wrap: wrap; }
.card.dim { opacity: 0.55; }
.card.sel { border-color: var(--gold); }
.price { font-weight: 700; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 0.9rem; }
.kv span:nth-child(odd) { color: var(--dim); }
.pill { display: inline-block; padding: 0 7px; border-radius: 9px; border: 1px solid var(--line); font-size: 0.78rem; margin: 1px 2px 1px 0; color: var(--dim); }
.pill.ok { border-color: #5a8a4a; color: var(--green); } .pill.no { border-color: #8a4a3a; color: var(--red); }
.odds { font-weight: 700; } .odds.hi { color: var(--green); } .odds.mid { color: var(--gold); } .odds.lo { color: var(--red); }
.adv { display: flex; gap: 6px; align-items: center; padding: 5px 6px; border: 1px solid var(--line); border-radius: 7px; margin: 3px 0; background: rgba(0, 0, 0, 0.2); cursor: pointer; min-height: 44px; }
.adv.picked { border-color: var(--gold); background: rgba(120, 90, 30, 0.35); }
.adv.off { opacity: 0.5; cursor: default; }
.adv .face { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #1a140e; font-family: var(--head); flex: none; }
.adv .who { flex: 1; min-width: 0; font-size: 0.88rem; line-height: 1.15; }
.adv .who small { color: var(--dim); display: block; }
.timer { height: 6px; background: #2a2218; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.timer i { display: block; height: 100%; background: var(--gold); }
.story { font-style: italic; color: #e8dcc0; font-size: 0.9rem; margin: 4px 0; }
.rel { border-left: 3px solid; padding-left: 8px; }

/* toasts, banner, modal */
#toasts { position: absolute; top: calc(192px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 5px; align-items: center; width: min(420px, 92vw); }
.toast { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 0.92rem; animation: tin 0.25s ease-out; text-align: center; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5); }
.toast.good { border-color: #6aa050; } .toast.bad { border-color: #b05040; color: #ffd0c8; } .toast.gold { border-color: var(--gold); color: #ffe8b0; }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.banner { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); text-align: center; animation: bin 4.4s ease forwards; width: min(560px, 94vw); }
.banner h2 { font-size: clamp(1.7rem, 7vw, 2.8rem); color: #ffd98a; text-shadow: 0 0 20px rgba(255, 140, 40, 0.6), 0 2px 0 #000; }
.banner p { margin: 4px 0; font-size: 1.05rem; text-shadow: 0 1px 3px #000; }
.banner.red h2 { color: #ff8a70; }
@keyframes bin { 0% { opacity: 0; transform: translate(-50%, -40%) scale(0.9); } 8% { opacity: 1; transform: translate(-50%, -50%); } 80% { opacity: 1; } 100% { opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 10px; }
.modal { background: var(--panel); border: 1px solid #7a6040; border-radius: 12px; padding: 14px 16px; width: min(460px, 100%); max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; }
.modal h2 { color: #ffd98a; font-size: 1.2rem; }
.modal button { width: 100%; }
.modal .row button { width: auto; flex: 1; }
.modal textarea { width: 100%; }
.tip { position: fixed; z-index: 60; background: #1a140e; border: 1px solid #7a6040; border-radius: 8px; padding: 6px 9px; font-size: 0.85rem; max-width: 280px; pointer-events: none; }
