/* Core CSS Variables and Stylesheet for AI Simulator Platform */
:root {
  --font-primary: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Core Color System (Aesthetic Dark Theme) */
  --bg-primary: #0a0813;
  --bg-secondary: rgba(20, 17, 34, 0.5);
  --bg-tertiary: rgba(30, 26, 51, 0.85);
  --text-main: #f1effb;
  --text-muted: #a6a1c2;
  --border-color: rgba(255, 255, 255, 0.09);
  
  /* Neon Accent Categories */
  --accent-neon: #a855f7; /* Primary Brand Purple */
  --color-survival: #22c55e; /* Green */
  --color-workplace: #0ea5e9; /* Sky Blue */
  --color-romance: #ec4899; /* Deep Pink */
  --color-pr: #f97316; /* Orange */
  --color-suspense: #ef4444; /* Red */
  --color-detective: #3b82f6; /* Blue */
  --color-ceo: #8b5cf6; /* Indigo */
  
  /* Glassmorphism Token */
  --glass-bg: rgba(14, 11, 26, 0.6);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --glass-blur: blur(16px);
}

/* Reset and Globals */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  background-image: radial-gradient(circle at 50% 0%, #17112d 0%, #0a0813 100%);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Background Ambient Orbs */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.15;
}
.orb-1 {
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, #a855f7 0%, transparent 70%);
  top: -10vw;
  left: -10vw;
  animation: float 25s infinite alternate ease-in-out;
}
.orb-2 {
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, #ec4899 0%, transparent 70%);
  bottom: -15vw;
  right: -10vw;
  animation: float 30s infinite alternate-reverse ease-in-out;
}
.orb-3 {
  width: 35vw;
  height: 35vw;
  background: radial-gradient(circle, #0ea5e9 0%, transparent 70%);
  top: 30vh;
  left: 30vw;
  animation: float 20s infinite alternate ease-in-out;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(5vw, 5vh) scale(1.1); }
}

/* Premium Layout Elements */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(10, 8, 19, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-main);
}
.logo-accent {
  background: linear-gradient(135deg, #d8b4fe 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-right: 4px;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-btn svg {
  transition: transform 0.3s;
}
.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}
.nav-btn.active {
  color: var(--text-main);
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.25);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.1);
}
.nav-btn.active svg {
  transform: scale(1.1);
}

.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
  z-index: 10;
  min-height: calc(100vh - 75px);
}

/* Panel transitions */
.view-panel {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}
.view-panel.active {
  display: block;
}

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

/* Glassmorphism Box Utilities */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
  padding: 1.5rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

/* Badge System */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.category-badge {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.25);
}
.turns-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.rating-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ================= EXPLORE SCREEN STYLES ================= */
.hero-section {
  text-align: center;
  padding: 4rem 1rem;
  max-width: 800px;
  margin: 0 auto;
}
.hero-section h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #ffffff 30%, #a6a1c2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}
.hero-section p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.search-bar-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}
.search-bar-container input {
  width: 100%;
  padding: 1rem 1.5rem 1rem 3.5rem;
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  background: rgba(18, 14, 32, 0.7);
  color: var(--text-main);
  font-size: 1.05rem;
  outline: none;
  backdrop-filter: blur(8px);
  transition: all 0.3s;
}
.search-bar-container input:focus {
  border-color: var(--accent-neon);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.2);
  background: rgba(24, 18, 41, 0.9);
}
.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.category-tabs-wrapper {
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
}
.category-tabs {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  width: max-content;
  margin: 0 auto;
  padding: 0 1rem;
}
.category-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s;
  white-space: nowrap;
}
.category-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}
.category-btn.active {
  background: var(--text-main);
  color: var(--bg-primary);
  border-color: var(--text-main);
  font-weight: 600;
}

