/* Premium CSS Styles for Tethysia Webclient */

/* ── Technical-mode hyperlinks ────────────────────────────────────── */
.game-link {
  text-decoration: underline dotted rgba(6, 182, 212, 0.5);
  color: inherit;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
}
.game-link:hover {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
  text-decoration: underline solid rgba(6, 182, 212, 0.8);
}

/* ── Skill / Ability list ─────────────────────────────────────────── */
.skill-item { padding: 0.3rem 0.4rem; border-radius: 5px; transition: background 0.15s; }
.skill-ready { background: rgba(16, 185, 129, 0.08); border-left: 2px solid #10b981; }
.skill-charging { background: rgba(100, 116, 139, 0.08); border-left: 2px solid #64748b; opacity: 0.65; }
.skill-cost { font-size: 0.75rem; color: var(--text-muted); }

/* ── Shop Modal ───────────────────────────────────────────────────── */
.shop-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center; z-index: 9000;
}
.shop-modal-overlay.hidden { display: none !important; }
.shop-modal-box {
  background: #111827; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 1.2rem 1.4rem; min-width: 320px; max-width: 480px;
  width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.shop-modal-header {
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 0.9rem; font-size: 1.05rem; font-weight: 700; color: #f8fafc;
}
.shop-modal-close {
  margin-left: 0.5rem; background: none; border: none; color: #94a3b8;
  cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.shop-modal-close:hover { color: #f8fafc; }
.shop-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; color: #cbd5e1; }
.shop-table th { text-align: left; padding: 0.3rem 0.4rem; color: #64748b; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.06); }
.shop-table td { padding: 0.4rem 0.4rem; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.shop-barter { font-size: 0.75rem; color: #a8ffb2; display: block; }
.shop-buy-btn, .shop-barter-btn, .shop-claim-btn {
  padding: 0.2rem 0.55rem; border-radius: 4px; border: none;
  cursor: pointer; font-size: 0.78rem; font-weight: 600; margin: 0 2px;
  transition: background 0.15s;
}
.shop-buy-btn { background: #10b981; color: #fff; }
.shop-buy-btn:hover { background: #059669; }
.shop-barter-btn { background: #6366f1; color: #fff; }
.shop-barter-btn:hover { background: #4f46e5; }
.shop-claim-btn { background: #f59e0b; color: #000; }
.shop-claim-btn:hover { background: #d97706; }

:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(17, 24, 39, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --xp-color: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

h1, h2, h3, h4, .char-name, .logo-text, .cyoa-header {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100vw;
  position: relative;
  background-radial: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #09070f 100%);
}

.main-layout-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Header */
.app-header {
  height: 60px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
}

.logo-text {
  font-size: 22px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.controls-panel {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.status-badge.connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Options Dropdown Menu */
.options-container {
  position: relative;
}

.options-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  user-select: none;
}

.options-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.options-btn:focus {
  outline: none;
}

.options-btn.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}

.options-arrow {
  font-size: 8px;
  transition: transform 0.2s ease;
}

.options-btn.active .options-arrow {
  transform: rotate(180deg);
}

.options-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 250px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: optionsFadeIn 0.15s ease-out;
}

@keyframes optionsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.options-menu.hidden {
  display: none !important;
}

/* Format toggle buttons inside dropdown */
.options-menu .toggle-btn {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  flex-direction: row-reverse;
  width: 100%;
  padding: 8px 10px !important;
  border-radius: 8px;
  transition: background 0.2s ease;
  margin: 0;
  cursor: pointer;
  background: transparent;
  border: none;
}

.options-menu .toggle-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.options-menu .toggle-label {
  display: block !important; /* Always show in dropdown */
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.options-divider {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 6px 0;
}

/* Text Size Control */
.text-size-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 10px;
}

.text-size-title {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.text-size-buttons {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
}

.text-size-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  text-align: center;
}

.text-size-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.text-size-btn:focus {
  outline: none;
}

.text-size-btn.active {
  background: var(--accent-cyan);
  color: #0b0f19;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

/* Dynamic Font Sizing for Narrative Log */
.narrative-log {
  font-size: var(--narrative-font-size, 15px) !important;
}

.narrative-entry {
  font-size: 1em !important;
}

.narrative-system {
  font-size: 0.85em !important;
}

.narrative-combat-dice {
  font-size: 0.85em !important;
}

.narrative-debug {
  font-size: 0.8em !important;
}

/* Toggle Switches */
.toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
  user-select: none;
}

.toggle-btn input {
  display: none;
}

.slider {
  position: relative;
  width: 32px;
  height: 18px;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(14px);
}

.toggle-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Main Split Body */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Left Pane: Narrative Flow */
.narrative-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
  gap: 15px;
}

.narrative-log {
  flex: 1;
  overflow-y: auto;
  padding-right: 10px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  /* 'auto' (instant) not 'smooth': the log scrolls to bottom on every appended
     message, and animating that scroll janked during rapid combat/dialogue output. */
  scroll-behavior: auto;
}

/* Custom Scrollbars */
.narrative-log::-webkit-scrollbar, .dashboard-content::-webkit-scrollbar {
  width: 6px;
}
.narrative-log::-webkit-scrollbar-track, .dashboard-content::-webkit-scrollbar-track {
  background: transparent;
}
.narrative-log::-webkit-scrollbar-thumb, .dashboard-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.narrative-log::-webkit-scrollbar-thumb:hover, .dashboard-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Log Entries */
.narrative-entry {
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  line-height: 1.6;
  max-width: 85%;
  align-self: flex-start;
  animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.narrative-system {
  align-self: center;
  max-width: 90%;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-size: 13px;
  text-align: center;
}

.narrative-user {
  align-self: flex-end;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--text-primary);
}

.narrative-combat-dice {
  background: rgba(245, 158, 11, 0.05);
  border-left: 3px solid var(--xp-color);
  font-family: monospace;
  font-size: 13px;
  color: var(--xp-color);
}

.narrative-npc {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent-cyan);
}

/* CYOA Option Cards */
.cyoa-container {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  transition: all 0.3s ease, max-height 0.3s ease, padding 0.3s ease;
  animation: fadeIn 0.4s ease;
}

.cyoa-container.minimized {
  max-height: 44px;
  overflow: hidden;
  padding-top: 10px;
  padding-bottom: 10px;
}

.cyoa-container.minimized .cyoa-options-grid {
  display: none !important;
}

#cyoa-minimize-btn:hover {
  background: rgba(6, 182, 212, 0.1);
  color: #22d3ee;
}

.cyoa-container.hidden {
  display: none !important;
}

.cyoa-header {
  font-size: 14px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cyoa-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.cyoa-card:last-child:nth-child(odd) {
  grid-column: span 2;
}

.cyoa-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  box-sizing: border-box;
  outline: none;
}

.cyoa-card:hover {
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.15);
}

.card-num {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-cyan);
  width: 24px;
  height: 24px;
  background: rgba(6, 182, 212, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

/* Right Pane: Dashboard & Tabs */
.dashboard-pane {
  width: 320px;
  height: 100vh;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.dashboard-tabs {
  height: 60px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
  gap: 6px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.05);
}

.toggle-dashboard-mobile {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  margin-left: auto;
  padding: 8px;
}

.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

#tab-map {
  padding: 12px;
  overflow: hidden;
  display: none;
}

#tab-map.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#visual-map-canvas {
  width: 100%;
  height: 450px;
  min-height: 450px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

/* Floating orientation controls layered over the map canvas (P2). */
.map-canvas-wrap {
  position: relative;
  flex-shrink: 0;
}

.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 5;
}

.map-control-btn {
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(11, 15, 25, 0.82);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.map-control-btn:hover {
  border-color: #06b6d4;
  color: #06b6d4;
}

.map-control-btn.active {
  border-color: #06b6d4;
  color: #06b6d4;
  background: rgba(6, 182, 212, 0.18);
}

/* Visually hidden but available to screen readers (map aria-live mirror). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dash-section {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 16px;
}

.dash-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

/* Player Identity Card */
.player-identity {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
  border: 1px solid rgba(6, 182, 212, 0.15);
}

.char-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.char-sub {
  font-size: 13px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

/* Progress Bars */
.progress-container {
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  height: 18px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar {
  height: 100%;
  width: 0%;
  transition: width 0.4s ease;
}

.xp-bar {
  background: linear-gradient(90deg, var(--xp-color) 0%, #f97316 100%);
}

.hp-bar {
  background: linear-gradient(90deg, #ef4444 0%, #f43f5e 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.progress-label {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Stats Attributes Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-lbl {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-val {
  font-size: 15px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
}

/* Equipment List */
.equip-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.equip-item:last-child {
  border-bottom: none;
}
.equip-lbl {
  color: var(--text-secondary);
}
.equip-val {
  color: var(--text-primary);
  font-weight: 500;
}

/* Quests */
.quest-list {
  list-style: none;
}
.quest-list li {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid var(--accent-purple);
  margin-bottom: 6px;
}
.quest-list li.completed {
  border-left-color: var(--success);
  text-decoration: line-through;
  opacity: 0.6;
}
.empty-quest {
  border-left: none !important;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  background: transparent !important;
}
/* P6 legibility: current step + objective shown inline on each quest row. */
.quest-list li .quest-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.quest-list li .quest-name {
  font-weight: 600;
}
.quest-list li .quest-step {
  font-size: 11px;
  color: var(--accent-cyan);
  white-space: nowrap;
  font-weight: 600;
}
.quest-list li.completed .quest-step {
  color: var(--success);
}
.quest-list li .quest-objective {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
}

/* ---- Status hover tooltips (gear / inventory / quests) ---- */
/* Hoverable rows get a "there's more here" affordance. */
.has-detail {
  cursor: help;
  transition: background 0.15s ease;
}
.equip-item.has-detail:hover,
.equip-item.has-detail:focus-visible,
.quest-list li.has-detail:hover,
.quest-list li.has-detail:focus-visible,
#dash-inventory-list li.has-detail:hover,
#dash-inventory-list li.has-detail:focus-visible {
  background: rgba(255, 255, 255, 0.05);
}
.has-detail:focus-visible {
  outline: 1px solid var(--accent-cyan);
  outline-offset: 1px;
  border-radius: 6px;
}

.status-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 280px;
  min-width: 170px;
  padding: 10px 12px;
  background: rgba(10, 14, 24, 0.97);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;     /* purely informational; never steals the cursor */
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.status-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.status-tooltip .st-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}
.status-tooltip .st-sub {
  font-size: 11px;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}
.status-tooltip .st-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.status-tooltip .st-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.status-tooltip .st-row-lbl {
  color: var(--text-secondary);
  white-space: nowrap;
}
.status-tooltip .st-row-val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}
.status-tooltip .st-desc {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-style: italic;
}
.status-tooltip .st-muted {
  opacity: 0.7;
}
.status-tooltip .st-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}
.status-tooltip .st-badge-done {
  background: rgba(16, 185, 129, 0.18);
  color: var(--success);
}
/* Condition tier colours (4 = pristine … 0 = broken). Declared last so they
   win over the generic .st-row-val colour. */
.status-tooltip .st-cond-4 { color: var(--success); }
.status-tooltip .st-cond-3 { color: #a3e635; }
.status-tooltip .st-cond-2 { color: var(--xp-color); }
.status-tooltip .st-cond-1 { color: #fb923c; }
.status-tooltip .st-cond-0 { color: var(--danger); }

/* Mobile Dashboard Trigger */
.mobile-dash-trigger {
  display: none;
  position: absolute;
  right: 20px;
  bottom: 85px;
  z-index: 50;
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  cursor: pointer;
}

/* Bottom Footer (Input) */
.app-footer {
  padding: 16px 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  z-index: 90;
}

.controls-row {
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

/* Voice Input Microphone Button */
.mic-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mic-button svg {
  width: 22px;
  height: 22px;
  fill: var(--text-secondary);
  transition: fill 0.3s;
  z-index: 2;
}

.mic-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.mic-button.listening {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.6);
}

.mic-button.listening svg {
  fill: #000;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent-cyan);
  opacity: 0;
  z-index: 1;
}

.mic-button.listening .pulse-ring {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Command Field Input */
#inputfield {
  flex: 1;
  height: 48px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 24px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: all 0.3s;
}

#inputfield:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

/* Send Button */
.send-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  transition: all 0.2s;
}

.send-button svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  transform: translate(2px, 0);
}

.send-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
}

.send-button:active {
  transform: scale(0.95);
}

/* Fade In animation */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .dashboard-pane {
    position: absolute;
    right: -320px;
    top: 50px;
    bottom: 0;
    height: calc(100vh - 50px);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  }

  .dashboard-pane.active {
    right: 0;
  }

  .toggle-dashboard-mobile {
    display: block;
  }

  .mobile-dash-trigger {
    display: block;
  }

  .narrative-pane {
    padding: 16px;
  }

  .narrative-entry {
    max-width: 95%;
  }

  .controls-panel {
    gap: 10px;
  }

  .toggle-label {
    display: none; /* Hide labels on mobile to save space */
  }
}

/* Inline Debug entries in the narrative log */
.narrative-debug {
  background: rgba(30, 41, 59, 0.4);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  color: #fbbf24; /* Muted amber */
  padding: 8px 12px;
  border-radius: 4px;
  margin-top: 4px;
  margin-bottom: 4px;
  align-self: flex-start;
  max-width: 90%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(234, 179, 8, 0.2);
  border-left: 3px solid #eab308;
}

.narrative-debug .debug-tag {
  color: #a855f7; /* purple tag */
  font-weight: bold;
  margin-right: 6px;
}

/* Tab button hidden class */
.tab-btn.hidden {
  display: none !important;
}

/* Testing Tab panel layout */
.testing-log-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px 0;
}

.testing-log-entry {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 6px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
}

.testing-log-entry .log-time {
  color: var(--text-muted);
  font-size: 10px;
  display: block;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 2px;
}

.testing-log-entry .log-type {
  font-weight: bold;
  text-transform: uppercase;
}

.testing-log-entry.intake .log-type {
  color: var(--accent-cyan);
}

.testing-log-entry.combat-eval .log-type {
  color: var(--accent-purple);
}

.testing-log-entry.combat-rolls .log-type {
  color: var(--success);
}

.testing-log-entry.api-log .log-type {
  color: var(--xp-color);
}

.testing-log-entry.api-log-pending .log-type {
  color: #ffb020;
  animation: pulse-pending 2s infinite;
}

@keyframes pulse-pending {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.testing-log-entry .log-details {
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-top: 4px;
}

.empty-testing {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Session API Cost widget (Testing tab) */
.testing-cost-widget .cost-headline {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--success);
  margin: 4px 0 8px;
  line-height: 1;
}

.testing-cost-widget .cost-breakdown {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.testing-cost-widget .cost-breakdown strong {
  color: var(--text-primary);
}

.testing-cost-widget .cost-lastcall {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'Consolas', 'Courier New', monospace;
}

.cost-est-badge {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
}

.testing-log-entry.api-cost .log-type {
  color: var(--success);
}

/* Per-kind breakdown line (in-game Testing cost widget). Reserves space for
   future kinds like image generation; rows appear as each kind reports cost. */
.testing-cost-widget .cost-bykind {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.testing-cost-widget .cost-bykind .ck-pending {
  color: var(--text-muted);
  font-style: italic;
}

/* World-gen wizard cost readout (dev tooling; gated to Testing mode below). */
.wg-cost-readout {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.wg-cost-readout .wg-cost-label {
  font-weight: 700;
  color: var(--text-primary);
}

.wg-cost-readout .wg-cost-est {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

.wg-cost-readout .wg-cost-total {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--success);
}

.wg-cost-readout .wg-cost-breakdown {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: 'Consolas', 'Courier New', monospace;
}

.wg-cost-readout .wg-cost-kind-pending {
  color: var(--text-muted);
  font-style: italic;
}

/* Both cost readouts are dev tooling: only show when Testing mode is active. */
body:not(.testing-active) #wg-cost-readout {
  display: none;
}

/* Global testing toggle display rule */
body:not(.testing-active) .narrative-debug {
  display: none !important;
}

/* Thinking Indicator Spinner & Latency Styles */
.logo-dot.thinking {
  background: var(--xp-color) !important;
  box-shadow: 0 0 15px var(--xp-color) !important;
  animation: pulse-thinking 1s infinite alternate;
}

@keyframes pulse-thinking {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 1; }
}

.thinking-inactive {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* Voice-to-Text Correction UI elements */
.corrected-marker {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  margin-right: 4px;
}

.original-whisper {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9em;
  margin-left: 8px;
}

/* Mobile and Android Responsive Optimization Rules */
@media (max-width: 768px) {
  /* Prevent browser focus auto-zoom on mobile inputs */
  #inputfield {
    font-size: 16px !important;
  }
  
  /* Make the header more compact on mobile */
  .app-header {
    height: 50px;
    padding: 0 12px;
  }
  .logo-text {
    font-size: 18px;
  }
  .controls-panel {
    gap: 8px;
  }
  .status-badge {
    font-size: 9px;
    padding: 2px 6px;
  }
  .toggle-btn {
    padding: 4px 6px;
  }
  
  /* Make narrative text readable and adjust heights dynamically */
  .narrative-pane {
    padding: 12px;
    height: calc(100vh - 50px - 76px); 
  }
  .narrative-entry {
    max-width: 100%;
    margin-bottom: 8px;
  }
  .narrative-body {
    font-size: inherit;
    line-height: 1.5;
  }
  
  /* Style the footer input bar for ease of thumb reach */
  .app-footer {
    padding: 10px 12px;
  }
  .controls-row {
    gap: 8px;
  }
  .mic-button, .send-button {
    width: 44px;
    height: 44px;
  }
  
  /* Stack CYOA choices beautifully on mobile */
  .cyoa-container {
    padding: 8px 12px;
    margin-top: 8px;
  }
  .cyoa-container.minimized {
    max-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .cyoa-options-grid {
    grid-template-columns: repeat(2, 1fr); /* Compact 2-column layout on mobile */
    gap: 6px;
  }
  .cyoa-card {
    padding: 8px 10px;
    font-size: 12px;
  }
  
  /* Adjust visual map height to fit tab nicely */
  #visual-map-canvas {
    height: 300px !important;
  }
  
  /* Highlighted body styles for Android mode */
  body.android-browser-mode {
    font-size: 14px;
  }
  
  /* Floating trigger button style for mobile status */
  .mobile-dash-trigger {
    bottom: 86px; /* Position right above input footer */
    right: 12px;
    padding: 10px 16px;
    font-size: 13px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent-purple) 0%, #6d28d9 100%);
    box-shadow: 0 4px 15px rgba(109, 40, 217, 0.4);
    border: none;
    z-index: 80;
  }
}

/* Secure context warning banner */
.secure-warning {
  display: flex;
  gap: 15px;
  background: rgba(245, 158, 11, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-left: 4px solid var(--xp-color);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  position: relative;
  animation: fadeIn 0.4s ease-out;
  color: var(--text-primary);
}

.secure-warning.hidden {
  display: none !important;
}

.warning-icon {
  font-size: 24px;
  align-self: flex-start;
}

.warning-body {
  flex: 1;
}

.warning-body strong {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  color: var(--xp-color);
  display: block;
  margin-bottom: 6px;
}

.warning-body p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

.warning-steps {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.warning-steps ol {
  margin: 0;
  padding-left: 20px;
}

.warning-steps li {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.warning-steps li:last-child {
  margin-bottom: 0;
}

.warning-steps code {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.close-warning-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  position: absolute;
  top: 10px;
  right: 12px;
  transition: color 0.2s;
}

.close-warning-btn:hover {
  color: var(--danger);
}

/* ==========================================================================
   World Generation Wizard Styles
   ========================================================================== */
.wg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 30, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.4s ease-out;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
}

.wg-overlay.fading {
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.wg-wizard-card {
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  background: linear-gradient(135deg, rgba(20, 30, 55, 0.85) 0%, rgba(10, 15, 30, 0.95) 100%);
  border: 1px solid rgba(6, 182, 212, 0.25);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 24px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* Progress Indicator */
.wg-progress-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 30px;
}

.wg-progress-dot {
  width: 32px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wg-progress-dot.active {
  background: var(--accent-cyan);
  width: 48px;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
}

.wg-progress-dot.completed {
  background: var(--accent-purple);
}

/* Steps */
.wg-step {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
}

.wg-step.active {
  display: flex;
  animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.wg-step h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wg-step-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Forms */
.wg-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.wg-form-group label {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
}

.wg-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.wg-wizard-card input[type="text"],
.wg-wizard-card select,
.wg-wizard-card textarea {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 18px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all 0.3s;
  outline: none;
}

.wg-wizard-card input[type="text"]:focus,
.wg-wizard-card select:focus,
.wg-wizard-card textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.2);
  background: rgba(0, 0, 0, 0.6);
}

.wg-wizard-card select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394a3b8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
}

.wg-wizard-card input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  margin: 15px 0;
}

.wg-wizard-card input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-cyan);
  transition: transform 0.1s;
}

.wg-wizard-card input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Buttons */
.wg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.wg-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wg-btn-primary {
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.wg-btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.wg-btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.wg-btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.wg-btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.wg-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Loader */
.wg-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 0;
}

.wg-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(6, 182, 212, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-cyan);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 24px;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.2);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.wg-error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 16px;
  color: #fca5a5;
  font-family: monospace;
  font-size: 13px;
  margin-top: 15px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* Review Tree Layout */
.wg-review-tree {
  flex: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Tree Nodes */
.wg-world-node {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wg-world-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 18px;
}

.wg-world-globe {
  font-size: 20px;
}

.wg-world-descriptors {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: auto;
}

.wg-world-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Sections */
.wg-tree-section {
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  overflow: hidden;
  transition: all 0.3s;
  flex-shrink: 0;
}

.wg-section-header {
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  display: flex;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
}

.wg-section-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.wg-section-icon {
  margin-right: 8px;
  font-size: 16px;
}

.wg-badge {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 8px;
  color: var(--text-secondary);
}

/* Zone Nodes */
.wg-zone-node {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.3s;
}

.wg-zone-header {
  padding: 12px 18px 12px 36px;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.wg-zone-header:hover {
  background: rgba(255, 255, 255, 0.01);
}

.wg-collapse-icon {
  position: absolute;
  left: 18px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.wg-zone-node.collapsed .wg-collapse-icon {
  transform: rotate(-90deg);
}

.wg-zone-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-right: 12px;
}

.wg-zone-desc-short {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.wg-zone-body {
  padding: 10px 18px 18px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}

.wg-zone-node.collapsed .wg-zone-body {
  display: none;
}

/* Room Nodes */
.wg-room-node {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wg-room-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wg-room-icon {
  font-size: 14px;
}

.wg-room-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--accent-cyan);
}

.wg-room-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* VIPs & Items */
.wg-vip-group, .wg-item-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
}

.wg-vip, .wg-item {
  display: flex;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px 12px;
  align-items: flex-start;
  gap: 10px;
}

.wg-vip.enemy {
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.02);
}

.wg-vip.friendly {
  border-left: 3px solid var(--accent-cyan);
}

.wg-vip-icon, .wg-item-icon {
  font-size: 14px;
  margin-top: 2px;
}

.wg-vip-info, .wg-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wg-vip-name, .wg-item-name {
  font-weight: 600;
  font-size: 13px;
}

.wg-vip-desc, .wg-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.wg-vip-accent {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.wg-vip-stats {
  font-size: 11px;
  color: #fca5a5;
  font-weight: 500;
}

/* Traps */
.wg-trap-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
}

.wg-trap {
  display: flex;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px 12px;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid #f59e0b;
  background: rgba(245, 158, 11, 0.02);
}

.wg-trap-icon {
  font-size: 14px;
  margin-top: 2px;
}

.wg-trap-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wg-trap-name {
  font-weight: 600;
  font-size: 13px;
  color: #fbbf24;
}

.wg-trap-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.wg-trap-details {
  font-size: 11px;
  color: var(--text-muted);
}

/* Challenges */
.wg-challenge-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
}

.wg-challenge {
  display: flex;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px 12px;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid #a855f7;
  background: rgba(168, 85, 247, 0.02);
}

.wg-challenge-icon {
  font-size: 14px;
  margin-top: 2px;
}

.wg-challenge-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wg-challenge-name {
  font-weight: 600;
  font-size: 13px;
  color: #c084fc;
}

.wg-challenge-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.wg-challenge-details {
  font-size: 11px;
  color: var(--text-muted);
}

/* Note/Revision Rows */
.wg-note-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

.wg-check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.wg-check-text {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.wg-regen-check:checked ~ .wg-check-text {
  color: var(--accent-cyan);
}

.wg-note-input {
  width: 100%;
  font-size: 12px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  margin-top: 4px;
  resize: vertical;
}

/* Quests & Lore Nodes */
.wg-quest-node, .wg-lore-node {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.wg-quest-node:last-child, .wg-lore-node:last-child {
  border-bottom: none;
}

.wg-quest-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.wg-quest-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-cyan);
}

.wg-quest-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.wg-quest-steps {
  margin: 8px 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}

.wg-quest-steps li {
  margin-bottom: 4px;
}

.wg-lore-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-purple);
  margin-bottom: 6px;
}

.wg-lore-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Tree Section Collapsed State */
.wg-tree-section.collapsed .wg-zone-node,
.wg-tree-section.collapsed .wg-quest-node,
.wg-tree-section.collapsed .wg-lore-node {
  display: none;
}

.wg-tree-section.collapsed {
  background: transparent;
}

@media (max-width: 768px) {
  .wg-wizard-card {
    padding: 24px;
    max-height: 95vh;
  }
  .wg-step h2 {
    font-size: 22px;
  }
  .wg-form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .wg-review-split {
    flex-direction: column;
    overflow-y: auto;
  }
  .wg-review-right {
    min-height: 350px;
  }
}

/* Review Split Panel */
.wg-review-split {
  display: flex;
  gap: 24px;
  flex: 1;
  overflow: hidden;
  margin-bottom: 20px;
  min-height: 400px;
}

.wg-review-left {
  flex: 4.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wg-review-right {
  flex: 5.5;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  overflow: hidden;
}

.wg-map-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  flex-shrink: 0;
}

.wg-map-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wg-map-tab:hover {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--text-primary);
}

.wg-map-tab.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #0f172a;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.wg-map-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wg-map-view.active {
  display: flex;
}

