/* ==================== THE LAVA GAME — PANEL UI ====================
   Loads AFTER legacy-ui.css and overrides the celestial codex styling.

   The old shell was fantasy-celestial: Cinzel serif, sage glass, soft glows.
   The Lava Game is industrial and hot — heavy display type, flat basalt surfaces,
   molten edges, hazard accents. Everything reads from theme.css tokens.

   Structural rule: every id and class the JS touches is preserved. This file
   restyles, it does not rename.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo+Black&display=swap');

/* Global typography rebrand. Every existing rule that reads --font-display or
   --disp picks this up automatically — one override instead of 4,000 lines. */
:root {
  --lf-display: 'Archivo Black', 'Arial Black', sans-serif;
  --font-display: var(--lf-display);
  --disp: var(--lf-display);

  --lf-r: 10px;
  --lf-r-sm: 6px;
}

/* ==================== SHELL ==================== */

#codex-shell {
  background: linear-gradient(180deg, #241a1b 0%, #1a1213 100%);
  border: 1px solid rgba(255, 122, 34, 0.22);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 30px 80px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 180, 60, 0.10);
  overflow: hidden;
  position: relative;
}

/* Molten seam along the top edge — the signature element */
#codex-shell::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%, var(--lf-lava-deep) 12%, var(--lf-lava) 34%,
    var(--lf-lava-core) 50%, var(--lf-lava) 66%, var(--lf-lava-deep) 88%, transparent 100%);
  opacity: 0.9;
  z-index: 3;
}

#cg-dim {
  background: radial-gradient(ellipse at center, rgba(20, 11, 12, 0.55) 0%, rgba(12, 7, 8, 0.86) 100%);
  backdrop-filter: blur(3px) saturate(0.85);
  -webkit-backdrop-filter: blur(3px) saturate(0.85);
}

/* ==================== RAIL ==================== */

.codex-rail {
  background: #180f10;
  border-right: 1px solid rgba(255, 122, 34, 0.16);
}

.codex-rail .cr-logo img {
  filter: drop-shadow(0 0 10px rgba(255, 122, 34, 0.45));
}

.codex-rail .cr-tab {
  color: var(--lf-smoke);
  border-radius: var(--lf-r-sm);
  border: 1px solid transparent;
  font-family: var(--font-mono, monospace);
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}

.codex-rail .cr-tab:hover {
  color: var(--lf-lava-core);
  background: rgba(255, 122, 34, 0.10);
  border-color: rgba(255, 122, 34, 0.30);
}

/* ==================== PANEL HEADER ==================== */

.lf-panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 18px 22px 0;
}

.lf-panel-title {
  font-family: var(--lf-display);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--lf-bone);
  line-height: 1;
  text-transform: uppercase;
}

.lf-panel-title em {
  font-style: normal;
  color: var(--lf-lava);
}

.lf-panel-sub {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--lf-smoke);
}

/* The one-line explainer. This exists because players could not tell the
   social world from the game queue — it names where you are and what happens. */
.lf-explainer {
  margin: 14px 22px 0;
  padding: 11px 14px;
  background: rgba(255, 122, 34, 0.07);
  border: 1px solid rgba(255, 122, 34, 0.20);
  border-left: 3px solid var(--lf-lava);
  border-radius: 0 var(--lf-r-sm) var(--lf-r-sm) 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--lf-ash);
}

.lf-explainer b {
  color: var(--lf-lava-core);
  font-weight: 600;
}

/* ==================== CARDS ==================== */

#side-panel .cg-card {
  background: #201617;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: var(--lf-r);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 14px 16px;
}

.section-title,
.input-label {
  font-family: var(--font-mono, monospace) !important;
  font-size: 10px !important;
  letter-spacing: 2.2px !important;
  text-transform: uppercase;
  color: var(--lf-smoke) !important;
}

#character-name-input {
  background: #170f10;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--lf-r-sm);
  color: var(--lf-bone);
  font-family: var(--font-body, sans-serif);
}

