/* ============================================================
   SaberdogCraft v2.8 — Hero Pack UI
   ============================================================ */

:root {
  --bg: #0a101c;
  --panel: rgba(10, 18, 36, 0.94);
  --panel-solid: #0e1830;
  --border: #4a7ab8;
  --border-bright: #7ad0ff;
  --accent: #9aeeff;
  --accent2: #40f0ff;
  --text: #f2f6ff;
  --muted: #9aacc8;
  --player: #5ec8ff;
  --enemy: #d070ff;
  --good: #5dff9a;
  --warn: #ffe066;
  --bad: #ff6b7a;
  --moon: #e0b0ff;
  --shield: #5ec8ff;
  --hero: #ffe08a;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,0.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: radial-gradient(ellipse at 50% 30%, #152040 0%, #0a101c 70%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
  height: 100vh;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#gameCanvas {
  background: #121c18;
  display: block;
  box-shadow: 0 0 80px rgba(0, 160, 255, 0.1);
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#ui-layer > * { pointer-events: auto; }

/* ---------- Top resource strip ---------- */
#resources {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 13px;
  display: flex;
  gap: 22px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 15;
}
#resources .res { display: flex; align-items: center; gap: 6px; }
#resources .icon { font-size: 14px; }
#resources .val { color: var(--accent); font-weight: 700; min-width: 28px; font-variant-numeric: tabular-nums; }
#resources .label { color: var(--muted); font-size: 11px; }
#resources .res[data-tip*="Moon"] .val { color: var(--moon); }
#resources .res[data-tip*="Pack"] .val { color: var(--good); }

/* ---------- Hero panel (left) ---------- */
#hero-panel {
  position: absolute;
  top: 64px; left: 12px;
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: none;
}
#hero-panel.visible { display: block; }
#hero-panel .hero-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hero);
  margin-bottom: 4px;
}
#hero-panel .hero-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
#hero-panel .bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted);
}
#hero-panel .bar-row span.label { width: 28px; }
#hero-panel .bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.4);
  border-radius: 4px;
  overflow: hidden;
}
#hero-panel .bar-fill.hp { height: 100%; background: linear-gradient(90deg, #e05060, #ff8a70); }
#hero-panel .bar-fill.shield { height: 100%; background: linear-gradient(90deg, #2a80c0, #6ad8ff); }
#hero-panel .bar-fill.abil { height: 100%; background: linear-gradient(90deg, #8060c0, #c9a0ff); }
#hero-panel .hero-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

/* ---------- Minimap ---------- */
#minimap {
  position: absolute;
  top: 12px; right: 12px;
  width: 200px; height: 134px;
  background: rgba(5, 10, 20, 0.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#minimap canvas { width: 100%; height: 100%; display: block; }

/* ---------- Status chips (top-right under minimap) ---------- */
#status-chips {
  position: absolute;
  top: 154px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  box-shadow: var(--shadow);
}
.chip.on { border-color: var(--good); color: var(--good); }
.chip.demo { border-color: var(--hero); color: var(--hero); }

/* ---------- Command card ---------- */
#command-card {
  position: absolute;
  bottom: 12px; left: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow);
  display: none;
}
#command-card h3 {
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--accent);
}
#command-card .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.hp-bar-bg {
  height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e05060, #ff8a70);
  transition: width 0.15s;
}
#cmd-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.cmd-btn {
  background: rgba(30, 50, 80, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.cmd-btn:hover { border-color: var(--accent); background: rgba(40, 70, 110, 0.95); }

/* ---------- Action / production bar ---------- */
#action-bar {
  position: absolute;
  bottom: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 420px; }