/* Simulators Grid */
.simulators-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}
.simulator-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.simulator-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  transform: translateY(-4px);
}
.sim-card-cover-area {
  position: relative;
  width: 100%;
  height: 160px;
  background-size: cover;
  background-position: center;
  background-color: rgba(30, 24, 48, 0.7);
  border-radius: 12px;
  margin-bottom: 1rem;
  overflow: hidden;
}
.sim-card-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 8, 19, 0.95) 0%, rgba(10, 8, 19, 0) 100%);
  display: flex;
  align-items: flex-end;
  padding: 0.75rem;
}
.simulator-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
.simulator-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sim-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 0.75rem;
}
.sim-plays {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Accent Card Borders based on category */
.simulator-card[data-cat="infinite_survival"] { --cat-color: var(--color-survival); }
.simulator-card[data-cat="workplace"] { --cat-color: var(--color-workplace); }
.simulator-card[data-cat="romance_shuraba"] { --cat-color: var(--color-romance); }
.simulator-card[data-cat="survival"] { --cat-color: var(--color-pr); }
.simulator-card[data-cat="detective"] { --cat-color: var(--color-detective); }
.simulator-card[data-cat="ugc"] { --cat-color: var(--accent-neon); }

.simulator-card:hover {
  border-color: rgba(var(--cat-color), 0.3) !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(var(--cat-color), 0.05);
}

/* ================= PLAY SCREEN SPLIT LAYOUT ================= */
.play-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 120px);
  min-height: 500px;
}

/* Sidebar Styling */
.state-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100%;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.sidebar-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.sidebar-meta {
  display: flex;
  gap: 0.5rem;
}

.state-group {
  background: rgba(14, 11, 26, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1rem;
}
.state-group h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
  border-left: 3px solid var(--accent-neon);
  padding-left: 0.5rem;
}

.player-info-card p {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Dynamic State Bars */
.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.metric-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.metric-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}
.metric-bar-outer {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.metric-bar-inner {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.1, 0.8, 0.3, 1);
  background: var(--accent-neon);
}

/* Relations List */
.relations-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.relation-row {
  display: grid;
  grid-template-columns: 80px 1fr 35px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.relation-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.relation-score {
  text-align: right;
  font-weight: 600;
  font-family: monospace;
}

/* Inline Tabs Group in Sidebar */
.state-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 0.75rem;
}
.state-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  flex-grow: 1;
  padding: 0.4rem 0.2rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}
.state-tab-btn:hover {
  color: var(--text-main);
}
.state-tab-btn.active {
  color: var(--text-main);
  border-color: var(--accent-neon);
  font-weight: 600;
}
.state-tab-panel {
  display: none;
  height: 120px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease-out;
}
.state-tab-panel.active {
  display: block;
}

/* Clues List */
.clues-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.clues-list li {
  font-size: 0.85rem;
  background: rgba(14, 165, 233, 0.08);
  border-left: 2px solid var(--color-workplace);
  padding: 0.35rem 0.6rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.4;
}

/* Inventory Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 0.5rem;
}
.inventory-item {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  position: relative;
  cursor: pointer;
}
.inventory-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
}

/* Tasks List */
.tasks-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tasks-list li {
  font-size: 0.85rem;
  background: rgba(249, 115, 22, 0.08);
  border-left: 2px solid var(--color-pr);
  padding: 0.35rem 0.6rem;
  border-radius: 0 6px 6px 0;
  line-height: 1.4;
}

/* Sidebar Actions */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}
.action-btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s;
}
.action-btn-outline:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.3);
}

.action-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s;
}
.action-btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