#character-name-input:focus {
  border-color: var(--lf-lava);
  box-shadow: 0 0 0 3px rgba(255, 122, 34, 0.14);
  outline: none;
}

/* ==================== ARENA CARDS ==================== */

.game-mode-card {
  position: relative;
  background: #221718;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--lf-r);
  padding: 14px 16px;
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

/* Molten left edge, brightens on hover */
.game-mode-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--lf-lava-deep);
  transition: background .18s ease, box-shadow .18s ease;
}

.game-mode-card:hover {
  border-color: rgba(255, 122, 34, 0.42);
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.game-mode-card:hover::before {
  background: var(--lf-lava-core);
  box-shadow: 0 0 14px var(--lf-lava);
}

.game-mode-card.free-mode-card::before { background: var(--lf-safe); }
.game-mode-card.free-mode-card:hover::before {
  background: var(--lf-safe);
  box-shadow: 0 0 14px var(--lf-safe);
}

.mode-name {
  font-family: var(--lf-display);
  font-size: 15px;
  letter-spacing: 0.4px;
  color: var(--lf-bone);
  text-transform: uppercase;
}

.mode-description {
  font-size: 11.5px;
  color: var(--lf-smoke);
}

.mode-fee {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 500;
  color: var(--lf-lava-core);
  background: rgba(255, 122, 34, 0.12);
  border: 1px solid rgba(255, 122, 34, 0.30);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

.mode-fee.free-fee {
  color: var(--lf-safe);
  background: rgba(124, 186, 82, 0.12);
  border-color: rgba(124, 186, 82, 0.35);
}

.mode-icon svg { fill: var(--lf-lava); }
.mode-icon.free-icon svg { fill: var(--lf-safe); }

.mode-stat,
.mode-prize-label { color: var(--lf-smoke); font-size: 11px; }
.stat-text { color: var(--lf-ash); }
.mode-prize-value {
  font-family: var(--font-mono, monospace);
  color: var(--lf-lava-core);
}

/* Locked / live states */
.game-mode-card.locked { opacity: 0.55; }

.mode-locked-banner {
  background: rgba(229, 72, 77, 0.14);
  border: 1px solid rgba(229, 72, 77, 0.34);
  color: var(--lf-danger);
  border-radius: var(--lf-r-sm);
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 1.4px;
  padding: 7px 10px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.mode-locked-banner.full {
  background: rgba(255, 180, 60, 0.14);
  border-color: rgba(255, 180, 60, 0.34);
  color: var(--lf-warn);
}

.live-indicator {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--lf-danger);
  box-shadow: 0 0 8px rgba(229, 72, 77, 0.75);
  animation: lfPulse 1.5s infinite;
}

@keyframes lfPulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ==================== BUTTONS ==================== */

#side-panel button.primary,
.lf-btn-primary {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(180deg, var(--lf-lava) 0%, var(--lf-lava-deep) 100%);
  border: 1px solid var(--lf-lava-hot);
  border-radius: var(--lf-r-sm);
  color: #1a0f08;
  cursor: pointer;
  transition: filter .16s ease, transform .1s ease;
}

#side-panel button.primary:hover,
.lf-btn-primary:hover { filter: brightness(1.14); }
#side-panel button.primary:active,
.lf-btn-primary:active { transform: scale(0.985); }

#side-panel button.secondary {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--lf-r-sm);
  color: var(--lf-ash);
  transition: all .16s ease;
}

#side-panel button.secondary:hover {
  background: rgba(255, 122, 34, 0.11);
  border-color: rgba(255, 122, 34, 0.34);
  color: var(--lf-lava-core);
}

/* "Back to the Rim" — leaving the panel, not a primary action */
.cg-close-codex {
  font-family: var(--font-mono, monospace) !important;
  font-size: 11px !important;
  letter-spacing: 1.6px !important;
  text-transform: uppercase;
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  border-radius: var(--lf-r-sm) !important;
  color: var(--lf-smoke) !important;
  padding: 11px 14px !important;
  width: 100%;
  cursor: pointer;
  transition: all .16s ease;
}