.wg-wizard-map-canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 300px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.wg-map-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.wg-map-controls select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
}

/* Make wizard card wider when in Step 4 */
.wg-wizard-card {
  max-width: 800px;
  transition: max-width 0.4s ease;
}

.wg-overlay:has(#wg-step-4.active) .wg-wizard-card {
  max-width: 1100px;
}

/* Pulse animation for continuous mic */
#mic-btn.listening {
  animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Character Generation Wizard Styles */
.cg-portrait-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.cg-portrait-option {
  font-size: 32px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.cg-portrait-option:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.35);
  transform: translateY(-2px);
}

.cg-portrait-option.active {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.cg-class-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 10px;
}

.cg-class-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cg-class-card:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.35);
  transform: translateY(-2px);
}

.cg-class-card.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.cg-class-card .class-icon {
  font-size: 28px;
}

.cg-class-card .class-name {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.cg-class-card .class-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.cg-stat-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.points-left-container {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(6, 182, 212, 0.15);
  font-size: 14px;
}

.points-counter {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: var(--accent-cyan);
  font-size: 16px;
  transition: all 0.2s ease;
}

.points-counter.empty {
  color: #ef4444;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.cg-stats-buy-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.cg-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 10px 16px;
}

.cg-stat-row .stat-info {
  flex: 2;
}

.cg-stat-row .stat-name {
  font-weight: 700;
  color: var(--text-primary);
}

.cg-stat-row .stat-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.cg-stat-row .stat-controls {
  flex: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.cg-stat-row .stat-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.cg-stat-row .stat-btn:hover:not(:disabled) {
  background: var(--accent-cyan);
  color: var(--bg-color);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.cg-stat-row .stat-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.05);
}

.cg-stat-row .stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  width: 24px;
  text-align: center;
  color: var(--text-primary);
}

