/* ═══════════════════════════════════════════════════════════════
   NIGHTFALL DOMINION RPG — Design System
   Dark gothic fantasy • Cinzel + Crimson Text
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Palette */
  --ink:        #070510;
  --void:       #0c0918;
  --abyss:      #110e1c;
  --shadow:     #18142a;
  --dusk:       #221c38;
  --twilight:   #2e2650;
  --mist:       #3d3560;

  --border-dim:  #2a2244;
  --border-mid:  #3d3060;
  --border-glow: #6b4fa8;

  --gold:       #c8922a;
  --gold-light: #e8b84b;
  --gold-pale:  #f5d98a;
  --gold-dim:   #6e4e14;

  --crimson:    #c42a2a;
  --violet:     #7c3aed;
  --violet-lt:  #a78bfa;
  --teal:       #0e9480;
  --silver:     #94a3b8;

  --text-bright: #ede8f5;
  --text-mid:    #a89fc8;
  --text-dim:    #5c5278;
  --text-ghost:  #332c50;

  --font-display: 'Cinzel Decorative', serif;
  --font-title:   'Cinzel', serif;
  --font-body:    'Crimson Text', serif;

  --cell: 54px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;

  --shadow-panel: 0 8px 32px rgba(0,0,0,0.7);
  --shadow-glow-v: 0 0 24px rgba(124,58,237,0.3);
  --shadow-glow-g: 0 0 24px rgba(200,146,42,0.25);

  --transition: 0.18s ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--text-bright); font-family: var(--font-body); font-size: 15px; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: var(--font-body); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--abyss); }
::-webkit-scrollbar-thumb { background: var(--mist); border-radius: 3px; }
.hidden { display: none !important; }

/* ── Screens ─────────────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; position: fixed; inset: 0; }
.screen.active { display: flex; }

/* ═══════════════════════════════════════════════════════════════
   SCREEN 1: ENTRY
   ═══════════════════════════════════════════════════════════════ */

#screen-entry {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 40% 50%, #1a0f35 0%, #070510 65%);
}

.entry-bg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}

.entry-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 10%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 70% 40%, rgba(200,180,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 75%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 55%, rgba(255,220,100,0.2) 0%, transparent 100%),
    radial-gradient(2px 2px at 5%  90%, rgba(180,140,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 15%, rgba(255,255,255,0.3) 0%, transparent 100%);
}

.entry-moon {
  position: absolute; top: 8%; right: 12%;
  font-size: 5rem; opacity: 0.4;
  filter: drop-shadow(0 0 30px rgba(180,140,255,0.5));
  animation: moonFloat 6s ease-in-out infinite;
}

@keyframes moonFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-15px) rotate(5deg); }
}

.entry-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 2.5rem;
  animation: fadeUp 0.8s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.entry-logo { text-align: center; }

.logo-main {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  text-shadow: 0 0 30px rgba(232,184,75,0.5), 0 0 80px rgba(200,146,42,0.2);
  line-height: 1;
}

.logo-sub {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.8rem);
  font-weight: 400;
  letter-spacing: 0.25em;
  color: var(--violet-lt);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.logo-tagline {
  font-family: var(--font-title);
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  margin-top: 0.75rem;
  text-transform: uppercase;
}

.entry-card {
  background: linear-gradient(160deg, var(--shadow) 0%, var(--abyss) 100%);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  width: 420px;
  box-shadow: var(--shadow-panel), var(--shadow-glow-v);
  position: relative;
}

