/* --- CSS Design Tokens (Harmonious Curated HSL Palette) --- */
:root {
  --bg-deep: hsl(222, 24%, 7%);
  --panel-bg: hsla(222, 24%, 12%, 0.65);
  --border-light: hsla(222, 20%, 25%, 0.4);
  --border-active: hsla(43, 85%, 55%, 0.55);
  
  --primary-gold: hsl(43, 85%, 55%);
  --primary-gold-glow: hsla(43, 85%, 55%, 0.25);
  
  --hp-green: hsl(145, 80%, 45%);
  --threat-red: hsl(355, 85%, 55%);
  
  --text-primary: hsl(220, 20%, 94%);
  --text-muted: hsl(220, 10%, 65%);
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --shadow-premium: 0 12px 40px -10px rgba(0, 0, 0, 0.6);
}

/* --- Base Framework Resets --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  height: 100vh;
  position: relative;
}

.title-font {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- Ambient Backdrops Glows --- */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
}
.glow-1 {
  width: 400px;
  height: 400px;
  background: var(--primary-gold);
  top: -100px;
  left: 10%;
}
.glow-2 {
  width: 500px;
  height: 500px;
  background: var(--threat-red);
  bottom: -150px;
  right: 15%;
}

/* --- Premium Glassmorphism Panels --- */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: hsla(220, 20%, 35%, 0.4);
}

/* --- Main Layout Grid --- */
.game-container {
  display: grid;
  grid-template-columns: 280px 1fr 400px;
  gap: 16px;
  padding: 16px;
  height: 100vh;
  max-width: 1800px;
  margin: 0 auto;
}

/* --- Sidebar HUD & widgets --- */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  gap: 16px;
}

.sidebar-header {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.sidebar-header h2 {
  font-size: 1.25rem;
  color: var(--primary-gold);
}

.character-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
}

.character-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.char-avatar {
  font-size: 2rem;
  background: rgba(255, 255, 255, 0.05);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.character-meta h3 {
  font-size: 1.1rem;
}

.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.badge.friendly {
  background: rgba(145, 80, 45, 0.15);
  color: var(--hp-green);
  border: 1px solid rgba(145, 80, 45, 0.3);
}

.badge.active-combat {
  background: rgba(355, 85, 55, 0.15);
  color: var(--threat-red);
  border: 1px solid rgba(355, 85, 55, 0.3);
}

/* HP Progress Bars */
.stat-group {
  margin-bottom: 12px;
}

.stat-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.progress-bar-bg {
  background: rgba(255, 255, 255, 0.05);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-hp {
  background: var(--hp-green);
  box-shadow: 0 0 8px var(--hp-green);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mini-stat {
  background: rgba(0, 0, 0, 0.2);
  padding: 6px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.8rem;
}

.mini-stat .label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.sub-section {
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  margin-top: 12px;
}

.sub-section h4 {
  font-size: 0.85rem;
  color: var(--primary-gold);
  margin-bottom: 6px;
}

.inventory-items, .quest-items {
  list-style: none;
  font-size: 0.8rem;
}

.inventory-items li, .quest-items li {
  padding: 4px 0;
  color: var(--text-muted);
}

.quest-active {
  color: var(--primary-gold) !important;
  font-weight: 500;
}

.relations-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.relation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Center Section: Narrative Chat Terminal --- */
.chat-terminal {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.terminal-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: var(--primary-gold);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary-gold);
}

.terminal-header h1 {
  font-size: 1.35rem;
  flex: 1;
}

.campaign-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.message-feed {
  flex: 1 1 0;
  /* min-height: 0 is required for overflow to trigger on a flex child;
     without it the column flex parent grows to fit content and the scrollbar
     never appears. */
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 85%;
  border-radius: 12px;
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 0.95rem;
  animation: messageSlideIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.system-msg {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  align-self: flex-start;
  color: var(--text-muted);
}

/* --- Collapsible system messages panel --- */
.system-messages-panel {
  position: sticky;
  top: 0;
  z-index: 5;
  align-self: stretch;
  background: rgba(15, 16, 22, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 4px;
}
.system-messages-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  text-align: left;
  transition: color 0.15s ease;
}
.system-messages-toggle:hover { color: var(--primary-gold); }
.system-messages-toggle .chevron {
  display: inline-block;
  font-size: 0.65rem;
  transition: transform 0.18s ease;
  width: 10px;
}
.system-messages-panel:not(.collapsed) .system-messages-toggle .chevron {
  transform: rotate(90deg);
}
.system-messages-toggle .badge {
  margin-left: auto;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.7rem;
  color: var(--primary-gold);
  min-width: 22px;
  text-align: center;
}
.system-messages-toggle .badge.is-empty {
  opacity: 0.4;
}
.system-messages-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 14px 10px;
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid var(--border-light);
}
.system-messages-panel.collapsed .system-messages-body {
  display: none;
}
.system-msg-line {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-family: 'Inter', monospace;
}
.system-msg-line .system-msg-time {
  opacity: 0.5;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* --- Header controls (room badge, invite, voice, date) --- */
.room-badge {
  font-size: 0.75rem;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--primary-gold);
  margin-left: 8px;
  font-weight: normal;
  font-family: 'Inter', sans-serif;
}
.header-icon-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-left: 6px;
  transition: all 0.15s ease;
}
.header-icon-btn:hover {
  border-color: var(--primary-gold);
  color: var(--primary-gold);
  background: rgba(212, 175, 55, 0.08);
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.voice-toggle-label {
  font-size: 0.8rem;
  color: #c8c8cb;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}
.voice-toggle-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: #d4af37;
}
.voice-picker {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.75rem;
  font-family: inherit;
  max-width: 180px;
  cursor: pointer;
}
.voice-picker:focus {
  outline: none;
  border-color: var(--primary-gold);
}
.voice-picker:hover { border-color: rgba(212, 175, 55, 0.4); }

/* --- Invite modal --- */
.invite-url-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.invite-url-row input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: 'Inter', monospace;
  font-size: 0.85rem;
}
.invite-url-row input:focus {
  outline: none;
  border-color: var(--primary-gold);
}

/* --- Danger button + zone (Restart Campaign) --- */
.danger-zone {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(201, 42, 42, 0.25);
  display: flex;
  flex-direction: column;
}
.btn-danger {
  background: rgba(201, 42, 42, 0.08);
  border: 1px solid rgba(201, 42, 42, 0.4);
  color: #f6b6b6;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.btn-danger:hover {
  background: rgba(201, 42, 42, 0.18);
  border-color: rgba(201, 42, 42, 0.7);
  color: #ffd0d0;
}

.gm-msg {
  background: rgba(43, 85, 55, 0.03);
  border: 1px solid hsla(43, 85, 55, 0.15);
  border-left: 4px solid var(--primary-gold);
  align-self: flex-start;
  color: var(--text-primary);
}

.player-msg {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  align-self: flex-end;
  color: var(--text-primary);
}

.msg-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  color: var(--primary-gold);
}