/* Theater Screen (Chat History Timeline) */
.theater-screen {
  background: rgba(14, 11, 26, 0.45);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  box-shadow: var(--glass-shadow);
}
.narrative-history {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Timeline Message Elements */
.msg-container {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: slideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

/* Narrator Message */
.msg-narrator {
  align-self: center;
  max-width: 95%;
  text-align: center;
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  border-left: none;
  background: transparent;
  padding: 1rem 2rem;
  position: relative;
}
.msg-narrator::before, .msg-narrator::after {
  content: '"';
  font-size: 2.5rem;
  font-family: Georgia, serif;
  color: rgba(255, 255, 255, 0.05);
  position: absolute;
}
.msg-narrator::before { top: -10px; left: 0; }
.msg-narrator::after { bottom: -30px; right: 0; }

/* NPC Dialogue Box */
.msg-npc {
  align-self: flex-start;
}
.npc-bubble {
  background: rgba(30, 26, 51, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0 16px 16px 16px;
  padding: 0.85rem 1.1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.npc-name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-neon);
  margin-bottom: 0.3rem;
  letter-spacing: 0.5px;
}
.npc-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-main);
}

/* System event bubble inside timeline */
.msg-system-event {
  align-self: center;
  background: rgba(14, 165, 233, 0.1);
  border: 1px dashed rgba(14, 165, 233, 0.3);
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Player Bubble */
.msg-player {
  align-self: flex-end;
}
.player-bubble {
  background: linear-gradient(135deg, #6b21a8 0%, #4c1d95 100%);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 16px 16px 0 16px;
  padding: 0.85rem 1.1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.player-name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #e9d5ff;
  margin-bottom: 0.3rem;
  text-align: right;
}
.player-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: #ffffff;
}

/* Bottom Action Bar */
.action-input-bar {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  background: rgba(8, 6, 15, 0.8);
}
.suggested-actions-bubbles {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.suggestion-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 99px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
}
.suggestion-btn:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
  color: var(--text-main);
  transform: translateY(-1px);
}

.action-form {
  display: flex;
  gap: 0.75rem;
}
.action-form input {
  flex-grow: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
}
.action-form input:focus {
  border-color: var(--accent-neon);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.15);
  background: rgba(255,255,255,0.05);
}

.submit-btn {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  padding: 0 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s;
}
.submit-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}

/* Play loading spinner */
.play-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 19, 0.9);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(168, 85, 247, 0.15);
  border-top-color: var(--accent-neon);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================= CREATOR STUDIO ================= */
.creator-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: stretch;
}
.creator-sidebar h2, .creator-preview h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.creator-sub, .preview-sub, .settings-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: all 0.3s;
}
.form-group select option {
  background-color: var(--bg-primary);
  color: var(--text-main);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent-neon);
  background: rgba(255,255,255,0.06);
}

.row-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.mt-3 { margin-top: 1rem; }

.action-btn-primary {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  border: none;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
.action-btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}
.action-btn-primary:disabled, .action-btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
.action-btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
}

.full-width { width: 100%; }

/* Schema Preview Drawer in Creator */
.schema-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 1.25rem;
}
.schema-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}
.schema-tab-btn:hover {
  color: var(--text-main);
}
.schema-tab-btn.active {
  color: var(--text-main);
  border-color: var(--accent-neon);
  font-weight: 600;
}
.schema-panel {
  display: none;
  animation: fadeIn 0.3s forwards;
}
.schema-panel.active {
  display: block;
}

.placeholder-text {
  text-align: center;
  color: var(--text-muted);
  padding: 4rem 1rem;
  font-style: italic;
  font-size: 0.9rem;
}

.code-textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.3) !important;
  color: #d8b4fe !important;
  border-color: rgba(255, 255, 255, 0.05) !important;
}

.creator-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 1rem;
}

/* Creator metrics editor items */
.metrics-editor-list, .endings-editor-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.metric-edit-row, .ending-edit-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 0.5rem;
}
.ending-edit-row {
  grid-template-columns: 1fr 1.5fr 1fr;
}