.entry-card::before {
  content: '';
  position: absolute; top: 0; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.role-selector {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.role-btn {
  background: var(--dusk);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  transition: all var(--transition);
}

.role-btn:hover { border-color: var(--border-glow); }

.role-btn.active {
  background: linear-gradient(135deg, #2a1d50, #1e1440);
  border-color: var(--violet);
  box-shadow: 0 0 12px rgba(124,58,237,0.3);
}

.role-icon { font-size: 1.4rem; }
.role-name { font-family: var(--font-title); font-size: 0.78rem; color: var(--text-bright); }
.role-desc { font-size: 0.68rem; color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════════
   SCREEN 2: CHARACTER CREATION
   ═══════════════════════════════════════════════════════════════ */

#screen-character {
  flex-direction: column;
  background: var(--void);
  overflow-y: auto;
}

.char-bg {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 70% 30%, #1a0f35 0%, transparent 60%);
}

.char-wrapper {
  position: relative; z-index: 2;
  max-width: 900px; width: 100%; margin: 0 auto;
  padding: 2rem 1.5rem;
}

.char-header { text-align: center; margin-bottom: 2rem; }

.char-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--gold-light);
  text-shadow: 0 0 20px rgba(232,184,75,0.4);
}

.char-subtitle {
  font-size: 1rem; color: var(--text-mid); font-style: italic; margin-top: 0.3rem;
}

.char-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.char-section {
  background: var(--shadow);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.char-section.span-full { grid-column: 1 / -1; }

.char-section-title {
  font-family: var(--font-title);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-dim);
}

.avatar-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4rem;
}

.avatar-opt {
  background: var(--dusk); border: 1px solid var(--border-dim);
  border-radius: var(--radius); font-size: 1.25rem; padding: 0.35rem;
  transition: all var(--transition);
}
.avatar-opt:hover { border-color: var(--violet); transform: scale(1.1); }
.avatar-opt.active {
  background: var(--twilight); border-color: var(--violet);
  box-shadow: 0 0 8px rgba(124,58,237,0.4);
}

.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}

.stat-box {
  background: var(--dusk);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 0.5rem;
  text-align: center;
  display: flex; flex-direction: column; gap: 0.2rem;
}

.stat-box label {
  font-family: var(--font-title);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.stat-box input {
  background: transparent;
  border: none; border-bottom: 1px solid var(--border-mid);
  color: var(--text-bright);
  font-size: 1.1rem; font-weight: 600;
  text-align: center; width: 100%; outline: none;
}

.stat-mod {
  font-size: 0.72rem; color: var(--violet-lt);
  font-family: var(--font-title);
}

.char-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   SCREEN 3: GAME
   ═══════════════════════════════════════════════════════════════ */

#screen-game {
  flex-direction: column;
  background: var(--ink);
}

/* ── Topbar ──────────────────────────────────────────────────── */
#topbar {
  height: 46px;
  background: linear-gradient(90deg, var(--abyss) 0%, var(--void) 50%, var(--abyss) 100%);
  border-bottom: 1px solid var(--border-dim);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5);
}

.game-wordmark {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-right: 0.75rem;
}

.map-name-badge {
  font-family: var(--font-title); font-size: 0.75rem;
  color: var(--text-mid); letter-spacing: 0.06em;
}

.combat-badge {
  background: var(--crimson); color: #fff;
  font-family: var(--font-title); font-size: 0.7rem;
  letter-spacing: 0.1em; padding: 0.15rem 0.5rem;
  border-radius: 3px; animation: pulse 1.5s ease infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.topbar-center { display: flex; align-items: center; gap: 0.3rem; }

.player-avatar-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: default; title: attr(title);
  transition: transform var(--transition);
}
.player-avatar-dot:hover { transform: scale(1.2); }

.topbar-btn {
  background: var(--dusk); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-mid);
  font-size: 0.85rem; padding: 0.25rem 0.5rem;
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ── Game layout ─────────────────────────────────────────────── */
#game-layout {
  display: grid;
  grid-template-columns: 220px 1fr 270px;
  flex: 1; overflow: hidden;
}

/* ── Panels ──────────────────────────────────────────────────── */
aside {
  background: var(--abyss);
  border-color: var(--border-dim);
  display: flex; flex-direction: column;
  overflow: hidden;
}

#panel-left { border-right: 1px solid var(--border-dim); overflow-y: auto; gap: 0; }
#panel-right { border-left: 1px solid var(--border-dim); }

.panel-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-dim);
}

.panel-title {
  font-family: var(--font-title);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;
}

/* ── My char summary ─────────────────────────────────────────── */
.my-char-card {
  background: var(--shadow);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 0.6rem;
}

