/* ==========================================================================
   BLACKWOOD MANOR - ACT 1 DESIGN TOKEN SYSTEM & ATMOSPHERIC STYLESHEET
   ========================================================================== */

/* -------------------------------------------------------------------------
   2. THE 4 DYNAMIC PRESENTATION THEMES
   ------------------------------------------------------------------------- */

/* Theme definitions have been extracted to individual theme-*.css files */

/* -------------------------------------------------------------------------
   3. BASE RESET & PAGE LAYOUT
   ------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

body {
    margin: 0;
}

.app-root {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  letter-spacing: var(--letter-spacing);
  text-shadow: var(--text-glow);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: 
    background-color var(--speed-theme-transition),
    color var(--speed-theme-transition),
    letter-spacing var(--speed-theme-transition),
    text-shadow var(--speed-theme-transition);
}

/* Viewport Layout Flex Container */
.game-viewport-container {
  display: flex;
  flex-direction: row;
  width: 100%;
  flex: 1 1 auto;
  position: relative;
  overflow-x: hidden;
  align-items: stretch;
}

/* Wrapper for HUD and Game Content (sibling to JournalDrawer) */
.game-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%; /* Prevents flex blowout from the drawer's negative margins */
  position: relative;
}

/* Game Content Container with Container Queries enabled */
.game-content-container {
  flex: 1 1 0%;
  min-width: 0;
  container-type: inline-size;
  container-name: game-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  overflow-y: auto;
  transition: margin-right var(--speed-drawer-transition), padding var(--speed-drawer-transition);
}

/* Main Content Container inside game-content */
.main-container {
  width: 100%;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  padding: var(--space-outer-padding);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-region-gap);
  transition: gap var(--speed-drawer-transition), padding var(--speed-drawer-transition);
}

.narrative-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

/* ==========================================================================
   CONTAINER QUERIES FOR GAME CONTENT AREA
   
   BREAKPOINT DICTIONARY:
   - WIDE   (>= 890px): Side-by-side narrative and buttons.
   - MEDIUM (841px - 889px): Tighter side-by-side fit.
   - NARROW (<= 700px): Stacked layout (narrative on top, buttons below).
   ========================================================================== */

/* LAYOUT WIDE (available content width >= 890px) */
@container game-content (min-width: 890px) {
  .main-container {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-region-gap);
    padding: clamp(1.25rem, 2.5vw, 2rem);
  }

  .narrative-column {
    flex: 55;
    min-width: 0;
  }

  .options-panel {
    flex: 45;
    min-width: 300px;
  }

  .options-container {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.85rem;
  }
}

/* LAYOUT MEDIUM (available content width between 841px and 889px) */
@container game-content (min-width: 841px) and (max-width: 889px) {
  .main-container {
    flex-direction: row;
    align-items: flex-start;
    gap: clamp(0.75rem, 1.5vw, 1.25rem);
    padding: clamp(0.75rem, 1.5vw, 1.25rem);
  }

  .narrative-column {
    flex: 54;
    min-width: 0;
  }

  .options-panel {
    flex: 46;
    min-width: 220px;
  }
}

/* LAYOUT NARROW / COLLAPSED MEDIUM (available content width <= 840px) */
@container game-content (max-width: 840px) {
  .main-container {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    padding: 0.75rem 1rem;
  }

  .narrative-column,
  .options-panel {
    width: 100%;
    flex: none;
  }
}

/* -------------------------------------------------------------------------
   4. HEADER / STATUS HUD BAR
   ------------------------------------------------------------------------- */
.hud-bar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: var(--hud-height);
    height: auto;
    background: var(--color-panel-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--drawer-bar-padding);
    gap: 1rem;
    flex-wrap: wrap;
    z-index: 1000;
    font-family: var(--font-mono);
    transition: transform var(--speed-drawer-transition), padding-right var(--speed-drawer-transition), background-color var(--speed-theme-transition), border-color var(--speed-theme-transition);
}

.hud-bar.hud-hidden {
  transform: translateY(-100%);
}

#hud-drawer-toggle {
  transition: opacity var(--speed-drawer-transition);
}