/* ================= SETTINGS SCREEN ================= */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
}
.settings-section {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 1.5rem 0;
}
.settings-section:first-of-type { padding-top: 0; }
.settings-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.settings-section h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.radio-label {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}
.radio-label:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
}
.radio-label input[type="radio"] {
  margin-top: 0.3rem;
  accent-color: var(--accent-neon);
}
.radio-content strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.radio-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.hint-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ================= MODAL OVERLAY BACKDROP ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 10, 0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s forwards;
}

.modal-card {
  max-width: 500px;
  width: 100%;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleUp {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.modal-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 1rem;
}

/* Info Modal Content */
.info-modal-card {
  max-width: 600px;
}
.info-modal-content {
  max-height: 400px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
}
.info-modal-content h4 {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  color: var(--accent-neon);
}
.info-modal-content ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

/* ================= ENDING SCREEN CARD ================= */
.ending-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 10, 0.85);
  backdrop-filter: blur(8px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.ending-card {
  max-width: 500px;
  width: 100%;
  text-align: center;
  padding: 2.5rem 2rem;
  border-color: rgba(168, 85, 247, 0.25);
  box-shadow: 0 15px 50px rgba(168, 85, 247, 0.15);
}
.ending-trophy {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  animation: bounce 2s infinite ease-in-out;
}
.ending-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.ending-badge {
  display: inline-block;
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.25);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  margin-bottom: 1.25rem;
}
.ending-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.75rem;
}
.ending-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  background: rgba(255,255,255,0.03);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}
.stat-item {
  display: flex;
  flex-direction: column;
}
.stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-neon);
}
.stat-item span:last-child {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ending-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ending-buttons button {
  width: 100%;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ================= TOAST TOASTER ================= */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.toast {
  background: rgba(14, 11, 26, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  font-size: 0.85rem;
  min-width: 250px;
  max-width: 350px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-left: 4px solid var(--accent-neon);
  animation: slideInLeft 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.toast.toast-success { border-left-color: var(--color-survival); }
.toast.toast-error { border-left-color: var(--color-suspense); }
.toast.toast-info { border-left-color: var(--color-workplace); }

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* NPC Avatar preview in edit panel */
.npc-edit-box {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 1024px) {
  .play-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .state-sidebar {
    height: auto;
  }
  .theater-screen {
    height: 500px;
  }
  .creator-container {
    grid-template-columns: 1fr;
  }
}

/* Active Sessions Carousel and Card Styles */
.active-sessions-section {
  width: 100%;
}
.sessions-carousel {
  padding: 0.5rem 0;
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.session-card {
  min-width: 300px;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.session-card:hover {
  transform: translateY(-4px);
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.15);
  background: rgba(255, 255, 255, 0.05);
}
.session-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.session-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}
.session-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.session-card-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.session-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}
.session-delete-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.session-delete-btn:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* Metric Delta Popups */
.metric-row {
  position: relative;
}
.metric-delta {
  position: absolute;
  right: 0;
  top: -10px;
  font-size: 0.9rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 10;
  animation: floatUpFadeOut 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.metric-delta.positive {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}
.metric-delta.negative {
  color: #f43f5e;
  text-shadow: 0 0 10px rgba(244, 63, 94, 0.5);
}

@keyframes floatUpFadeOut {
  0% {
    opacity: 0;
    transform: translateY(5px);
  }
  20% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-25px);
  }
}

/* ================= EPIC 10 & 11 ADDED CSS RULES ================= */

/* Header Energy Widget */
.header-energy {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.3s;
}
.energy-icon {
  color: #eab308;
  font-size: 0.95rem;
  animation: energyPulse 2.5s infinite ease-in-out;
}
.energy-recharge-btn {
  background: var(--accent-neon);
  border: none;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 0.25rem;
  font-weight: 700;
  padding: 0;
  line-height: 1;
}
.energy-recharge-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 0 8px var(--accent-neon);
}
@keyframes energyPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.15); filter: brightness(1.25); }
}