.cg-stat-row .stat-mod {
  flex: 1;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}

.cg-stat-row .mod-value {
  font-weight: 700;
  color: var(--accent-purple);
}

.cg-review-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.cg-sheet-card {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.cg-sheet-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.cg-sheet-portrait {
  font-size: 40px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  padding: 8px;
}

.cg-sheet-title h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.cg-sheet-subtitle {
  font-size: 13px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.cg-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cg-sheet-section {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 12px;
}

.cg-sheet-section:last-child {
  border: none;
  padding: 0;
}

.cg-sheet-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-top: 0;
  margin-bottom: 8px;
}

.cg-sheet-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  font-size: 13px;
}

.cg-sheet-derived-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  font-size: 14px;
}

.cg-sheet-section p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.backstory-text {
  font-style: italic;
  line-height: 1.4;
}

/* ── Chargen portrait mode tabs ─────────────────────────────────────────── */
.cg-portrait-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cg-mode-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.4);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.cg-mode-tab input[type="radio"] {
  display: none;
}

.cg-mode-tab:hover {
  border-color: rgba(6, 182, 212, 0.35);
  color: var(--text-primary);
}

.cg-mode-tab.active {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.cg-portrait-panel {
  margin-bottom: 10px;
}

/* AI portrait placeholder: silhouette SVG stacked above the info text */
.cg-ai-portrait-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cg-ai-silhouette {
  width: 96px;
  height: 128px;
  border-radius: 10px;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.cg-ai-silhouette:hover {
  opacity: 1;
}

.cg-portrait-info {
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.15);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
  line-height: 1.5;
}

.cg-portrait-drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 90px;
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.3);
  cursor: pointer;
  padding: 14px 20px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.cg-portrait-drop-area:hover,