.app-root.drawer-is-open #hud-drawer-toggle {
  opacity: 0;
  pointer-events: none;
}

.app-root.drawer-is-open #hud-reset-btn {
  display: none;
}

.app-root.drawer-is-open .hud-items-right,
:has(.status-drawer.drawer-open) .hud-items-right {
  display: none;
}

#drawer-reset-btn {
  display: none;
}

.app-root.drawer-is-open #drawer-reset-btn {
  display: inline-block;
}

.hud-items-left {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    position: relative;
    align-items: center;
}

.settings-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* Natively spans from left edge to the end of the Settings button */
    background: var(--color-panel-bg);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 4px 4px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform-origin: top;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
    z-index: 999;
}

.settings-dropdown.closed {
    transform: scaleY(0);
    opacity: 0;
    pointer-events: none;
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
    background: transparent;
}

.settings-dropdown .btn-drawer-toggle {
    width: 100%;
    text-align: left;
}

.hud-items-center {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    flex-grow: 1;
    justify-content: center;
}

.hud-items-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Layout B: Same as C but DOM order places right items after center items. */
.hud-bar.hud-layout-b {
    justify-content: space-between;
    display: flex;
    align-items: center;
}
.hud-bar.hud-layout-b .hud-items-right {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 0.5rem;
}
.hud-bar.hud-layout-b .hud-items-center {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: space-between;
}
/* Layout C: Right items in a compact grid, center items in a 2-column grid. */
.hud-bar.hud-layout-c {
    justify-content: space-between;
    display: flex;
    align-items: center;
}
.hud-bar.hud-layout-c .hud-items-right {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 0.5rem;
}
.hud-bar.hud-layout-c .hud-items-center {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: space-between;
}
h1.h4.mb-0.title-font.text-accent {
    margin: 0;
    font-size: var(--font-size-hud-title) !important;
    line-height: 1.2;
}

.btn-reset {
    border-color: var(--color-border) !important;
    color: var(--color-text) !important;
}

.btn-confirming-reset {
    border-color: var(--color-danger) !important;
    color: var(--color-danger) !important;
    background: var(--color-danger-glow) !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4) !important;
    animation: pulseResetConfirm 1.5s infinite ease-in-out;
}

@keyframes pulseResetConfirm {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.04); }
}

.btn-muted {
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: rgba(255, 255, 255, 0.45) !important;
}
.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-hud-item);
    letter-spacing: 0.05em;
}

.hud-label {
  opacity: 0.75;
  font-weight: bold;
  font-size: var(--font-size-hud-label);
}

/* Badges */
.badge-stable,
.badge-basement-fault,
.badge-purge-emergency {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: var(--font-size-hud-badge);
}

.badge-stable {
  color: #10b981;
  border: 1px solid #10b981;
}

.badge-basement-fault {
  color: #f59e0b;
  border: 1px solid #f59e0b;
}

.badge-purge-emergency {
  color: #ff1a1a;
  border: 1px solid #ff1a1a;
  animation: pulseWarning 1.2s infinite ease-in-out;
}

/* Purge Clock Gauge */
.purge-timer {
  background: rgba(153, 0, 0, 0.25);
  border: 1px solid #ff1a1a;
  padding: 4px 12px;
  border-radius: 4px;
  color: #ff1a1a;
  font-weight: bold;
  font-size: var(--font-size-hud-badge);
  animation: pulsePurgeHUD 2s infinite ease-in-out;
}

.btn-drawer-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  padding: 0.5rem 0.5rem;
  font-family: var(--font-mono) !important;
  font-size: var(--font-size-hud-btn);
  cursor: pointer;
  border-radius: 4px;
  position: relative;
  transition: all var(--speed-hover);
  text-shadow: none !important;
}

.btn-drawer-toggle:hover {
  background: var(--color-shadow);
  box-shadow: 0 0 10px var(--color-shadow);
  color: var(--color-text);
}

.btn-settings-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    line-height: 1;
}

.btn-settings-icon svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    transition: transform var(--speed-hover);
}

.btn-settings-icon:hover svg {
    transform: rotate(45deg);
}