.my-char-name {
  font-family: var(--font-title); font-size: 0.88rem; color: var(--text-bright);
  margin-bottom: 0.25rem;
}
.my-char-class { font-size: 0.75rem; color: var(--text-mid); font-style: italic; margin-bottom: 0.5rem; }

.hp-bar-wrap { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.4rem; }
.hp-bar-track { flex: 1; height: 6px; background: var(--dusk); border-radius: 3px; overflow: hidden; }
.hp-bar-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #22c55e); border-radius: 3px; transition: width 0.3s; }
.hp-label { font-size: 0.72rem; color: var(--text-mid); white-space: nowrap; font-family: monospace; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; }
.mini-stat { background: var(--dusk); border-radius: 3px; text-align: center; padding: 0.2rem; }
.mini-stat-label { font-size: 0.55rem; color: var(--gold); font-family: var(--font-title); letter-spacing: 0.08em; display: block; }
.mini-stat-val { font-size: 0.82rem; color: var(--text-bright); font-weight: 600; }

/* ── Dice ────────────────────────────────────────────────────── */
.dice-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.dice-btn {
  background: var(--dusk); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-mid);
  font-family: var(--font-title); font-size: 0.78rem; padding: 0.35rem;
  transition: all var(--transition);
}
.dice-btn:hover { border-color: var(--violet-lt); color: var(--violet-lt); background: var(--twilight); }
.dice-btn:active { transform: scale(0.9); }
.dice-btn.featured { grid-column: span 2; color: var(--violet-lt); border-color: var(--violet); font-size: 0.9rem; }

.dice-custom { display: flex; gap: 0.35rem; margin-bottom: 0.4rem; }
.dice-custom input {
  flex: 1; background: var(--shadow); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-bright); font-size: 0.82rem;
  padding: 0.3rem 0.5rem; outline: none; min-width: 0;
}
.dice-custom input:focus { border-color: var(--violet-lt); }
.dice-custom input::placeholder { color: var(--text-ghost); }
#dice-custom-btn {
  background: var(--twilight); border: 1px solid var(--violet); border-radius: var(--radius);
  color: var(--violet-lt); font-size: 0.9rem; padding: 0.3rem 0.5rem;
  transition: all var(--transition);
}
#dice-custom-btn:hover { background: var(--mist); }

#dice-last-result {
  text-align: center; font-size: 0.78rem; color: var(--text-dim);
  font-style: italic; min-height: 1.2rem;
}

/* ── Players list ────────────────────────────────────────────── */
#players-list { display: flex; flex-direction: column; gap: 0.35rem; }
.player-list-row {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.82rem; color: var(--text-mid); padding: 0.2rem 0;
}
.player-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.player-role-badge {
  font-size: 0.6rem; padding: 0.1rem 0.3rem;
  background: var(--dusk); border-radius: 2px; color: var(--gold);
  font-family: var(--font-title); letter-spacing: 0.06em;
}

/* ── Initiative ──────────────────────────────────────────────── */
#initiative-list { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem; }
.init-row {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--dusk); border-radius: var(--radius); padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
}
.init-rank { font-family: var(--font-title); font-size: 0.65rem; color: var(--text-dim); width: 14px; }
.init-emoji { font-size: 0.9rem; }
.init-name { flex: 1; color: var(--text-bright); }
.init-val { font-family: monospace; font-size: 0.9rem; color: var(--gold); font-weight: 700; }
.init-active { border: 1px solid var(--gold); background: var(--shadow); }

#my-initiative-form { display: flex; gap: 0.35rem; }
#initiative-input {
  flex: 1; background: var(--shadow); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-bright); font-size: 0.88rem;
  padding: 0.3rem 0.5rem; outline: none; min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BOARD
   ═══════════════════════════════════════════════════════════════ */

#board-area {
  display: flex; flex-direction: column;
  background: #05030d; overflow: hidden;
}

#board-toolbar {
  height: 40px;
  background: var(--abyss); border-bottom: 1px solid var(--border-dim);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0.75rem; flex-shrink: 0; gap: 0.5rem;
}

