/* Layout: full-screen, fixed 320 px right panel, canvas fills the rest.
   Min viewport 1280x720 — anything smaller gets a horizontal scroll. */

:root {
  --panel-w: 320px;
  --bg: #0a0a14;
  --panel-bg: #14141f;
  --panel-fg: #d8d8e0;
  --panel-dim: #6e6e80;
  --accent: #5da1ff;
  --slot-bg: #1d1d2d;
  --slot-border: #2a2a3c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--panel-fg);
  font-family: ui-sans-serif, system-ui, sans-serif;
  overflow: hidden;
  min-width: 1280px;
  min-height: 720px;
}

body {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  grid-template-rows: 100vh;
}

#stage {
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  /* Crisp pixel grid */
  image-rendering: pixelated;
  cursor: crosshair;
}

#panel {
  background: var(--panel-bg);
  border-left: 1px solid #1f1f2e;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow-y: auto;
  font-size: 13px;
}

.panel-section h3 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--panel-dim);
  font-weight: 600;
}

#minimap-section {
  padding: 0;
}

#minimap {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: #05050b;
  border-radius: 3px;
  image-rendering: pixelated;
}

#status {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, monospace;
  padding: 4px 0;
}

#players {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#players li {
  padding: 4px 6px;
  background: var(--slot-bg);
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

#players li.empty {
  color: var(--panel-dim);
  background: transparent;
  font-style: italic;
}

#action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.action-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.action-slot:not(:disabled):hover {
  border-color: var(--accent);
}

.action-slot:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.action-slot.firing {
  outline: 2px solid #ffe066;
  outline-offset: -2px;
}

.action-slot .cd-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.action-slot .slot-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: var(--panel-dim);
  z-index: 2;
}

.action-slot .slot-name {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  font-family: ui-monospace, monospace;
  font-size: 9px;
  text-align: center;
  color: var(--panel-fg);
  z-index: 2;
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
}

.muted { color: var(--panel-dim); }

.enter-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.enter-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.enter-field span { color: var(--panel-dim); min-width: 40px; }

.enter-field input {
  flex: 1;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  color: var(--panel-fg);
  padding: 4px 6px;
  border-radius: 3px;
  font: inherit;
  min-width: 0;
}

#class-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.class-pick {
  padding: 4px 6px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  color: var(--panel-fg);
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.class-pick:hover { border-color: var(--accent); }
.class-pick.selected { background: var(--accent); color: #0a0a14; border-color: var(--accent); }

#play-btn {
  padding: 8px;
  background: var(--accent);
  border: 0;
  color: #0a0a14;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
}

#play-btn:disabled {
  background: var(--slot-bg);
  color: var(--panel-dim);
  cursor: not-allowed;
}

/* Once the player has entered the realm, hide the entry section to
   give the panel back to the live HUD. */
body.playing #enter-section {
  display: none;
}

.bar {
  height: 6px;
  background: var(--slot-bg);
  border-radius: 3px;
  overflow: hidden;
  margin: 2px 0 6px;
}

.bar-fill {
  height: 100%;
  width: 0%;
  transition: width 120ms linear;
}

.bar-fill.hp     { background: #ff7676; }
.bar-fill.growth { background: #7ad97a; }

.upgrade-btn {
  width: 100%;
  margin-top: 4px;
  padding: 6px;
  background: var(--accent);
  color: #0a0a14;
  border: 0;
  border-radius: 3px;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.upgrade-btn.shift { background: #c490ff; }

.buffs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.buff-chip {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
}

.buff-chip.speed    { color: #5dd1ff; }
.buff-chip.att      { color: #ff6b4a; }
.buff-chip.damageReduction { color: #a0a8b8; }

.shift-option {
  padding: 8px 10px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  color: var(--panel-fg);
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.shift-option:hover { border-color: #c490ff; }

.boss-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  z-index: 5;
  background: rgba(122, 31, 31, 0.85);
  color: #ffe066;
  border: 1px solid #3a0a0a;
}
.boss-banner.totem {
  background: rgba(196, 144, 255, 0.85);
  color: #1a1a2a;
  border-color: #5a2099;
}

#leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#leaderboard li {
  padding: 3px 6px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  background: var(--slot-bg);
  border-radius: 2px;
}

#leaderboard li.you {
  outline: 1px solid var(--accent);
}

#leaderboard li.empty {
  background: transparent;
  font-style: italic;
  color: var(--panel-dim);
}

#leaderboard .lb-name { color: var(--panel-fg); flex: 1; overflow: hidden; text-overflow: ellipsis; }
#leaderboard .lb-score { color: #ffe066; }
#leaderboard .lb-peak { color: var(--panel-dim); font-size: 10px; }

.tier3-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 12px 0;
  max-height: 360px;
  overflow-y: auto;
}

.tier3-option {
  padding: 6px 4px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  color: var(--panel-fg);
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  text-align: center;
}

.tier3-option:hover { border-color: #c490ff; }
.shift-option:disabled {
  color: var(--panel-dim);
  cursor: not-allowed;
  border-color: var(--slot-border);
}
.shift-option .cost {
  color: #c490ff;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}
.shift-option .why {
  color: var(--panel-dim);
  font-size: 11px;
  margin-left: 8px;
}

#shift-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  max-height: 320px;
  overflow-y: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 11, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal[hidden] { display: none; }

.modal-inner {
  background: var(--panel-bg);
  border: 1px solid #2a2a3c;
  border-radius: 6px;
  padding: 20px;
  min-width: 320px;
  max-width: 480px;
}

.modal-inner h2 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--accent);
}

#upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.upgrade-option {
  padding: 8px 10px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  color: var(--panel-fg);
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.upgrade-option:hover {
  border-color: var(--accent);
}

.upgrade-option .name {
  font-weight: 600;
  display: block;
}

.upgrade-option .stats {
  color: var(--panel-dim);
  font-size: 11px;
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}

.modal-cancel {
  background: transparent;
  border: 1px solid var(--slot-border);
  color: var(--panel-dim);
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

#players li.you {
  outline: 1px solid var(--accent);
}

#players li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.class-tag {
  color: var(--panel-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