.cg-close-codex:hover {
  border-color: rgba(255, 122, 34, 0.32) !important;
  color: var(--lf-lava-core) !important;
}

/* ==================== LAUNCHER + POPULATION ==================== */

#cg-launcher {
  background: linear-gradient(180deg, #241a1b, #1a1213);
  border: 1px solid rgba(255, 122, 34, 0.34);
  border-radius: 12px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55), 0 0 22px rgba(255, 122, 34, 0.10);
}

#cg-launcher .lk i {
  background: var(--lf-lava);
  box-shadow: 0 0 12px var(--lf-lava);
}

#cg-launcher .ltxt .a {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--lf-bone);
}

#cg-launcher .ltxt .b {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--lf-smoke);
}

#cg-pop {
  background: rgba(24, 15, 16, 0.86);
  border: 1px solid rgba(255, 122, 34, 0.20);
  border-radius: 10px;
}

#cg-pop .pdot {
  background: var(--lf-safe);
  box-shadow: 0 0 8px var(--lf-safe);
}

#cg-pop .pn {
  font-family: var(--lf-display);
  color: var(--lf-lava-core);
}

#cg-pop .pl {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  letter-spacing: 1.4px;
  color: var(--lf-smoke);
}

/* ==================== WELCOME BANNER ==================== */

#cg-welcome {
  background: linear-gradient(180deg, rgba(36, 26, 27, 0.90), rgba(20, 11, 12, 0.92));
  border: 1px solid rgba(255, 122, 34, 0.22);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.cg-welcome-eyebrow {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--lf-lava);
  text-transform: uppercase;
}

.cg-welcome-title {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--lf-bone);
}

.cg-welcome-title span { color: var(--lf-lava); }
.cg-welcome-sub { color: var(--lf-ash); }

/* Contract address placeholder — no token yet */
.cg-welcome-ca {
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 122, 34, 0.30);
  border-radius: 999px;
  color: var(--lf-smoke);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 1.4px;
  cursor: default;
}

.cg-welcome-ca .ca-k {
  background: rgba(255, 122, 34, 0.16);
  color: var(--lf-lava-core);
  border-radius: 999px;
  padding: 2px 8px;
  margin-right: 7px;
  font-size: 10px;
}

/* ==================== TOP BAR ==================== */

#game-title {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--lf-bone);
}

#token-display {
  border: 1px dashed rgba(255, 122, 34, 0.28);
  border-radius: 999px;
  color: var(--lf-smoke);
  font-family: var(--font-mono, monospace);
  cursor: default;
}

/* ==================== HELP MODALS ==================== */

.help-modal-content {
  background: linear-gradient(180deg, #241a1b, #180f10);
  border: 1px solid rgba(255, 122, 34, 0.22);
  border-radius: 14px;
}

.help-modal-title {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--lf-bone);
}

.help-modal-subtitle {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--lf-smoke);
}

.help-modal-icon { color: var(--lf-lava); }

.help-step-number {
  background: rgba(255, 122, 34, 0.14);
  border: 1px solid rgba(255, 122, 34, 0.32);
  color: var(--lf-lava-core);
  font-family: var(--font-mono, monospace);
  border-radius: var(--lf-r-sm);
}

.help-step-text { color: var(--lf-ash); }
.help-highlight { color: var(--lf-lava-core); font-weight: 600; }
.help-highlight-danger { color: var(--lf-danger); font-weight: 600; }

.help-note {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--lf-lava);
  border-radius: 0 var(--lf-r-sm) var(--lf-r-sm) 0;
  color: var(--lf-ash);
}

.help-note-icon { color: var(--lf-lava); }

/* ==================== HUD ==================== */

.timer-label {
  font-family: var(--font-mono, monospace);
  font-size: 9px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--lf-smoke);
}

.timer-value {
  font-family: var(--font-mono, monospace);
  color: var(--lf-bone);
}