.cg-portrait-drop-area.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.06);
}

.cg-portrait-drop-area.has-image {
  border-style: solid;
  border-color: rgba(6, 182, 212, 0.4);
}

#cg-portrait-drop-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.cg-portrait-preview-thumb {
  max-width: 160px;
  max-height: 112px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.cg-artist-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 0 0;
  padding: 0;
  font-style: italic;
  line-height: 1.4;
}

/* Review portrait: supports both emoji and image */
.cg-review-portrait-img {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

/* ── Worldgen review tree: upload + export controls ─────────────────────── */
.wg-artist-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.wg-artist-banner-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
}

.wg-export-btn {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.12);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.wg-export-btn:hover {
  background: rgba(139, 92, 246, 0.25);
  color: var(--text-primary);
  border-color: rgba(139, 92, 246, 0.6);
}

.wg-upload-img-btn {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px dashed rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.wg-upload-img-btn:hover {
  background: rgba(6, 182, 212, 0.12);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.wg-upload-img-btn.wg-upload-img-done {
  border-style: solid;
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.08);
  color: #34d399;
}

/* Warning Pill */
.warning-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 8px 16px;
  border-radius: 20px;
  margin-bottom: 12px;
  color: var(--danger);
  font-size: 13px;
  backdrop-filter: blur(8px);
  animation: fadeInDown 0.3s ease-out;
  justify-content: space-between;
  width: 100%;
}
.warning-pill-icon {
  font-size: 16px;
}
.warning-pill-text {
  flex: 1;
}
.close-pill-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
  transition: color 0.2s;
}
.close-pill-btn:hover {
  color: var(--danger);
}
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Manual Editor Modal & Controls */
.wg-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.wg-modal-card {
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(6, 182, 212, 0.15);
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.wg-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.wg-modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.wg-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.2s;
}