.toolbar-left, .toolbar-right { display: flex; gap: 0.3rem; align-items: center; }
.toolbar-center { display: flex; gap: 0.3rem; align-items: center; overflow-x: auto; flex: 1; padding: 0 0.5rem; }

.tool-btn {
  background: var(--dusk); border: 1px solid var(--border-dim);
  border-radius: var(--radius); color: var(--text-mid);
  font-size: 0.82rem; padding: 0.2rem 0.5rem; min-width: 28px;
  transition: all var(--transition);
}
.tool-btn:hover { border-color: var(--border-glow); color: var(--text-bright); }
.tool-btn.active { background: var(--twilight); border-color: var(--violet); color: var(--violet-lt); }

.map-tab {
  background: var(--dusk); border: 1px solid var(--border-dim);
  border-radius: var(--radius); color: var(--text-mid);
  font-family: var(--font-title); font-size: 0.7rem; padding: 0.2rem 0.6rem;
  white-space: nowrap; transition: all var(--transition);
}
.map-tab:hover { border-color: var(--border-glow); color: var(--text-bright); }
.map-tab.active { background: var(--shadow); border-color: var(--gold-dim); color: var(--gold); }

#board-viewport {
  flex: 1; overflow: auto; position: relative;
  display: flex; align-items: flex-start; justify-content: flex-start;
}

#board-scale-wrapper {
  position: relative;
  transform-origin: top left;
  transition: transform 0.15s ease;
}

#board-canvas { display: block; }
#tokens-layer { position: absolute; top: 0; left: 0; pointer-events: none; }
#pings-layer  { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 50; }

/* ── Tokens ──────────────────────────────────────────────────── */
.token {
  position: absolute; pointer-events: all;
  width: var(--cell); height: var(--cell);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: grab; user-select: none;
  transition: filter 0.15s;
  z-index: 10;
}
.token:active { cursor: grabbing; }

.token-body {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.7);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.token:hover .token-body { transform: scale(1.12); }

.token-hp-ring {
  position: absolute; inset: -3px;
  border-radius: 50%; border: 2px solid transparent;
  background-clip: padding-box;
}

.token-label {
  font-size: 0.55rem; color: #fff; text-shadow: 0 1px 3px #000;
  font-family: var(--font-title); white-space: nowrap;
  max-width: calc(var(--cell) + 10px); overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}

.token.dragging { z-index: 100; filter: drop-shadow(0 8px 20px rgba(0,0,0,0.9)); }
.token.dragging .token-body { transform: scale(1.2); }