.alert-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--color-accent);
  border-radius: 50%;
  margin-left: 6px;
  box-shadow: 0 0 5px var(--color-accent);
  animation: alertPulse 1.5s infinite;
}

/* -------------------------------------------------------------------------
   5. NARRATIVE TEXT PANEL & PROSE
   ------------------------------------------------------------------------- */
.text-panel {
  flex: 2;
  background-color: var(--color-panel-bg);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  padding: 2.5rem;
  border-radius: 6px;
  min-height: 200px;
  transition: background-color var(--speed-theme-transition), border-color var(--speed-theme-transition);
}

.narrative-paragraph {
  line-height: var(--line-height-narrative);
  margin-bottom: 1.5rem;
  font-size: var(--font-size-narrative);
}

.narrative-paragraph:last-child {
  margin-bottom: 0;
}

.fade-in-para {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInPara var(--speed-fade-in) forwards;
}

.skip-animations .fade-in-para {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.speaker-tag {
  font-weight: bold;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-right: 0.35rem;
  letter-spacing: 0.05em;
  font-size: var(--font-size-speaker-tag);
}

.speaker-tag.alex { color: #60a5fa; }
.speaker-tag.liam { color: #f59e0b; }
.speaker-tag.arthur { color: #a78bfa; }

/* -------------------------------------------------------------------------
   6. OPTIONS CONTAINER & CATEGORIZED BUTTON STYLING
   ------------------------------------------------------------------------- */
.options-panel {
  width: 100%;
}

.options-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0.85rem;
}

.scene-option {
  background: var(--color-panel-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 1.125rem 1.5rem;
  font-family: inherit;
  font-size: var(--font-size-option-text);
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  transition: 
    background-color var(--speed-hover),
    border-color var(--speed-hover),
    box-shadow var(--speed-hover),
    transform var(--speed-hover);
}

.option-text {
  flex: 1;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
}

.scene-option:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--color-border-active);
  box-shadow: 0 4px 14px var(--color-shadow);
}

.option-prefix {
  font-weight: bold;
  font-family: var(--font-mono);
  font-size: var(--font-size-option-prefix);
  opacity: 0.9;
  flex-shrink: 0;
}

/* Category: Setting */
.option-setting {
  border: 1px solid rgba(226, 217, 207, 0.2);
}

/* Category: Emotion */
.option-emotion {
  border: 1px solid rgba(212, 165, 165, 0.3);
}

/* Category: Golden Path (isGolden: true with #d4af37 gold border) */
.option-golden,
.golden-path {
  border: 1px solid #d4af37 !important;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.12) 0%, transparent 100%);
}

.option-golden:hover:not(:disabled),
.golden-path:hover:not(:disabled) {
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.35) !important;
}

/* Category: Learned / Conditional */
.option-conditional {
  border: 1px solid #00ffcc !important;
  background: rgba(0, 255, 204, 0.08);
}

/* Locked / Disabled Option */
.option-locked {
  opacity: 0.45;
  cursor: not-allowed;
  border: 1px dashed #666;
}

/* Custom AI Natural Language Prompt Bar */
.ai-prompt-container {
  width: 100%;
}

.ai-prompt-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-prompt-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: var(--font-mono) !important;
  font-size: var(--font-size-ai-prompt-input);
  padding: 0.55rem 0.85rem;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-prompt-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 10px var(--color-shadow);
}