.wg-modal-close:hover {
  color: var(--text-primary);
}

.wg-modal-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.wg-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
  flex-shrink: 0;
}

.wg-edit-btn, .wg-delete-btn, .wg-add-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  gap: 4px;
  transition: all 0.2s;
  user-select: none;
}

.wg-edit-btn:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

.wg-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.wg-add-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

/* Modal field groups */
.wg-modal-body .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.wg-modal-body .form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 2px;
}

.wg-modal-body .form-group input[type="text"],
.wg-modal-body .form-group input[type="number"],
.wg-modal-body .form-group select,
.wg-modal-body .form-group textarea {
  background: rgba(0, 0, 0, 0.25) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  color: #ffffff !important;
  font-size: 0.85rem !important;
  font-family: inherit !important;
  width: 100% !important;
  box-sizing: border-box !important;
  outline: none !important;
}

.wg-modal-body .form-group input:focus,
.wg-modal-body .form-group select:focus,
.wg-modal-body .form-group textarea:focus {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.2) !important;
}

.wg-modal-body .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ==========================================================================
   Progress Bar & Tidbits inside Loading Screens
   ========================================================================== */
.wg-progress-wrapper {
  width: 80%;
  max-width: 400px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  margin: 15px 0 8px 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.wg-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
  transition: width 0.4s cubic-bezier(0.1, 0.8, 0.25, 1);
}