@keyframes tokenSnap {
  0%   { transform: scale(1.15); }
  60%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.token.snapping .token-body { animation: tokenSnap 0.25s ease; }

/* Ping de localización */
@keyframes pingAnim {
  0%   { transform: scale(0); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}
.ping-marker {
  position: absolute;
  width: 30px; height: 30px;
  border: 3px solid var(--gold);
  border-radius: 50%;
  animation: pingAnim 1s ease forwards;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   CHAT
   ═══════════════════════════════════════════════════════════════ */

#chat-log {
  flex: 1; overflow-y: auto; padding: 0.5rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}

.chat-msg { padding: 0.4rem 0.6rem; border-radius: var(--radius); animation: msgSlide 0.18s ease; }
@keyframes msgSlide { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }

.chat-msg.type-system {
  color: var(--text-dim); font-style: italic; font-size: 0.78rem;
  text-align: center; background: transparent;
}

.chat-msg.type-chat {
  background: var(--shadow); border: 1px solid var(--border-dim);
}

.chat-msg.type-announcement {
  background: linear-gradient(135deg, #2d1e0a, #1a1205);
  border: 1px solid var(--gold-dim);
  text-align: center; color: var(--gold-light);
  font-family: var(--font-title); font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.chat-msg.type-whisper {
  background: linear-gradient(135deg, #1a1030, #120c22);
  border: 1px solid var(--violet);
  font-style: italic;
}

.msg-header { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.15rem; }
.msg-name { font-family: var(--font-title); font-size: 0.75rem; font-weight: 600; }
.msg-time { font-size: 0.65rem; color: var(--text-dim); margin-left: auto; }
.msg-text { font-size: 0.85rem; color: var(--text-bright); line-height: 1.35; }
.msg-me-tag { font-size: 0.62rem; color: var(--text-dim); }

/* Dice */
.chat-msg.type-dice {
  background: linear-gradient(135deg, #16102a, #1e1638);
  border: 1px solid var(--violet);
  text-align: center;
}
.dice-result-display { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.dice-caster { font-size: 0.72rem; color: var(--text-mid); }
.dice-notation { font-size: 0.75rem; color: var(--violet-lt); font-family: monospace; }
.dice-total {
  font-family: var(--font-display); font-size: 1.8rem; line-height: 1;
  font-weight: 700; transition: color 0.2s;
}
.dice-total.crit   { color: var(--gold-light); text-shadow: 0 0 16px rgba(232,184,75,0.8); }
.dice-total.fumble { color: var(--crimson);    text-shadow: 0 0 12px rgba(196,42,42,0.7); }
.dice-total.normal { color: var(--violet-lt); }
.dice-breakdown { font-size: 0.68rem; color: var(--text-dim); font-family: monospace; }
.dice-tag-crit  { font-size: 0.68rem; color: var(--gold); letter-spacing: 0.1em; }
.dice-tag-fumble{ font-size: 0.68rem; color: var(--crimson); letter-spacing: 0.1em; }
.dice-secret-tag{ font-size: 0.65rem; color: var(--violet-lt); font-style: italic; }

#chat-bar {
  display: flex; gap: 0.4rem;
  padding: 0.5rem;
  border-top: 1px solid var(--border-dim);
  flex-shrink: 0;
}
#chat-input {
  flex: 1; background: var(--shadow); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-bright); font-size: 0.88rem;
  padding: 0.4rem 0.6rem; outline: none; min-width: 0;
}
#chat-input:focus { border-color: var(--violet-lt); }
#chat-input::placeholder { color: var(--text-ghost); font-style: italic; }
#chat-send {
  background: var(--violet); border: none; border-radius: var(--radius);
  color: #fff; font-size: 1rem; padding: 0.4rem 0.7rem;
  transition: background var(--transition);
}
#chat-send:hover { background: #8b5cf6; }

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */

.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }

.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(5,3,13,0.85);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative; z-index: 501;
  background: var(--shadow);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-xl);
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-panel), var(--shadow-glow-v);
  animation: modalIn 0.22s ease;
  width: 560px;
}

.modal-lg  { width: 680px; }
.modal-xl  { width: 820px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.93) translateY(20px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

.modal-header h3 {
  font-family: var(--font-title); font-size: 1rem;
  color: var(--gold-light); letter-spacing: 0.05em;
}

.modal-close {
  background: none; border: 1px solid var(--border-mid); border-radius: var(--radius);
  color: var(--text-dim); font-size: 0.85rem; padding: 0.2rem 0.5rem;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--crimson); color: var(--crimson); }

/* ── DM Tabs ─────────────────────────────────────────────────── */
.dm-tabs {
  display: flex; gap: 0; flex-shrink: 0;
  border-bottom: 1px solid var(--border-dim);
  background: var(--abyss);
}

.dm-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-family: var(--font-title);
  font-size: 0.75rem; letter-spacing: 0.06em;
  padding: 0.6rem 1rem; transition: all var(--transition);
}
.dm-tab:hover { color: var(--text-mid); }
.dm-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

#dm-tab-content {
  flex: 1; overflow-y: auto; padding: 1.25rem;
}

/* DM tab inner styles */
.dm-section { margin-bottom: 1.25rem; }
.dm-section-title {
  font-family: var(--font-title); font-size: 0.78rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold-dim); margin-bottom: 0.6rem;
  padding-bottom: 0.35rem; border-bottom: 1px solid var(--border-dim);
}