.btn-ai-send {
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   7. PLAYER & COMPANION STATUS DRAWER (RESPONSIVE SIDE-DRAWER & OVERLAY)
   ------------------------------------------------------------------------- */
.status-drawer {
  background-color: var(--color-panel-bg);
  opacity: 1;
  backdrop-filter: none;
  border-left: 1px solid var(--color-border);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  height: stretch;
  overflow: hidden;
  box-sizing: border-box;
}

/* Desktop & Tablet Side-Drawer (Viewport Width >= 640px) */
@media (min-width: 640px) {
  .status-drawer {
    width: var(--drawer-width, 380px);
    max-width: 42vw;
    min-width: 320px;
    /*height: 100%;*/
    align-self: stretch;
    position: sticky;
    top: 0;
    flex: 0 0 auto;
    transition: margin-right var(--speed-drawer-transition), transform var(--speed-drawer-transition), opacity var(--speed-drawer-transition);
  }

  .status-drawer.drawer-closed {
    margin-right: calc(-1 * var(--drawer-width, 380px));
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }

  .status-drawer.drawer-open {
    margin-right: 0;
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }
}

/* Mobile & High-Zoom Full-Screen Overlay (Viewport Width < 640px) */
@media (max-width: 639px) {
  .status-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    /*height: 100vh;*/
    max-width: 100vw;
    z-index: 9999;
    border-left: none;
    border-radius: 0;
    transition: transform var(--speed-drawer-transition), opacity var(--speed-drawer-transition);
  }

  .status-drawer.drawer-closed {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }

  .status-drawer.drawer-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Make underlying game content non-interactable when full-screen Journal is open */
  .drawer-is-open .game-content-container {
    pointer-events: none;
    user-select: none;
  }
}

button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-accent) !important;
  outline-offset: 2px !important;
}

.drawer-header {
  height: auto;
  min-height: var(--hud-height);
  padding: var(--drawer-bar-padding);
  background-color: var(--color-panel-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.drawer-ambient-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0.45rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: var(--font-size-journal-ambient);
    color: var(--color-accent);
    letter-spacing: 0.04em;
}

.ambient-item {
  white-space: nowrap;
  opacity: 0.9;
}

.drawer-header h2 {
  margin: 0;
  font-size: var(--font-size-journal-title) !important;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--color-accent);
  line-height: 1.2;
}

.btn-close-drawer {
  font-size: calc(1.4rem * var(--font-scale-ratio));
  line-height: 1;
  padding: 0.35rem;
  width: calc(1.8rem * var(--font-scale-ratio));
  height: calc(1.8rem * var(--font-scale-ratio));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--speed-hover);
}

.btn-close-drawer:hover,
.btn-close-drawer:focus-visible {
  color: var(--color-danger) !important;
  border-color: var(--color-danger) !important;
  background: var(--color-danger-glow) !important;
}

/* Segmented View Tabs */
.drawer-tabs-bar {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--color-border);
}

.drawer-tab-btn {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text);
  font-size: var(--font-size-journal-tab);
  padding: 0.55rem 0.2rem;
  cursor: pointer;
  opacity: 0.65;
  transition: all var(--speed-hover);
  letter-spacing: var(--tracking-wide);
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
}

.drawer-tab-btn:hover {
  opacity: 1;
  color: var(--color-accent);
  background: rgba(255, 255, 255, 0.02);
}

.drawer-tab-btn.active {
  opacity: 1;
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  background: rgba(212, 175, 55, 0.08);
}

/* Progressive Disclosure Help Details */
.drawer-help-details {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}

.drawer-help-summary {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    font-size: var(--font-size-journal-help-summary);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: var(--color-accent);
    letter-spacing: var(--tracking-wide);
    user-select: none;
    list-style: none;
}

.drawer-help-summary::-webkit-details-marker,
.drawer-help-summary::marker {
  display: none;
  content: "";
}

.drawer-help-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.drawer-help-arrow {
  text-align: center;
  font-size: var(--font-size-journal-help-summary);
  opacity: 0.85;
  transition: transform var(--speed-drawer-transition);
  display: inline-block;
  transform-origin: center;
  transform: rotate(0deg);
}

.drawer-help-details[open] .drawer-help-arrow {
  transform: rotate(180deg);
}

.drawer-help-content {
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    gap: 0.5rem;
    display: flex;
    flex-direction: column;
    font-size: var(--font-size-journal-help-text);
}

.drawer-controls-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.drawer-content {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
  font-family: var(--font-mono);
}

.drawer-footer {
  padding: var(--drawer-bar-padding);
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.status-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.status-card h3,
.inventory-section h3,
.journal-section h3 {
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-journal-card-title);
  letter-spacing: var(--tracking-wide);
  color: var(--color-accent);
}

.stat-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--font-size-journal-stat-value);
}