/* Contextual Slash Commands Menu */
.slash-menu {
  position: absolute;
  bottom: 100%;
  left: 1.5rem;
  right: 1.5rem;
  background: rgba(15, 12, 28, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: slideDownFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.slash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.slash-item:hover, .slash-item.selected {
  background: rgba(168, 85, 247, 0.15);
  color: var(--text-main);
}
.slash-item .cmd-name {
  font-weight: 600;
  color: var(--accent-neon);
}
.slash-item .cmd-desc {
  font-size: 0.8rem;
  margin-left: 0.5rem;
  flex: 1;
}
.slash-item .cmd-cost {
  font-size: 0.75rem;
  color: #eab308;
  background: rgba(234, 179, 8, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(234, 179, 8, 0.15);
}
@keyframes slideDownFadeIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Monetization Recharge Wave Animation */
.recharge-option:hover {
  border-color: rgba(168, 85, 247, 0.4) !important;
  background: rgba(255, 255, 255, 0.05) !important;
}
.recharge-option.active {
  border-color: var(--accent-neon) !important;
  background: rgba(168, 85, 247, 0.08) !important;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.15);
}
.wave-ripple {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--accent-neon);
  border-radius: 50%;
  animation: rippleOut 2s infinite cubic-bezier(0.1, 0.8, 0.3, 1);
  opacity: 0;
  pointer-events: none;
}
.ripple-2 {
  animation-delay: 0.6s;
}
.ripple-3 {
  animation-delay: 1.2s;
}
@keyframes rippleOut {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(2.2); opacity: 0; }
}
.payment-spinner {
  animation: pulseGlow 1.5s infinite ease-in-out;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(168, 85, 247, 0.1); }
  50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.4); }
}
.pay-icon.pay-success {
  color: #22c55e !important;
  font-size: 2rem !important;
  animation: scalePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes scalePop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1.1); opacity: 1; }
}

/* Low Sanity Glitch Effects */
.low-sanity-glitch {
  animation: vignetteDrift 4s infinite ease-in-out;
}
.low-sanity-glitch::after {
  content: "";
  position: fixed;
  inset: 0;
  box-shadow: inset 0 0 100px rgba(168, 85, 247, 0.35);
  pointer-events: none;
  z-index: 999;
  mix-blend-mode: color-burn;
  animation: vignetteFlicker 0.2s infinite alternate;
}
@keyframes vignetteDrift {
  0%, 100% { filter: contrast(1) saturate(1); }
  50% { filter: contrast(1.05) saturate(1.15) hue-rotate(5deg); }
}
@keyframes vignetteFlicker {
  0% { opacity: 0.85; }
  100% { opacity: 0.95; }
}

/* Fluid Spring transition for progress bars */
.metric-bar-inner {
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 3D card tilt & Stream-light Border for Ending Cards */
.ending-card {
  transition: transform 0.1s ease-out, box-shadow 0.3s;
  transform-style: preserve-3d;
  perspective: 1000px;
  position: relative;
}
.ending-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(90deg, #a855f7, #06b6d4, #a855f7);
  background-size: 200% auto;
  border-radius: 18px;
  z-index: -1;
  animation: streamBorder 4s linear infinite;
  opacity: 0.45;
}
@keyframes streamBorder {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.ending-card > * {
  transform: translateZ(25px);
}

/* Mock AI Canvas Illustration Layouts */
.msg-illustration-card {
  align-self: center;
  width: 100%;
  max-width: 480px;
  background: rgba(14, 11, 26, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 0.5rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.illustration-canvas {
  width: 100%;
  height: 180px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.illustration-canvas svg {
  width: 100%;
  height: 100%;
}
.illustration-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 0 0.25rem;
}
.illustration-scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-neon);
  box-shadow: 0 0 12px var(--accent-neon);
  opacity: 0.8;
  animation: laserScan 2s infinite ease-in-out;
}
@keyframes laserScan {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}
.illustrate-btn {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  align-self: flex-start;
}
.illustrate-btn:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.45);
  color: #fff;
}