#action-bar .btn-row { display: grid; grid-template-columns: repeat(4, minmax(70px, 1fr)); max-width: 380px; }
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  max-height: 58vh;
  overflow-y: auto;
  margin: 12px 0;
}
.mode-card {
  background: rgba(16, 28, 52, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.mode-card:hover { border-color: var(--accent); box-shadow: 0 0 16px rgba(80,180,255,0.25); }
.mode-card.locked { opacity: 0.45; cursor: not-allowed; }
.mode-ico { font-size: 22px; display: block; }
.mode-title { display: block; font-weight: 700; margin: 4px 0; }
.mode-desc { display: block; font-size: 11px; color: var(--muted); }
.mode-rules { margin: 8px 0 0; padding-left: 16px; font-size: 11px; color: #c8d4ea; }
#inv-panel {
  position: absolute;
  left: 16px; bottom: 150px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  z-index: 25;
  box-shadow: var(--shadow);
}
#inv-panel.hidden { display: none; }
.inv-head { font-size: 12px; color: var(--accent); display: flex; justify-content: space-between; margin-bottom: 8px; }
.inv-equip { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.inv-slot, .inv-cell {
  background: #101a30;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  min-height: 52px;
}
.inv-slot.filled, .inv-cell.filled { border-color: var(--accent2); }
.inv-ico { font-size: 16px; display: block; }
.inv-name { font-size: 10px; display: block; }
.inv-d20 { font-size: 9px; color: var(--warn); }
.inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.inv-cell { min-height: 36px; }
.inv-hint { font-size: 10px; color: var(--muted); margin-top: 6px; }
#d20-chip {
  position: absolute; top: 52px; left: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; color: var(--warn);
}
.act-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  cursor: pointer;
  position: relative;
}
.act-btn:hover, .act-btn.active { border-color: var(--accent2); color: var(--accent); }
.act-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.act-btn .key {
  position: absolute;
  top: -6px; right: -4px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 9px;
  padding: 0 3px;
  color: var(--accent);
}

/* ---------- Ability bar ---------- */
#ability-bar {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
  z-index: 20;
}
.abil-btn {
  position: relative;
  min-width: 88px;
  padding: 10px 10px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-shadow: var(--shadow);
}
.abil-btn.ready {
  border-color: var(--border-bright);
  box-shadow: 0 0 16px rgba(80, 180, 255, 0.35);
}
.abil-btn.ready:hover {
  transform: translateY(-3px);
  border-color: #b0f0ff;
}
.abil-btn.cd { opacity: 0.7; border-color: #3a5070; }
.abil-key {
  position: absolute;
  top: 5px; left: 7px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
}
.abil-icon { font-size: 20px; display: block; line-height: 1.2; }
.abil-name { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.abil-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--warn);
}

/* ---------- Toasts ---------- */
#toasts {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  z-index: 30;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
}
.toast.good { border-color: var(--good); color: var(--good); }
.toast.error { border-color: var(--bad); color: var(--bad); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Hotkey hint ---------- */
#hotkey-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 14, 28, 0.85);
  border: 1px solid rgba(90, 140, 200, 0.35);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

#fps {
  position: absolute;
  top: 12px; left: 12px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}

#tooltip {
  position: absolute;
  display: none;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  max-width: 220px;
  z-index: 40;
  pointer-events: none;
  box-shadow: var(--shadow);
}
#ghost-cost {
  position: absolute;
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  z-index: 25;
  pointer-events: none;
}

/* ---------- Tech panel ---------- */
#tech-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  z-index: 50;
}
#tech-panel.hidden { display: none; }

/* ---------- Modal ---------- */
#modal {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  backdrop-filter: blur(6px);
}
#modal.hidden { display: none; }
.modal-box {
  background: linear-gradient(165deg, #142038 0%, #0c1428 100%);
  border: 1px solid var(--border-bright);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 820px;
  width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  color: var(--text);
}
.modal-box h2 {
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--accent);
}
.modal-box p { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 14px; }
.modal-box .btn-row { justify-content: center; margin-top: 12px; gap: 10px; }
.modal-btn {
  background: linear-gradient(180deg, #3a7ab8, #2a5a90);
  border: 1px solid var(--border-bright);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-btn:hover { filter: brightness(1.1); }
.modal-btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.modal-btn.secondary:hover { color: var(--text); border-color: var(--accent); }

input, select {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}
input:focus, select:focus { outline: 1px solid var(--accent); }

/* Auth form layout */
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.auth-tabs { display: flex; gap: 8px; justify-content: center; }