.wg-progress-percent {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 20px;
}

.wg-loading-tidbit {
  width: 100%;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 14px 20px;
  margin-top: 10px;
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
}

.wg-loading-tidbit .tidbit-label {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-purple);
}

.wg-loading-tidbit .tidbit-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  transition: opacity 0.3s ease-in-out;
}

/* Modal Loader Overlay for Revision */
.wg-modal-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 30, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

.wg-modal-loader-card {
  width: 90%;
  max-width: 500px;
  background: linear-gradient(135deg, rgba(20, 30, 55, 0.9) 0%, rgba(10, 15, 30, 0.98) 100%);
  border: 1px solid rgba(6, 182, 212, 0.25);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  border-radius: 20px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
}

.wg-modal-loader-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 10px 0;
  color: var(--text-primary);
}

/* Full Screen Initial Connection Loader */
.game-connect-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 10, 20, 1);
  background-image: radial-gradient(circle at center, rgba(109, 40, 217, 0.15) 0%, rgba(8, 10, 20, 0) 70%);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out;
}

.game-connect-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 90%;
  max-width: 450px;
  animation: fadeIn 0.5s ease-out;
}

.game-connect-loader-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, white 40%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-connect-status-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Vis.js Manipulation Toolbar Styling */
.vis-manipulation {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-top: none !important;
  border-bottom-left-radius: 12px !important;
  border-bottom-right-radius: 12px !important;
  height: auto !important;
  padding: 8px 16px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
  justify-content: flex-start !important;
  box-sizing: border-box !important;
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
}