.map-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.map-card {
  background: var(--dusk); border: 1px solid var(--border-mid);
  border-radius: var(--radius); padding: 0.75rem; cursor: pointer;
  transition: all var(--transition); text-align: center;
}
.map-card:hover { border-color: var(--gold-dim); }
.map-card.active-map { border-color: var(--gold); background: var(--shadow); }
.map-card-icon { font-size: 2rem; margin-bottom: 0.35rem; }
.map-card-name { font-family: var(--font-title); font-size: 0.78rem; color: var(--text-bright); }
.map-card-size { font-size: 0.68rem; color: var(--text-dim); margin-top: 0.15rem; }
.map-card-actions { display: flex; gap: 0.3rem; justify-content: center; margin-top: 0.5rem; }

.char-dm-card {
  background: var(--dusk); border: 1px solid var(--border-dim);
  border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.5rem;
}
.char-dm-name { font-family: var(--font-title); font-size: 0.88rem; color: var(--text-bright); }
.char-dm-class { font-size: 0.75rem; color: var(--text-mid); font-style: italic; margin-bottom: 0.5rem; }
.char-dm-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.char-dm-hp { font-size: 0.8rem; color: var(--text-mid); white-space: nowrap; }

.npc-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

/* ── Charsheet modal ─────────────────────────────────────────── */
.charsheet-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  padding: 1.25rem; overflow-y: auto;
}
.charsheet-section {
  background: var(--dusk); border: 1px solid var(--border-dim);
  border-radius: var(--radius); padding: 0.75rem;
}
.charsheet-section.span-full { grid-column: 1 / -1; }
.cs-title {
  font-family: var(--font-title); font-size: 0.75rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 0.6rem;
  padding-bottom: 0.35rem; border-bottom: 1px solid var(--border-dim);
}
.cs-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.cs-stat { background: var(--shadow); border-radius: var(--radius); padding: 0.4rem; text-align: center; }
.cs-stat-label { font-size: 0.6rem; color: var(--gold); font-family: var(--font-title); letter-spacing: 0.1em; display: block; }
.cs-stat-val { font-size: 1.1rem; font-weight: 700; color: var(--text-bright); }
.cs-stat-mod { font-size: 0.7rem; color: var(--violet-lt); }
.cs-hp-edit { display: flex; align-items: center; gap: 0.5rem; }
.cs-hp-edit input { width: 60px; background: var(--shadow); border: 1px solid var(--border-mid); border-radius: var(--radius); color: var(--text-bright); font-size: 1rem; text-align: center; padding: 0.25rem; outline: none; }

/* ═══════════════════════════════════════════════════════════════
   FORMS (shared)
   ═══════════════════════════════════════════════════════════════ */
.form-label {
  display: block; font-family: var(--font-title); font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold-dim); margin-bottom: 0.3rem;
}
input[type=text], input[type=number], select, textarea {
  width: 100%;
  background: var(--dusk); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-bright);
  font-size: 0.9rem; padding: 0.45rem 0.65rem; outline: none;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus { border-color: var(--violet-lt); }
