:root {
  --gold: #c9a44c;
  --gold-hi: #f0d48a;
  --blood: #8e2f2f;
  --bone: #e8ddc4;
  --ink: #0d0a12;
  --panel: rgba(16, 12, 22, 0.92);
  --edge: rgba(201, 164, 76, 0.45);
  --font-d: "Cinzel", serif;
  --font-b: "Crimson Pro", serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--bone); font-family: var(--font-b); user-select: none; -webkit-user-select: none; cursor: default; }
.hud-row span[data-tip], .hp-wrap[data-tip] { cursor: help; }
canvas.game { display: block; position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 40%, #1a1226 0%, #0d0a12 70%); display: flex; align-items: center; justify-content: center; transition: opacity .8s; }
#loading.done { opacity: 0; pointer-events: none; }
.load-inner { text-align: center; }
.load-die { font-size: 64px; color: var(--gold); animation: spin 1.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-inner h1 { font-family: var(--font-d); font-weight: 800; letter-spacing: .35em; color: var(--gold-hi); margin: 12px 0 22px; text-shadow: 0 0 30px rgba(201,164,76,.4); }
.load-bar { width: 260px; height: 6px; background: #241c33; border: 1px solid var(--edge); margin: 0 auto 12px; }
#load-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--blood), var(--gold)); transition: width .3s; }
#load-text { color: #8f8377; font-style: italic; }

/* ---------- vignette & cinema ---------- */
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 5; box-shadow: inset 0 0 180px 60px rgba(0,0,0,.85); transition: box-shadow .5s; }
body.hurt #vignette { box-shadow: inset 0 0 180px 80px rgba(120,10,10,.75); }
#cine-bars .bar { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 40; transition: height .9s cubic-bezier(.7,0,.3,1); }
#cine-bars .top { top: 0; } #cine-bars .bot { bottom: 0; }
body.cine #cine-bars .bar { height: 11vh; }
#cine-text { position: fixed; bottom: 13vh; width: 100%; text-align: center; z-index: 41; font-family: var(--font-d); font-size: 22px; letter-spacing: .18em; color: var(--gold-hi); text-shadow: 0 2px 12px #000; opacity: 0; transition: opacity .8s; pointer-events: none; }
body.cine #cine-text { opacity: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; padding: 14px 18px; pointer-events: none; }
#hud > div { pointer-events: auto; }
.hp-wrap { display: flex; align-items: center; gap: 8px; }
.hp-label { color: var(--blood); font-size: 20px; text-shadow: 0 0 8px rgba(200,40,40,.7); }
.hp-bar { position: relative; width: 210px; height: 18px; background: #1c1526; border: 1px solid var(--edge); box-shadow: 0 2px 10px rgba(0,0,0,.6); }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(180deg, #b8433d, #6e1f22); transition: width .35s; }
.hp-bar span { position: absolute; inset: 0; text-align: center; font-size: 13px; line-height: 18px; font-family: var(--font-d); color: #fff; text-shadow: 0 1px 2px #000; }
.hud-row { margin-top: 6px; display: flex; gap: 14px; font-family: var(--font-d); font-size: 14px; color: var(--gold); text-shadow: 0 1px 3px #000; }
#hud-right { display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; font-size: 19px; background: var(--panel); color: var(--bone); border: 1px solid var(--edge); cursor: pointer; transition: all .2s; }
.icon-btn:hover { border-color: var(--gold-hi); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(201,164,76,.25); }
.icon-btn.badge { position: relative; }
.icon-btn.badge::after { content: "!"; position: absolute; top: -6px; right: -6px; background: var(--blood); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px; }

/* ---------- roll bar ---------- */
#rollbar { position: fixed; bottom: 26px; width: 100%; text-align: center; z-index: 20; }
#roll-hint { font-style: italic; color: #a99a86; margin-bottom: 8px; text-shadow: 0 1px 4px #000; min-height: 20px; }
#btn-roll { font-family: var(--font-d); font-weight: 600; font-size: 19px; letter-spacing: .12em; padding: 14px 34px; color: var(--ink); background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #8a6c2c); border: none; cursor: pointer; box-shadow: 0 6px 24px rgba(201,164,76,.35), inset 0 1px 0 #fff6; transition: transform .15s, box-shadow .2s; }
#btn-roll:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 34px rgba(201,164,76,.5); }
#btn-roll:disabled { filter: grayscale(.8) brightness(.6); cursor: default; transform: none; }
.die-face { display: inline-block; margin-right: 6px; }
#btn-roll:not(:disabled) .die-face { animation: jiggle 2.2s ease-in-out infinite; }
@keyframes jiggle { 0%,80%,100% { transform: rotate(0); } 85% { transform: rotate(-18deg); } 92% { transform: rotate(14deg); } }

/* ---------- combat ---------- */
#combat { position: fixed; bottom: 0; left: 0; right: 0; z-index: 22; padding: 12px 16px 18px; background: linear-gradient(180deg, transparent, rgba(8,5,12,.94) 30%); }
#foe-plate { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 8px; }
#foe-name { font-family: var(--font-d); color: var(--gold-hi); letter-spacing: .1em; font-size: 17px; text-shadow: 0 2px 8px #000; }
.hp-bar.foe { width: 240px; } .hp-bar.foe > div { height: 100%; width: 100%; background: linear-gradient(180deg, #7ea35b, #3f5a2c); transition: width .35s; }
#combat-log { max-width: 640px; margin: 0 auto 10px; text-align: center; min-height: 44px; font-size: 17px; color: #d8cdb8; text-shadow: 0 1px 3px #000; }
#combat-log b { color: var(--gold-hi); }
#combat-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#combat-actions button { font-family: var(--font-d); font-size: 15px; padding: 11px 20px; background: var(--panel); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; transition: all .18s; }
#combat-actions button:hover:not(:disabled) { border-color: var(--gold-hi); color: var(--gold-hi); transform: translateY(-2px); }
#combat-actions button:disabled { opacity: .35; cursor: default; }

/* ---------- overlays & panels ---------- */
.overlay { position: fixed; inset: 0; z-index: 55; background: rgba(5,3,9,.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.panel { background: var(--panel); border: 1px solid var(--edge); box-shadow: 0 20px 80px #000, inset 0 0 60px rgba(201,164,76,.05); padding: 22px 26px; max-width: 560px; width: min(92vw, 560px); max-height: 88vh; overflow: auto; }
.panel.wide { max-width: 960px; width: min(94vw, 960px); }
.panel.narrow { max-width: 470px; text-align: center; }
.panel h2 { font-family: var(--font-d); letter-spacing: .12em; color: var(--gold-hi); display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel .close { background: none; border: none; color: #8f8377; font-size: 18px; cursor: pointer; } .panel .close:hover { color: var(--gold-hi); }
.hint { color: #8f8377; font-style: italic; font-size: 14px; margin-bottom: 10px; }
#modal-body { font-size: 18px; line-height: 1.55; margin: 6px 0 18px; color: #d8cdb8; }
#modal-actions, #modal2-actions { display: flex; flex-direction: column; gap: 8px; }
#modal-actions button, button.big { font-family: var(--font-d); font-size: 15px; padding: 12px 18px; background: rgba(201,164,76,.08); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; transition: all .18s; }
#modal-actions button:hover, button.big:hover { border-color: var(--gold-hi); color: var(--gold-hi); background: rgba(201,164,76,.16); }
#modal-actions button small { display: block; font-family: var(--font-b); color: #8f8377; font-size: 13px; margin-top: 3px; }

/* ---------- icons (game-icons.net, masked so they take the text color) ---------- */
.gi { display: inline-block; width: 1.02em; height: 1.02em; vertical-align: -0.13em; background-color: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }

/* ---------- inventory ---------- */
#inv-top { display: flex; gap: 14px; margin-bottom: 10px; align-items: stretch; }
#inv-hero { width: 230px; height: 290px; flex: 0 0 auto; border: 1px solid var(--edge); background: radial-gradient(ellipse at 50% 32%, rgba(90,70,120,.4), rgba(0,0,0,.5)); }
#inv-top-side { flex: 1; display: flex; flex-direction: column; }
#equips { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; flex: 1; }
.eq { flex: 1; text-align: center; }
.eq label { font-family: var(--font-d); font-size: 12px; letter-spacing: .15em; color: #8f8377; display: block; margin-bottom: 5px; }
.eq-cell { height: 58px; border: 1px dashed var(--edge); display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer; background: rgba(0,0,0,.25); }
.eq-cell:hover { border-color: var(--gold-hi); }
#stats-line { text-align: center; font-family: var(--font-d); font-size: 14px; color: var(--gold); margin-bottom: 12px; }
#bag-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.slot { aspect-ratio: 1; border: 1px solid #2c2340; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: grab; position: relative; transition: transform .15s; touch-action: none; user-select: none; }
.slot:hover { transform: scale(1.06); z-index: 2; }
.slot .qty { position: absolute; bottom: 2px; right: 4px; font-size: 11px; color: var(--bone); font-family: var(--font-d); }

/* ---------- rarities: white / green / blue / purple / rainbow ---------- */
.r-common { border-color: #d8d8dc !important; }
.r-uncommon { border-color: #4caf50 !important; box-shadow: 0 0 9px rgba(76,175,80,.35); }
.r-rare { border-color: #4a8fd5 !important; box-shadow: 0 0 11px rgba(74,143,213,.45); }
.r-epic { border-color: #a45ce0 !important; box-shadow: 0 0 13px rgba(164,92,224,.55); }
.r-legendary { animation: legend-border 2.6s linear infinite; }
@keyframes legend-border {
  0%   { border-color: #ff5555 !important; box-shadow: 0 0 14px rgba(255,85,85,.7); }
  20%  { border-color: #ffb84d !important; box-shadow: 0 0 17px rgba(255,184,77,.75); }
  40%  { border-color: #7dff6e !important; box-shadow: 0 0 15px rgba(125,255,110,.7); }
  60%  { border-color: #5fd7ff !important; box-shadow: 0 0 17px rgba(95,215,255,.75); }
  80%  { border-color: #b06eff !important; box-shadow: 0 0 15px rgba(176,110,255,.7); }
  100% { border-color: #ff5555 !important; box-shadow: 0 0 14px rgba(255,85,85,.7); }
}
.t-common { color: #d8d8dc; } .t-uncommon { color: #6fce74; } .t-rare { color: #6ea8e8; } .t-epic { color: #bd85f2; } .t-boon { color: var(--gold-hi); }
.t-legendary { background: linear-gradient(90deg, #ff5555, #ffb84d, #7dff6e, #5fd7ff, #b06eff, #ff5555); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: legend-text 3s linear infinite; }
@keyframes legend-text { to { background-position: 300% 0; } }

/* ---------- tooltip & drag ---------- */
#tooltip { position: fixed; z-index: 140; max-width: 250px; background: var(--panel); border: 1px solid var(--edge); box-shadow: 0 14px 40px #000; padding: 10px 13px; pointer-events: none; }
.tip-name { font-family: var(--font-d); font-size: 15px; margin-bottom: 3px; }
.tip-meta { font-size: 12.5px; color: #8f8377; text-transform: capitalize; margin-bottom: 6px; }
.tip-meta b { color: var(--bone); }
.tip-desc { font-size: 14px; font-style: italic; color: #c9bda6; line-height: 1.35; }
.tip-hint { font-size: 11.5px; color: #6b6156; margin-top: 7px; border-top: 1px solid #2c2340; padding-top: 5px; }
.tip-art { font-size: 13px; color: var(--gold); margin-top: 6px; line-height: 1.35; }
.tip-art small { color: #6b6156; }
.drag-ghost { position: fixed; z-index: 85; font-size: 30px; pointer-events: none; transform: translate(-50%, -50%) scale(1.15); filter: drop-shadow(0 6px 10px #000); }
#bin { margin-top: 10px; padding: 11px; text-align: center; border: 1px dashed #6b4a4a; color: #a0766f; font-family: var(--font-d); font-size: 13px; letter-spacing: .06em; transition: all .18s; }
body.dragging #bin { border-color: var(--blood); color: #d98880; background: rgba(142,47,47,.12); }
.mini-die { position: fixed; left: 50%; bottom: 44%; transform: translateX(-50%); z-index: 38; font-size: 66px; color: var(--gold-hi); text-shadow: 0 0 24px rgba(201,164,76,.6), 0 4px 8px #000; pointer-events: none; }
.stat-float { position: fixed; z-index: 62; font-family: var(--font-d); font-size: 17px; font-weight: 600; pointer-events: none; text-shadow: 0 2px 6px #000; animation: stat-rise 1.5s ease-out forwards; white-space: nowrap; }
.stat-float.gain { color: #8fd48f; }
.stat-float.loss { color: #e08a80; }
@keyframes stat-rise { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 15% { opacity: 1; transform: translateY(0) scale(1.15); } 30% { transform: translateY(-4px) scale(1); } 100% { opacity: 0; transform: translateY(-30px); } }
.mini-die.foe { color: #d98880; text-shadow: 0 0 24px rgba(200,60,60,.6), 0 4px 8px #000; }
.mini-die.settled { animation: die-pop .5s ease-out; }
@keyframes die-pop { 0% { transform: translateX(-50%) scale(1.6); } 40% { transform: translateX(-50%) scale(.95); } 60% { transform: translateX(-50%) scale(1.05); opacity: 1; } 100% { transform: translateX(-50%) scale(1); opacity: 0; } }
body.dragging { cursor: grabbing; }
body.dragging .slot, body.dragging .eq-cell { cursor: grabbing; }
body.dragging .slot:hover, body.dragging [data-eq-slot]:hover { border-color: var(--gold-hi) !important; background: rgba(201,164,76,.14); }

/* ---------- tavern ---------- */
#tavern { position: fixed; inset: 0; z-index: 45; display: flex; justify-content: flex-end; align-items: stretch; pointer-events: none; }
#tv-panel { pointer-events: auto; width: min(430px, 94vw); background: linear-gradient(270deg, rgba(13,9,18,.97) 75%, rgba(13,9,18,.55)); border-left: 1px solid var(--edge); padding: 22px 24px; overflow-y: auto; animation: tv-in .5s ease-out; }
@keyframes tv-in { from { transform: translateX(60px); opacity: 0; } }
#tv-panel h2 { font-family: var(--font-d); letter-spacing: .1em; color: var(--gold-hi); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; white-space: nowrap; }
#tv-shards { font-size: 15px; white-space: nowrap; }
#tv-stock { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.tv-card { border: 1px solid #2c2340; background: rgba(0,0,0,.35); padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 5px; }
.tv-card.sold { opacity: .35; }
.tv-icon { font-size: 30px; }
.tv-name { font-family: var(--font-d); font-size: 13.5px; }
.tv-desc { font-size: 12.5px; color: #9d917f; font-style: italic; flex: 1; line-height: 1.3; }
.tv-buy { font-family: var(--font-d); padding: 7px; background: rgba(201,164,76,.1); border: 1px solid var(--edge); color: var(--gold); cursor: pointer; }
.tv-buy:hover:not(:disabled) { background: rgba(201,164,76,.22); color: var(--gold-hi); }
.tv-buy:disabled { opacity: .45; cursor: default; }
#tv-reroll { width: 100%; font-family: var(--font-d); padding: 10px; background: rgba(155,89,182,.12); border: 1px solid rgba(155,89,182,.5); color: #cfa6e8; cursor: pointer; }
#tv-reroll:hover:not(:disabled) { background: rgba(155,89,182,.24); }
#tv-reroll:disabled { opacity: .4; cursor: default; }
.tv-divider { text-align: center; color: #6b6156; font-size: 12px; letter-spacing: .2em; margin: 14px 0 8px; }
#tv-stats { font-size: 14.5px; color: #c9bda6; margin-bottom: 8px; }
#tv-stats b { color: var(--gold-hi); }
#tv-satchel, #chest-satchel { width: 100%; font-family: var(--font-d); padding: 9px; background: rgba(201,164,76,.07); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; }
#tv-satchel:hover, #chest-satchel:hover { border-color: var(--gold-hi); color: var(--gold-hi); }
.tv-art { font-family: var(--font-d); font-size: 12px; color: var(--gold); }
.art-btn { display: flex; flex-direction: column; align-items: center; max-width: 210px; }
.art-btn small { font-family: var(--font-b); font-size: 12px; color: #9d917f; margin-top: 2px; white-space: normal; line-height: 1.25; }
#tv-upgrades { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.tv-up { font-family: var(--font-d); font-size: 14px; text-align: left; padding: 9px 13px; background: rgba(201,164,76,.07); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; }
.tv-up small { display: block; font-family: var(--font-b); color: #8f8377; font-size: 12.5px; margin-top: 2px; }
.tv-up:hover:not(:disabled) { border-color: var(--gold-hi); color: var(--gold-hi); }
.tv-up:disabled { opacity: .45; cursor: default; }
#tv-leave { width: 100%; margin-top: 6px; }

/* satchel docked beside the tavern counter */
#inv.tavern-side { justify-content: flex-start; align-items: flex-start; background: none; backdrop-filter: none; pointer-events: none; }
#inv.tavern-side .panel { pointer-events: auto; margin: 70px 0 0 22px; width: min(360px, 55vw); box-shadow: 0 20px 60px #000; }

/* ---------- map ---------- */
#map-canvas { width: 100%; background: radial-gradient(ellipse at center, #171022, #0a0710); border: 1px solid #2c2340; cursor: pointer; }

/* ---------- toast ---------- */
#toast { position: fixed; top: 84px; width: 100%; text-align: center; z-index: 90; pointer-events: none; }
.toast-msg { display: inline-block; background: var(--panel); border: 1px solid var(--edge); color: var(--gold-hi); font-family: var(--font-d); font-size: 15px; letter-spacing: .06em; padding: 10px 22px; margin: 4px; animation: toast-in 3.4s forwards; box-shadow: 0 8px 30px #000; }
@keyframes toast-in { 0% { opacity: 0; transform: translateY(-14px); } 8%,82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, rgba(38,22,54,.55), rgba(10,7,16,.92) 75%); }
.title-inner { text-align: center; animation: rise 1.2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } }
.title-kicker { font-style: italic; letter-spacing: .3em; color: #8f8377; text-transform: uppercase; font-size: 13px; }
#title h1 { font-family: var(--font-d); font-weight: 800; font-size: clamp(52px, 10vw, 96px); letter-spacing: .22em; color: var(--gold-hi); text-shadow: 0 0 60px rgba(201,164,76,.45), 0 4px 0 #4a3617; margin: 4px 0 10px; }
.title-sub { color: #b3a691; font-size: 18px; line-height: 1.5; margin-bottom: 26px; }
.title-btns { display: flex; flex-direction: column; gap: 10px; width: 380px; max-width: 92vw; margin: 0 auto 20px; }
.title-btns button { font-family: var(--font-d); font-size: 15px; padding: 12px 18px; background: rgba(201,164,76,.08); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; transition: all .18s; }
.title-btns button:hover { border-color: var(--gold-hi); color: var(--gold-hi); background: rgba(201,164,76,.16); }
.title-credit { color: #5d554b; font-size: 13px; }
#account-line { color: #8f8377; font-size: 14px; margin-bottom: 8px; }
#account-line b { color: var(--gold); }
#account-line button { background: none; border: 1px solid #3a3148; color: #8f8377; font-size: 12px; padding: 3px 10px; cursor: pointer; margin-left: 6px; }
#account-line button:hover { border-color: var(--gold-hi); color: var(--gold-hi); }
#acc-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.acc-profile { font-family: var(--font-d); padding: 9px 14px; background: rgba(201,164,76,.06); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; display: flex; justify-content: space-between; }
.acc-profile:hover { border-color: var(--gold-hi); color: var(--gold-hi); }
.acc-profile.current { border-color: var(--gold-hi); color: var(--gold-hi); cursor: default; }
.acc-row { display: flex; gap: 6px; margin: 8px 0; }
.acc-row input { flex: 1; background: rgba(0,0,0,.35); border: 1px solid #2c2340; color: var(--bone); padding: 9px 11px; font-family: var(--font-b); font-size: 14px; user-select: text; -webkit-user-select: text; cursor: text; }
.acc-row input:focus { outline: none; border-color: var(--gold); }
.acc-row button { font-family: var(--font-d); padding: 0 16px; background: rgba(201,164,76,.1); border: 1px solid var(--edge); color: var(--gold); cursor: pointer; }
.acc-row button:hover { color: var(--gold-hi); border-color: var(--gold-hi); }
.linkish { background: none; border: none; color: #8f8377; font-family: var(--font-b); font-style: italic; font-size: 13.5px; cursor: pointer; margin-top: 10px; text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { color: var(--gold-hi); }
#account-line button { background: none; border: 1px solid #3a3148; color: #8f8377; font-size: 12px; padding: 3px 10px; cursor: pointer; margin-left: 6px; }
#account-line button:hover { border-color: var(--gold-hi); color: var(--gold-hi); }

/* ---------- xp / level ---------- */
#xp-wrap { display: flex; align-items: center; gap: 8px; margin-top: 6px; cursor: help; }
#hud-lv { font-family: var(--font-d); font-size: 13px; color: var(--gold-hi); text-shadow: 0 1px 3px #000; }
#xp-bar { width: 150px; height: 5px; background: #1c1526; border: 1px solid #2c2340; }
#xp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #7d5fc0, #c9a44c); transition: width .4s; }

/* ---------- modal gold chip ---------- */
.modal-gold { font-family: var(--font-d); font-size: 14px; color: var(--gold); margin-bottom: 4px; }

/* ---------- title char line ---------- */
#char-line { font-family: var(--font-d); font-size: 15px; color: var(--gold); margin-bottom: 10px; letter-spacing: .06em; }

/* ---------- stage map ---------- */
#stage-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.stage-node { aspect-ratio: 1; font-family: var(--font-d); font-size: 14px; border: 1px solid #2c2340; background: rgba(0,0,0,.35); color: var(--bone); cursor: pointer; position: relative; transition: all .15s; }
.stage-node small { position: absolute; bottom: 1px; right: 3px; font-size: 10px; color: #7ec97e; }
.stage-node.open { border-color: var(--gold); color: var(--gold-hi); box-shadow: 0 0 10px rgba(201,164,76,.3); animation: node-pulse 2s ease-in-out infinite; }
@keyframes node-pulse { 50% { box-shadow: 0 0 16px rgba(201,164,76,.55); } }
.stage-node.done { border-color: #4a6a4a; color: #8fb98f; }
.stage-node.locked { color: #3a3148; cursor: default; font-size: 11px; }
.stage-node.milestone { border-width: 2px; font-size: 16px; }
.stage-node.milestone.locked { border-color: #3a2b45; }
.stage-node.milestone.open, .stage-node.milestone.done { border-color: var(--blood); }
.stage-node:hover:not(.locked) { transform: scale(1.12); z-index: 2; }

/* ---------- lore book ---------- */
#lore-list { max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 6px; }
.lore-entry h3 { font-family: var(--font-d); font-size: 15px; letter-spacing: .08em; color: var(--gold-hi); margin-bottom: 4px; }
.lore-entry p { font-size: 15.5px; line-height: 1.55; color: #cfc3ac; }
.lore-entry.locked h3 { color: #5d554b; }
.lore-entry.locked p { color: #5d554b; font-style: italic; }

/* ---------- refinement ---------- */
#tv-refine { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.refine-card { border: 1px solid #3a2b45; background: rgba(0,0,0,.3); padding: 10px 12px; }
.refine-head { display: flex; justify-content: space-between; font-family: var(--font-d); font-size: 14px; margin-bottom: 4px; }
.refine-pts { color: var(--gold); }
.refine-fodder { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fodder-btn { width: 44px; height: 44px; font-size: 19px; background: rgba(0,0,0,.35); border: 1px solid #2c2340; cursor: pointer; position: relative; color: var(--bone); }
.fodder-btn small { position: absolute; bottom: 0; right: 2px; font-size: 10px; color: var(--gold); }
.fodder-btn:hover { transform: scale(1.1); border-color: var(--blood) !important; }

@media (max-width: 640px) {
  .hp-bar { width: 140px; }
  #btn-roll { font-size: 16px; padding: 12px 22px; }
  #bag-grid { grid-template-columns: repeat(4, 1fr); }
  #inv-hero { display: none; } /* phones: the road itself is the mirror */
}

.fx[data-tip] { cursor: help; }
.fx.trait { border-color: rgba(201,164,76,.5); color: var(--gold); background: rgba(201,164,76,.08); }

#flash { position: fixed; inset: 0; z-index: 88; pointer-events: none; opacity: 0; mix-blend-mode: screen; }

/* ---------- dev console (walker HEELO only) ---------- */
#btn-dev { position: fixed; bottom: 14px; left: 14px; z-index: 70; font-family: var(--font-d); font-size: 12px; letter-spacing: .12em; padding: 7px 12px; background: rgba(16,12,22,.9); border: 1px solid #3a5a3a; color: #7ec97e; cursor: pointer; }
#btn-dev:hover { border-color: #aef2b0; color: #aef2b0; }
#dev-panel { position: fixed; bottom: 54px; left: 14px; z-index: 71; width: min(440px, 94vw); max-height: 74vh; overflow: auto; background: var(--panel); border: 1px solid #3a5a3a; box-shadow: 0 20px 80px #000; padding: 16px 18px; }
#dev-panel h2 { font-family: var(--font-d); font-size: 16px; letter-spacing: .1em; color: #aef2b0; display: flex; justify-content: space-between; margin-bottom: 8px; }
.dev-sect { font-family: var(--font-d); font-size: 12px; letter-spacing: .14em; color: #8f8377; margin: 12px 0 6px; }
#dev-items { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.dev-item { aspect-ratio: 1; font-size: 17px; background: rgba(0,0,0,.3); border: 1px solid #2c2340; color: var(--bone); cursor: pointer; }
.dev-item:hover { transform: scale(1.1); }
#dev-nums, #dev-stage-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.dev-num { font-size: 12px; color: #8f8377; display: flex; flex-direction: column; gap: 3px; }
.dev-num input { width: 74px; background: rgba(0,0,0,.35); border: 1px solid #2c2340; color: var(--bone); padding: 5px 7px; font-family: var(--font-d); }
#dev-stage-row button { font-family: var(--font-d); font-size: 12px; padding: 7px 12px; background: rgba(126,201,126,.08); border: 1px solid #3a5a3a; color: #aef2b0; cursor: pointer; }

/* ---------- chest spoils (docks right; satchel docks left) ---------- */
#chest { position: fixed; inset: 0; z-index: 45; display: flex; justify-content: flex-end; align-items: stretch; pointer-events: none; }
#chest-panel { pointer-events: auto; width: min(400px, 94vw); background: linear-gradient(270deg, rgba(13,9,18,.97) 75%, rgba(13,9,18,.55)); border-left: 1px solid var(--edge); padding: 22px 24px; overflow-y: auto; animation: tv-in .5s ease-out; }
#chest-panel h2 { font-family: var(--font-d); letter-spacing: .1em; color: var(--gold-hi); margin-bottom: 8px; }
#chest-stock { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
#chest-leave { width: 100%; margin-top: 10px; }

/* ---------- status-effect chips ---------- */
#fx-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.fx { font-family: var(--font-d); font-size: 12px; letter-spacing: .05em; padding: 3px 9px; border: 1px solid var(--edge); background: rgba(0,0,0,.55); color: var(--bone); }
.fx.you { border-color: #4a6a4a; color: #a8d8a8; }
.fx.foe { border-color: #6a4a4a; color: #e0a8a0; }
#foe-fx { display: flex; gap: 5px; }
#foe-fx .fx { font-size: 11px; padding: 2px 7px; }

/* ---- impact dressing: speed-lines, cinema bars, screen punch ---- */
#speedlines { position: fixed; inset: 0; z-index: 87; pointer-events: none; opacity: 0; mix-blend-mode: screen; }
.cine { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 86; transition: height 140ms ease-out; pointer-events: none; }
#cine-top { top: 0; }
#cine-bottom { bottom: 0; }
body.cinema #cine-top, body.cinema #cine-bottom { height: 6vh; }
canvas.game { transition: transform 90ms ease-out; }
body.impact canvas.game { transform: scale(1.05); }

/* ---- crossroads choice ---- */
#fork-choice { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(5,3,10,0.7); }
#fork-choice .fork-box { background: #14101e; border: 1px solid #3a3148; border-radius: 12px; padding: 22px 26px; max-width: 420px; text-align: center; }
#fork-choice h2 { font-family: Cinzel, serif; color: #e0c060; margin: 0 0 8px; }
#fork-choice p { color: #b9aed0; font-size: 14px; margin: 0 0 14px; }
#fork-choice button { display: block; width: 100%; margin: 8px 0; padding: 10px 14px; text-align: center; }
#fork-choice button b { display: block; font-family: Cinzel, serif; letter-spacing: 0.04em; }
#fork-choice button small { color: #c9a44c; letter-spacing: 0.2em; }

/* ---- the Walker's Chronicle: a library with a keeper ---- */
#lore { padding: 0; }
#lore-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#lore-close { position: absolute; top: 14px; right: 18px; z-index: 3; }
#lore-book { position: absolute; left: 50%; bottom: 3vh; width: min(700px, 92vw); z-index: 2;
  transform: perspective(1300px) translateX(-50%) rotateX(9deg); transform-origin: 50% 100%;
  background: linear-gradient(160deg, #4a3018, #2e1c0e 70%); color: #2a2118; border-radius: 10px 14px 14px 10px;
  border: 1px solid #1a0f06;
  box-shadow: 0 26px 70px rgba(0,0,0,0.8), inset 0 0 24px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,214,150,0.12);
  padding: 18px 24px 12px; }
#lore-book::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(230,190,110,0.28); border-radius: 8px; pointer-events: none; }
#lore-spread { display: flex; align-items: stretch; position: relative; perspective: 1400px; min-height: 240px; max-height: 40vh; transform-style: preserve-3d; box-shadow: 0 10px 26px rgba(0,0,0,0.5); }
/* the body of the book — a real tome has a block of pages under the open spread */
#lore-spread::before, #lore-spread::after { content: ""; position: absolute; top: 3px; bottom: -7px; width: 9px; pointer-events: none; z-index: -1;
  background: repeating-linear-gradient(90deg, #efe1bd 0 1px, #cbb98f 1px 2px, #e6d6ae 2px 3px); }
#lore-spread::before { left: -9px; border-radius: 6px 0 0 6px; transform: skewY(4deg); }
#lore-spread::after { right: -9px; border-radius: 0 6px 6px 0; transform: skewY(-4deg); }
#lore-pageL { width: 44%; background: linear-gradient(95deg, #cdb890 0%, #e6d6ae 22%, #f0e2be 70%); border-radius: 6px 0 0 6px; padding: 10px; display: flex; align-items: center;
  box-shadow: inset -18px 0 26px rgba(90,63,28,0.35), inset 4px 4px 10px rgba(255,248,224,0.5); }
#lore-pageL img { width: 100%; max-height: 100%; object-fit: cover; border: 3px solid #8a744e; border-radius: 3px; box-shadow: 0 4px 14px rgba(42,33,24,0.4); }
#lore-pageL img.locked-img { filter: brightness(0.25) saturate(0.3) blur(2px); }
#lore-spine { width: 3%; background: linear-gradient(90deg, rgba(60,40,16,0.65), rgba(244,232,198,0.95) 50%, rgba(60,40,16,0.65)); box-shadow: inset 0 -10px 16px rgba(60,40,16,0.4); }
#lore-pageR { width: 53%; background: linear-gradient(265deg, #cdb890 0%, #e6d6ae 22%, #f2e4c0 70%); border-radius: 0 6px 6px 0; padding: 14px 18px; overflow-y: auto;
  box-shadow: inset 18px 0 26px rgba(90,63,28,0.35), inset -4px 4px 10px rgba(255,248,224,0.5); }
#lore-pageR h3 { font-family: var(--font-d); font-size: 17px; letter-spacing: .06em; color: #5a3f1c; margin-bottom: 8px; }
#lore-pageR p { font-size: 15px; line-height: 1.6; color: #3a2e20; }
#lore-pageR .locked-note { font-style: italic; color: #7a6a52; }
#lore-turn { position: absolute; right: 0; top: 0; width: 53%; height: 100%; border-radius: 0 6px 6px 0;
  background: linear-gradient(265deg, #c3b088, #e9dab4 45%, #f4e8c8 90%); transform-origin: left center; backface-visibility: hidden; }
#lore-turn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(80deg, rgba(60,40,16,0) 55%, rgba(60,40,16,0.35)); }
#lore-turn.turning { animation: pageturn 540ms cubic-bezier(0.6, 0.04, 0.3, 1) forwards; }
@keyframes pageturn {
  0% { transform: rotateY(0deg); box-shadow: -4px 2px 10px rgba(42,33,24,0.3); }
  45% { transform: rotateY(-74deg) scale(1.02); box-shadow: -34px 6px 44px rgba(42,33,24,0.6); }
  100% { transform: rotateY(-158deg) scale(1); box-shadow: 0 0 0 rgba(42,33,24,0); }
}
#lore-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; border-top: 1px solid rgba(230,190,110,0.25); padding-top: 10px; }
#lore-nav button { background: #3a2e20; color: #e8d8b0; border: 1px solid #8a744e; }
#lore-nav button:disabled { opacity: 0.4; }
#lore-nav #lore-voice.speaking { background: #6a5436; box-shadow: 0 0 12px rgba(230,190,110,0.5); }
#lore-pageno { font-family: var(--font-d); font-size: 12px; letter-spacing: .12em; color: #c9a96a; }
@media (max-width: 700px) { #lore-book { padding: 14px 16px 10px; } }

/* ---- boss cutscene video ---- */
#cutscene { position: fixed; inset: 0; z-index: 95; background: #000; display: flex; align-items: center; justify-content: center; }
#cutscene video { width: 100%; height: 100%; object-fit: contain; }
#cutscene #cs-skip { position: absolute; right: 22px; bottom: 22px; opacity: 0.8; }

/* ---- the road's story cards ---- */
#story-card { position: fixed; inset: 0; z-index: 62; display: flex; align-items: center; justify-content: center; background: rgba(5,3,10,0.78); }
#story-card .story-box { width: min(560px, 92vw); background: #14101e; border: 1px solid #3a3148; border-radius: 12px; overflow: hidden; box-shadow: 0 22px 70px rgba(0,0,0,0.75); }
#story-card img { width: 100%; max-height: 46vh; object-fit: cover; display: block; border-bottom: 1px solid #3a3148; }
#story-card h2 { font-family: Cinzel, serif; color: #e0c060; font-size: 17px; letter-spacing: 0.08em; margin: 14px 20px 6px; }
#story-card p { color: #cfc3ac; font-size: 15.5px; line-height: 1.55; margin: 0 20px 14px; }
#story-card button { display: block; margin: 0 20px 18px auto; }

/* ---- slot-based refinement ---- */
.ref-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.ref-label { font-family: var(--font-d); font-size: 12px; letter-spacing: .14em; color: #c9a44c; width: 58px; }
.ref-slot { width: 52px; height: 52px; border: 1px dashed #4a4058; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(10,8,16,0.6); }
.ref-slot.filled { border-style: solid; }
.ref-plus { color: #5d554b; font-size: 22px; }
.ref-item { width: 46px; height: 46px; border-radius: 6px; position: relative; font-size: 20px; }
.ref-item small { position: absolute; right: 2px; bottom: 0; font-size: 10px; color: #c9a44c; }
.ref-info { line-height: 1.35; }
.ref-pick-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
#ref-go { margin-left: auto; }

/* ---------- chronicle: hover the page edges to turn, the wax seal to leave ---------- */
#lore-spread { position: relative; }
#lore-hotL, #lore-hotR { position: absolute; top: 0; bottom: 0; width: 24%; display: flex; align-items: center; cursor: pointer; z-index: 5; color: #e8d8b0; opacity: 0; transition: opacity 0.25s; }
#lore-hotL { left: 0; justify-content: flex-start; padding-left: 14px; background: linear-gradient(90deg, rgba(20, 12, 4, 0.45), transparent); }
#lore-hotR { right: 0; justify-content: flex-end; padding-right: 14px; background: linear-gradient(270deg, rgba(20, 12, 4, 0.45), transparent); }
#lore-hotL:hover, #lore-hotR:hover { opacity: 1; }
#lore-hotL span, #lore-hotR span { font-size: 40px; text-shadow: 0 0 14px #ffb45a; animation: hotNudgeR 1.2s ease-in-out infinite; }
#lore-hotL span { animation-name: hotNudgeL; }
#lore-hotL.off, #lore-hotR.off { display: none; }
@keyframes hotNudgeR { 50% { transform: translateX(5px); } }
@keyframes hotNudgeL { 50% { transform: translateX(-5px); } }
#lore-close { position: absolute; top: 16px; right: 16px; width: 54px; height: 54px; border-radius: 50%; border: 2px solid #7a5a2a; background: radial-gradient(circle at 35% 30%, #8a2a1a, #4a1008); cursor: pointer; z-index: 6; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 18px rgba(0, 0, 0, 0.7), inset 0 0 10px rgba(255, 180, 90, 0.25); transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s; }
#lore-close .gi { width: 26px; height: 26px; background: #ffd9a0; }
#lore-close:hover { transform: rotate(180deg) scale(1.12); box-shadow: 0 0 28px rgba(255, 140, 58, 0.55), inset 0 0 12px rgba(255, 180, 90, 0.4); }
#lore.closing { transition: opacity 0.5s; opacity: 0; pointer-events: none; }
#lore.closing #lore-book { animation: bookClose 0.5s ease-in forwards; }
@keyframes bookClose { to { transform: perspective(900px) translateX(-50%) rotateX(42deg) scale(0.6); opacity: 0; } }

/* ---------- refinement drag & drop ---------- */
.ref-item[draggable="true"] { cursor: grab; }
.ref-item[draggable="true"]:active { cursor: grabbing; }
.ref-slot.drag-over { outline: 2px solid #e6be6e; box-shadow: 0 0 16px rgba(230, 190, 110, 0.55); transform: scale(1.06); }
.ref-slot { transition: transform 0.12s, box-shadow 0.12s; }
.ref-item.ref-dim { opacity: 0.35; }

/* ---------- gear sets: pips, whole-set glow, tooltip checklist ---------- */
.slot, .eq-cell { position: relative; }
.set-pip { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--sc, #e6be6e); box-shadow: 0 0 6px var(--sc, #e6be6e); pointer-events: none; }
.eq-cell.set-on { border-color: var(--sc); box-shadow: 0 0 12px var(--sc), inset 0 0 8px var(--sc); animation: setBreathe 2.2s ease-in-out infinite; }
@keyframes setBreathe { 50% { box-shadow: 0 0 20px var(--sc), inset 0 0 12px var(--sc); } }
.tip-set { border-left: 3px solid var(--sc, #e6be6e); padding-left: 8px; }
.tip-set .set-have { color: #9fe89f; }
.tip-set .set-miss { opacity: 0.5; }
#set-line { margin-top: 6px; font-size: 13px; line-height: 1.5; }
#set-line .set-passive { color: #9a8fa8; font-size: 12px; }

/* ---------- The Walkers' Rest (multiplayer) ---------- */
#mp { position: fixed; inset: 0; z-index: 80; background: #0a0714; }
#mp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
#mp-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mp-label { position: absolute; transform: translate(-50%, -100%); text-align: center; font-family: var(--font-d); font-size: 13px; letter-spacing: 0.06em; color: #f0e6c0; text-shadow: 0 2px 6px #000, 0 0 12px rgba(0, 0, 0, 0.8); white-space: nowrap; }
.mp-label small { display: block; font-size: 10px; color: #b9aed0; letter-spacing: 0.1em; }
#mp-topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: linear-gradient(180deg, rgba(6, 4, 12, 0.85), transparent); }
#mp-topbar .mp-title { font-family: var(--font-d); letter-spacing: 0.14em; color: #e6be6e; font-size: 14px; }
#mp-topbar #mp-room-code { color: #fff; letter-spacing: 0.2em; }
#mp-topbar #mp-count { color: #b9aed0; font-size: 13px; }
#mp-topbar #mp-leave { margin-left: auto; }
#mp-chat { position: absolute; left: 14px; bottom: 14px; width: min(340px, 82vw); background: rgba(10, 7, 20, 0.88); border: 1px solid #3a2e50; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
#mp-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; font-family: var(--font-d); font-size: 12px; letter-spacing: 0.12em; color: #e6be6e; border-bottom: 1px solid #3a2e50; }
#mp-chat-head button { padding: 0 8px; font-size: 15px; line-height: 1.4; }
#mp-chat-log { height: 170px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
#mp-chat.closed #mp-chat-log, #mp-chat.closed #mp-chat-row { display: none; }
.mp-msg { color: #d8cfc0; line-height: 1.35; overflow-wrap: anywhere; }
.mp-msg b { color: #9fd0ff; margin-right: 4px; }
.mp-msg.me b { color: #ffd27a; }
.mp-msg.sys { color: #8a7fa0; font-style: italic; font-size: 12px; }
#mp-chat-row { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #3a2e50; }
#mp-chat-row input { flex: 1; min-width: 0; }
#mp-profile { position: absolute; right: 16px; top: 64px; width: min(300px, 86vw); background: rgba(12, 8, 22, 0.94); border: 1px solid #4a3a66; border-radius: 10px; padding: 16px; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.7); }
#mp-profile h3 { font-family: var(--font-d); color: #f0e6c0; letter-spacing: 0.08em; margin-bottom: 2px; }
.mp-prof-sub { color: #b9aed0; font-size: 12px; margin-bottom: 10px; }
#mp-prof-close { position: absolute; top: 8px; right: 8px; }
.mp-eq { display: flex; align-items: center; gap: 6px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(90, 74, 120, 0.25); }
.mp-eq-slot { width: 58px; color: #8a7fa0; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.mp-eq-none { color: #6a5f80; font-style: italic; }
#mp-befriend { margin-top: 12px; width: 100%; }
#mp-gate .acc-row { display: flex; gap: 8px; margin-top: 12px; }
#mp-gate .acc-row input { flex: 1; text-transform: uppercase; letter-spacing: 0.2em; }

/* ---------- Rest polish: whispers, hover, requests, ledger ---------- */
#inv { z-index: 90; }
.mp-msg.whisper { color: #c8a8ff; }
.mp-msg.whisper b { color: #b08cff; }
.mp-msg.whisper i { color: #8a7fa0; font-size: 11px; }
.mp-label.hot { transform: translate(-50%, -100%) scale(1.15); color: #ffffff; text-shadow: 0 0 14px rgba(223, 232, 255, 0.9), 0 2px 6px #000; }
#mp-freq { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(14, 9, 26, 0.96); border: 1px solid #6a5490; border-radius: 10px; padding: 16px 20px; text-align: center; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.8), 0 0 24px rgba(138, 90, 255, 0.25); animation: freqIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes freqIn { from { transform: translateX(-50%) translateY(-14px); opacity: 0; } }
#mp-freq p { color: #e8dcc8; margin-bottom: 12px; }
.mp-freq-btns { display: flex; gap: 10px; justify-content: center; }
.friend-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid rgba(90, 74, 120, 0.3); color: #e8dcc8; }
.friend-row button { padding: 2px 9px; }

/* ---------- no button is ever naked again: a global base + variants ---------- */
button { font-family: var(--font-d); font-size: 14px; padding: 8px 14px; background: linear-gradient(180deg, rgba(201, 164, 76, 0.12), rgba(201, 164, 76, 0.04)); border: 1px solid var(--edge); color: var(--bone); cursor: pointer; transition: all 0.18s; border-radius: 4px; }
button:hover { border-color: var(--gold-hi); color: var(--gold-hi); background: rgba(201, 164, 76, 0.18); box-shadow: 0 0 12px rgba(230, 190, 110, 0.22); }
button:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
.btn-gold { background: linear-gradient(180deg, #c9a44c, #8a6a2a); color: #1a1208; border-color: #e6be6e; font-weight: 700; }
.btn-gold:hover { background: linear-gradient(180deg, #e6be6e, #a5813a); color: #120c04; box-shadow: 0 0 18px rgba(230, 190, 110, 0.45); }
.btn-danger { border-color: #6a3038; color: #d8a0a8; background: linear-gradient(180deg, rgba(160, 50, 60, 0.16), rgba(160, 50, 60, 0.05)); }
.btn-danger:hover { border-color: #d05060; color: #ffb8c0; background: rgba(160, 50, 60, 0.25); box-shadow: 0 0 12px rgba(208, 80, 96, 0.3); }
.btn-ghost { background: none; border-color: #3a3148; color: #8f8377; }
#mp-chat-toggle { border-radius: 50%; width: 26px; height: 26px; padding: 0; line-height: 1; }

/* ---------- the "/" command palette ---------- */
#mp-cmds { border-top: 1px solid #3a2e50; background: rgba(16, 11, 30, 0.97); max-height: 150px; overflow-y: auto; }
.mp-cmd { padding: 7px 10px; cursor: pointer; font-size: 13px; color: #d8cfc0; border-left: 2px solid transparent; }
.mp-cmd:hover, .mp-cmd.active { background: rgba(138, 108, 255, 0.12); border-left-color: #b08cff; }
.mp-cmd b { color: #b08cff; }
.mp-cmd-args { color: #8fa3d0; font-style: italic; margin-left: 4px; }
.mp-cmd small { display: block; color: #8a7fa0; font-size: 11px; }
.mp-cmd.none { color: #8a7fa0; font-style: italic; cursor: default; }
.mp-msg.act i { color: #e6be6e; }

/* ---------- the title, retold: a moonlit diorama behind glass ---------- */
#title { background: radial-gradient(ellipse at 50% 30%, rgba(16, 10, 26, 0.15), rgba(10, 7, 16, 0.86) 88%); }
#title::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(10, 7, 16, 0.55), transparent 25%, transparent 70%, rgba(10, 7, 16, 0.75)); }
#title > div, #title .title-inner { position: relative; z-index: 2; }
.title-kicker { animation: titleFadeDown 1.1s ease-out both; }
#title h1 { animation: titleFloat 7s ease-in-out infinite, titleGlow 4s ease-in-out infinite, titleFadeDown 1.1s 0.15s ease-out both; }
.title-sub { animation: titleFadeDown 1.1s 0.3s ease-out both; }
@keyframes titleFadeDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes titleFloat { 50% { letter-spacing: 0.24em; } }
@keyframes titleGlow { 50% { text-shadow: 0 0 90px rgba(230, 190, 110, 0.65), 0 4px 0 #4a3617; } }
.title-btns { background: linear-gradient(180deg, rgba(14, 9, 24, 0.78), rgba(14, 9, 24, 0.55)); border: 1px solid rgba(201, 164, 76, 0.3); border-radius: 12px; padding: 18px; backdrop-filter: blur(7px); box-shadow: 0 22px 64px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(230, 190, 110, 0.14); }
.title-btns button { position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; text-align: left; border-radius: 6px; animation: titleBtnIn 0.7s ease-out both; white-space: nowrap; }
.title-btns button::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(230, 190, 110, 0.16) 50%, transparent 80%); transform: translateX(-110%); transition: transform 0.5s; }
.title-btns button:hover::before { transform: translateX(110%); }
.title-btns button::after { content: "\276F"; margin-left: auto; color: rgba(230, 190, 110, 0.4); transition: all 0.2s; }
.title-btns button:hover::after { color: var(--gold-hi); transform: translateX(3px); }
.title-btns button:hover { transform: translateX(4px); }
.title-btns button .gi { width: 20px; height: 20px; }
.title-btns button:nth-child(1) { animation-delay: 0.35s; }
.title-btns button:nth-child(2) { animation-delay: 0.45s; }
.title-btns button:nth-child(3) { animation-delay: 0.55s; }
.title-btns button:nth-child(4) { animation-delay: 0.65s; }
.title-btns button:nth-child(5) { animation-delay: 0.75s; }
.title-btns button:nth-child(6) { animation-delay: 0.85s; }
.title-btns button:nth-child(7) { animation-delay: 0.95s; }
@keyframes titleBtnIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
/* embers drift up through the title like the road is just below */
#title::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 200%; pointer-events: none; z-index: 1;
  background-image: radial-gradient(2px 2px at 12% 85%, rgba(255, 170, 80, 0.9), transparent 60%), radial-gradient(2px 2px at 28% 60%, rgba(255, 200, 110, 0.7), transparent 60%), radial-gradient(3px 3px at 45% 75%, rgba(230, 150, 70, 0.8), transparent 60%), radial-gradient(2px 2px at 63% 55%, rgba(255, 190, 100, 0.6), transparent 60%), radial-gradient(2px 2px at 78% 82%, rgba(255, 170, 80, 0.85), transparent 60%), radial-gradient(3px 3px at 91% 65%, rgba(240, 170, 90, 0.6), transparent 60%);
  background-size: 100% 50%; animation: embersUp 17s linear infinite; opacity: 0.7; }
@keyframes embersUp { from { transform: translateY(0); } to { transform: translateY(-50%); } }

/* ---------- online dots, notices, call-ins ---------- */
.online-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4a4358; margin-right: 7px; vertical-align: 1px; }
.online-dot.on { background: #5fd06f; box-shadow: 0 0 8px rgba(95, 208, 111, 0.8); }
.online-tag { color: #5fd06f; font-size: 11px; margin-left: 6px; }
.online-tag.off { color: #6a5f80; }
#mp-notice { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); background: rgba(14, 9, 26, 0.92); border: 1px solid #4a3a66; border-left: 3px solid #e6be6e; border-radius: 6px; padding: 9px 18px; color: #e8dcc8; font-size: 14px; z-index: 5; animation: noticeIn 0.35s ease-out; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); }
#mp-notice.out { opacity: 0; transition: opacity 0.4s; }
@keyframes noticeIn { from { transform: translateX(-50%) translateY(-12px); opacity: 0; } }
#mp-invite-panel { position: absolute; right: 16px; top: 64px; width: min(300px, 86vw); background: rgba(12, 8, 22, 0.94); border: 1px solid #4a3a66; border-radius: 10px; padding: 14px 16px; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.7); }
#mp-invite-panel h4 { font-family: var(--font-d); color: #e6be6e; letter-spacing: 0.08em; margin-bottom: 8px; }
#mp-invite-panel button[data-invite] { padding: 3px 12px; font-size: 12px; }
#mp-invite-close { margin-top: 10px; width: 100%; }
#mp-callin { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 120; background: rgba(14, 9, 26, 0.97); border: 1px solid #6a5490; border-radius: 10px; padding: 14px 20px; text-align: center; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.8), 0 0 24px rgba(230, 190, 110, 0.2); animation: freqIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
#mp-callin p { color: #e8dcc8; margin-bottom: 10px; }
#cg-join { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(14, 9, 26, 0.97); border: 1px solid #e6be6e; border-radius: 10px; padding: 16px 22px; text-align: center; z-index: 10; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.8), 0 0 24px rgba(230, 190, 110, 0.25); animation: freqIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap; }
#cg-join p { color: #e8dcc8; margin-bottom: 12px; }

/* ---------- SEALS: the card duel ---------- */
#cg-hud { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); text-align: center; z-index: 6; background: rgba(12, 8, 22, 0.85); border: 1px solid #4a3a66; border-radius: 10px; padding: 8px 18px; }
#cg-score { font-family: var(--font-d); font-size: 15px; letter-spacing: 0.06em; }
#cg-score .cg-p.me { color: #7fb2ff; }
#cg-score .cg-p.them { color: #ff8f8f; }
#cg-score .cg-vs { color: #8a7fa0; font-size: 12px; }
#cg-turn { font-size: 12px; color: #b9aed0; margin-top: 3px; min-height: 15px; }
#cg-turn.mine { color: #e6be6e; animation: cgPulse 1.6s ease-in-out infinite; }
@keyframes cgPulse { 50% { opacity: 0.55; } }
#cg-hud button { margin-top: 6px; padding: 3px 12px; font-size: 12px; }
#cg-result { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); z-index: 7; text-align: center; background: rgba(14, 9, 26, 0.96); border: 1px solid #6a5490; border-radius: 12px; padding: 22px 34px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(230, 190, 110, 0.2); animation: freqIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
#cg-result h3 { font-family: var(--font-d); font-size: 26px; letter-spacing: 0.14em; color: #e6be6e; margin-bottom: 6px; }
#cg-result p { color: #b9aed0; margin-bottom: 14px; }

/* ---------- SEALS refinements ---------- */
#cg-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at 50% 55%, transparent 38%, rgba(6, 4, 12, 0.55) 78%, rgba(6, 4, 12, 0.85)); }
#cg-callout { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); z-index: 8; pointer-events: none; font-family: var(--font-d); font-size: 44px; letter-spacing: 0.22em; color: #dfe8ff; text-shadow: 0 0 30px rgba(160, 190, 255, 0.8), 0 4px 12px #000; opacity: 0; }
#cg-callout.gold { color: #ffd88a; text-shadow: 0 0 30px rgba(230, 190, 110, 0.9), 0 4px 12px #000; }
#cg-callout.purple { color: #c8a8ff; text-shadow: 0 0 30px rgba(138, 90, 255, 0.9), 0 4px 12px #000; }
#cg-callout.pop { animation: cgCall 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes cgCall { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 30% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1); } }
#cg-score.punch { animation: cgPunch 0.35s ease-out; }
@keyframes cgPunch { 30% { transform: scale(1.18); } }
.cg-table-label { font-size: 12px; letter-spacing: 0.12em; color: #e6be6e; background: rgba(12, 8, 22, 0.7); padding: 4px 10px; border-radius: 12px; border: 1px solid rgba(230, 190, 110, 0.35); }
.cg-table-label.live { color: #9fd0ff; border-color: rgba(120, 170, 255, 0.4); }

/* ---------- SEALS inspector: the card, writ large ---------- */
#cg-inspect { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 230px; z-index: 7; background: linear-gradient(170deg, rgba(24, 16, 38, 0.96), rgba(14, 9, 24, 0.96)); border: 2px solid #6a5490; border-radius: 14px; padding: 16px 18px; text-align: center; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(230, 190, 110, 0.15); animation: freqIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
#cg-inspect h4 { font-family: var(--font-d); font-size: 20px; letter-spacing: 0.06em; margin-bottom: 2px; }
.cg-i-rar { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.8; margin-bottom: 10px; }
.cg-i-pips { position: relative; width: 110px; height: 110px; margin: 0 auto 10px; border: 1px solid rgba(230, 190, 110, 0.3); border-radius: 50%; }
.cg-i-pips span { position: absolute; font-family: var(--font-d); font-size: 26px; color: #f0e6c0; }
.cg-i-pips .n { top: 2px; left: 50%; transform: translateX(-50%); }
.cg-i-pips .s { bottom: 2px; left: 50%; transform: translateX(-50%); }
.cg-i-pips .w { left: 10px; top: 50%; transform: translateY(-50%); }
.cg-i-pips .e { right: 10px; top: 50%; transform: translateY(-50%); }
.cg-i-ab { font-size: 13px; line-height: 1.5; color: #cfc4e0; font-style: italic; }
@media (max-width: 900px) { #cg-inspect { width: 180px; right: 8px; } }

/* ---------- SEALS hand tray: the real card faces, Hearthstone-style ---------- */
#cg-hand { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 8; display: flex; gap: 12px; pointer-events: none; align-items: flex-end; }
#cg-hand.hidden { display: none; }
.cg-card { pointer-events: auto; position: relative; width: 128px; height: 179px; box-sizing: border-box; border-radius: 11px; border: 2px solid var(--rc, #8a744e); background-size: cover; background-position: center; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(0, 0, 0, 0.5); cursor: pointer; transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s; overflow: hidden; }
.cg-card:hover { transform: translateY(-16px) scale(1.04); box-shadow: 0 20px 40px rgba(0, 0, 0, 0.75), 0 0 20px color-mix(in srgb, var(--rc) 60%, transparent); z-index: 2; }
.cg-card.picked { transform: translateY(-26px) scale(1.08); box-shadow: 0 24px 46px rgba(0, 0, 0, 0.8), 0 0 26px var(--rc); z-index: 3; }
.cg-card.spent { border-style: dashed; border-color: #3a3148; background: rgba(20, 16, 30, 0.4); opacity: 0.3; pointer-events: none; }
#cg-hand.waiting .cg-card { filter: grayscale(0.4) brightness(0.72); cursor: default; }
#cg-hand.waiting .cg-card:hover { transform: none; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65); }
.cg-card .pip { position: absolute; width: 24px; height: 24px; border-radius: 50%; background: rgba(8, 5, 14, 0.85); border: 1.5px solid #e6be6e; color: #f6ecd0; font-family: var(--font-d); font-size: 14px; line-height: 21px; text-align: center; text-shadow: 0 1px 2px #000; }
.cg-card .pip.n { top: 5px; left: 50%; transform: translateX(-50%); }
.cg-card .pip.s { bottom: 44px; left: 50%; transform: translateX(-50%); }
.cg-card .pip.w { left: 5px; top: 42%; transform: translateY(-50%); }
.cg-card .pip.e { right: 5px; top: 42%; transform: translateY(-50%); }
.cg-c-foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 7px 6px; background: linear-gradient(transparent, rgba(8, 5, 14, 0.94) 42%); text-align: center; }
.cg-c-foot b { display: block; font-family: var(--font-d); font-size: 11px; letter-spacing: 0.02em; color: var(--rc, #e6be6e); line-height: 1.1; }
.cg-c-foot span { display: block; font-size: 8.5px; line-height: 1.22; color: #d8cfe0; font-style: italic; margin-top: 2px; }
@media (max-width: 820px) { .cg-card { width: 96px; height: 134px; } .cg-c-foot span { font-size: 7.5px; } }
.cg-card .cg-str { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 38px; height: 38px; border-radius: 50%; background: rgba(8, 5, 14, 0.9); border: 2.5px solid var(--rc, #e6be6e); color: #f6ecd0; font-family: var(--font-d); font-size: 20px; font-weight: bold; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 3px #000; box-shadow: 0 2px 8px rgba(0,0,0,0.6); pointer-events: none; }
#cg-waiting { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(14, 9, 26, 0.97); border: 1px solid #6a5490; border-radius: 10px; padding: 14px 22px; text-align: center; z-index: 10; box-shadow: 0 14px 44px rgba(0,0,0,0.8); animation: freqIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap; }
#cg-waiting p { color: #e8dcc8; margin-bottom: 10px; }

/* ---------- SEALS: drag ghost, rules popup, 3D card viewer ---------- */
.cg-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 9999; width: 108px; height: 151px; opacity: 0.97; box-shadow: 0 24px 50px rgba(0,0,0,0.9), 0 0 0 2px var(--rc, #e6be6e); border-radius: 11px; transition: none !important; border: 2px solid var(--rc, #e6be6e); }
.cg-card.dragging { opacity: 0.15 !important; pointer-events: none; transition: none; }
#cg-hud #cg-rules-btn { padding: 3px 12px; font-size: 12px; margin-top: 6px; }
#cg-rules { position: absolute; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; background: rgba(6, 4, 12, 0.78); }
.cg-rules-box { width: min(560px, 92vw); background: linear-gradient(172deg, rgba(26, 18, 40, 0.98), rgba(14, 9, 24, 0.98)); border: 1px solid #6a5490; border-radius: 14px; padding: 22px 26px; box-shadow: 0 22px 64px rgba(0,0,0,0.75); }
.cg-rules-box h3 { font-family: var(--font-d); font-size: 22px; letter-spacing: 0.12em; color: #e6be6e; text-align: center; margin-bottom: 14px; }
.cg-rules-box ul { list-style: none; padding: 0; margin: 0 0 12px; }
.cg-rules-box li { position: relative; padding: 6px 0 6px 22px; font-size: 14px; line-height: 1.5; color: #e0d8ea; border-bottom: 1px solid rgba(106, 84, 144, 0.2); }
.cg-rules-box li::before { content: "◆"; position: absolute; left: 2px; color: #9a7fd0; font-size: 10px; top: 9px; }
.cg-rules-box li b { color: #f0e6c0; }
.cg-rules-tip { font-size: 13px; font-style: italic; color: #b9aed0; text-align: center; margin: 10px 0 16px; }
#cg-rules-ok { display: block; margin: 0 auto; }
#cg-view { position: absolute; inset: 0; z-index: 13; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(6, 4, 12, 0.9); }
#cg-view-canvas { width: min(420px, 84vw); height: min(560px, 68vh); cursor: grab; touch-action: none; }
#cg-view-canvas:active { cursor: grabbing; }
#cg-view-name { font-family: var(--font-d); font-size: 24px; letter-spacing: 0.06em; color: #f0e6c0; margin-top: 6px; }
#cg-view-name span { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; margin-left: 8px; }
#cg-view-desc { font-size: 14px; font-style: italic; color: #cfc4e0; margin-top: 6px; max-width: 420px; text-align: center; }
.cg-view-hint { font-size: 12px; letter-spacing: 0.12em; color: #8a7fa0; margin-top: 14px; text-transform: uppercase; }
#cg-view-close { position: absolute; top: 18px; right: 20px; width: 42px; height: 42px; border-radius: 50%; font-size: 18px; }