.vis-edit-mode {
  border-radius: 12px 12px 0 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.vis-manipulation .vis-button {
  background: rgba(255, 255, 255, 0.04) !important;
  background-image: none !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 6px !important;
  color: var(--text-secondary) !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 6px 12px !important;
  height: auto !important;
  line-height: 1.4 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.vis-manipulation .vis-button .vis-label {
  display: inline !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: inherit !important;
}

.vis-manipulation .vis-button:hover {
  background: rgba(139, 92, 246, 0.15) !important;
  border-color: rgba(139, 92, 246, 0.4) !important;
  color: #c4b5fd !important;
}

.vis-manipulation .vis-button.vis-active {
  background: rgba(139, 92, 246, 0.25) !important;
  border-color: var(--accent-purple) !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3) !important;
}

.vis-manipulation .vis-text {
  font-family: 'Inter', sans-serif !important;
  font-size: 11px !important;
  color: var(--text-muted) !important;
  margin: 0 8px !important;
  line-height: 1.4 !important;
  display: inline-block !important;
}

.vis-manipulation .vis-close {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted) !important;
  font-size: 14px !important;
  cursor: pointer !important;
  padding: 4px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-image: none !important;
}

.vis-manipulation .vis-close:hover {
  color: var(--text-primary) !important;
}

.vis-manipulation .vis-button.vis-delete:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
}

