:root {
  --bg: #070d18;
  --panel: #121a28;
  --panel2: #1a2436;
  --line: #3a4a63;
  --gold: #c9a24a;
  --gold2: #8a6a2a;
  --text: #e8eef6;
  --muted: #95a6bd;
  --accent: #f2c95c;
  --good: #7fe08a;
  --bad: #ff6b5e;
  --ice: #9fd8ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; color: var(--text);
  font: 14px/1.4 "Trebuchet MS", system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 0%, #1b2f4f 0%, #0b1424 55%, var(--bg) 100%) fixed;
}
h1, h2, h3, .stat .lbl, .btns .nm, #selName { font-family: "Cinzel", "Trajan Pro", Georgia, serif; }
button {
  font: inherit; color: var(--text); cursor: pointer; padding: 7px 12px;
  background: linear-gradient(#26324a, #161f30); border: 1px solid var(--gold2); border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.5);
}
button:hover:not(:disabled) { border-color: var(--gold); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 0 8px rgba(201,162,74,.35); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(#e7c66a, #a77c2c); color: #1d1405; border-color: #f3dc94; font-weight: 700;
  font-family: "Cinzel", Georgia, serif; letter-spacing: .5px; text-shadow: 0 1px 0 rgba(255,255,255,.3);
}
input { font: inherit; color: var(--text); background: #0a111d; border: 1px solid var(--gold2); border-radius: 4px; padding: 7px 10px; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
input:focus { outline: none; border-color: var(--gold); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
kbd { background: #0a111d; border: 1px solid var(--gold2); border-radius: 3px; padding: 0 4px; font-size: 12px; color: var(--accent); }
code { background: #0a111d; padding: 1px 5px; border-radius: 4px; color: var(--ice); }
/* Ornate frame used by the lobby card, side panel and game-over card */
.frame {
  background:
    linear-gradient(rgba(159,216,255,.05), transparent 40%),
    linear-gradient(160deg, #18233a, #0e1522);
  border: 2px solid var(--gold2);
  box-shadow: inset 0 0 0 1px #000, inset 0 0 0 3px rgba(201,162,74,.35), 0 10px 40px rgba(0,0,0,.6);
}
.g { color: var(--good); } .r { color: var(--bad); }

/* Lobby */
#lobby { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.lobby-card { width: 100%; max-width: 480px; border-radius: 8px; padding: 28px; }
h1 { margin: 0; font-size: 32px; letter-spacing: 1px; color: #f4f8ff; text-shadow: 0 0 18px rgba(159,216,255,.55), 0 2px 0 #000; }
h1 span { color: var(--accent); text-shadow: 0 0 14px rgba(242,201,92,.5), 0 2px 0 #000; }
.tag { color: var(--muted); margin: 6px 0 20px; }
#joinForm { display: flex; gap: 8px; margin-bottom: 16px; }
#joinForm input { flex: 1; }
#slots { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
#slots li { display: flex; align-items: center; gap: 10px; background: #0a111d; border: 1px solid rgba(201,162,74,.35); border-radius: 4px; padding: 9px 12px; }
#slots li.empty { color: var(--muted); border-style: dashed; background: transparent; }
#slots .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
#slots .nm { flex: 1; }
#slots .tagb { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
#slots .x { padding: 0 8px; line-height: 20px; }
#hostCtl { margin-bottom: 12px; }
#watchBtn { width: 100%; margin-bottom: 12px; }
.howto { margin-top: 16px; border-top: 1px solid rgba(201,162,74,.3); padding-top: 12px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); font-family: Cinzel, Georgia, serif; }
.howto ul { padding-left: 18px; color: #c4cad6; }
.howto li { margin: 6px 0; }

/* Game */
#game { display: flex; height: 100vh; }
#board { background: #0b1424; }
#board { flex: 1; min-width: 0; position: relative; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#panel { width: 300px; flex: none; border-width: 0 0 0 2px; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
#panel section { border-top: 1px solid rgba(201,162,74,.3); padding-top: 10px; }
#panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
#panel h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; float: right; }
#stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: #0a111d; border: 1px solid rgba(201,162,74,.35); border-radius: 4px; padding: 6px 8px; }
.stat .lbl { display: block; font-size: 11px; color: var(--muted); }
.stat .val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.val.gold { color: var(--accent); } .val.inc { color: var(--good); } .val.lives { color: #ff8a80; }
#incBar { position: relative; height: 18px; background: #0a111d; border: 1px solid rgba(201,162,74,.35); border-radius: 4px; overflow: hidden; }
#incFill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2a6fa8, var(--ice)); width: 0; }
#incTxt { position: relative; display: block; text-align: center; font-size: 11px; line-height: 16px; text-shadow: 0 1px 2px #000; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btns button { text-align: left; padding: 6px 8px; display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 6px; align-items: center; }
.btns button .sw { width: 12px; height: 12px; border-radius: 3px; }
.btns button .nm { font-weight: 600; }
.btns button .hk { font-size: 11px; color: var(--muted); }
.btns button .sub { grid-column: 2 / 4; font-size: 11px; color: var(--muted); }
.btns button .sub b { color: var(--accent); font-weight: 600; }
.btns button .sub i { color: var(--good); font-style: normal; }
.btns button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 10px rgba(242,201,92,.4); }
.btns button.poor { opacity: .45; }
#phaseNote { background: #2a2414; border: 1px solid #5a4a20; color: var(--accent); border-radius: 8px; padding: 6px 8px; margin-bottom: 8px; font-size: 12px; font-weight: 600; text-align: center; }
#selInfo { position: absolute; z-index: 14; width: 260px; background: linear-gradient(#141e30f2, #0b1322f2); border: 1px solid var(--gold); border-radius: 6px; padding: 8px 10px; box-shadow: 0 8px 30px rgba(0,0,0,.55); }
#selActions button { flex: 1; padding: 7px 6px; font-weight: 600; }
#upBtn:not(:disabled) { background: linear-gradient(#3a2d12, #1d160a); border-color: var(--gold); color: var(--accent); }
#selName { font-weight: 600; margin-bottom: 2px; }
#selActions { margin-top: 8px; }
#plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#plist li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 6px; }
#plist li.me { background: rgba(159,216,255,.08); }
#plist li.dead { opacity: .4; text-decoration: line-through; }
#plist .sw { width: 10px; height: 10px; border-radius: 2px; }
#plist .num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
/* Chat is pinned to the bottom of the side panel; the rest of the panel scrolls behind it. */
#panel { padding-bottom: 0; }
#feedSec { position: sticky; bottom: 0; z-index: 5; margin: auto -12px 0; padding: 8px 12px 12px !important; display: flex; flex-direction: column;
  background: linear-gradient(rgba(14,21,34,.86), rgba(10,15,25,.97)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--gold2) !important; box-shadow: 0 -10px 24px rgba(0,0,0,.55); }
#feedHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#feedTabs { display: flex; gap: 4px; }
#feedTabs button, #feedMin { padding: 2px 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
#feedTabs button.on { color: var(--accent); border-color: var(--gold); }
#chatUnread { display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 3px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; line-height: 15px; text-align: center; letter-spacing: 0; }
#feed { height: 170px; overflow-y: auto; font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
#feed > div:first-child { margin-top: auto; } /* new lines sit at the bottom, like a chat */
#feed .chat { color: var(--text); font-size: 13px; }
#feed .chat b { color: var(--accent); }
#feed.chatOnly > div:not(.chat) { display: none; }
#feedSec.min #feed { display: none; }
#feedSec.min #feedMin { transform: rotate(180deg); }
#chatIn { width: 100%; }

#overlay { position: fixed; inset: 0; background: rgba(5, 7, 10, .7); display: flex; align-items: center; justify-content: center; z-index: 10; }
.over-card { border-radius: 8px; padding: 28px 36px; text-align: center; }
.over-card h2 { margin: 0 0 18px; font-size: 28px; text-shadow: 0 2px 0 #000; }
#toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: #3a1f1f; border: 1px solid #6b2f2f; color: #ffd5d0; padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }

@media (max-width: 800px) {
  #game { flex-direction: column; height: auto; }
  #board { height: 70vh; }
  #panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  /* On narrow screens the page scrolls, so pin chat to the bottom of the screen instead. */
  #feed { height: 96px; }
}
.subtitle { margin: 2px 0 0; font-family: Cinzel, Georgia, serif; color: var(--ice); letter-spacing: 3px; font-size: 12px; text-transform: uppercase; }
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
#lobby { position: relative; z-index: 1; }

/* 3D board overlays */
#board { overflow: hidden; }
#board canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.labels3d { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl3d { position: absolute; left: 0; top: 0; white-space: nowrap; font: 600 13px Cinzel, Georgia, serif; color: #f4f8ff;
  background: linear-gradient(#1d2940ee, #0e1626ee); border: 1px solid var(--gold2); border-radius: 4px; padding: 3px 9px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5); display: flex; align-items: center; gap: 6px; }
.lbl3d.me { border-color: var(--gold); font-size: 14px; }
.lbl3d .sw, .pip-lbl .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lbl3d b, .pip-lbl b { color: #ff8a80; font-family: system-ui, sans-serif; }
.lbl3d small { font: 10px system-ui; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; }
.lbl3d i { font-style: normal; color: var(--accent); font-size: 11px; }
.lbl3d em, .pip-lbl em { font-style: normal; color: var(--bad); }
.pip-lbl { position: absolute; font: 600 11px Cinzel, Georgia, serif; color: #f4f8ff; text-shadow: 0 1px 3px #000;
  display: flex; align-items: center; gap: 5px; overflow: hidden; white-space: nowrap; }
.pip-lbl.target { color: var(--accent); }
.pip-lbl.target::after { content: '◀ target'; font-size: 9px; letter-spacing: .5px; }
#phaseBanner { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  font: 700 18px Cinzel, Georgia, serif; color: var(--accent); padding: 10px 22px; white-space: nowrap;
  background: linear-gradient(#1d2940f0, #0e1626f0); border: 2px solid var(--gold); border-radius: 4px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#camHint { position: absolute; left: 12px; bottom: 8px; z-index: 2; pointer-events: none; font-size: 11px; color: rgba(230,240,255,.75); text-shadow: 0 1px 2px #000; }
.ladder { display: grid; gap: 2px; margin-top: 6px; }
.ladder span { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 1px 4px; border-radius: 3px; }
.ladder span i { width: 8px; height: 8px; border-radius: 2px; opacity: .5; }
.ladder span.done { color: #c4cad6; }
.ladder span.done i { opacity: 1; }
.ladder span.cur { color: var(--accent); background: rgba(242,201,92,.1); font-weight: 600; }
.ladder span.cur i { opacity: 1; }
.btns button .pt { width: 34px; height: 34px; grid-row: 1 / 3; border-radius: 4px; background: radial-gradient(#2a3a55, #0a111d); object-fit: cover; }
.btns button.has-pt { grid-template-columns: 34px 1fr auto; }
#selInfo .portrait { float: right; width: 56px; height: 56px; margin: 0 0 4px 8px; border-radius: 4px; border: 1px solid var(--gold2); background: radial-gradient(#2a3a55, #0a111d); }
.tierHead { grid-column: 1 / -1; font: 600 11px Cinzel, Georgia, serif; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; margin-top: 4px; }
.tierHead.locked { color: var(--muted); }
.btns button.locked { opacity: .35; filter: grayscale(.8); }
#creepUpBtn { width: 100%; margin-top: 8px; text-align: left; line-height: 1.3; background: linear-gradient(#3a2d12, #1d160a); border-color: var(--gold); }
#creepUpBtn b { color: var(--accent); }
#creepUpBtn small { display: block; font-size: 11px; color: var(--muted); }
#creepUpBtn.done { background: linear-gradient(#18301f, #0d1a11); border-color: #3d7a45; }
#slots { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, auto); grid-auto-flow: column; column-gap: 14px; }
#slots li.teamHead { background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 35%, transparent), transparent); border: 0; border-left: 3px solid var(--tc); padding: 6px 10px; }
#slots li.teamHead .tn { flex: 1; font: 700 14px Cinzel, Georgia, serif; color: #f2e6cf; letter-spacing: .5px; }
#slots li.teamHead small { color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 10px; }
#slots li.teamHead button { padding: 2px 8px; }
#slots li.team0 { border-left: 3px solid #e0473c; } #slots li.team1 { border-left: 3px solid #3f8fe6; }
#slots .raceSel { font: inherit; font-size: 12px; color: var(--text); background: #0a111d; border: 1px solid var(--gold2); border-radius: 4px; padding: 2px 4px; max-width: 120px; }
#slots .tagb.race { color: #e8d9b0; }
#selPortrait[src=""] { display: none; }
#selInfo::after { content: ''; display: block; clear: both; }
.lbl3d small.up { color: var(--accent); border-color: var(--gold2); }
#gallery { display: grid; gap: 6px; margin-top: 8px; }
.grow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gcard { background: #0a111d; border: 1px solid rgba(201,162,74,.3); border-radius: 4px; padding: 4px; text-align: center; }
.gcard img { width: 100%; aspect-ratio: 1; display: block; background: radial-gradient(#2a3a55, #0a111d); border-radius: 3px; }
.gcard b { display: block; font: 600 10px Cinzel, Georgia, serif; color: #e8eef6; margin-top: 3px; line-height: 1.15; }
.gcard small { font-size: 9px; color: var(--muted); }
.lobby-card { max-width: 560px; }
#botLevel { font: inherit; color: var(--text); background: #0a111d; border: 1px solid var(--gold2); border-radius: 4px; padding: 6px 8px; flex: 0 0 auto; }
#slots .tagb.lvl-easy { color: var(--good); }
#slots .tagb.lvl-hard { color: var(--bad); border-color: #6b2f2f; }
#slots .tagb.lvl-impossible { color: #ff6a3a; border-color: #8a2a10; background: #2a0c06; text-shadow: 0 0 6px #ff3a10; }
#plist li { cursor: pointer; }
#plist li:hover { background: rgba(242,201,92,.08); }
.invite { margin: 4px 0 12px; padding: 10px; background: #0a111d; border: 1px solid rgba(201,162,74,.35); border-radius: 6px; display: grid; gap: 8px; }
.invite-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.invite-head b { color: var(--accent); font-family: Cinzel, Georgia, serif; letter-spacing: 2px; font-size: 16px; }
.invite-head small { color: var(--muted); font-size: 11px; }
.invite .row > input { flex: 1; min-width: 0; }
.invite .row > button { flex: 0 0 auto; }
#slots .tagb.away { color: var(--bad); }
.gsub { font: 600 11px/1 'Cinzel', serif; letter-spacing: .08em; text-transform: uppercase; color: #e8c86a; margin: 10px 0 2px; }

/* Income ranking that pops up every game minute */
#incomePop { position: absolute; top: 56px; left: 50%; transform: translate(-50%, -8px); min-width: 230px; padding: 10px 14px 8px;
  background: rgba(10, 16, 28, .92); border: 1px solid var(--gold2); border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  pointer-events: none; opacity: 0; z-index: 20; transition: opacity .35s, transform .35s; }
#incomePop.show { opacity: 1; transform: translate(-50%, 0); }
#incomePop.show.fade { opacity: 0; transition: opacity 3s ease-in; }
#incomePop h4 { margin: 0 0 6px; font: 600 12px Cinzel, Georgia, serif; letter-spacing: .08em; color: var(--accent); text-align: center; }
#incomePop ol { margin: 0; padding: 0; list-style: none; }
#incomePop li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
#incomePop li.me .nm { color: var(--accent); }
#incomePop .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
#incomePop .nm { flex: 1; }
#incomePop b { color: var(--good); }

/* Summoning Palace menu (opened by clicking your palace or pressing P) */
#palaceMenu { position: absolute; left: 14px; top: 54px; width: min(470px, calc(100% - 28px)); max-height: calc(100% - 80px); overflow-y: auto;
  z-index: 15; padding: 10px 12px; background: linear-gradient(#141e30f2, #0b1322f2); border: 1px solid var(--gold); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
#palaceMenu .pm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#palaceMenu h3 { margin: 0; }
#palaceMenu h3 small { display: block; margin-top: 2px; }
#pmClose { padding: 2px 8px; font-size: 14px; }
#palaceBtn { width: 100%; text-align: left; padding: 9px 10px; background: linear-gradient(#24314d, #141d30); border-color: var(--gold); display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; }
#palaceBtn b { font: 700 14px Cinzel, Georgia, serif; color: var(--accent); }
#palaceBtn small { color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; font-size: 11px; align-self: center; }
#palaceBtn > span { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
#palaceBtn.active { box-shadow: inset 0 0 0 1px var(--accent), 0 0 12px rgba(242,201,92,.35); }
.lbl3d.pal { font: 600 12px Cinzel, Georgia, serif; color: var(--accent); }
.lbl3d.pal small { color: var(--muted); font-family: inherit; margin-left: 4px; }

/* Portrait cards: the sprite itself, with its name just below */
#towerBtns { grid-template-columns: repeat(3, 1fr); }
#creepBtns { grid-template-columns: repeat(4, 1fr); }
.btns button.has-pt { display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; padding: 4px 4px 5px; gap: 0; }
.btns button.has-pt .pt { width: 100%; height: auto; aspect-ratio: 1; border-radius: 3px; }
.btns button.has-pt .nm { margin-top: 3px; font-size: 11px; line-height: 1.15; }
.btns button.has-pt .hk { position: absolute; top: 4px; right: 5px; font-size: 10px; color: #e8eef6; background: rgba(8,12,20,.75); border-radius: 3px; padding: 0 4px; }
.btns button.has-pt .sub { font-size: 10px; margin-top: 1px; }
/* creep stock: count in the top-left corner, refill bar along the bottom */
.btns button.has-pt .stk { position: absolute; top: 4px; left: 5px; font-size: 10px; font-weight: 700; color: var(--good); background: rgba(8,12,20,.8); border-radius: 3px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.btns button.has-pt .stk:empty { display: none; }
.btns button.has-pt .stk.empty { color: var(--bad); }
.btns button.has-pt .refill { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--ice); border-radius: 0 2px 2px 0; transition: width .2s linear; }
.btns button { min-width: 0; }
.btns { clear: both; }

/* compact palace menu: keep most of the board visible */
#palaceMenu { width: min(300px, calc(100% - 28px)); padding: 7px 8px; top: 48px; }
#palaceMenu h3 { font-size: 13px; }
#palaceMenu h3 small { font-size: 10px; }
#palaceMenu > p { display: none; }
#palaceMenu #creepBtns { gap: 4px; }
#palaceMenu .tierHead { font-size: 9.5px; margin-top: 2px; }
#palaceMenu .btns button.has-pt { padding: 2px 2px 3px; }
#palaceMenu .btns button.has-pt .nm { font-size: 9.5px; margin-top: 1px; }
#palaceMenu .btns button.has-pt .sub { font-size: 8.5px; }
#palaceMenu .btns button.has-pt .hk { font-size: 8.5px; top: 2px; right: 3px; padding: 0 3px; }
#palaceMenu #creepUpBtn { margin-top: 5px; padding: 5px 7px; font-size: 12px; }
#palaceMenu #creepUpBtn small { font-size: 9.5px; }
#palaceMenu .btns button.has-pt .pt { height: 46px; aspect-ratio: auto; object-fit: cover; }
#palaceMenu .btns button.has-pt .nm, #palaceMenu .btns button.has-pt .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* picture placeholder: same footprint as the portrait, so cards never jump when art loads */
.btns button.has-pt .sw { width: 100%; height: auto; aspect-ratio: 1; border-radius: 3px; opacity: .55; }
#palaceMenu .btns button.has-pt .sw { height: 46px; aspect-ratio: auto; }

/* end-of-game scoreboard */
.over-card { max-width: min(1100px, calc(100vw - 32px)); }
#overSub { color: var(--muted); font-size: 12px; margin: -10px 0 14px; letter-spacing: .04em; }
#overStats { overflow-x: auto; margin-bottom: 18px; }
table.stats { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.stats th { font: 600 10px Cinzel, Georgia, serif; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); padding: 6px 8px; border-bottom: 1px solid var(--gold2); text-align: right; }
table.stats th:nth-child(2), table.stats td.nm, table.stats td.mvp, table.stats th:last-child { text-align: left; }
table.stats td { padding: 6px 8px; text-align: right; border-bottom: 1px solid rgba(201,162,74,.12); font-variant-numeric: tabular-nums; }
table.stats tr.me td { background: rgba(242,201,92,.07); }
table.stats td.best { color: var(--accent); font-weight: 700; }
table.stats td.pl { text-align: center; font-size: 14px; }
table.stats td.nm .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
table.stats small { color: var(--muted); font-size: 10px; margin-left: 3px; }
table.stats th, table.stats td { padding: 5px 6px; }
#patchTag { margin-left: 6px; font: 600 10px Cinzel, Georgia, serif; color: var(--muted); letter-spacing: .06em; }
.patchnotes ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }

/* sound controls */
#soundCtl { position: absolute; left: 12px; bottom: 26px; z-index: 6; display: flex; align-items: center; gap: 6px; background: rgba(10,16,28,.7); border: 1px solid var(--line); border-radius: 16px; padding: 3px 8px 3px 4px; }
#soundCtl .soundBtn { background: none; border: 0; padding: 2px 4px; font-size: 15px; cursor: pointer; }
#soundCtl .volSlider { width: 80px; accent-color: var(--accent); }

/* ================= Lobby redesign: key art, glass panels, gold trim ================= */
#lobby { position: relative; z-index: 2; min-height: 100vh; display: block; padding: 0; overflow-x: hidden; }
#lobbyBg { position: fixed; inset: -4%; z-index: -1; background: url(assets/textures/lobby-dark.jpg) 60% 30% / cover no-repeat; animation: bgdrift 60s ease-in-out infinite alternate; }
#lobbyBg::after { content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(4,8,18,.92) 0%, rgba(4,8,18,.70) 32%, rgba(4,8,18,.25) 62%, rgba(4,8,18,.35) 100%),
    linear-gradient(0deg, rgba(4,8,18,.85) 0%, rgba(4,8,18,0) 45%),
    radial-gradient(ellipse at 70% 20%, rgba(150,90,255,.12), transparent 60%); }
@keyframes bgdrift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, 1%); } }
#snow { z-index: 3; }

.lobby-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 30px 44px 18px; position: relative; z-index: 4; }
.logo-main { font: 700 clamp(38px, 5vw, 64px)/1 Cinzel, Georgia, serif; letter-spacing: .04em;
  background: linear-gradient(180deg, #fffaf0 0%, #f6dc8f 45%, #c08d2f 75%, #f4e1a6 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #1a1206) drop-shadow(0 0 22px rgba(242,201,92,.35)); }
.logo-sub { margin-top: 8px; font: 600 12px Cinzel, Georgia, serif; letter-spacing: .38em; text-transform: uppercase; color: #bfe6ff; text-shadow: 0 0 12px rgba(120,200,255,.6); }
.logo-sub span { color: #e8f6ff; }
.top-right { display: flex; align-items: center; gap: 10px; }
button.ghost { background: rgba(10,16,30,.55); border: 1px solid rgba(242,201,92,.4); box-shadow: none; backdrop-filter: blur(6px); }
button.ghost:hover { border-color: var(--accent); }
button.ghost.small { padding: 3px 9px; font-size: 11px; }
button.big { padding: 11px 18px; font-size: 14px; }
#patchBadge { font: 600 11px Cinzel, Georgia, serif; letter-spacing: .06em; color: var(--accent); }
#patchTag { margin: 0; color: #fff; font: inherit; }
.soundCtl { display: flex; align-items: center; gap: 6px; background: rgba(10,16,30,.55); border: 1px solid rgba(242,201,92,.3); border-radius: 18px; padding: 3px 10px 3px 4px; backdrop-filter: blur(6px); }
.soundCtl .soundBtn { background: none; border: 0; box-shadow: none; padding: 2px 4px; font-size: 15px; }
.soundCtl .volSlider { width: 84px; accent-color: var(--accent); }

.lobby-grid { position: relative; z-index: 4; display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 28px; padding: 6px 44px 44px; align-items: start; }
.panel { position: relative; background: linear-gradient(180deg, rgba(16,24,42,.80), rgba(8,13,25,.86)); backdrop-filter: blur(10px) saturate(1.15);
  border: 1px solid rgba(242,201,92,.38); border-radius: 12px; padding: 22px 24px 20px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.07), inset 0 0 0 1px rgba(0,0,0,.4); }
.panel::before, .panel::after { content: ''; position: absolute; width: 22px; height: 22px; border: 2px solid var(--accent); opacity: .8; pointer-events: none; }
.panel::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.panel::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.panel-title { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font: 700 18px Cinzel, Georgia, serif; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.panel-title::before, .panel-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(242,201,92,.6), transparent); }
.war-room .tag { text-align: center; margin: 0 0 16px; color: #b9c7d9; font-size: 13px; }
#joinForm { display: flex; gap: 8px; margin-bottom: 10px; }
#joinForm input { flex: 1; padding: 11px 12px; font-size: 15px; background: rgba(4,8,16,.75); }
.status { text-align: center; color: #cfe3f7; font-size: 12.5px; min-height: 18px; margin: 4px 0 12px; }

#slots { grid-template-columns: 1fr 1fr; gap: 7px; margin: 0 0 14px; }
#slots li { position: relative; overflow: hidden; padding: 10px 12px 10px 16px; border-radius: 6px; border: 1px solid rgba(242,201,92,.28);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #5a6a85) 30%, transparent), rgba(6,10,20,.7) 70%); }
#slots li::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pc, #5a6a85); box-shadow: 0 0 12px var(--pc, transparent); }
#slots li.empty { background: rgba(6,10,20,.35); border-style: dashed; border-color: rgba(149,166,189,.3); color: #6f7f96; font-style: italic; }
#slots li.empty::before { display: none; }
#slots li .sw { display: none; }
#slots li .nm { font-weight: 600; color: #f1f5fb; text-shadow: 0 1px 2px #000; }
.host-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-bottom: 12px; }
.host-row select { font: inherit; color: var(--text); background: rgba(4,8,16,.75); border: 1px solid var(--gold2); border-radius: 4px; padding: 0 8px; }
#watchBtn { width: 100%; margin-bottom: 12px; }
.share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--muted); padding-top: 10px; border-top: 1px solid rgba(242,201,92,.15); }

.codex { margin-top: 16vh; max-height: calc(100vh - 16vh - 150px); display: flex; flex-direction: column; padding-top: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid rgba(242,201,92,.2); }
.tabs button { background: none; border: 0; box-shadow: none; border-radius: 0; padding: 8px 14px 9px; font: 600 12px Cinzel, Georgia, serif; letter-spacing: .08em; text-transform: uppercase; color: #8fa2bb; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: #e9f1fb; box-shadow: none; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); text-shadow: 0 0 10px rgba(242,201,92,.4); }
.tab-pane { overflow-y: auto; padding-right: 6px; min-height: 0; }
.tab-pane::-webkit-scrollbar { width: 8px; } .tab-pane::-webkit-scrollbar-thumb { background: rgba(242,201,92,.25); border-radius: 4px; }
#gallery, #creepGallery { display: grid; gap: 10px; margin: 0; }
.gline { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.gline-head b { display: block; font: 700 13px Cinzel, Georgia, serif; color: #f1e3b5; letter-spacing: .04em; }
.gline-head kbd { font-size: 10px; } .gline-head small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.codex .grow { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.codex .gcard { background: linear-gradient(180deg, rgba(20,30,50,.85), rgba(8,12,22,.9)); border: 1px solid rgba(242,201,92,.22); border-radius: 8px; padding: 6px 6px 7px; transition: transform .15s, border-color .15s, box-shadow .15s; }
.codex .gcard:hover { transform: translateY(-3px); border-color: rgba(242,201,92,.7); box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 14px rgba(242,201,92,.18); }
.codex .gcard img { border-radius: 6px; background: radial-gradient(circle at 50% 40%, #2c3f60, #0a111d 75%); }
.codex .gsub { margin: 14px 0 2px; font-size: 12px; }
.codex .gsub:first-child { margin-top: 0; }
.howto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.how { background: rgba(8,13,25,.6); border: 1px solid rgba(242,201,92,.2); border-radius: 8px; padding: 12px 14px; }
.how b { font: 700 13px Cinzel, Georgia, serif; color: var(--accent); letter-spacing: .04em; }
.how p { margin: 6px 0 0; font-size: 12.5px; color: #c4d1e1; line-height: 1.5; }
.keys { margin-top: 14px; line-height: 2; }
.codex [data-pane="patch"] h3 { margin: 0 0 6px; color: var(--accent); font-size: 15px; }
.codex [data-pane="patch"] h4 { margin: 14px 0 4px; color: #c9d6e6; font: 600 12px Cinzel, Georgia, serif; }
#patchNotes, #patchHistory ul { margin: 0; padding-left: 18px; color: #c4d1e1; font-size: 13px; line-height: 1.55; }

@media (max-width: 980px) {
  .lobby-top { padding: 22px 18px 10px; flex-direction: column; }
  .lobby-grid { grid-template-columns: 1fr; padding: 0 16px 28px; }
  .codex { margin-top: 0; max-height: none; }
  .gline { grid-template-columns: 1fr; }
}
.codex .grow { grid-template-columns: repeat(4, minmax(0, 118px)); }
.codex #creepGallery .grow { grid-template-columns: repeat(4, minmax(0, 118px)); }
.codex .gcard b { font-size: 10px; }
#slots .tagb { white-space: nowrap; font-size: 9.5px; padding: 0 4px; }
#slots li { display: flex; align-items: center; gap: 6px; }
#slots li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codex { justify-self: end; width: min(100%, 700px); }
@media (max-width: 520px) {
  #slots { grid-template-columns: 1fr; }
  .tabs button { padding: 8px 8px 9px; font-size: 10.5px; }
  .host-row { grid-template-columns: 1fr 1fr; } .host-row #startBtn { grid-column: 1 / -1; }
  .logo-sub { letter-spacing: .22em; }
}

/* ================= Lobby theme: dark & tough (iron, blood, ember) ================= */
#lobby { --iron: #1a1c20; --iron2: #26292f; --steel: #8e98a6; --blood: #8f1d1d; --blood2: #c0302a; --ember: #ff8a3a; --bone: #e6dcc8; }
#lobbyBg { filter: saturate(.85) contrast(1.08); }
#lobbyBg::after { background:
    linear-gradient(90deg, rgba(3,4,7,.95) 0%, rgba(3,4,7,.78) 32%, rgba(3,4,7,.35) 62%, rgba(3,4,7,.45) 100%),
    linear-gradient(0deg, rgba(3,4,7,.92) 0%, rgba(3,4,7,0) 50%),
    radial-gradient(ellipse at 50% 120%, rgba(160,30,20,.22), transparent 60%); }
.logo-main { font-weight: 900; letter-spacing: .06em; text-transform: uppercase;
  background: linear-gradient(180deg, #f2f4f7 0%, #b9c0ca 38%, #5d6570 55%, #9aa3ae 72%, #e4e8ee 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #000) drop-shadow(0 0 2px #000) drop-shadow(0 0 24px rgba(190,30,20,.45)); }
.logo-sub { color: var(--bone); text-shadow: 0 2px 0 #000, 0 0 10px rgba(190,40,25,.5); letter-spacing: .42em; }
.logo-sub span { color: var(--blood2); }
.panel { border-radius: 2px; border: 1px solid #3a3d44;
  background: linear-gradient(180deg, rgba(22,24,28,.93), rgba(10,11,14,.95)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 2px, transparent 2px 6px);
  box-shadow: 0 24px 70px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.05), inset 0 0 0 1px #000, inset 0 0 40px rgba(0,0,0,.6);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px); }
.panel::before, .panel::after { width: 100%; height: 3px; left: 0; border: 0; border-radius: 0; opacity: 1;
  background: linear-gradient(90deg, transparent, var(--blood) 15%, var(--blood2) 50%, var(--blood) 85%, transparent); }
.panel::before { top: 0; } .panel::after { bottom: 0; right: auto; }
.panel-title { color: var(--bone); font-weight: 900; letter-spacing: .2em; text-shadow: 0 2px 0 #000; }
.panel-title::before, .panel-title::after { background: linear-gradient(90deg, transparent, rgba(192,48,42,.8), transparent); }
.war-room .tag, .status { color: #a9aeb6; }
#joinForm input, .host-row select { background: #0b0c0f; border-color: #3a3d44; border-radius: 2px; }
#joinForm input:focus { border-color: var(--blood2); box-shadow: 0 0 0 1px var(--blood2), inset 0 1px 3px rgba(0,0,0,.6); }
#lobby button { border-radius: 2px; }
#lobby button.primary { background: linear-gradient(#b3261e, #6e1210); color: var(--bone); border-color: #d64a3a; text-shadow: 0 1px 0 #000; letter-spacing: .1em; text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255,200,180,.25), 0 0 0 1px #000, 0 6px 18px rgba(140,20,15,.35); }
#lobby button.primary:hover:not(:disabled) { background: linear-gradient(#cf3326, #821512); box-shadow: inset 0 1px 0 rgba(255,200,180,.3), 0 0 0 1px #000, 0 0 22px rgba(220,50,30,.5); }
#lobby button:not(.primary):not(.soundBtn) { background: linear-gradient(#2b2e34, #17191d); border-color: #474b53; color: #d5d9df; }
#lobby button.ghost { background: rgba(12,13,16,.7); border-color: #474b53; color: var(--bone); }
#patchBadge { color: var(--bone); } #patchTag { color: var(--ember); }
.soundCtl { background: rgba(12,13,16,.7); border-color: #474b53; border-radius: 2px; }
.soundCtl .volSlider { accent-color: var(--blood2); }
#slots li { border-radius: 2px; border-color: #34373d; background: linear-gradient(90deg, color-mix(in srgb, var(--pc, #555) 26%, #0b0c0f), #0b0c0f 72%); }
#slots li.empty { background: rgba(10,11,14,.6); border-color: #2c2f35; color: #5c6168; }
#slots li .nm { color: #eef0f3; }
#slots .tagb { border-radius: 2px; border-color: #474b53; color: #9aa1aa; }
.share { border-top-color: #2c2f35; }
.share code { background: #0b0c0f; color: #c8cdd4; border: 1px solid #2c2f35; }
.tabs { border-bottom-color: #2c2f35; }
.tabs button { color: #7d838c; }
.tabs button:hover { color: var(--bone); }
.tabs button.on { color: var(--bone); border-bottom-color: var(--blood2); text-shadow: 0 0 10px rgba(200,40,30,.45); }
.codex .gcard { border-radius: 2px; border-color: #2f3238; background: linear-gradient(180deg, #17191d, #0b0c0f); }
.codex .gcard:hover { border-color: var(--blood2); box-shadow: 0 8px 24px rgba(0,0,0,.7), 0 0 14px rgba(200,40,30,.25); }
.codex .gcard img { border-radius: 1px; background: radial-gradient(circle at 50% 40%, #2a2d33, #0b0c0f 75%); }
.codex .gcard b { color: #e9e4d8; }
.gline-head b { color: var(--bone); }
.codex .gsub { color: var(--ember); }
.how { border-radius: 2px; background: rgba(12,13,16,.75); border-color: #2c2f35; border-left: 3px solid var(--blood); }
.how b { color: var(--bone); }
.how p { color: #a9aeb6; }
#lobby kbd { background: #0b0c0f; border-color: #474b53; color: var(--ember); border-radius: 2px; }
.codex [data-pane="patch"] h3 { color: var(--bone); }
.codex [data-pane="patch"] h4 { color: var(--ember); }
#patchNotes, #patchHistory ul { color: #a9aeb6; }
#lobby #codexTabs button { background: none; border: 0; border-bottom: 2px solid transparent; box-shadow: none; color: #7d838c; }
#lobby #codexTabs button:hover { color: var(--bone); }
#lobby #codexTabs button.on { color: var(--bone); border-bottom-color: var(--blood2); }

/* Codex drawer: closed by default, opened from a small tab on the right edge */
.lobby-grid { grid-template-columns: minmax(340px, 600px); }
#lobby .codex { position: fixed; z-index: 6; top: 110px; right: 24px; bottom: 24px; width: min(700px, calc(100vw - 48px)); margin: 0; max-height: none;
  transform: translateX(calc(100% + 40px)); opacity: 0; pointer-events: none; transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .25s; }
#lobby .codex.open { transform: none; opacity: 1; pointer-events: auto; }
#codexClose { position: absolute; top: 10px; right: 12px; z-index: 2; padding: 2px 8px; font-size: 13px; }
#codexToggle { position: fixed; z-index: 7; right: 0; top: 50%; transform: translateY(-50%); writing-mode: vertical-rl; padding: 16px 8px; border-right: 0;
  font: 700 12px Cinzel, Georgia, serif; letter-spacing: .22em; text-transform: uppercase; color: var(--bone, #e6dcc8); border-radius: 2px 0 0 2px; }
#lobby #codexToggle { background: linear-gradient(90deg, #2b2e34, #17191d); border-color: #474b53; color: var(--bone); box-shadow: -4px 0 18px rgba(0,0,0,.6), inset 2px 0 0 var(--blood2); }
#lobby #codexToggle:hover, #lobby #codexToggle.on { color: #fff; box-shadow: -4px 0 22px rgba(200,40,30,.35), inset 3px 0 0 var(--blood2); }
#lobby #codexToggle.on { right: min(724px, calc(100vw - 24px)); }
@media (max-width: 980px) { #lobby .codex { top: 70px; right: 8px; left: 8px; width: auto; bottom: 8px; } #lobby #codexToggle.on { right: 0; } }

/* in-game sound toggle, in the stats row */
#stats { display: flex; align-items: stretch; gap: 6px; }
#stats .stat { flex: 1; }
button.gameSound { flex: none; width: 40px; padding: 0; font-size: 18px; line-height: 1; }
button.gameSound.off { border-color: var(--bad); box-shadow: inset 0 0 0 1px rgba(255,107,94,.4); }

/* lobby browser */
.fld { display: block; margin-bottom: 10px; }
.fld span { display: block; font: 600 10px Cinzel, Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #8e959e; margin-bottom: 4px; }
.fld input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 15px; background: #0b0c0f; border: 1px solid #3a3d44; border-radius: 2px; }
.create-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 16px; }
.create-row input { padding: 10px 12px; background: #0b0c0f; border: 1px solid #3a3d44; border-radius: 2px; }
.list-title { margin: 4px 0 8px; font: 700 12px Cinzel, Georgia, serif; letter-spacing: .16em; text-transform: uppercase; color: #e6dcc8; display: flex; align-items: center; gap: 8px; }
.list-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(192,48,42,.7), transparent); }
.list-title small { color: #8e959e; font-size: 11px; letter-spacing: 0; }
#roomList { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
#roomList li { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 12px; background: linear-gradient(90deg, rgba(143,29,29,.18), #0b0c0f 70%); border: 1px solid #34373d; border-left: 3px solid #c0302a; border-radius: 2px; }
#roomList li.busy { border-left-color: #ff8a3a; background: linear-gradient(90deg, rgba(255,138,58,.12), #0b0c0f 70%); }
#roomList li.none { display: block; border-left-color: #474b53; background: rgba(10,11,14,.6); color: #7d838c; font-style: italic; font-size: 12.5px; text-align: center; }
#roomList .ri { flex: 1; min-width: 0; }
#roomList .ri b { display: block; color: #f1ece2; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#roomList .ri small { color: #8e959e; font-size: 11.5px; }
#roomList button { flex: none; min-width: 64px; }
#lobby button.primary.small { padding: 5px 12px; font-size: 11px; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 6px; }
.room-head b { font: 700 16px Cinzel, Georgia, serif; color: #f1ece2; letter-spacing: .04em; }
.room-head small { color: #8e959e; font: 600 11px Cinzel, Georgia, serif; letter-spacing: .12em; }
#joinRoomBtn { width: 100%; margin-bottom: 12px; }
/* income ranking pops up bottom-left, above the camera hint */
#incomePop { top: auto; bottom: 34px; left: 14px; transform: translateY(8px); }
#incomePop.show { transform: none; }

/* Upgrade Sanctum (beside the palace; click it or press K) */
#sanctumMenu { position: absolute; left: 14px; top: 48px; width: min(330px, calc(100% - 28px)); max-height: calc(100% - 80px); overflow-y: auto; z-index: 15; padding: 7px 9px;
  background: linear-gradient(#1e1210f2, #0e0a0af2); border: 1px solid #b4541e; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6), inset 0 0 30px rgba(180,60,20,.12); }
#sanctumMenu .pm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#sanctumMenu h3 { margin: 0; font-size: 13px; color: #ff9a52; }
#sanctumMenu h3 small { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
#smClose { padding: 2px 8px; font-size: 14px; }
.smRow { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 6px 4px; border-top: 1px solid rgba(255,140,70,.14); }
.smRow .ic { font-size: 20px; text-align: center; filter: drop-shadow(0 0 4px rgba(255,120,40,.5)); }
.smRow .info b { font: 700 12px Cinzel, Georgia, serif; color: #f0d0b0; margin-right: 6px; }
.smRow .pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.smRow .pips i { width: 12px; height: 6px; border-radius: 1px; background: #2a1a14; border: 1px solid #5a3424; }
.smRow .pips i.on { background: linear-gradient(#ffb060, #d0441a); border-color: #ff9a52; box-shadow: 0 0 5px rgba(255,120,40,.6); }
.smRow .eff { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.smRow .buy { padding: 5px 8px; font-size: 11px; font-weight: 700; min-width: 78px; background: linear-gradient(#4a2412, #26120a); border-color: #b4541e; color: #ffc890; }
.smRow .buy:disabled { opacity: .5; }
.smRow.max .buy { color: #ffd27a; opacity: .8; }
#sanctumBtn { width: 100%; text-align: left; padding: 9px 10px; margin-top: 6px; background: linear-gradient(#3a1c12, #1e0e0a); border-color: #b4541e; display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; }
#sanctumBtn b { font: 700 14px Cinzel, Georgia, serif; color: #ff9a52; }
#sanctumBtn small { color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; font-size: 11px; align-self: center; }
#sanctumBtn > span { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
#sanctumBtn.active { box-shadow: inset 0 0 0 1px #ff9a52, 0 0 12px rgba(255,120,40,.35); }
.lbl3d.pal.san { color: #ff9a52; }

/* inspect card extras */
#selStats .cstats { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 4px 0; }
#selStats .cstats b { color: var(--text, #e8eef6); }
#selStats .hpbar { position: relative; height: 14px; background: #1a0c0c; border: 1px solid #000; border-radius: 3px; margin: 4px 0; overflow: hidden; }
#selStats .hpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#5fe08a, #2f9a50); }
#selStats .hpbar span { position: relative; display: block; text-align: center; font-size: 10.5px; line-height: 13px; color: #fff; text-shadow: 0 1px 2px #000; }
#selStats .fx { color: #9fd8ff; margin-top: 3px; }

/* "Towers & Creeps" drawer tab: bigger, blood-red and gently pulsing so it's easy to find */
#lobby #codexToggle { padding: 22px 11px; font-size: 14px; letter-spacing: .16em; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #6a1410, #34100c); border-color: #b4321e; color: #fff1dc; text-shadow: 0 1px 3px #000;
  box-shadow: -4px 0 22px rgba(200,40,30,.45), inset 3px 0 0 #ff6a3a; animation: ctPulse 2.6s ease-in-out infinite; }
#lobby #codexToggle .ic { writing-mode: horizontal-tb; font-size: 17px; letter-spacing: 0; filter: drop-shadow(0 0 4px rgba(255,120,60,.7)); }
#lobby #codexToggle:hover, #lobby #codexToggle.on { background: linear-gradient(90deg, #8a1c14, #44140e); box-shadow: -4px 0 30px rgba(255,80,40,.6), inset 3px 0 0 #ff8a5a; animation: none; }
@keyframes ctPulse { 50% { box-shadow: -4px 0 34px rgba(255,70,30,.7), inset 3px 0 0 #ff8a5a; } }
#selStats .cstats .blood, #selStats .cstats .blood b { color: #ff5a64; }

/* "+N" gold pop-ups over kills */
.goldpop { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; will-change: transform, opacity;
  font: 800 15px Cinzel, Georgia, serif; color: #ffd24a; letter-spacing: .02em;
  text-shadow: 0 0 2px #000, 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000, 0 0 8px rgba(255,180,40,.6); }
.goldpop::after { content: 'g'; font-size: .75em; margin-left: 1px; color: #f0b830; }
.goldpop.big { font-size: 19px; color: #ffe27a; }

/* drag-to-select box over your towers */
#selBox { display: none; position: absolute; z-index: 13; pointer-events: none; border: 1px solid rgba(242,201,92,.95); background: rgba(242,201,92,.12);
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), inset 0 0 18px rgba(242,201,92,.15); border-radius: 2px;
  font: 700 12px Cinzel, Georgia, serif; color: #ffe08a; text-shadow: 0 1px 2px #000; padding: 2px 5px; box-sizing: border-box; }

/* graphics quality button (Auto / High / Medium / Low) */
button.gfxBtn { flex: none; width: 40px; padding: 0; font-size: 18px; line-height: 1; position: relative; }
button.gfxBtn small { position: absolute; bottom: 1px; left: 0; right: 0; font-size: 8px; letter-spacing: .04em; color: var(--muted); }

/* settings menu */
#settingsMenu { position: absolute; right: 14px; top: 48px; width: min(320px, calc(100% - 28px)); max-height: calc(100% - 70px); overflow-y: auto; z-index: 16; padding: 9px 12px;
  background: linear-gradient(#141e30f4, #0b1322f4); border: 1px solid var(--gold); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
#settingsMenu .pm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
#settingsMenu h3 { margin: 0; font-size: 14px; }
#settingsMenu h4 { margin: 10px 0 5px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
#settingsMenu h4 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: normal; }
#settingsMenu .seg { display: flex; gap: 4px; }
#settingsMenu .seg button { flex: 1; padding: 5px 0; font-size: 12px; }
#settingsMenu .seg button.on { border-color: var(--gold); color: var(--gold); box-shadow: inset 0 0 8px rgba(255, 200, 90, .25); }
#settingsMenu .row { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 12px; }
#settingsMenu .row > span:first-child { width: 78px; flex: none; }
#settingsMenu .row input[type=range] { flex: 1; min-width: 0; }
#settingsMenu .row.chk span { width: auto; }
#settingsMenu button.danger { width: 100%; padding: 7px 0; background: linear-gradient(#5a1c1c, #2e0e0e); border-color: #8a3030; color: #ffd8d0; }
#settingsMenu button.danger.confirm { background: linear-gradient(#a02a1a, #5a1208); color: #fff; }
#settingsMenu p { margin: 4px 0 0; }
#settingsMenu .row.chk input[type=checkbox] { width: 16px; height: 16px; flex: none; margin: 0; padding: 0; accent-color: var(--gold); }
#settingsMenu .row.chk span { flex: 1; }

/* lobby: pick your spot */
#slots li.pickable { cursor: pointer; }
#slots li.pickable:hover { outline: 1px solid var(--pc, var(--gold)); background: rgba(255, 255, 255, .05); }
#slots li.empty .sw.open { background: transparent; border: 1px dashed var(--pc); opacity: .7; }
#slots li.empty.pickable:hover .nm { color: var(--text, #fff); }

#slots li[data-seat]::before { content: attr(data-seat); position: absolute; left: 3px; top: 2px; font-size: 8px; color: var(--muted); }

/* lobby suggestion box */
.suggest { margin-top: 16px; padding-top: 10px; border-top: 1px solid rgba(201, 162, 74, .2); }
.suggest .list-title { margin: 0 0 6px; }
.suggest textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 44px; padding: 8px 10px; font: inherit; font-size: 13px;
  color: #e6e6e6; background: #0a0c10; border: 1px solid #34373d; border-radius: 3px; }
.suggest textarea:focus { outline: none; border-color: var(--gold); }
.suggest-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.suggest-row small { color: var(--muted); font-size: 10px; }

/* Wintermaul Wars: team rows in the in-game player list */
#plist li.teamRow { background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 30%, transparent), transparent); border-left: 3px solid var(--tc); font: 700 12px Cinzel, Georgia, serif; color: #f2e6cf; cursor: default; margin-top: 4px; }
#plist li.teamRow .tn { flex: 1; }
#plist li.teamRow .num { color: #ff8a80; font-size: 13px; }
#plist li.teamRow.dead { opacity: .5; text-decoration: line-through; }
#slots li { padding: 8px 10px; gap: 8px; min-width: 0; }
#slots li .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { #slots { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; } }
#gallery .gsub.race { margin-top: 10px; font: 700 14px Cinzel, Georgia, serif; color: #f2e6cf; }
#gallery .gsub.race small { display: block; font: 400 11px system-ui, sans-serif; color: var(--muted); margin-top: 2px; }

/* X14 HUD */
#topHud { position: absolute; top: 10px; right: 12px; z-index: 6; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; font: 700 13px Cinzel, Georgia, serif; }
#topHud > div { background: rgba(8, 12, 20, 0.78); border: 1px solid rgba(201,162,74,.5); border-radius: 4px; padding: 3px 10px; color: #e8dcc0; }
#topHud b { color: #fff; } #topHud .ta b { color: #ff8a80; } #topHud .to b { color: #8ab8ff; }
.stat .upkeep { display: block; font-size: 10px; color: var(--good); }
.val.lumber { color: #c8a070; } .val.food { color: #e8dcc0; font-size: 17px; }
.sbHead { display: grid; grid-template-columns: 1fr 48px 64px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 0 6px 2px; }
.sbHead span:first-child { grid-column: 2; text-align: right; } .sbHead span:last-child { text-align: right; }
#plist li:not(.teamRow) { display: grid; grid-template-columns: 14px 1fr 48px 64px; align-items: center; gap: 6px; }
#plist li .num.k, #plist li .num.i { text-align: right; }
.sbFoot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 4px 6px 0; }
.upAlt { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; } .upAlt button { flex: 1 1 100%; }
.optBox { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 0 0 10px; font-size: 12px; }
.optBox .opt { display: flex; justify-content: space-between; align-items: center; gap: 6px; color: var(--muted); }
.optBox select { font: inherit; font-size: 12px; color: var(--text); background: #0a111d; border: 1px solid var(--gold2); border-radius: 4px; padding: 1px 4px; max-width: 150px; }
.optBox b { color: #e8dcc0; }
.teamTotals { display: flex; justify-content: space-around; margin-top: 8px; font-size: 13px; }

/* race picker */
#racePicker { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20; width: min(920px, 94%); max-height: 88%; overflow-y: auto; padding: 14px 16px; }
#racePicker h3 { margin: 0 0 10px; font: 700 17px Cinzel, Georgia, serif; color: var(--accent); text-align: center; }
#rpGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.rpCard { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; min-height: 150px; }
.rpCard .ic { font-size: 22px; } .rpCard b { font: 700 13px Cinzel, Georgia, serif; color: #f2e6cf; }
.rpCard small { font-size: 11px; color: var(--muted); } .rpCard p { margin: 4px 0 0; font-size: 11px; color: #c4cad6; line-height: 1.3; }
.rpCard .d-easy { color: #7be08a; font-style: normal; } .rpCard .d-medium { color: #f0c860; font-style: normal; } .rpCard .d-hard { color: #ff7a6a; font-style: normal; }
.rpNav { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }

.rpNote { margin: 8px 0 0; text-align: center; font-size: 11px; color: var(--muted); }
#pickRaceBtn { margin-top: 3px; padding: 2px 6px; font-size: 10px; }

/* game select (homepage) */
#gamePick { position: relative; z-index: 4; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 44px 14px; }
#gamePick .gp-label { width: 100%; font: 600 11px/1 Cinzel, Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#gamePick .gp-card { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 14px 8px 10px; text-decoration: none; color: #d5d9df;
  background: linear-gradient(180deg, rgba(16,24,42,.82), rgba(8,13,25,.9)); border: 1px solid #3a3d44; border-radius: 2px; transition: border-color .15s, background .15s; }
#gamePick .gp-card:hover { border-color: var(--gold); }
#gamePick .gp-card.on { border-color: var(--gold); box-shadow: inset 0 0 14px rgba(201, 162, 74, .18); cursor: default; }
#gamePick .gp-card.off { opacity: .62; }
#gamePick .gp-card.off:hover { border-color: #555a63; }
#gamePick .gp-ic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; font-size: 16px; border-radius: 50%;
  background: radial-gradient(circle, rgba(201,162,74,.28), rgba(201,162,74,.05)); border: 1px solid rgba(201,162,74,.45); }
#gamePick .gp-txt { display: flex; flex-direction: column; min-width: 0; }
#gamePick .gp-txt b { font: 700 14px/1.15 Cinzel, Georgia, serif; letter-spacing: .03em; color: #f0e6cc; white-space: nowrap; }
#gamePick .gp-txt small { font-size: 11px; color: #a9aeb6; white-space: nowrap; }
#gamePick .gp-tag { margin-left: 6px; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 2px;
  color: #111; background: var(--gold); white-space: nowrap; }
#gamePick .gp-card.off .gp-tag { color: #c9ccd2; background: #2a2d33; }
@media (max-width: 760px) { #gamePick { padding: 0 16px 12px; } #gamePick .gp-card { flex: 1 1 260px; } }