input::placeholder, textarea::placeholder { color: var(--text-ghost); font-style: italic; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%235c5278'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.6rem center; padding-right: 2rem; }
select option { background: #18142a; }
textarea { resize: vertical; line-height: 1.4; }

.form-row { margin-bottom: 0.75rem; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.form-row.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; margin-bottom: 0; }
.form-group { display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn-primary {
  background: linear-gradient(135deg, var(--violet), #5b21b6);
  border: 1px solid var(--violet-lt);
  border-radius: var(--radius); color: #fff;
  font-family: var(--font-title); font-size: 0.9rem; letter-spacing: 0.05em;
  padding: 0.55rem 1.25rem; transition: all var(--transition);
  box-shadow: 0 4px 12px rgba(124,58,237,0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, #8b5cf6, var(--violet)); box-shadow: 0 6px 20px rgba(124,58,237,0.5); transform: translateY(-1px); }
.btn-primary.btn-lg { font-size: 1rem; padding: 0.65rem 1.5rem; width: 100%; }

.btn-secondary {
  background: var(--dusk); border: 1px solid var(--border-mid);
  border-radius: var(--radius); color: var(--text-mid);
  font-family: var(--font-title); font-size: 0.8rem; padding: 0.4rem 0.8rem;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--gold-dim); color: var(--gold); }
.btn-secondary.btn-sm { font-size: 0.72rem; padding: 0.3rem 0.6rem; }

.btn-ghost {
  background: none; border: 1px solid var(--border-dim);
  border-radius: var(--radius); color: var(--text-dim);
  font-family: var(--font-title); font-size: 0.82rem; padding: 0.45rem 0.9rem;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text-mid); }

.btn-danger {
  background: none; border: 1px solid #7f1d1d;
  border-radius: var(--radius); color: #f87171; font-size: 0.75rem;
  padding: 0.25rem 0.5rem; transition: all var(--transition);
}
.btn-danger:hover { background: #7f1d1d; color: #fff; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold-dim), #3d2700);
  border: 1px solid var(--gold);
  border-radius: var(--radius); color: var(--gold-light);
  font-family: var(--font-title); font-size: 0.78rem; padding: 0.35rem 0.7rem;
  transition: all var(--transition);
}
.btn-gold:hover { background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: var(--ink); }

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  z-index: 9999; pointer-events: none;
}

.toast {
  background: var(--shadow); border: 1px solid var(--border-glow);
  border-radius: var(--radius); padding: 0.5rem 1.25rem;
  font-family: var(--font-title); font-size: 0.8rem; color: var(--text-bright);
  letter-spacing: 0.04em; box-shadow: var(--shadow-panel);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-mid); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; cursor: pointer;
  transition: all var(--transition); margin-bottom: 1rem;
  color: var(--text-dim); font-size: 0.85rem;
}
.upload-zone:hover { border-color: var(--violet-lt); color: var(--text-mid); }
.upload-zone input[type=file] { display: none; }
.upload-zone-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }

/* Misc */
.separator { height: 1px; background: var(--border-dim); margin: 0.75rem 0; }
.text-gold { color: var(--gold); }
.text-dim  { color: var(--text-dim); font-size: 0.8rem; }
.flex-row  { display: flex; align-items: center; gap: 0.5rem; }
.flex-wrap { flex-wrap: wrap; }
.mt-half   { margin-top: 0.5rem; }

.token-img{width:100%;height:100%;object-fit:cover;border-radius:50%;display:block;}
.mini-avatar-img{width:32px;height:32px;object-fit:cover;border-radius:50%;border:1px solid var(--violet);}
.spec-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.35rem;font-size:.82rem;color:var(--text-mid);max-height:170px;overflow:auto;padding:.25rem;border:1px solid rgba(139,92,246,.15);border-radius:6px;}
.spec-grid label{display:flex;gap:.35rem;align-items:center;}
.spec-grid input{width:auto;}
.nightfall-stats{grid-template-columns:repeat(auto-fit,minmax(95px,1fr));}
.quick-guide{padding:1rem;color:var(--text-mid);line-height:1.45;}
.quick-guide h4{color:var(--gold);font-family:var(--font-title);margin:.75rem 0 .25rem;}
.quad-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.5rem;color:var(--text-mid);font-size:.86rem;}

/* Campaign lobby additions */
.campaign-entry-box {
  margin-top: 1rem;
  padding: .85rem;
  border: 1px solid rgba(168,85,247,.25);
  border-radius: .85rem;
  background: rgba(15, 10, 25, .45);
}
.campaign-entry-box input { margin-bottom: .5rem; }
.campaign-actions { display: flex; gap: .5rem; margin-top: .25rem; }
.campaign-actions button { flex: 1; }
.campaign-list {
  margin-top: .65rem;
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: .35rem;
}
.campaign-pick {
  text-align: left;
  padding: .55rem .65rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: .6rem;
  background: rgba(255,255,255,.05);
  color: var(--text-light);
  cursor: pointer;
}
.campaign-pick:hover { border-color: rgba(168,85,247,.75); background: rgba(168,85,247,.12); }
.campaign-pick span { color: var(--text-mid); font-size: .78rem; }