/* Options Collapsible Accordions */
.options-menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.options-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.options-section-header:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(6, 182, 212, 0.2);
}

.options-section-header.active {
  background: rgba(6, 182, 212, 0.08);
  border-color: var(--accent-cyan);
}

.options-section-header .section-arrow {
  font-size: 8px;
  transition: transform 0.2s ease;
}

.options-section-header.collapsed .section-arrow {
  transform: rotate(-90deg);
}

.options-section-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 6px 0 6px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.options-section-content.collapsed {
  display: none !important;
}

/* Choices Tab Grid & Cards */
.cyoa-tab-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 0;
}

.cyoa-tab-card {
  display: flex !important;
  align-items: center !important;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  color: var(--text-primary) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  width: 100% !important;
  margin: 0 !important;
  user-select: none !important;
}

.cyoa-tab-card:hover {
  background: rgba(139, 92, 246, 0.1) !important;
  border-color: rgba(139, 92, 246, 0.25) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.cyoa-tab-card .card-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.cyoa-tab-card .card-text {
  flex: 1;
  line-height: 1.4;
}

/* CYOA Refresh Button */
.cyoa-refresh-btn {
  transition: all 0.2s ease;
}

.cyoa-refresh-btn:hover {
  background: rgba(6, 182, 212, 0.1) !important;
  border-color: rgba(6, 182, 212, 0.3) !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.2);
}

.cyoa-refresh-btn:active {
  transform: scale(0.95);
}

.cyoa-refresh-btn.cooldown {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-muted) !important;
}

/* CYOA Choice Hover Expansion Styles */
.cyoa-card, .cyoa-tab-card {
  align-items: flex-start !important;
}

.card-text-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-short-text {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text-primary);
}

.card-long-text {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.cyoa-card:hover .card-long-text,
.cyoa-tab-card:hover .card-long-text {
  max-height: 150px;
  opacity: 1;
  margin-top: 4px;
}

.cyoa-tab-card .card-short-text {
  font-size: 13px !important;
}

.cyoa-tab-card .card-long-text {
  font-size: 11px !important;
}

/* ── Scene banner (Phase 2: room art above the narrative log) ─────── */
.scene-banner {
  width: 100%;
  max-height: 220px;
  overflow: hidden;
  flex-shrink: 0;
  background: #0a0f1e;
}
.scene-banner-fade {
  animation: scene-banner-crossfade 0.6s ease forwards;
}
@keyframes scene-banner-crossfade {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
.scene-banner-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0));
}

/* ── Top-down baked zone map + walking token (world_map_rendering.md) ── */
.zone-map-view { width: 100%; margin-bottom: 8px; }
.zone-map-frame {
  position: relative;
  width: 100%;
  line-height: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #0a0f1e;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
.zone-map-img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;            /* crisp pixel-art scaling */
}
.zone-map-overlay, .zone-map-hotspots { position: absolute; inset: 0; }
.zone-map-hotspot {
  position: absolute;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  cursor: pointer;
}
.zone-map-hotspot:not(.is-current):hover {
  background: rgba(255,255,255,0.16);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45);
}
.zone-map-hotspot:focus-visible { outline: 2px solid #8fd0ff; outline-offset: 2px; }
.zone-map-hotspot.is-current { box-shadow: 0 0 0 3px rgba(120,200,255,0.85); }
.zone-map-hotspot.is-hostile::after {
  content: ''; position: absolute; right: 3px; top: 3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff5a5a; box-shadow: 0 0 4px #ff5a5a;
}
.zone-map-token {
  position: absolute;
  width: 18px; height: 18px;
  transform: translate(-50%, -60%);
  background: #ffe08a;
  border: 2px solid #20242c;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 3;
  pointer-events: none;
  /* tween along the edge on a move (choppy retro slide) + 2-frame jRPG idle bounce */
  transition: left 0.5s steps(6), top 0.5s steps(6);
  animation: zmBounce 0.6s steps(2) infinite;
}
@keyframes zmBounce { 0%, 100% { margin-top: 0; } 50% { margin-top: -5px; } }
.zone-map-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px; }
.zone-map-title { font-size: 0.85em; font-weight: 600; color: #cdd6e6; }
@media (prefers-reduced-motion: reduce) {
  .zone-map-token { animation: none; transition: none; }
}

/* ── Generated images (in-log portraits — NPC / character) ────────── */
.narrative-entry.generated-image {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}
.generated-image-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.generated-image-npc .generated-image-img,
.generated-image-character .generated-image-img { max-width: 220px; }

/* ── Status-tab context image (rotates: room / npc / character) ─────── */
.status-image-block {
  width: 100%;
  position: relative;
  background: #0a0f1e;
  overflow: hidden;
  border-radius: 0 0 8px 8px;
  margin-bottom: 2px;
  flex-shrink: 0;
}
.status-image-fade {
  animation: status-img-fadein 0.5s ease forwards;
}
@keyframes status-img-fadein {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
.status-context-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: center 25%;
  display: block;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 55%, rgba(0,0,0,0));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 55%, rgba(0,0,0,0));
}
.status-image-label {
  position: absolute;
  bottom: 6px;
  left: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  letter-spacing: 0.03em;
  pointer-events: none;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}



