:root {
  --bg: #0a0a0c;
  --panel: #131216;
  --panel2: #1b191e;
  --line: #3a3226;
  --gold: #c9a44c;
  --gold2: #ecd082;
  --text: #ddd4bf;
  --muted: #8a8270;
  --red: #c0392b;
  --green: #86a845;
  --blue: #62b0e8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif; overflow: hidden; user-select: none;
}
.hidden { display: none !important; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  height: 50px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 14px;
  background: linear-gradient(#1f1c21, #111014); border-bottom: 2px solid var(--line);
  box-shadow: 0 2px 10px #000;
}
.brand { font-family: 'Cinzel', Georgia, serif; font-weight: 800; color: var(--gold); letter-spacing: 3px; font-size: 18px; }
.mission { font-family: 'Cinzel', Georgia, serif; color: var(--muted); font-size: 14px; letter-spacing: 1px; }
.stat { display: flex; align-items: center; gap: 7px; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.ico { font-size: 18px; }
.ico.lives { color: #d8453a; }
.ico.req { color: var(--gold); }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; background: #29251f; color: var(--text); border: 1px solid #5a4b30;
  padding: 6px 12px; font-weight: 700; font-size: 14px; letter-spacing: .5px; cursor: pointer; border-radius: 3px;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: #3a3326; border-color: var(--gold); }
.btn.gold { background: linear-gradient(#b59240, #7d6024); color: #1a1407; border-color: #e6c878; }
.btn.gold:hover:not(:disabled) { background: linear-gradient(#cfa84c, #8f6d28); }
.btn.red { background: linear-gradient(#8f2b20, #5a1712); border-color: #c0392b; color: #f6dcd2; }
.btn.red:hover:not(:disabled) { background: linear-gradient(#a8352a, #6a1d16); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.on { border-color: var(--gold); color: var(--gold2); background: #3a3326; }
.btn.wide { width: 100%; padding: 9px; font-size: 16px; }
.btn.small { padding: 3px 8px; font-size: 12px; }

/* ---------- layout ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #050506; min-width: 0; overflow: hidden; }
#game { display: block; box-shadow: 0 0 0 2px #2a241a, 0 0 50px #000; cursor: crosshair; }
#side {
  width: 304px; flex: none; background: var(--panel); border-left: 2px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sect { padding: 9px 10px; border-bottom: 1px solid #26221b; }
.sect h3 {
  margin: 0 0 7px; font-family: 'Cinzel', Georgia, serif; font-size: 13px; letter-spacing: 2px;
  color: var(--gold); text-transform: uppercase; font-weight: 600;
}

/* ---------- wave panel ---------- */
#waveInfo { font-size: 14px; color: var(--muted); margin-bottom: 6px; min-height: 18px; }
#waveInfo b { color: var(--text); }
#wavePreview { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; min-height: 30px; }
.wp { display: flex; align-items: center; gap: 2px; background: #1e1b20; border: 1px solid #2f2a33; border-radius: 3px; padding: 1px 5px 1px 1px; font-weight: 700; font-size: 13px; }
.wp img { width: 26px; height: 26px; }
.wp.boss { border-color: #9a2f2a; color: #f0a49a; }

/* ---------- shop ---------- */
.shop { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.card {
  position: relative; background: var(--panel2); border: 1px solid #2f2a22; border-radius: 4px;
  padding: 3px 2px 2px; text-align: center; cursor: pointer; overflow: hidden;
}
.card:hover { border-color: #7a6436; }
.card canvas { width: 54px; height: 54px; display: block; margin: 0 auto; }
.card .cost { font-size: 13px; font-weight: 700; color: var(--gold2); line-height: 1.1; }
.card .key { position: absolute; top: 1px; left: 4px; font-size: 11px; color: var(--muted); font-weight: 700; }
.card.sel { border-color: var(--gold); box-shadow: 0 0 10px rgba(201,164,76,.45) inset; }
.card.poor .cost { color: #b0574d; }
.card.poor canvas { opacity: .5; }
.card .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.68); pointer-events: none; }
.card .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 0 4px #000; pointer-events: none; }

/* ---------- info panel ---------- */
#info { flex: 1; font-size: 14px; line-height: 1.35; }
.ihead { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.ihead img { width: 48px; height: 48px; background: #1b191e; border: 1px solid #2f2a22; border-radius: 4px; }
.iname { font-family: 'Cinzel', Georgia, serif; font-weight: 600; color: var(--gold2); font-size: 15px; }
.isub { color: var(--muted); font-size: 13px; }
.idesc { color: #b9b09b; font-size: 13px; margin: 4px 0 8px; }
.istats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 10px; margin-bottom: 8px; }
.istats div { display: flex; justify-content: space-between; border-bottom: 1px dotted #2c2822; }
.istats span:first-child { color: var(--muted); }
.istats .up { color: var(--green); }
.row { display: flex; gap: 4px; margin: 5px 0; flex-wrap: wrap; align-items: center; }
.row .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-right: 2px; }
.spec { display: block; width: 100%; text-align: left; margin: 4px 0; padding: 6px 8px; }
.spec small { display: block; font-weight: 500; font-size: 12px; opacity: .85; }
.tips { color: var(--muted); font-size: 13px; }
.tips p { margin: 0 0 7px; }
.tips b { color: var(--text); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 2px; background: #2b2620; color: var(--gold2); margin: 0 3px 3px 0; text-transform: uppercase; letter-spacing: .5px; }
.tag.bad { background: #3a1c1a; color: #f0a49a; }

/* ---------- boss bar / toasts ---------- */
#bossbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(520px, 60%); text-align: center; pointer-events: none; }
#bossbar .bname { font-family: 'Cinzel', Georgia, serif; color: #f0b0a6; font-weight: 800; letter-spacing: 2px; text-shadow: 0 0 6px #000, 0 0 2px #000; font-size: 16px; }
#bossbar .bbar { height: 12px; background: #1a0d0d; border: 1px solid #8a2a22; margin-top: 3px; border-radius: 2px; overflow: hidden; }
#bossbar .bfill { height: 100%; background: linear-gradient(#d64535, #7a1a12); width: 100%; transition: width .15s; }
#toasts { position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-width: 380px; }
.toast {
  background: rgba(16,14,18,.92); border: 1px solid #4a3f2b; border-left: 3px solid var(--gold); padding: 6px 10px;
  font-weight: 600; font-size: 15px; border-radius: 2px; animation: tin .25s ease-out; box-shadow: 0 2px 8px #000;
}
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--green); }
.toast.intro { display: flex; gap: 10px; align-items: center; border-left-color: #b04aa0; padding: 8px 12px; }
.toast.intro img { width: 52px; height: 52px; flex: none; }
.toast.intro .t1 { font-family: 'Cinzel', Georgia, serif; color: #e7a6e0; font-size: 12px; letter-spacing: 2px; }
.toast.intro .t2 { font-size: 17px; font-weight: 700; color: #fff; }
.toast.intro .t3 { font-size: 13px; color: #c9bfae; font-weight: 500; }
.toast.out { opacity: 0; transition: opacity .5s; }
@keyframes tin { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
/* ---------- siege mode ---------- */
#stage.siege { display: block; }
#stage.siege #glc, #stage.siege #game { position: absolute; left: 0; top: 0; box-shadow: none; }
#stage.siege #game { cursor: default; }
#stage.siege::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%); }
#minimap { position: absolute; left: 10px; bottom: 10px; width: 240px; border: 2px solid #3a3226; box-shadow: 0 0 12px #000; z-index: 2; cursor: pointer; image-rendering: pixelated; }
.wpv { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.wpv .isub { width: 100%; }
#fps { position: absolute; right: 12px; bottom: 10px; font: 700 13px monospace; color: #9f9; background: #000a; padding: 2px 6px; border-radius: 2px; pointer-events: none; }
#leakflash { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(200,20,10,.85); opacity: 0; transition: opacity .35s; }

/* ---------- overlay screens ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(28,21,17,.96), rgba(4,4,5,.99)); overflow-y: auto; padding: 20px;
}
.screen { width: min(1060px, 100%); max-height: 100%; }
.screen.narrow { width: min(560px, 100%); }
.title { font-family: 'Cinzel', Georgia, serif; font-weight: 800; color: var(--gold); display: flex; justify-content: center; letter-spacing: 6px; padding-left: 6px; font-size: clamp(32px, 5vw, 64px); white-space: nowrap; margin: 0; text-shadow: 0 0 30px rgba(201,164,76,.3), 0 3px 0 #3a2c10; }
.subtitle { text-align: center; color: #b9ae96; letter-spacing: 4px; padding-left: 4px; text-transform: uppercase; font-size: 15px; margin: 6px 0 30px; }
.h2 { font-family: 'Cinzel', Georgia, serif; color: var(--gold); letter-spacing: 3px; font-size: 26px; margin: 0 0 14px; text-align: center; }
.menu { display: flex; flex-direction: column; gap: 10px; width: 280px; margin: 0 auto; }
.menu .btn { padding: 12px; font-size: 18px; letter-spacing: 2px; font-family: 'Cinzel', Georgia, serif; }
.quote { text-align: center; font-style: italic; color: #8f866f; margin-top: 30px; font-size: 15px; }
.fine { text-align: center; color: #5e584b; margin-top: 16px; font-size: 12px; }
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mcard { background: linear-gradient(#1d1a1f, #141216); border: 1px solid #3a3226; border-radius: 5px; padding: 0 0 10px; cursor: pointer; overflow: hidden; position: relative; }
.mcard:hover { border-color: var(--gold); }
.mcard canvas { width: 100%; display: block; aspect-ratio: 16/9; border-bottom: 1px solid #3a3226; }
.mcard .mn { padding: 7px 10px 0; font-family: 'Cinzel', Georgia, serif; color: var(--gold2); font-weight: 600; font-size: 15px; }
.mcard .ms { padding: 0 10px; color: var(--muted); font-size: 13px; }
.mcard .stars { padding: 3px 10px 0; color: var(--gold); font-size: 17px; letter-spacing: 2px; }
.mcard.locked { opacity: .45; cursor: not-allowed; }
.mcard.future { cursor: default; border-style: dashed; }
.mcard.future .mn { padding-right: 74px; }
.mcard.future:hover { border-color: #3a3226; }
.lockico { position: absolute; top: 8px; right: 10px; font-size: 12px; background: #000a; padding: 2px 6px; border-radius: 2px; color: #ccc; letter-spacing: 1px; }
.brief { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; background: #141216; border: 1px solid #3a3226; border-radius: 5px; padding: 18px; }
.brief canvas { width: 100%; border: 1px solid #3a3226; border-radius: 3px; }
.brief p { color: #c6bca6; line-height: 1.5; margin: 0 0 10px; }
.roster { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 12px; }
.roster img { width: 38px; height: 38px; background: #1d1a1f; border: 1px solid #2f2a33; border-radius: 3px; }
.diffs { display: flex; gap: 6px; margin: 8px 0 14px; }
.diffs .btn { flex: 1; }
.endstars { text-align: center; font-size: 54px; color: var(--gold); letter-spacing: 10px; margin: 6px 0; }
.endstats { display: flex; justify-content: center; gap: 30px; margin: 10px 0 24px; font-size: 18px; }
.endstats div { text-align: center; }
.endstats b { display: block; font-size: 30px; color: var(--text); }
.endstats span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; max-height: 64vh; overflow-y: auto; padding-right: 6px; }
.centry { display: flex; gap: 10px; background: #161419; border: 1px solid #2f2a33; border-radius: 4px; padding: 8px; }
.centry img { width: 64px; height: 64px; flex: none; }
.centry .cn { font-weight: 700; color: #e7a6e0; font-size: 16px; }
.centry .cd { font-size: 13px; color: #b9b09b; }
.centry.unknown { opacity: .4; }
.help { background: #141216; border: 1px solid #3a3226; border-radius: 5px; padding: 18px 22px; columns: 2; column-gap: 30px; max-height: 70vh; overflow-y: auto; }
.help h4 { margin: 0 0 4px; color: var(--gold); font-family: 'Cinzel', Georgia, serif; letter-spacing: 1px; break-after: avoid; }
.help p { margin: 0 0 12px; color: #c6bca6; font-size: 14px; line-height: 1.45; break-inside: avoid; }
kbd { background: #2a2620; border: 1px solid #5a4b30; border-radius: 3px; padding: 0 5px; font-family: inherit; font-weight: 700; color: var(--gold2); font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 16px; }

@media (max-width: 900px) {
  #side { width: 250px; }
  .shop { grid-template-columns: repeat(3, 1fr); }
  .brief { grid-template-columns: 1fr; }
  .help { columns: 1; }
  #topbar { gap: 10px; }
  .mission { display: none; }
}

/* siege: xenos inspector */
.xhead { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.xhead img { width: 46px; height: 46px; background: #15120e; border: 1px solid #3a3226; border-radius: 3px; image-rendering: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.tags span { font-size: 11px; padding: 1px 6px; border: 1px solid #5a3a32; border-radius: 9px; color: #f0b4a4; background: rgba(120, 30, 20, 0.25); }

/* settings */
.settings { max-width: 760px; }
.stabs { display: flex; gap: 6px; justify-content: center; margin: 4px 0 14px; }
.stabs .btn { min-width: 110px; }
.sbody { background: #141216; border: 1px solid #3a3226; border-radius: 5px; padding: 12px 18px; text-align: left; }
.srow { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dotted #2c2822; }
.srow:last-child { border-bottom: 0; }
.srow label { flex: 1; font-size: 16px; }
.srow label small { display: block; color: var(--muted); font-size: 12px; }
.srow input[type=range] { width: 220px; accent-color: #c9a44c; }
.srow .sval { width: 44px; text-align: right; color: #ecd082; font-variant-numeric: tabular-nums; }
.schoice { display: flex; gap: 4px; }
.snote { color: var(--muted); font-size: 13px; margin: 10px 0 2px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 12px; }
.keys h4 { margin: 0 0 6px; color: #c9a44c; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; }
.keys div > div { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; font-size: 13px; }
.keys kbd { flex: 0 0 130px; text-align: center; }
.keys span { color: #b9b09b; }
@media (max-width: 760px) { .keys { grid-template-columns: 1fr; } .srow input[type=range] { width: 140px; } }

/* unlocks */
.card .lock { display: none; position: absolute; right: 4px; top: 2px; font-size: 13px; }
.card.locked { filter: grayscale(1) brightness(0.55); }
.card.locked .lock { display: block; filter: none; }
.card.locked .cost { text-decoration: line-through; }
.ms.reward { margin-top: 4px; font-size: 12px; color: #c9b88a; }
.rewards { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 4px; }
.ups { margin: 6px 0; }
.ups .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ups .up { padding: 3px 6px; margin: 2px 0; border: 1px solid #2c2822; border-radius: 3px; font-size: 13px; }
.ups .up small { display: block; color: var(--muted); font-size: 11px; }
.ups .up.done { border-color: #4a6a32; color: #a8d08a; }
.ups .up.done, .ups .up.later { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ups .up.done small, .ups .up.later small { display: inline; }
.ups .up.done b::before { content: '✓ '; }
.ups .up.later { opacity: 0.55; }
.gains { margin: 8px auto 12px; max-width: 420px; text-align: center; color: #e6c46a; font-size: 15px; }
.gains div { margin: 2px 0; }

/* compact siege panel: six cards a row, no visible scrollbar (the wheel still scrolls) */
#side { scrollbar-width: none; }
#side::-webkit-scrollbar { display: none; }
#siegeSide .shop { grid-template-columns: repeat(6, 1fr); gap: 4px; }
#siegeSide .contents { display: contents; }
#siegeSide .card { padding: 2px 1px 1px; }
#siegeSide .card canvas { width: 40px; height: 40px; }
#siegeSide .card .cost { font-size: 12px; }
#siegeSide .card .key { font-size: 10px; left: 3px; }
#siegeSide .card .lock { font-size: 10px; right: 2px; }
#siegeSide .sect { padding: 7px 9px; }
/* target priority: five choices on one line */
.row.tgt { flex-wrap: nowrap; gap: 3px; }
.row.tgt .lbl { letter-spacing: 0; white-space: nowrap; margin-right: 1px; }
.row.tgt .btn.small { padding: 3px 3px; font-size: 11.5px; flex: 1 1 auto; min-width: 0; }
