* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --orange: #ff8c1a;
  --orange-dim: #b35900;
  --bg: #0b0a10;
  --panel: rgba(18, 15, 24, 0.94);
  --border: #3a2f22;
  --text: #e8ddc8;
}
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: "Trebuchet MS", "Segoe UI", sans-serif; color: var(--text); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,8,14,0.55) 0%, rgba(5,4,8,0.92) 100%);
  z-index: 20;
}
.overlay.show { display: flex; }
.panel {
  background: var(--panel); border: 2px solid var(--border); border-radius: 12px;
  padding: 28px 36px; max-width: 620px; width: min(92vw, 620px); text-align: center;
  box-shadow: 0 0 60px rgba(255, 140, 26, 0.08), 0 12px 48px rgba(0,0,0,0.7);
  max-height: 92vh; overflow-y: auto;
}
.title { font-size: 44px; letter-spacing: 6px; color: #f5efdf; text-shadow: 0 2px 12px rgba(255,140,26,0.35); }
.title .orange { color: var(--orange); }
.subtitle { color: #9c8f77; margin: 6px 0 18px; font-style: italic; }
h2 { color: var(--orange); letter-spacing: 2px; margin-bottom: 10px; }

.loading-panel .loadbar { height: 14px; background: #1c1826; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; margin: 18px 0 8px; }
#loadfill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--orange-dim), var(--orange)); transition: width 0.2s; }
#loadtext { color: #9c8f77; font-size: 13px; }

.row { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 14px; }
.row label { color: #9c8f77; }
input {
  background: #17131f; border: 1px solid var(--border); color: var(--text); padding: 9px 12px;
  border-radius: 6px; font-size: 16px; outline: none; text-align: center;
}
input:focus { border-color: var(--orange-dim); }
#joinCode { width: 100px; text-transform: uppercase; letter-spacing: 4px; font-weight: bold; }

/* class cards */
.classes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.ccard {
  border: 2px solid var(--border); border-radius: 10px; padding: 12px 6px; cursor: pointer;
  background: #16121e; transition: all 0.15s;
}
.ccard:hover { border-color: var(--orange-dim); transform: translateY(-2px); }
.ccard.sel { border-color: var(--orange); background: #241a12; box-shadow: 0 0 18px rgba(255,140,26,0.25); }
.ccard .icon { font-size: 30px; }
.ccard .cname { font-weight: bold; margin: 4px 0 2px; color: #f0e6d2; }
.ccard .cdesc { font-size: 11px; color: #9c8f77; line-height: 1.35; }

/* appearance customization */
.customize { display: flex; gap: 16px; align-items: center; justify-content: center; margin-bottom: 16px; }
#lookPreview { background: radial-gradient(circle at 50% 35%, #241c30, #120e1a); border: 1px solid var(--border); border-radius: 10px; }
.lookopts { text-align: left; }
.lookrow { margin-bottom: 8px; font-size: 14px; color: #cfc3a8; }
.lookrow input { width: auto; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid #2b2436; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,0.4); }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 6px; }
button.big {
  font-size: 17px; padding: 12px 34px; border-radius: 8px; cursor: pointer; min-width: 260px;
  background: #221c2e; color: var(--text); border: 2px solid var(--border); transition: all 0.15s;
  font-family: inherit; letter-spacing: 1px;
}
button.big:hover { border-color: var(--orange-dim); transform: translateY(-1px); }
button.orange-btn { background: linear-gradient(180deg, #d97613, #a04f00); color: #fff8ec; border-color: #ffab4a; }
button.orange-btn:hover { filter: brightness(1.15); }
.joinrow { display: flex; gap: 8px; }
.joinrow button { min-width: 150px; }
.menu-note { margin-top: 16px; font-size: 12px; color: #7d7260; }
.credits { margin-top: 8px; font-size: 11px; color: #55503f; }
.credits a { color: #8a6d3b; }

.roomcode { font-size: 30px; letter-spacing: 8px; color: var(--orange); font-weight: bold; }
.lobby-status { color: #9c8f77; margin: 10px 0; }
.lobby-list { list-style: none; margin: 8px 0 14px; }
.lobby-list li { padding: 7px; border-bottom: 1px solid #262032; font-size: 16px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#topleft { position: absolute; top: 16px; left: 16px; width: 280px; }
.statname { font-weight: bold; text-shadow: 0 1px 3px #000; margin-bottom: 4px; color: #f0e6d2; }
.bar { position: relative; height: 20px; background: rgba(10,8,14,0.75); border: 1px solid #000; border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 20px; color: #fff; text-shadow: 0 1px 2px #000; }
#hpfill { height: 100%; background: linear-gradient(180deg, #e04545, #8f1f1f); transition: width 0.15s; }
.manabar { height: 12px; }
#manafill { height: 100%; background: linear-gradient(180deg, #4a7de0, #23408f); transition: width 0.15s; }
.xpbar { height: 8px; }
#xpfill { height: 100%; background: linear-gradient(180deg, #ffd35c, #c78c00); transition: width 0.2s; }
.xpbar span { line-height: 8px; font-size: 8px; }

#topright { position: absolute; top: 16px; right: 16px; }
#minimap { border: 2px solid rgba(60,48,34,0.9); border-radius: 8px; background: rgba(8,6,12,0.82); }

#bossbarWrap { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: min(520px, 60vw); text-align: center; }
.bossname { font-weight: bold; letter-spacing: 3px; color: #ffb066; text-shadow: 0 2px 6px #000; margin-bottom: 4px; }
.bossbar { height: 16px; border: 1px solid #442; }
#bossfill { height: 100%; background: linear-gradient(180deg, #b03df0, #5c1a85); transition: width 0.2s; }

#bottombar { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.slot {
  position: relative; background: rgba(14,11,20,0.85); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; font-size: 16px; text-shadow: 0 1px 2px #000; overflow: hidden;
}
.slot-tag { font-size: 10px; letter-spacing: 0.08em; color: #8b96a4; font-weight: 700; }
.slot .key { font-size: 10px; background: #2c2438; padding: 2px 5px; border-radius: 3px; color: #b3a68c; margin-left: 4px; }
.slot .cool { position: absolute; left: 0; bottom: 0; height: 3px; width: 0%; background: var(--orange); }

#prompt {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: rgba(14,11,20,0.9); border: 1px solid var(--orange-dim); border-radius: 8px;
  padding: 8px 18px; font-size: 16px; color: #ffd9a8;
}
#msgs { position: absolute; bottom: 16px; left: 16px; width: 340px; font-size: 14px; }
.msg { background: rgba(10,8,14,0.72); border-left: 3px solid var(--orange-dim); padding: 4px 10px; margin-top: 4px; border-radius: 0 5px 5px 0; animation: msgfade 6s forwards; }
.msg.gold { border-left-color: #ffd35c; }
.msg.bad { border-left-color: #e04545; }
@keyframes msgfade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }

#partyBar { position: absolute; top: 130px; left: 16px; }
.pcard { background: rgba(10,8,14,0.72); border: 1px solid #2b2436; border-radius: 6px; padding: 5px 10px; margin-bottom: 6px; width: 190px; font-size: 13px; }
.pcard .pname { color: #cfc3a8; }
.pcard .pbar { height: 7px; background: #1c1520; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.pcard .pfill { height: 100%; background: #e04545; }
.pcard.dead { opacity: 0.45; }

/* crosshair */
#crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; }
.ch-dot { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; background: #f0e6d2; border-radius: 50%; box-shadow: 0 0 3px #000; }
.ch-l { position: absolute; background: #f0e6d2; box-shadow: 0 0 3px #000; transition: all 0.12s; }
.ch-t { left: 50%; top: 0; width: 2px; height: 9px; margin-left: -1px; }
.ch-b { left: 50%; bottom: 0; width: 2px; height: 9px; margin-left: -1px; }
.ch-lf { top: 50%; left: 0; height: 2px; width: 9px; margin-top: -1px; }
.ch-rt { top: 50%; right: 0; height: 2px; width: 9px; margin-top: -1px; }
#crosshair.aiming .ch-t { height: 6px; top: 6px; }
#crosshair.aiming .ch-b { height: 6px; bottom: 6px; }
#crosshair.aiming .ch-lf { width: 6px; left: 6px; }
#crosshair.aiming .ch-rt { width: 6px; right: 6px; }
#crosshair.hostile .ch-l, #crosshair.hostile .ch-dot { background: #ff8c4a; }
#hitmark {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.5);
  color: #ffdd66; font-size: 26px; font-weight: bold; opacity: 0; text-shadow: 0 0 4px #000;
}
#hitmark.crit { color: #ff5533; }
#hitmark.show { animation: hitpop 0.28s; }
@keyframes hitpop { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } }

/* spell slots */
.slot.spell { position: relative; min-width: 52px; text-align: center; }
.slot.spell .sp-icon { font-size: 19px; }
.slot.spell .cdmask { position: absolute; left: 0; bottom: 0; width: 100%; height: 0%; background: rgba(10,8,14,0.82); pointer-events: none; }
.slot.spell.nomana .sp-icon { filter: grayscale(1) brightness(0.6); }

/* inventory */
.inv-panel { max-width: 760px; width: min(94vw, 760px); }
.inv-cols { display: flex; gap: 22px; text-align: left; }
.equip-col { width: 250px; }
.bag-col { flex: 1; }
.equip-title { color: var(--orange); letter-spacing: 2px; font-size: 13px; margin-bottom: 8px; text-transform: uppercase; }
.eq-slot {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 7px;
  background: #16121e; min-height: 44px; font-size: 13px;
}
.eq-slot .slot-label { font-size: 10px; color: #7d7260; text-transform: uppercase; letter-spacing: 1px; }
.item-name { font-weight: bold; }
.item-stats { font-size: 11px; color: #9c8f77; }
.bag-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.bag-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; cursor: pointer;
  background: #16121e; font-size: 12px; transition: all 0.1s; min-height: 52px;
}
.bag-item:hover { border-color: var(--orange-dim); transform: translateY(-1px); }
.inv-stats { margin-top: 12px; font-size: 12.5px; color: #b3a68c; line-height: 1.8; border-top: 1px solid #262032; padding-top: 8px; }
.inv-hint { margin-top: 10px; font-size: 11px; color: #7d7260; }

#hitVignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 120px 40px rgba(200, 30, 30, 0.55);
}

/* transition banner */
#transition {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #050408; z-index: 15; transition: opacity 0.6s; pointer-events: none;
}
#transTitle { font-size: 42px; letter-spacing: 8px; color: var(--orange); text-shadow: 0 0 30px rgba(255,140,26,0.5); }
#transSub { color: #8d8168; margin-top: 10px; font-style: italic; letter-spacing: 2px; }

/* merchant */
.shop { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.shopitem {
  border: 2px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; background: #16121e;
  transition: all 0.12s; text-align: center;
}
.shopitem:hover:not(.off) { border-color: var(--orange-dim); }
.shopitem.off { opacity: 0.4; cursor: not-allowed; }
.shopitem .sicon { font-size: 26px; }
.shopitem .sname { font-weight: bold; margin: 3px 0; color: #f0e6d2; }
.shopitem .sdesc { font-size: 11px; color: #9c8f77; }
.shopitem .sprice { margin-top: 5px; color: #ffd35c; font-weight: bold; }
.shop-gold { color: #ffd35c; margin-bottom: 8px; }

/* game mode selector */
.moderow { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.modebtn {
  border: 2px solid var(--border); border-radius: 10px; padding: 10px 18px; cursor: pointer;
  background: #16121e; font-weight: bold; color: #f0e6d2; transition: all 0.15s; font-size: 15px;
}
.modebtn span { display: block; font-weight: normal; font-size: 11px; color: #9c8f77; margin-top: 2px; }
.modebtn:hover { border-color: var(--orange-dim); }
.modebtn.sel { border-color: var(--orange); background: #241a12; box-shadow: 0 0 14px rgba(255,140,26,0.2); }
.publabel { font-size: 12.5px; color: #9c8f77; cursor: pointer; }
.publabel input { width: auto; }

/* tavern board */
.board-list { max-height: 300px; overflow-y: auto; margin: 12px 0; text-align: left; }
.board-game {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: #16121e; padding: 10px 14px; margin-bottom: 8px;
}
.board-game .bg-name { font-weight: bold; color: #f0e6d2; }
.board-game .bg-meta { font-size: 12px; color: #9c8f77; }
.board-game button { font-size: 14px; padding: 7px 18px; border-radius: 6px; cursor: pointer; background: linear-gradient(180deg, #d97613, #a04f00); color: #fff8ec; border: 1px solid #ffab4a; }
.board-empty { color: #7d7260; text-align: center; padding: 18px; }

/* horde wave hud */
#waveHud {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(14,11,20,0.85); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 18px; font-size: 15px; color: #ffd9a8; letter-spacing: 1px;
}
#waveBanner {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
  font-size: 52px; font-weight: bold; letter-spacing: 10px; color: var(--orange);
  text-shadow: 0 0 40px rgba(255,140,26,0.6), 0 3px 6px #000; opacity: 0;
}
#waveBanner.show { animation: wavein 2.4s ease-out; }
@keyframes wavein { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

.runstats { margin: 14px 0; line-height: 1.9; font-size: 16px; }
.runstats b { color: var(--orange); }
.keys { margin: 10px auto 16px; border-collapse: collapse; }
.keys td { padding: 5px 14px; border-bottom: 1px solid #262032; font-size: 14px; text-align: left; }
.keys td:first-child { color: var(--orange); font-weight: bold; text-align: right; }

/* floor select */
.floor-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; max-height: 300px; overflow-y: auto; }
.floorbtn {
  background: #16121e; border: 2px solid var(--border); border-radius: 8px; color: #f0e6d2;
  padding: 10px 8px; cursor: pointer; font-family: inherit; font-size: 14px; transition: all 0.12s;
}
.floorbtn span { display: block; font-size: 10.5px; color: #9c8f77; margin-top: 3px; }
.floorbtn:hover { border-color: var(--orange); transform: translateY(-1px); }

/* ---- combat codex (drillmaster / bestiary) ---- */
.codex-body { max-height: 54vh; overflow-y: auto; margin: 12px 0; text-align: left; }
.codex-entry { background: #16121e; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.codex-entry h3 { margin: 0 0 6px; color: #f0c869; font-size: 15px; }
.codex-stats { font-size: 13px; color: #cfc4ae; line-height: 1.5; }
.codex-stats b { color: #f0e6d2; }
.codex-note { font-size: 12px; color: #9c8f77; font-style: italic; margin: 4px 0 10px; }

/* ---- commander map ---- */
.cmd-canvas { width: min(58vh, 82vw); height: min(58vh, 82vw); border: 2px solid var(--border); border-radius: 8px; background: #0d0a14; cursor: crosshair; margin: 8px 0; }

/* ---- weapon signature slot: fills as you land hits, blazes when ready ---- */
#sigSlot { position: relative; overflow: hidden; }
#sigSlot .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: rgba(240,180,60,0.28); transition: height 0.15s; pointer-events: none; }
#sigSlot .icon { position: relative; }
#sigSlot.charged { border-color: #ffcc44; box-shadow: 0 0 12px rgba(255,204,68,0.7); animation: sigpulse 0.9s infinite alternate; }
@keyframes sigpulse { from { box-shadow: 0 0 6px rgba(255,204,68,0.4); } to { box-shadow: 0 0 16px rgba(255,204,68,0.9); } }

/* ---- boss title card ---- */
#bossCard { position: fixed; top: 26%; left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1.2s; z-index: 60; }
#bossCard.show { opacity: 1; }
#bossCard .bc-name { font-size: 64px; letter-spacing: 14px; color: #ffb347; text-shadow: 0 0 24px rgba(255, 80, 20, 0.8), 0 4px 12px #000; font-weight: bold; }
#bossCard .bc-sub { font-size: 20px; letter-spacing: 10px; color: #d8c9a8; margin-top: 4px; text-shadow: 0 2px 8px #000; }

/* ---- spell loadout picker ---- */
#spellPick { margin: 10px 0 4px; text-align: left; }
#spellPick .sp-head { font-size: 13px; color: #cfc4ae; margin-bottom: 6px; }
#spellChips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #16121e; border: 1px solid var(--border); border-radius: 14px; color: #cfc4ae; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--orange); }
.chip.sel { border-color: var(--orange); color: #ffd9a0; background: #241a12; }