.input-area {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
}

.input-area input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.input-area input:focus {
  outline: none;
  border-color: var(--primary-gold);
  box-shadow: 0 0 10px var(--primary-gold-glow);
}

/* --- Buttons Styles --- */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-gold), hsl(43, 85%, 45%));
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  padding: 12px 24px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px var(--primary-gold-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-gold);
}

/* --- Tactical Board Sidebar --- */
.tactical-board {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.board-header h2 {
  font-size: 1.25rem;
}

.canvas-container {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#battlefield-canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.board-instructions {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.action-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

/* --- Setup Modal Overlay --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Allow the overlay itself to scroll on tiny viewports — falls back to a
     scrollbar around the card when even the card can't shrink any further. */
  overflow-y: auto;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.modal-card {
  width: 500px;
  max-width: 90%;
  /* Cap to the viewport (minus the overlay padding above) so the card never
     extends below the fold; the body of the card scrolls internally. */
  max-height: calc(100vh - 32px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* Smooth-scroll keeps the click-to-scroll-to-buttons UX nice on long forms. */
  scroll-behavior: smooth;
}

.modal-card h2 {
  font-size: 1.75rem;
  color: var(--primary-gold);
  margin-bottom: 8px;
}

.modal-card .description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.setup-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.campaign-cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.concept-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.concept-card:hover {
  border-color: var(--primary-gold);
  background: rgba(255, 255, 255, 0.04);
}

.concept-card.active {
  border-color: var(--primary-gold);
  background: rgba(43, 85, 55, 0.04);
  box-shadow: 0 0 12px rgba(43, 85, 55, 0.2);
}

.concept-card h4 {
  margin-bottom: 4px;
}

.concept-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-row input, .form-row select {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-row select {
  height: 46px;
  padding-right: 38px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d4af37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
}

.form-row select option {
  background-color: #12131a;
  color: #fff;
  padding: 12px;
}

.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.mt-2 {
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

/* --- Dice Roll Spinner Overlay --- */
.dice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.dice-card {
  width: 280px;
  padding: 24px;
  text-align: center;
}

.dice-wrapper {
  margin: 32px 0;
  perspective: 1000px;
}

.dice-wrapper {
  position: relative;
}
.d20-visual {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  background: radial-gradient(circle at 30% 30%, hsl(45, 50%, 35%), hsl(20, 60%, 15%));
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 8px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.8);
  border: 2px solid var(--primary-gold);
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
  animation: d20RollSpin 1.8s cubic-bezier(0.25, 0.8, 0.25, 1);
  transition: box-shadow 0.3s ease, background 0.3s ease;
}

/* Outcome flourishes — applied to .dice-card after the spin settles. */
.dice-card.outcome-critical_success .d20-visual {
  background: radial-gradient(circle at 30% 30%, #ffd97a, #b8860b);
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.85), 0 0 100px rgba(255, 215, 0, 0.4);
  animation: critSuccessPulse 1.6s ease-out infinite;
}
.dice-card.outcome-critical_failure .d20-visual {
  background: radial-gradient(circle at 30% 30%, #c92a2a, #5a0d0d);
  box-shadow: 0 0 40px rgba(201, 42, 42, 0.7);
  animation: critFailShake 0.6s ease-in-out 3;
}
.dice-card.outcome-critical_success .dice-outcome { color: #ffd97a; text-shadow: 0 0 12px rgba(255, 215, 0, 0.7); }
.dice-card.outcome-critical_failure .dice-outcome { color: #ff6b6b; }
.dice-card.outcome-success .dice-outcome { color: var(--primary-gold); }
.dice-card.outcome-partial_success .dice-outcome { color: #d4a76a; }
.dice-card.outcome-failure .dice-outcome { color: #c8c8cb; }

/* Particle burst on crits */
.dice-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.dice-particles .particle {
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
.dice-particles.crit-success .particle {
  background: radial-gradient(circle, #fff8d0, #d4af37);
  box-shadow: 0 0 8px #ffd97a;
  animation: particleBurstGold 1.2s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.dice-particles.crit-fail .particle {
  background: radial-gradient(circle, #ffb0b0, #c92a2a);
  box-shadow: 0 0 8px #c92a2a;
  animation: particleBurstRed 1.0s ease-out forwards;
}

.dice-formula {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dice-outcome {
  font-size: 1.35rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--primary-gold);
}

/* --- CSS3 Animations --- */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes d20RollSpin {
  0%   { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(0.5); opacity: 0.4; }
  20%  { opacity: 1; }
  60%  { transform: rotateX(900deg) rotateY(540deg) rotateZ(220deg) scale(1.18); }
  85%  { transform: rotateX(1350deg) rotateY(720deg) rotateZ(335deg) scale(1.04); }
  100% { transform: rotateX(1440deg) rotateY(720deg) rotateZ(360deg) scale(1); opacity: 1; }
}

@keyframes critSuccessPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

@keyframes critFailShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px) rotate(-2deg); }
  40%      { transform: translateX(8px) rotate(2deg); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

/* 12 particles spread evenly: each gets a CSS custom property --angle set at
   runtime via inline style, and the keyframe reads it via tan/cos transforms.
   Falls back to a fixed direction if the browser doesn't support custom props
   in keyframes (very rare today). */
@keyframes particleBurstGold {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  15%  { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%)
               rotate(var(--angle, 0deg))
               translateX(140px)
               scale(0.6);
  }
}
@keyframes particleBurstRed {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15%  { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%)
               rotate(var(--angle, 0deg))
               translateX(110px)
               scale(0.4);
  }
}

/* --- GM "is composing" typing indicator --- */
.gm-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(43, 85, 55, 0.04);
  border: 1px solid hsla(43, 85, 55, 0.18);
  border-left: 4px solid var(--primary-gold);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.92rem;
  animation: messageSlideIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.gm-typing .dots { display: inline-flex; gap: 4px; }
.gm-typing .dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary-gold);
  opacity: 0.4;
  animation: typingDot 1.2s ease-in-out infinite;
}
.gm-typing .dots span:nth-child(2) { animation-delay: 0.18s; }
.gm-typing .dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

/* --- Campaign Creator Extras --- */
.w-full {
  width: 100%;
}

.flex-row {
  display: flex;
  gap: 12px;
}

.flex-grow {
  flex: 1;
}

.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.architect-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(145, 80, 45, 0.08);
  border: 1px dashed rgba(145, 80, 45, 0.3);
  border-radius: 8px;
  padding: 10px;
  color: var(--primary-gold);
  font-size: 0.85rem;
  font-weight: 500;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--primary-gold);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* --- Ability Edit Grid and Edit Button --- */
.ability-edit-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  text-align: center;
}

.ability-edit-grid label {
  font-size: 0.7rem;
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.ability-edit-grid input {
  width: 100%;
  padding: 6px;
  text-align: center;
}

.mini-btn {
  font-size: 0.7rem;
  padding: 4px 8px;
  margin-left: 8px;
  border-radius: 4px;
}

/* --- Overworld Map / Grid navigation tabs --- */
.tab-navigation {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(145, 80, 45, 0.18);
  color: var(--primary-gold);
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.tab-btn:hover:not(.active) {
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.04);
}

/* --- Asymmetric Private Whisper bubble --- */
.private-whisper-msg {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.35);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
  border-left: 4px solid var(--primary-gold);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  animation: privateWhisperPulse 2.5s infinite alternate ease-in-out;
}

.private-whisper-msg .msg-header {
  color: var(--primary-gold);
  font-weight: bold;
  font-size: 0.85rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@keyframes privateWhisperPulse {
  0% {
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.08);
    background: rgba(212, 175, 55, 0.06);
  }
  100% {
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.22);
    background: rgba(212, 175, 55, 0.11);
  }
}