.stat-group label {
  width: 70px;
  opacity: 0.8;
  font-size: var(--font-size-journal-stat-label);
}

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

.progress-bar .fill {
  height: 100%;
  transition: width 0.4s ease;
}

.fill-health { background: linear-gradient(90deg, #ef4444, #10b981); }
.fill-sanity { background: linear-gradient(90deg, #8b5cf6, #3b82f6); }
.fill-trust { background: linear-gradient(90deg, #f59e0b, #d4af37); }
.fill-romance { background: linear-gradient(90deg, #ec4899, #f43f5e); }

/* Condition Badges */
.conditions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.badge {
  font-size: var(--font-size-journal-badge);
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid #f59e0b;
  color: #f59e0b;
}

.badge-red {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #ef4444;
}

.badge-purple {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid #8b5cf6;
  color: #c084fc;
}

/* Inventory Grid */
.inventory-section h3,
.journal-section h3 {
  margin-bottom: 0.75rem;
  opacity: 0.85;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.inventory-slot {
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--color-border);
  padding: 0.6rem;
  border-radius: 4px;
  font-size: var(--font-size-journal-body);
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
}

.inventory-slot.filled {
  border: 1px solid var(--color-accent);
  background: rgba(212, 175, 55, 0.1);
}

/* Clue Journal */
.clue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.clue-item {
  font-size: var(--font-size-journal-body);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--color-accent);
}

/* -------------------------------------------------------------------------
   8. VISUAL FX ANIMATIONS & OVERLAYS
   ------------------------------------------------------------------------- */

/* Screen Shake Animation */
@keyframes screenShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-8px, 6px) rotate(-1deg); }
  40% { transform: translate(8px, -6px) rotate(1deg); }
  60% { transform: translate(-5px, -3px) rotate(-0.5deg); }
  80% { transform: translate(5px, 3px) rotate(0.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.fx-screen-shake {
  animation: screenShake 0.45s ease-in-out;
}

/* Emergency Purge and Computer Terminal effects have been extracted to individual theme files */

/* Keyframe Animations */
@keyframes fadeInPara {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseWarning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes pulsePurgeHUD {
  0%, 100% { border-color: #ff1a1a; box-shadow: 0 0 5px rgba(255, 26, 26, 0.3); }
  50% { border-color: #ff4d4d; box-shadow: 0 0 15px rgba(255, 26, 26, 0.7); }
}

@keyframes alertPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

/* Utility */
.hidden {
  display: none !important;
}

/* Original UI Legacy Utilities */
.title-font {
  font-family: var(--font-primary);
  font-weight: bold;
}
.text-accent {
  color: var(--color-accent);
}
.mb-3 {
  margin-bottom: 1rem;
}
.pb-2 {
  padding-bottom: 0.5rem;
}
.border-bottom {
  border-bottom: 1px solid;
}
.border-secondary {
  border-color: rgba(255, 255, 255, 0.15);
}



/* -------------------------------------------------------------------------
   AI Connection Modal & Styled HUD Selector
   ------------------------------------------------------------------------- */
.hud-ai-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--color-bg);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  padding: 0.5rem 1.8rem 0.5rem 0.6rem;
  font-family: var(--font-mono, monospace) !important;
  font-size: var(--font-size-hud-btn);
  cursor: pointer;
  border-radius: 4px;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23c9a55c%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem top 50%;
  background-size: 0.65rem auto;
  transition: all var(--speed-hover);
}

.hud-ai-select:hover {
  background-color: var(--color-shadow);
  box-shadow: 0 0 10px var(--color-shadow);
  color: var(--color-text);
}

.hud-ai-select option {
  background: #141721;
  color: #e0e0e0;
  padding: 8px 12px;
}

.hud-option-disconnect {
  color: #ff6b6b !important;
  font-weight: bold;
  background: #2a1515 !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ai-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ai-modal-container {
  background: #12141d;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.85), 0 0 20px rgba(201, 165, 92, 0.25);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  animation: modalFadeIn 0.22s ease-out;
  color: #e0e0e0;
  font-family: var(--font-mono);
}

.ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(201, 165, 92, 0.25);
  background: rgba(201, 165, 92, 0.06);
}

.ai-modal-title {
  margin: 0;
  font-size: var(--font-size-modal-title);
  color: var(--color-accent);
  letter-spacing: 0.08em;
}

.ai-modal-subtitle {
  margin: 0.25rem 0 0 0;
  font-size: var(--font-size-modal-subtitle);
  color: #a0a5b5;
}

.ai-modal-close-btn {
  background: transparent;
  border: none;
  color: #a0a5b5;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.ai-modal-close-btn:hover {
  color: #ff6b6b;
}

.ai-modal-body {
  padding: 1.5rem;
}

.ai-provider-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
  gap: 8px;
  margin-bottom: 1.25rem;
}

.ai-provider-tab {
  background: #181b27;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #c0c5d5;
}

.ai-provider-tab:hover {
  border-color: rgba(201, 165, 92, 0.5);
  background: #1e2232;
}

.ai-provider-tab.active {
  background: rgba(201, 165, 92, 0.15);
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: 0 0 10px rgba(201, 165, 92, 0.25);
}

.provider-name {
  display: block;
  font-weight: bold;
  font-size: var(--font-size-modal-body);
}

.provider-badge {
  display: block;
  font-size: var(--font-size-modal-subtitle);
  opacity: 0.75;
  margin-top: 2px;
}

.ai-portal-action-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(201, 165, 92, 0.35);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 1.25rem;
}

.portal-info {
  display: flex;
  flex-direction: column;
}

.portal-info strong {
  color: #e0e0e0;
  font-size: var(--font-size-modal-body);
}

.portal-desc {
  font-size: var(--font-size-modal-subtitle);
  color: #9095a5;
}

.btn-open-browser-tab {
  background: var(--color-accent);
  color: #0f1117;
  font-weight: bold;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-modal-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-open-browser-tab:hover {
  background: #e5bd6a;
  box-shadow: 0 0 10px rgba(201, 165, 92, 0.4);
  transform: translateY(-1px);
}

.ai-credentials-group {
  margin-bottom: 1.25rem;
}

.ai-input-label {
  display: block;
  font-size: var(--font-size-modal-body);
  color: #c0c5d5;
  margin-bottom: 6px;
  font-weight: 600;
}

.ai-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-input-field {
  flex: 1;
  background: #0b0c12;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 10px 12px;
  font-size: var(--font-size-modal-body);
  transition: border-color 0.2s;
}

.ai-input-field:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 6px rgba(201, 165, 92, 0.3);
}

.btn-toggle-key-visibility {
  background: #1e2230;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #a0a5b5;
  padding: 0 12px;
  font-size: var(--font-size-modal-subtitle);
  cursor: pointer;
}

.btn-toggle-key-visibility:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.ai-demo-shortcuts {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 1rem;
  font-size: var(--font-size-modal-subtitle);
}

.demo-label {
  color: #8a8f9e;
}

.btn-demo-fill {
  background: transparent;
  border: none;
  color: var(--color-accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: var(--font-size-modal-subtitle);
}

.btn-demo-fill:hover {
  color: #e5bd6a;
}

.ai-models-preview {
  background: #0c0d13;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.preview-label {
  display: block;
  font-size: var(--font-size-modal-subtitle);
  color: #8a8f9e;
  margin-bottom: 6px;
}

.model-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-tag {
  background: rgba(201, 165, 92, 0.12);
  color: var(--color-accent);
  border: 1px solid rgba(201, 165, 92, 0.25);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-modal-subtitle);
}

.ai-modal-error {
  background: var(--color-danger-glow);
  border: 1px solid var(--color-danger);
  color: #ff8080;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-modal-body);
  margin-top: 1rem;
}

.ai-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-modal-primary {
  background: var(--color-accent);
  color: #0f1117;
  font-weight: bold;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-modal-btn);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-primary:hover {
  background: #e5bd6a;
  box-shadow: 0 0 10px rgba(201, 165, 92, 0.5);
}

.btn-modal-secondary {
  background: transparent;
  color: #a0a5b5;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-modal-btn);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-secondary:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