#dark-curse-timer { color: var(--lf-lava-core); }

.movement-status.needs-move,
.movement-hud.needs-move {
  background: rgba(255, 180, 60, 0.12);
  border: 1px solid rgba(255, 180, 60, 0.38);
  color: var(--lf-warn);
}

.movement-status.has-moved,
.movement-hud.has-moved {
  background: rgba(124, 186, 82, 0.12);
  border: 1px solid rgba(124, 186, 82, 0.34);
  color: var(--lf-safe);
}

.movement-status-text,
.movement-hud-text {
  font-family: var(--font-mono, monospace);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

/* ==================== MODAL TITLES ==================== */

.modal-title,
.victory-title {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-title.death { color: var(--lf-danger); }
.victory-title { color: var(--lf-lava-core); }
.victory-title.draw-title { color: var(--lf-warn); }

.queued-title {
  font-family: var(--lf-display);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--lf-safe);
}

/* ==================== LEADERBOARD ==================== */

#lf-leaderboard {
  background: #201617;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: var(--lf-r);
  padding: 13px 15px;
  margin-top: 10px;
}

.lf-lb-head {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
}
.lf-lb-head .lf-lb-sub { margin-left: auto; }

.lf-lb-toggle {
  font-size: 10px;
  color: var(--lf-soot, #5c4a46);
  transition: transform .22s ease, color .15s ease;
}
.lf-lb-head:hover .lf-lb-toggle { color: var(--lf-lava-core, #ffc24a); }
#lf-leaderboard.collapsed .lf-lb-toggle { transform: rotate(-90deg); }

/* Collapsed shrinks to just the header row */
.lf-lb-body {
  max-height: 320px;
  overflow: hidden;
  padding-top: 10px;
  transition: max-height .26s ease, padding-top .26s ease, opacity .18s ease;
  opacity: 1;
}
#lf-leaderboard.collapsed .lf-lb-body {
  max-height: 0;
  padding-top: 0;
  opacity: 0;
}
.lf-lb-title {
  font-family: var(--font-mono, monospace);
  font-size: 10px; letter-spacing: 2.2px; text-transform: uppercase;
  color: var(--lf-lava-core, #ffc24a);
}
.lf-lb-sub {
  font-family: var(--font-mono, monospace);
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--lf-soot, #5c4a46);
}

.lf-lb-cols {
  display: grid; grid-template-columns: 22px 1fr 42px 42px;
  gap: 8px; padding: 0 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-mono, monospace);
  font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--lf-soot, #5c4a46);
}
.lf-lb-cols .r { text-align: right; }

.lf-lb-list { max-height: 232px; overflow-y: auto; }
.lf-lb-list::-webkit-scrollbar { width: 3px; }
.lf-lb-list::-webkit-scrollbar-thumb { background: rgba(255,122,34,.24); }

.lf-lb-row {
  display: grid; grid-template-columns: 22px 1fr 42px 42px;
  gap: 8px; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  font-size: 13px;
}
.lf-lb-row:last-child { border-bottom: none; }

.lf-lb-rank {
  font-family: var(--font-mono, monospace);
  font-size: 11px; color: var(--lf-soot, #5c4a46);
}
.lf-lb-row.top .lf-lb-rank { color: var(--lf-lava, #ff7a22); font-weight: 600; }

.lf-lb-name {
  color: var(--lf-ash, #c7afa4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lf-lb-row.top .lf-lb-name { color: var(--lf-bone, #f6ede6); font-weight: 500; }

.lf-lb-wins {
  text-align: right;
  font-family: var(--font-mono, monospace);
  color: var(--lf-lava-core, #ffc24a); font-weight: 600;
}
.lf-lb-days {
  text-align: right;
  font-family: var(--font-mono, monospace);
  color: var(--lf-smoke, #8a756d);
}

.lf-lb-empty {
  font-size: 12.5px; font-style: italic;
  color: var(--lf-soot, #5c4a46);
  padding: 10px 0 4px;
}