:root {
  --bg: #101522;
  --panel: #192235;
  --panel-2: #22304b;
  --text: #e8edf7;
  --muted: #a9b4c8;
  --accent: #e4b15d;
  --danger: #d86666;
  --good: #67c28a;
  --rare: #6aa8ff;
  --epic: #b56cff;
  --legendary: #ffb347;
  --artifact: #ff5f95;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  overflow: hidden;
  background: #0c1020;
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
}

/* === Fullscreen Canvas === */
#gameCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #0f1725;
}

/* === Overlay: Top Bar === */
.overlay-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(12, 16, 32, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.overlay-bar select,
.overlay-bar button {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.topBarInput {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--panel-2);
  color: var(--text);
  width: 100px;
}

/* === Overlay: Action Toolbar === */
.overlay-toolbar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(12, 16, 32, 0.88);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
}
.overlay-toolbar button {
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 8px;
}
.toolbar-separator {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  margin: 0 4px;
}

/* === Overlay: Event Log (always visible) === */
.overlay-log {
  position: fixed;
  bottom: 60px;
  right: 14px;
  z-index: 8;
  width: 280px;
  max-height: 220px;
  background: rgba(12, 16, 32, 0.82);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px 10px;
  pointer-events: none;
}
.overlay-log .log {
  pointer-events: auto;
  max-height: 190px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
  font-size: 12px;
}

/* === Overlay: Support Meter (always visible) === */
.overlay-meter {
  position: fixed;
  bottom: 60px;
  left: 14px;
  z-index: 8;
  width: 200px;
  background: rgba(12, 16, 32, 0.82);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px 10px;
}
.meterLabel { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }

/* === Overlay Panels (toggle with hotkeys) === */
.overlay-panel {
  position: fixed;
  top: 52px;
  z-index: 12;
  width: 320px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: rgba(25, 34, 53, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.overlay-panel.right { right: 14px; }
.overlay-panel.left { left: 14px; }

.overlay-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.hotkey-hint {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.panel-section { margin-bottom: 12px; }
.panel-section h3 { font-size: 14px; margin: 0 0 8px; color: var(--text); }

/* === Common Elements === */
h1, h2 { margin: 0 0 12px; }
h1 { font-size: 28px; color: var(--accent); }
h2 { font-size: 18px; }
.buttonRow { display: flex; gap: 8px; flex-wrap: wrap; }
select, button {
  background: linear-gradient(180deg, #2c4266, #22344f);
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}
select { width: auto; color: var(--text); background: var(--panel-2); }
select option { color: var(--text); background: var(--panel-2); }
button { cursor: pointer; }
button:hover, select:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.meter {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: #111927;
  border: 1px solid rgba(255,255,255,0.08);
}
.meterFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #72a5ff, #f0bd63);
}

#inventory, #equipment { display: grid; gap: 8px; }
.item {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.item.Common { border-left: 4px solid #8994a8; }
.item.Rare { border-left: 4px solid var(--rare); }
.item.Epic { border-left: 4px solid var(--epic); }
.item.Legendary { border-left: 4px solid var(--legendary); }
.item.Artifact { border-left: 4px solid var(--artifact); }
.itemTitle { font-weight: 700; }
.muted { color: var(--muted); }

.logEntry {
  background: rgba(22, 32, 51, 0.8);
  padding: 6px 8px;
  border-radius: 6px;
}

/* === Toast / Modals === */
.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(20, 28, 44, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 280px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,0.35);
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.52);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modalCard {
  width: min(560px, calc(100vw - 40px));
  background: #172234;
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.1);
}
.hidden { display: none !important; }

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #1e2c42;
  border: 1px solid rgba(255,255,255,0.08);
  color: #dfe8f7;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge.gold { background: #4f3d1f; color: #ffe0a6; }

/* === Dungeon Summary === */
.runStatsGrid {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 12px 0 16px;
}
.runStatsGrid > div {
  background: #1d2a40; border-radius: 12px; padding: 10px; border: 1px solid rgba(255,255,255,0.08);
}
.runStatsGrid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.runStatsGrid strong { font-size: 18px; }
.classBadge { display: inline-block; margin-top: 8px; padding: 4px 8px; border-radius: 999px; background: #2a3b5b; font-size: 12px; font-weight: 700; }

/* === Items === */
.affixList { margin-top: 6px; padding-left: 16px; color: #cfd7e6; font-size: 12px; }
.itemMetaRow { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.identifyBtn { margin-top: 8px; background: linear-gradient(180deg, #7b58d5, #5a3ab1); }
.identifyCard { max-width: 520px; border: 1px solid rgba(255, 197, 79, 0.45); box-shadow: 0 0 40px rgba(255, 197, 79, 0.18); }
.identifyItemName { font-size: 22px; font-weight: 700; color: #ffd971; margin-bottom: 10px; }
.identifyRevealLines { min-height: 120px; }
.identifyRevealLine { margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.05); color: #eef4ff; font-weight: 600; animation: fadeUp 0.25s ease; }
.identifyBadge { display: inline-block; margin-top: 10px; padding: 8px 12px; border-radius: 999px; background: linear-gradient(180deg, #ffcf57, #ff8a2d); color: #251300; font-weight: 800; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.materialsSummary { display: grid; gap: 6px; }
.salvageBtn { margin-top: 8px; background: linear-gradient(180deg, #7a5b35, #5c421d); }
.legendaryBanner { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 20; padding: 10px 18px; border-radius: 999px; background: linear-gradient(180deg, rgba(68,44,10,0.96), rgba(103,61,12,0.96)); border: 1px solid rgba(255, 196, 75, 0.45); color: #ffd36c; font-weight: 800; letter-spacing: .04em; box-shadow: 0 12px 32px rgba(0,0,0,0.3); pointer-events: none; }
.itemPickupHint { font-size: 11px; color: var(--muted); margin-top: 6px; }

#objectiveList li.done { color: var(--good); }
#objectiveList li.active { color: #ffd36c; font-weight: 700; }

/* Quest Log */
.quest-entry { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.quest-entry:last-child { border-bottom: none; }
.quest-name { font-size: 13px; font-weight: 600; color: #ffdd57; }
.quest-completed .quest-name { color: var(--good); }
.quest-objective { font-size: 12px; color: var(--muted); padding-left: 12px; margin-top: 2px; }
.quest-obj-done { color: var(--good); text-decoration: line-through; }

/* Party */
.partyBtn { padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.15); background: var(--panel-2); color: var(--text); cursor: pointer; }
.partyBtn:hover { background: #2a3d5c; }
.partyBtn-danger { border-color: var(--danger); color: var(--danger); }
.partyBtn-danger:hover { background: rgba(216,102,102,0.15); }
.partyInput { padding: 4px 8px; font-size: 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.15); background: var(--bg); color: var(--text); width: 100px; }
.party-roster { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.party-member { display: flex; align-items: center; gap: 6px; padding: 4px 6px; background: rgba(255,255,255,0.04); border-radius: 6px; font-size: 12px; }
.party-role-icon { font-size: 14px; width: 18px; text-align: center; }
.party-member-name { flex: 1; color: var(--text); }
.party-member-class { font-size: 11px; }
.party-leader-badge { background: var(--accent); color: var(--bg); font-size: 10px; padding: 0 4px; border-radius: 3px; font-weight: 700; }
.party-role-status { display: flex; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.role-filled { color: var(--good); }
.role-missing { color: var(--danger); }
.party-ready { font-size: 12px; color: var(--good); font-weight: 600; margin-bottom: 6px; }
.party-not-ready { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.party-invite-row { display: flex; gap: 4px; margin-bottom: 6px; }
.party-invite { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; background: rgba(255,179,71,0.1); border-radius: 6px; margin-bottom: 4px; font-size: 12px; }
.party-invites { margin-bottom: 8px; }
.party-section-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.party-pending { margin-bottom: 6px; font-size: 11px; }

/* Twitch Login */
.twitch-login-btn {
  background: linear-gradient(180deg, #9146ff, #7b2ff2) !important;
  color: white !important;
  font-weight: 700;
  padding: 8px 16px !important;
  border-radius: 8px !important;
  border: none !important;
  cursor: pointer;
  font-size: 13px !important;
}
.twitch-login-btn:hover { filter: brightness(1.15) !important; }
.dev-login-group { display: flex; gap: 4px; align-items: center; opacity: 0.6; }
.dev-login-btn { font-size: 11px !important; padding: 6px 8px !important; }
