/* Wyrdweaver — modern app shell + book vibe (2025)
*/

:root{
  --bg0:#07080b;
  --bg1:#0c0e13;
  --glass: rgba(16,18,26,.58);
  --glass2: rgba(16,18,26,.72);
  --line: rgba(255,255,255,.10);
  --line2: rgba(255,255,255,.16);

  --text:#eef0f4;
  --muted:#b4bcc7;
  --ink:#14151a;

  /* palette: torch + arcane, but not “yellow UI” */
  --accent:#b76cff;      /* primary UI accent (violet) */
  --accent2:#5eead4;     /* teal highlight */
  --ember:#ffb84a;       /* warm torch glow (sparingly) */
  --danger:#ef4444;

  /* Danger Level Color Themes */
  --theme-peaceful: #b76cff;      /* Arcane purple (default) */
  --theme-calm: #5eead4;          /* Teal/cyan */
  --theme-tense: #ffb84a;         /* Amber/orange */
  --theme-dangerous: #ef4444;     /* Red */
  --theme-critical: #dc2626;      /* Deep crimson */

  --radius: 18px;
  --shadow: 0 26px 80px rgba(0,0,0,.55);
  --shadow2: 0 18px 50px rgba(0,0,0,.42);
  --ease: cubic-bezier(.2,.8,.2,1);

  --wrap: 1120px;
  --hero-url: none;
}

*{box-sizing:border-box;}
html,body{height:100%;}

/* Ensure all form inputs use the site font consistently */
input, textarea, select, button {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* iOS Safari safe area fix - ensure background covers entire viewport including notch areas */
html {
  background: #0a0a0f;
  min-height: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

body{
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display:flex;
  flex-direction:column;
  margin:0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: transparent;
  overflow-x:hidden;
  
  /* Safe area handling for iOS */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Stories pages: suppress the default purple/teal sky so it doesn't flash before the dungeon bg loads */
html.stories-route, html.stories-route body{background-color:#05060a;}

/* Opened story background: use generated hero art blended + faded to bottom (no tiling) */
.story-full-bg{position:fixed; left:0; right:0; top:0; bottom:0; z-index:0; pointer-events:none;
  /* extend *behind* the sticky header so there's no black bar */
  top: calc(-1 * (env(safe-area-inset-top, 0px) + 70px));
  bottom: 0;
  background-image: var(--story-bg, none);
  background-size: cover;
  background-position: top center;
  background-repeat: no-repeat;
  /* keep the art crisp; blur will be applied behind panels only */
  filter: saturate(1.02) contrast(1.06) brightness(0.52);
  opacity: .62;
}
.story-full-bg::after{content:""; position:absolute; inset:0;
  background-image: url('/static/art/noise_128.png');
  background-repeat: repeat;
  background-size: 128px 128px;
  opacity:.06;
  mix-blend-mode: overlay;
  pointer-events:none;
}

/* Stories list: action buttons in bottom-right, level badge with char info */
.story-actions{position:absolute; right:12px; bottom:12px; z-index:2; display:flex; gap:8px;}
.story-actions .btn{background: rgba(16,18,26,.45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border:1px solid rgba(255,255,255,.14); padding:6px 12px; font-size:12px; font-weight:800;}
.story-actions .btn:hover{background: rgba(16,18,26,.55); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);}
.story-actions a[href$="/delete"] .btn:hover{background: rgba(239,68,68,.25); border-color: rgba(239,68,68,.60); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);}

.story-char-badge{position:absolute; left:12px; bottom:12px; width: calc(50% - 18px); padding:10px 12px; border-radius: 14px; border:1px solid rgba(255,255,255,.12); background: rgba(16,18,26,.40); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index:2;}
.story-char-name{font-weight:950; font-size:13px; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.story-char-meta{display:flex; align-items:center; gap:8px; margin-top:3px;}
.story-char-class{font-size:12px; color: var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.story-level-badge{padding:2px 8px; border-radius:999px; border:1px solid rgba(255,255,255,.14); background: rgba(16,18,26,.35); font-weight:900; font-size:11px; line-height:1.4;}
.story-level-badge.standalone{position:absolute; right:12px; bottom:12px; z-index:2;}

/* Opened story: blur only behind log/action panels */
.story-pane{background: rgba(0,0,0,.50) !important; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);}

html.stories-route body{
  background: linear-gradient(180deg, rgba(6,7,10,1) 0%, rgba(5,6,9,1) 55%, rgba(2,3,6,1) 100%);
}
html.stories-route body::before{
  opacity: 0; /* disables the drifting highlight layer on stories routes */
  animation: none;
}

/* During the enter blur, keep it neutral-dark (don’t reveal the default purple backdrop) */
html.stories-route.page-enter .page-transition,
html.stories-route.page-exit .page-transition{
  background: rgba(5,6,10,.55);
}


/* page backdrop (subtle animated) */
body::before{
  content:"";
  position:fixed; inset:-40px;
  pointer-events:none;
  background:
    radial-gradient(720px 520px at 20% 18%, rgba(255,184,74,.09), transparent 60%),
    radial-gradient(620px 520px at 78% 12%, rgba(183,108,255,.10), transparent 62%),
    radial-gradient(1200px 900px at 50% 80%, rgba(0,0,0,.55), transparent 65%);
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity:.85;
  animation: drift 18s ease-in-out infinite;
}
@keyframes drift{0%{transform:translate3d(0,0,0) scale(1);}50%{transform:translate3d(-10px,8px,0) scale(1.02);}100%{transform:translate3d(0,0,0) scale(1);}}

/* story-specific hero backdrop hook */
body.has-hero::after{
  content:"";
  position:fixed; inset:0;
  pointer-events:none;
  background:
    linear-gradient(180deg, rgba(7,8,11,.72), rgba(7,8,11,.86)),
    var(--hero-url);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.05) contrast(1.05);
  opacity:.22;
}

a{color:inherit; text-decoration:none;}
a:hover{opacity:.92;}

.wrap{max-width: var(--wrap); margin:0 auto; padding: 80px 18px 26px; width:100%; flex:1; position:relative; z-index:1;}

/* Top nav */
.topbar{
  position:fixed; top:0; left:0; right:0; z-index:200;
  background: linear-gradient(180deg, rgba(10,12,16,.90), rgba(10,12,16,.68));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner{
  max-width: var(--wrap);
  margin:0 auto;
  padding: 12px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
@media (max-width: 720px){
  .topbar-inner{flex-wrap:wrap;}
}

.brand{
  display:flex; align-items:center; gap:10px;
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 800;
  letter-spacing: .03em;
}
.sigil{
  width:12px;height:12px;border-radius:999px;
  background: radial-gradient(circle at 30% 30%, var(--ember), var(--accent));
  box-shadow: 0 0 20px rgba(183,108,255,.45);
}

/* Server Alerts */
.server-alerts-container {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 1000;
  pointer-events: none;
}

.server-alerts-container:has(.server-alert.top) {
  top: 0;
}

.server-alerts-container:has(.server-alert.bottom) {
  bottom: 0;
}

.server-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  margin: 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  pointer-events: auto;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid;
}

.server-alert.info {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.server-alert.warning {
  background: rgba(250, 204, 21, 0.15);
  border-color: rgba(250, 204, 21, 0.4);
  color: #facc15;
}

.server-alert.critical {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

.alert-dismiss {
  background: none;
  border: none;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.alert-dismiss:hover {
  opacity: 1;
}

.nav{display:flex; align-items:center; gap:10px; justify-content:flex-end; flex-wrap:wrap; position:relative;}
.nav-link{color: var(--muted); font-weight:800; padding:8px 10px; border-radius: 12px;}
.nav-link:hover{color: var(--text); background: rgba(255,255,255,.06);}

/* Buttons: accent color themed */
.btn{
  border:1px solid var(--accent-border);
  background: transparent;
  color: var(--text);
  font-weight:900;
  border-radius: 14px;
  padding: 10px 12px;
  cursor:pointer;
  transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), filter 160ms var(--ease);
}
.btn:hover{transform: translateY(-1px); background: var(--accent-soft); border-color: var(--accent);}

.btn-primary{
  border-color: var(--accent);
  background: transparent;
  color: var(--text);
}
.btn-primary:hover{
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-secondary{
  border-color: var(--accent2);
  background: transparent;
  color: var(--text);
}
.btn-secondary:hover{
  background: rgba(94,234,212,.20);
  border-color: var(--accent2);
}

/* Speak/Act tabs (dialogue scenes) */
.mw-tabs{display:flex; gap:8px; padding:6px; border-radius: 16px; border:1px solid rgba(255,255,255,.12); background: rgba(16,18,26,.36); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); width: fit-content;}
.mw-tab{border:1px solid rgba(255,255,255,.12); background: transparent; color: var(--muted); font-weight: 950; border-radius: 12px; padding: 8px 12px; cursor:pointer;}
.mw-tab.active{color: var(--text); border-color: rgba(183,108,255,.55); background: linear-gradient(180deg, rgba(183,108,255,.18), rgba(255,255,255,.03));}

/* Roll required block (replaces Action form) */
.roll-required{
  margin: 0 auto;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(16,18,26,.40);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-width: 680px;
  width: 100%;
  box-sizing: border-box;
}

.roll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.roll-title{
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
  color: rgba(238,240,244,.92);
}

.roll-dc-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

.roll-dc-badge[data-difficulty="easy"] {
  background: rgba(74, 222, 128, 0.2);
  border-color: rgba(74, 222, 128, 0.4);
}

.roll-dc-badge[data-difficulty="medium"] {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.4);
}

.roll-dc-badge[data-difficulty="hard"] {
  background: rgba(251, 146, 60, 0.2);
  border-color: rgba(251, 146, 60, 0.4);
}

.roll-dc-badge[data-difficulty="very-hard"] {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.4);
}

.roll-dc-badge .dc-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.8;
}

.roll-dc-badge .dc-value {
  font-size: 16px;
  font-weight: 800;
}

.roll-details {
  margin-bottom: 16px;
}

.roll-type {
  font-size: 18px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.roll-ability {
  font-size: 14px;
  opacity: 0.7;
  font-weight: 500;
}

.roll-reason {
  margin-top: 8px;
  font-size: 14px;
  color: rgba(238, 240, 244, 0.7);
  font-style: italic;
}

.roll-action-area {
  margin-top: 16px;
}

.roll-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-roll {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
}

.roll-icon {
  font-size: 20px;
}

.roll-alternative {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.alternative-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.alternative-form textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.2);
  color: rgba(238, 240, 244, 0.95);
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
  box-sizing: border-box;
}

/* Roll explanation in log */
.roll-explanation-log {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  font-style: italic;
  color: rgba(238, 240, 244, 0.85);
}

/* Dice Animation */
@keyframes dice-roll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

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

.dice-rolling {
  animation: dice-roll 0.6s ease-in-out, dice-bounce 0.3s ease-in-out 0.6s;
  display: inline-block;
}

.btn-roll:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-roll:disabled .roll-icon {
  animation: dice-roll 1s linear infinite;
}

/* Generation Error Banner */
.generation-error-banner {
  margin: 16px 20px;
  padding: 20px;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.generation-error-banner .error-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.generation-error-banner .error-message {
  flex: 1;
}

.generation-error-banner .error-message strong {
  display: block;
  font-size: 16px;
  margin-bottom: 8px;
  color: rgba(238, 240, 244, 0.95);
}

.generation-error-banner .error-message p {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: rgba(238, 240, 244, 0.8);
  line-height: 1.5;
}

/* Log entry baseline */
.log-entry{
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  max-width: 86%;
}
.log-entry .log-text{margin-top:4px;}

/* Book-style formatting for GM text */
.log-text.book-style {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.8;
  color: rgba(238, 240, 244, 0.95);
  text-align: justify;
  text-align-last: left;
  max-width: 65ch;
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(25, 25, 35, 0.6), rgba(20, 20, 30, 0.5));
  border-left: 3px solid var(--accent-border);
  border-radius: 0 12px 12px 0;
  margin: 8px 0;
}

.log-text.book-style p {
  margin-bottom: 1em;
  text-indent: 0;
}

.log-text.book-style p:first-of-type {
  text-indent: 0;
}

.log-text.book-style p:first-of-type::first-letter {
  font-size: 3em;
  float: left;
  line-height: 0.8;
  padding-right: 8px;
  color: var(--accent);
  font-weight: bold;
  font-family: 'Cinzel', serif;
}

/* Centered Roll Card for Log */
#logbox .roll-card {
  align-self: center !important;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  width: 100%;
  max-width: 400px;
  min-width: 280px;
  box-sizing: border-box;
}

/* Dice Animation Container - Centered */
.dice-anim-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 32px;
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.9), rgba(20, 20, 30, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 320px;
  margin: 16px auto;
}

.dice-anim-container .roll-header {
  font-size: 12px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.dice-anim-container .die {
  font-size: 51px;
  font-weight: 900;
  color: var(--accent);
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: diceShake 0.5s ease-in-out infinite;
}

@keyframes diceShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* Chat-log alignment */
#logbox{align-items:flex-start;}
#logbox .log-entry[data-role="user"]{align-self: flex-end;}
#logbox .log-entry[data-role="gm"]{align-self: flex-start;}

/* Rolls align to whoever is rolling (no special centering) */
#logbox .log-entry.roll{max-width: 92%;}
/* NEW: Redesigned Dice Roll Cards */
.roll-card {
  position: relative;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.9), rgba(20, 20, 30, 0.95));
  overflow: visible;
  max-width: 100%;
  width: auto;
  min-width: 200px;
  max-width: 350px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.roll-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

/* Success styling */
.roll-card.success {
  border-color: rgba(34, 197, 94, 0.4);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(20, 30, 25, 0.95));
}

/* Critical styling */
.roll-card.crit {
  border-color: rgba(234, 179, 8, 0.5);
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(40, 35, 20, 0.95));
  box-shadow: 0 4px 20px rgba(234, 179, 8, 0.2);
}

/* Fail styling */
.roll-card.fail {
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(35, 20, 20, 0.95));
}

.roll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}

.roll-actor {
  font-size: 12px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.roll-outcome-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(238, 240, 244, 0.9);
}

.roll-outcome-badge.success {
  background: rgba(34, 197, 94, 0.25);
  color: rgba(34, 197, 94, 1);
}

.roll-outcome-badge.crit {
  background: rgba(234, 179, 8, 0.25);
  color: rgba(234, 179, 8, 1);
}

.roll-outcome-badge.fail {
  background: rgba(239, 68, 68, 0.25);
  color: rgba(239, 68, 68, 1);
}

.roll-body {
  position: relative;
  z-index: 2;
}

.roll-check {
  font-size: 13px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
  margin-bottom: 6px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.roll-total {
  font-size: 24px;
  font-weight: 900;
  color: rgba(238, 240, 244, 0.98);
  line-height: 1.2;
}

.roll-card.success .roll-total {
  color: rgba(34, 197, 94, 1);
}

.roll-card.crit .roll-total {
  color: rgba(234, 179, 8, 1);
}

.roll-card.fail .roll-total {
  color: rgba(239, 68, 68, 1);
}

/* Decorative dice pattern background */
.roll-decoration {
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: 
    radial-gradient(circle at 80% 20%, rgba(183, 108, 255, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(94, 234, 212, 0.1) 0%, transparent 40%);
  pointer-events: none;
  z-index: 1;
}

.roll-card.crit .roll-decoration {
  background: 
    radial-gradient(circle at 80% 20%, rgba(234, 179, 8, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(234, 179, 8, 0.15) 0%, transparent 40%);
}

/* Positioning in log */
#logbox .roll-card[data-who="user"] {
  align-self: flex-end;
  margin-left: auto;
}

#logbox .roll-card[data-who="gm"] {
  align-self: flex-start;
  margin-right: auto;
}

@media (max-width: 520px) {
  .roll-card {
    max-width: 280px;
    padding: 14px 16px;
  }

  .roll-total {
    font-size: 24px;
  }
}

/* Rolling state - styled like a fail card but grey, and centered */
.roll-card.rolling {
  border-color: rgba(150, 150, 150, 0.4);
  background: linear-gradient(135deg, rgba(100, 100, 110, 0.2), rgba(40, 40, 45, 0.95));
  align-self: center !important;
  margin-left: auto;
  margin-right: auto;
}

.roll-card.rolling .roll-outcome-badge {
  background: rgba(150, 150, 150, 0.25);
  color: rgba(200, 200, 200, 1);
}

.roll-card.rolling .roll-total.cycling {
  color: rgba(180, 180, 180, 1);
  animation: diceCycle 0.1s infinite;
}

.btn-danger{border-color: rgba(239,68,68,.55);}
.btn-danger:hover{background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.75);}

/* Panels / cards */
.panel,
.card{
  border:1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,18,26,.62), rgba(16,18,26,.42));
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  margin-top: 12px;
  overflow:hidden;
}
.panel-inner{padding: 18px;}

.h1{font-family: "Cinzel", ui-serif, Georgia, serif; font-size: 26px; margin:0; letter-spacing: .02em;}
.h2{font-family: "Cinzel", ui-serif, Georgia, serif; font-size: 16px; margin:0; color: rgba(238,240,244,.92);}
.sub{color: var(--muted); font-size: 13px; line-height: 1.55;}

.grid{display:grid; gap: 12px;}
.grid.cols-2{grid-template-columns: 1.25fr .9fr;}
@media (max-width: 920px){.grid.cols-2{grid-template-columns: 1fr;}}

.story-hero{
  position:relative;
  border-radius: calc(var(--radius) + 2px);
  border:1px solid rgba(255,255,255,.12);
  overflow:hidden;
  box-shadow: var(--shadow);
}
.story-hero::before{
  content:"";
  position:absolute; inset:0;
  background:
    linear-gradient(90deg, rgba(0,0,0,.70), rgba(0,0,0,.18) 55%, rgba(0,0,0,.64)),
    var(--hero-url);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.06) contrast(1.06);
}
.story-hero .hero-inner{position:relative; padding: 18px;}

.story-grid{display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items:start;}
@media (max-width: 899px){
  .story-grid{grid-template-columns: 1fr;}
}

/* Smooth transitions for story card reordering */
.story-grid {
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure no animations on story cards unless specifically needed */
.story-card {
  animation: none !important;
}

.story-card:not(.story-drop) {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure drop zone is completely stable and doesn't fade */
.story-card.story-drop,
.story-card.story-drop *,
.story-card.story-drop::before,
.story-card.story-drop::after {
  transition: none !important;
  animation: none !important;
  opacity: 1 !important;
}

.story-card {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1);
  animation: storySlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes storySlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.story-card{
  position:relative;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  overflow:hidden;
  height: 240px;
  min-height: 240px;
  max-height: 240px;
  box-shadow: 0 18px 45px rgba(0,0,0,.45);
  transition: box-shadow 180ms var(--ease);
}
.story-card.hover{box-shadow: 0 26px 70px rgba(0,0,0,.62);}
.story-card.hover{transform: translateY(-6px);}
.story-card.dragging{opacity:.72; transform:none !important;}

/* Drag/drop indicator + pinned zone */
.pin-zone{border:1px dashed rgba(255,255,255,.18); border-radius: 18px; padding: 14px; background: rgba(16,18,26,.22);}
.story-card.story-drop{ 
  border: 2px solid rgba(183,108,255,.9) !important; 
  background: rgba(183,108,255,.25) !important; 
  box-shadow: 0 0 30px rgba(183,108,255,.5) !important; 
  transform: none !important; 
  z-index: 10 !important;
  opacity: 1 !important;
  transition: none !important;
  animation: none !important;
}
.story-card.story-drop .inner{ 
  opacity: 1 !important; 
  transition: none !important;
}
.story-card::before{
  content:"";
  position:absolute; inset:0;
  z-index: 0;
  background: var(--hero-url);
  background-size: 120%;
  background-position: center;
  background-repeat: no-repeat;
  filter: saturate(1.04) contrast(1.05);
}

/* Static vignette/overlay (does NOT parallax) - stretches full width to blend with art */
.story-card::after{
  content:"";
  position:absolute; inset:0;
  z-index: 1;
  pointer-events:none;
  background: linear-gradient(180deg, 
    rgba(0,0,0,0.7) 0%, 
    rgba(0,0,0,0.4) 25%, 
    rgba(0,0,0,0.2) 40%, 
    rgba(0,0,0,0.65) 70%, 
    rgba(0,0,0,0.85) 100%
  );
}

.story-card .inner{position: relative; z-index: 2;}
.story-card .story-char-badge{z-index: 2;}
.story-card .inner{position:relative; padding: 16px; display:flex; justify-content:space-between; gap:12px; align-items:flex-start;}
.story-card .sub{display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; max-width: 42ch;}

.story-header{flex:1; min-width:0;}
.story-title{font-family: 'Cinzel', ui-serif, Georgia, serif; font-weight: 800; font-size: 13px; text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.8), 0 0 16px rgba(0,0,0,0.7); display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; line-height:1.2;}
.story-header .sub{font-size:12px; color: var(--muted);}

/* Credits inline bar */
.credits-pill{display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius: 999px; border:1px solid rgba(255,255,255,.12); background: rgba(16,18,26,.35); backdrop-filter: blur(14px); color: var(--muted); font-weight:800;}
.credits-bar{height:10px; width: 120px; border-radius: 999px; border:1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); overflow:hidden;}
.credits-fill{height:100%; background: linear-gradient(90deg, rgba(183,108,255,.95), rgba(94,234,212,.85));}
.credits-fill.credits-low{background: linear-gradient(90deg, rgba(239,68,68,.95), rgba(255,184,74,.78));}

/* Dropdown credits (inside hamburger menu) */
.dropdown-credits{display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius: 12px; border:1px solid rgba(255,255,255,.10); background: rgba(16,18,26,.25); color: var(--muted); font-weight:700;}
.dropdown-credits .credits-bar{flex:1; min-width:0;}
.dropdown-credits-label{font-size:12px; color: var(--muted);}
.dropdown-credits-value{font-size:12px; color: var(--text);}

/* Character wizard */
.spell-card.selected{border-color: rgba(183,108,255,.65); background: rgba(183,108,255,.10);}
.spell-level{margin-bottom: 16px;}
.spell-level-title{font-weight: 950; font-size: 15px; margin-bottom: 8px; color: var(--muted);}
.spell-card{padding: 12px 12px; border-radius: 16px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); cursor:pointer; transition: border-color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease); min-height: 80px;}
.spell-card:hover{background: rgba(255,255,255,.06); transform: translateY(-1px);}
.spell-card.selected{border-color: rgba(183,108,255,.85); background: rgba(183,108,255,.10); box-shadow: 0 0 0 2px rgba(183,108,255,.35) inset;}
.spell-name{font-weight:950; font-size:15px; margin-bottom: 6px; display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden;}
.spell-dc{font-size:12px; opacity:.8; margin-bottom: 4px; font-size: 11px; color: rgba(183,108,255,.85);}
.spell-desc{font-size:12px; opacity:.7; line-height: 1.3; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}
.spells-grid{display:grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px;}

/* Ability scores tiles */
.ability-tiles{display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px;}
.ability-tile{padding: 12px 16px; border-radius: 16px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); text-align: center; transition: all 160ms var(--ease);}
.ability-tile.ability-locked{opacity: .5; cursor: not-allowed;}
.ability-tile.ability-primary{border-color: rgba(183,108,255,.65); background: rgba(183,108,255,.10);}
.ability-name{font-weight: 950; font-size: 14px; margin-bottom: 4px;}
.ability-score{font-weight: 950; font-size: 24px; color: var(--muted);}
.ability-mod{font-size: 12px; opacity: .8; margin-top: 2px;}
.btn-reroll{background: rgba(94,234,212,.15); border-color: rgba(94,234,212,.60); color: rgba(255,255,255,.92); font-weight: 800;}
.btn-reroll:hover{background: rgba(94,234,212,.20); border-color: rgba(94,234,212,.80);}
.btn-reroll:disabled{background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.20); color: rgba(255,255,255,.40); cursor: not-allowed;} 
.chip{display:inline-flex; align-items:center; justify-content:center; padding:6px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.14); background: rgba(16,18,26,.35); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-weight:800; font-size:12px; line-height:1;}
.step.active{border-color: rgba(183,108,255,.55); background: rgba(183,108,255,.10);} 
.step.disabled{opacity:.45; filter: grayscale(0.6); cursor:not-allowed; pointer-events:none;}

/* Inventory chips: removable X */
.inv-x{position:absolute; top:4px; right:6px; width:18px; height:18px; border-radius:999px; border:1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.20); color: rgba(255,255,255,.92); font-weight:950; line-height: 16px; padding:0; cursor:pointer;}
.inv-x:hover{background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.28);} 
.type-icon{display:inline-flex; vertical-align:middle; margin-right:6px; opacity:.92;}

/* Shop affordability */
.shop-item.can-buy{border-color: rgba(94,234,212,.22);}
.shop-item.cant-buy{opacity:.55;}
.shop-item.cant-buy .chip{border-color: rgba(239,68,68,.35); color: rgba(255,255,255,.75);} 

/* Shop cost text (no bubble) */
.cost-text{min-width: 52px; text-align:center; font-weight:950; font-size:12px; color: rgba(238,240,244,.92); opacity:.9;}
.shop-item.cant-buy .cost-text{color: rgba(255,255,255,.70);}

/* Inventory hover description */
.inv-chip[data-desc]:hover::after{content: attr(data-desc); position:absolute; left:0; top: calc(100% + 8px); width: min(320px, 70vw); padding:10px 12px; border-radius: 14px; border:1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.28); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px); color: rgba(238,240,244,.95); font-size: 12px; line-height: 1.35; z-index: 9999; box-shadow: 0 18px 50px rgba(0,0,0,.45);}
.inv-chip{position:relative;}
.inv-chip:hover{z-index: 10000;}
.inv-panel{overflow: visible !important;}
.inv-chip[data-desc]:hover::before{content:""; position:absolute; left:16px; top: calc(100% + 2px); width:10px; height:10px; background: rgba(0,0,0,.75); border-left:1px solid rgba(255,255,255,.14); border-top:1px solid rgba(255,255,255,.14); transform: rotate(45deg); z-index: 10001;}

.pick-card{position:relative; padding:12px 12px; border-radius: 16px; border:1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); cursor:pointer; overflow:hidden; transition: border-color 160ms var(--ease), background 160ms var(--ease), transform 160ms var(--ease);
  isolation: isolate;
}
.pick-card::before{content:""; position:absolute; inset:0; background-image: linear-gradient(90deg, rgba(0,0,0,.70), rgba(0,0,0,.22) 55%, rgba(0,0,0,.60)), var(--card-bg, none); background-size: cover; background-position: top center; opacity:.62; pointer-events:none; z-index:0; transition: filter 180ms var(--ease), opacity 180ms var(--ease);}
.pick-card > *{position:relative; z-index:1;}

/* When a choice is made, fade unselected race/class cards to B&W unless hovered */
.race-card.dimmed::before,
.class-card.dimmed::before{
  filter: grayscale(1) contrast(1.05) brightness(0.70);
  opacity: .55;
}
.race-card.dimmed:hover::before,
.class-card.dimmed:hover::before{
  filter: none;
  opacity: 1;
}

.pick-card:hover{background: rgba(255,255,255,.06); transform: translateY(-1px);} 
.pick-card.selected{
  border-color: rgba(183,108,255,.95);
  background: rgba(183,108,255,.10);
  /* Outer ring so it's never hidden by the background image */
  box-shadow: 0 0 0 2px rgba(183,108,255,.65), 0 0 12px rgba(183,108,255,.16);
} 
.pick-title{font-weight:950; font-size:15px;}

/* Race/class cards: width controlled by the grid (match background card column width) */
.race-card, .class-card{aspect-ratio: 16/9; width:100%; display:flex; flex-direction:column;}

/* Background + skill cards: uniform height and tidy layout */
.background-card{min-height: 150px; height: 100%; display:flex; flex-direction:column;}
.skill-card{min-height: 75px; height: 100%; display:flex; flex-direction:column;}
.background-card .sub{display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;}
.skill-card .sub{display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}

/* Forms */
label{display:block; color: rgba(180,188,199,.85); font-size: 12px; margin: 12px 0 6px;}
input,select,textarea{
  width:100%;
  padding: 12px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline:none;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  transition: all 160ms var(--ease);
}

/* Enhanced select styling with better theming */
select {
  /* Remove default OS styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(180,188,199,0.85)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  padding-right: 44px;
  cursor: pointer;
  position: relative;
}

/* For browsers that don't support custom appearance */
select::-ms-expand {
  display: none;
}

/* Enhanced select states */
select:hover:not(:disabled) {
  border-color: rgba(255,255,255,.22);
  background-color: rgba(255,255,255,.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

select:focus:not(:disabled) {
  border-color: rgba(183,108,255,.65);
  background-color: rgba(183,108,255,.10);
  box-shadow: 0 0 0 3px rgba(183,108,255,.25), 0 4px 12px rgba(0,0,0,0.15);
  outline: none;
}

select:active:not(:disabled) {
  transform: scale(0.98);
}

/* Multi-select styling */
select[multiple] {
  background-image: none;
  padding-right: 16px;
  min-height: 180px;
}

select[multiple] option {
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 120ms var(--ease);
}

select[multiple] option:hover {
  background-color: rgba(255,255,255,.08);
}

/* Better scrollbar for dropdowns */
select[multiple]::-webkit-scrollbar {
  width: 8px;
}

select[multiple]::-webkit-scrollbar-track {
  background: rgba(255,255,255,.02);
  border-radius: 4px;
}

select[multiple]::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 4px;
}

select[multiple]::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.3);
}

/* Disabled state styling */
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: rgba(255,255,255,.03);
  color: rgba(180,188,199,.5);
}

select:disabled:hover {
  border-color: rgba(255,255,255,.14);
  background-color: rgba(255,255,255,.06);
  box-shadow: none;
}

/* Loading state for selects */
select.loading {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(180,188,199,0.85)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='12' cy='12' r='10'%3e%3c/circle%3e%3c/circle%3e%3cpath d='M12 6v6l4 2'%3e%3c/path%3e%3c/svg%3e"), url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(180,188,199,0.85)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-size: 18px 18px, 18px 18px;
  background-position: right 16px center, right 44px center;
  background-repeat: no-repeat;
}

/* Small selects */
select.small {
  padding: 8px 10px;
  font-size: 12px;
  min-width: 120px;
}

/* Large selects */
select.large {
  padding: 16px 16px;
  font-size: 16px;
  font-weight: 600;
}

/* Custom dropdown styling to override OS appearance */
select {
  /* Remove default OS styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(180,188,199,0.85)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* For browsers that don't support custom appearance */
select::-ms-expand {
  display: none;
}

/* Select hover and focus states */
select:hover {
  border-color: rgba(255,255,255,.22);
  background-color: rgba(255,255,255,.08);
}

select:focus {
  border-color: rgba(183,108,255,.65);
  background-color: rgba(183,108,255,.10);
  box-shadow: 0 0 0 2px rgba(183,108,255,.35);
}

/* Multi-select specific styling */
select[multiple] {
  background-image: none;
  padding-right: 12px;
}

select[multiple] option {
  padding: 8px 12px;
}

/* Improved scrollbar for dropdowns */
.select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.select-dropdown::-webkit-scrollbar-track {
  background: rgba(255,255,255,.02);
  border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.2);
  border-radius: 3px;
}

.select-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.3);
}

/* Better styling for disabled state */
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: rgba(255,255,255,.03);
}

select:disabled:hover {
  border-color: rgba(255,255,255,.14);
  background-color: rgba(255,255,255,.06);
}

/* Custom dropdown menu styling */
.select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(16,18,26,.96);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  margin-top: 4px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.select-dropdown-option {
  padding: 12px 16px;
  color: var(--text);
  cursor: pointer;
  border-radius: 10px;
  transition: all 160ms var(--ease);
  font-weight: 500;
}

.select-dropdown-option:hover {
  background: rgba(255,255,255,.08);
  color: rgba(238,240,244,.92);
}

.select-dropdown-option:first-child {
  border-radius: 14px 14px 0 0;
}

.select-dropdown-option:last-child {
  border-radius: 0 0 14px 14px;
}

.select-dropdown-option.selected {
  background: rgba(183,108,255,.15);
  color: rgba(238,240,244,.92);
  font-weight: 600;
}

/* Hide default dropdown arrow in all browsers */
select {
  /* This ensures custom styling works across browsers */
}
textarea{min-height: 110px; resize: vertical;}

/* Toast/overlay */
#loading-overlay{position:fixed; inset:0; background: rgba(7,8,11,.74); display:none; align-items:center; justify-content:center; z-index: 9999;}
#loading-overlay.show{display:flex;}
.loading-card{background: rgba(16,18,26,.92); border:1px solid rgba(255,255,255,.14); border-radius:16px; padding:16px 18px; min-width: 220px; text-align:center; box-shadow: var(--shadow);}
.spinner{width:28px; height:28px; border-radius:999px; border:3px solid rgba(255,255,255,.18); border-top-color: var(--accent); margin: 0 auto 10px; animation: spin 900ms linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}

/* Dice animation (used during optimistic roll) */
.dice-anim {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 950;
}

.dice-anim .die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(16,18,26,.35);
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  line-height: 1;
}

/* D20 dice - completely remove all background and make it huge */
.dice-anim.d20 .die {
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  font-size: 64px !important;
  font-weight: 900 !important;
  padding: 0 20px !important;
  text-shadow: 0 0 24px rgba(255,183,74,1) !important;
  line-height: 1 !important;
  min-width: 80px !important;
  color: #ffbe4a !important;
}
.loading-text{font-weight:900; color: var(--text);}

.toast{position:fixed; left:50%; bottom:18px; transform: translateX(-50%); background: rgba(16,18,26,.95); border:1px solid rgba(255,255,255,.16); color: var(--text); padding: 12px 14px; border-radius: 14px; box-shadow: var(--shadow2); max-width:min(520px, calc(100vw - 36px));}

/* Stories page background */
.stories-full-bg{position:fixed; inset:0; z-index:0; pointer-events:none; background-image: url('/static/art/stories_bg.svg'); background-size: cover; background-position: top center; filter: saturate(0.98) contrast(1.06) brightness(0.66); opacity: .78; -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%); mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);} 
/* Dither/grain overlay to reduce gradient banding on large fades */
.stories-full-bg::after{content:""; position:absolute; inset:0; background-image: url('/static/art/noise_128.png'); background-repeat: repeat; background-size: 128px 128px; opacity:.065; mix-blend-mode: overlay; pointer-events:none; -webkit-mask-image: inherit; mask-image: inherit;}

.stories-page{position:relative; padding: 0; border-radius: 0; overflow:visible;}
.stories-page::after{content:none;}
.stories-page > *{position:relative; z-index:1;}

/* Menu button + dropdown */
.menu-btn{width:42px; height:42px; border-radius: 16px; display:inline-flex; align-items:center; justify-content:center; border:1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: rgba(238,240,244,.92); cursor:pointer; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);} 
.menu-btn:hover{transform: translateY(-1px); background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.22);} 

.burger-btn{flex-direction:column; gap:5px; padding:0 11px;}
.burger-btn .bar{display:block; width:18px; height:2px; border-radius:999px; background: rgba(255,255,255,.82); box-shadow: 0 1px 0 rgba(0,0,0,.15);} 
.icon-btn{padding:0;}



.dropdown{
  position:fixed;
  width:min(360px, calc(100vw - 36px));
  border:1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(16,18,26,.96);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  color: var(--text);
  overflow:hidden;
  z-index:1001;
  /* Animation properties */
  opacity: 0;
  transform: translateY(-10px);
  transform-origin: top right;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  pointer-events: none;
}

.dropdown.open{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.menu-backdrop{
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height: var(--menu-backdrop-height, 100vh);
  background:rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index:105;
  /* Animation properties */
  opacity: 0;
  transition: opacity 200ms var(--ease);
  pointer-events: none;
}

.menu-backdrop.open{
  opacity: 1;
  pointer-events: auto;
}

.dropdown-head{display:flex; align-items:center; justify-content:space-between; gap:12px; padding: 12px 12px; border-bottom: 1px solid rgba(255,255,255,.10);} 
.dropdown-title{font-weight:950;} 
.dropdown-sub{font-size:12px; color: var(--muted); margin-top:2px;} 
.dropdown-body{padding: 10px;} 
.dropdown-item{display:flex; align-items:center; gap:10px; width:100%; padding: 10px 12px; border-radius: 14px; color: var(--text); background: transparent; border: 1px solid rgba(255,255,255,.10); text-decoration:none; font-weight:800; margin-bottom: 8px;} 
.dropdown-item:hover{background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18);}
.dropdown-item svg{flex-shrink:0; opacity:.7;} 
.dropdown-sep{height:1px; background: rgba(255,255,255,.10); margin: 8px 2px 10px;} 

.footer{color: rgba(180,188,199,.8); font-size: 12px; padding: 22px 18px; text-align:center; border-top: 1px solid var(--line);} 

/* Site Footer - ensure it sticks to bottom */
.site-footer {
  padding: 24px;
  text-align: center;
  border-top: 1px solid var(--line);
  margin-top: auto;
  flex-shrink: 0;
  background: transparent;
}

/* Content typography */
.content p{margin: 10px 0;}
.content h2{margin: 18px 0 8px;}

/* ToS Agreement Box on Signup */
.tos-agreement-box {
  margin-top: 16px;
  padding: 16px;
  background: rgba(16, 18, 26, 0.5);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.tos-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.6;
}

.tos-checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.tos-text {
  display: block;
}


/* log scrollbar + top fade */
#logbox{scrollbar-width: none; -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 100%); mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 100%);} 
#logbox.at-top{-webkit-mask-image: none; mask-image: none;}
#logbox::-webkit-scrollbar{width:0;height:0;}

/* Story VIEW page: let the log fill the viewport height on desktop; stack on small screens */
.grid.story-grid{align-items: stretch;}
@media (min-width: 900px){
  .grid.story-grid{height: calc(100vh - 240px);} /* header + paddings; tuned by feel */
  .grid.story-grid > .panel{height: 100%;}
  .grid.story-grid > .panel .panel-inner{height: 100%; display:flex; flex-direction:column;}
  .grid.story-grid > .panel .panel-inner .h2{flex: 0 0 auto;}
  .grid.story-grid #logbox{flex: 1 1 auto; min-height: 260px; max-height: none;}
}
@media (max-width: 899px){
  .grid.story-grid{height:auto;}
  .grid.story-grid #logbox{max-height: 55vh;}
}


/* options animations */
.options-exit{opacity:0 !important; transform: translateY(-4px) !important; transition: opacity 220ms ease, transform 220ms ease;}
.options-enter{opacity:0; transform: translateY(6px);}
.options-enter.ready{opacity:1; transform:none; transition: opacity 260ms ease, transform 260ms ease;}


/* Character Sheet Overlay Styles */
.char-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s ease;
}

.char-sheet-overlay.active {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s, opacity 0.3s ease;
}

.char-sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 10, 0.85);
  backdrop-filter: blur(4px);
}

.char-sheet-panel {
  position: relative;
  margin-left: auto;
  margin-top: 52px;
  width: 100%;
  max-width: 480px;
  height: calc(100% - 52px);
  padding-top: env(safe-area-inset-top, 0px);
  background: linear-gradient(180deg, rgba(20, 22, 35, 0.98), rgba(16, 18, 30, 0.98));
  border-left: 1px solid var(--accent-border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.char-sheet-overlay.active .char-sheet-panel {
  transform: translateX(0);
}

.char-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--accent-border);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
}

.char-sheet-header h2 {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 22px;
  margin: 0;
  color: rgba(238, 240, 244, 0.95);
}

.char-sheet-close {
  background: none;
  border: none;
  color: rgba(238, 240, 244, 0.7);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.char-sheet-close:hover {
  color: rgba(238, 240, 244, 1);
}

.char-sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.char-sheet-section {
  margin-bottom: 28px;
}

.char-sheet-section h3 {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 16px;
  color: var(--accent);
  margin: 0 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--accent-border);
}

.char-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.char-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.char-info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(180, 188, 199, 0.7);
}

.char-info-value {
  font-size: 15px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.ability-scores-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ability-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  text-align: center;
}

.ability-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(180, 188, 199, 0.8);
  margin-bottom: 6px;
}

.ability-score {
  font-size: 22px;
  font-weight: 900;
  color: rgba(238, 240, 244, 0.98);
}

.ability-mod {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.7);
  margin-top: 2px;
}

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

.combat-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  text-align: center;
}

.combat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(180, 188, 199, 0.7);
  margin-bottom: 6px;
}

.combat-value {
  font-size: 20px;
  font-weight: 800;
  color: rgba(238, 240, 244, 0.98);
}

.equipment-list,
.spells-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.equipment-item,
.spell-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.equipment-item:hover,
.spell-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.equipment-item.equipped {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
}

.equipment-name,
.spell-name {
  font-size: 14px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.95);
}

.equipment-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  background: rgba(34, 197, 94, 0.2);
  color: rgba(34, 197, 94, 1);
  border-radius: 12px;
}

.spell-level {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.7);
}

.char-sheet-empty {
  text-align: center;
  padding: 20px;
  color: rgba(180, 188, 199, 0.5);
  font-style: italic;
  font-size: 14px;
}

.char-sheet-content::-webkit-scrollbar {
  width: 8px;
}

.char-sheet-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.char-sheet-content::-webkit-scrollbar-thumb {
  background: var(--accent-border);
  border-radius: 4px;
}

.char-sheet-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Skills section */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.skill-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.skill-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.skill-item::before {
  content: "✦";
  color: var(--accent);
  margin-right: 8px;
  font-size: 10px;
}

.skill-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.95);
}

/* Features section */
.features-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.feature-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.feature-item::before {
  content: "⚔️";
  margin-right: 10px;
  font-size: 14px;
}

.feature-name {
  font-size: 14px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.95);
}

@media (max-width: 520px) {
  .char-sheet-panel {
    max-width: 100%;
  }
  
  .char-info-grid {
    grid-template-columns: 1fr;
  }
  
  .ability-scores-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .combat-stats-grid {
    grid-template-columns: 1fr;
  }
  
  .skills-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   DANGER LEVEL THEMES
   ============================================ */

/* Peaceful - Arcane purple (default) */
.story-container.danger-peaceful {
  --accent: var(--theme-peaceful);
  --accent-rgb: 183, 108, 255;
}

/* Calm - Teal/cyan */
.story-container.danger-calm {
  --accent: var(--theme-calm);
  --accent-rgb: 94, 234, 212;
}

/* Tense - Amber/orange */
.story-container.danger-tense {
  --accent: var(--theme-tense);
  --accent-rgb: 255, 184, 74;
}

/* Dangerous - Red */
.story-container.danger-dangerous {
  --accent: var(--theme-dangerous);
  --accent-rgb: 239, 68, 68;
}

/* Critical - Deep crimson */
.story-container.danger-critical {
  --accent: var(--theme-critical);
  --accent-rgb: 220, 38, 38;
}

/* ============================================
   DANGER LEVEL VISUAL THEMES
   ============================================ */

/* Apply theme colors to story-specific UI elements */
.story-container.danger-peaceful .character-float-inner {
  border-color: rgba(183, 108, 255, 0.25);
  box-shadow: 0 0 20px rgba(183, 108, 255, 0.15);
}

.story-container.danger-calm .character-float-inner {
  border-color: rgba(94, 234, 212, 0.25);
  box-shadow: 0 0 20px rgba(94, 234, 212, 0.15);
}

.story-container.danger-tense .character-float-inner {
  border-color: rgba(255, 184, 74, 0.25);
  box-shadow: 0 0 20px rgba(255, 184, 74, 0.15);
}

.story-container.danger-dangerous .character-float-inner {
  border-color: rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
}

.story-container.danger-critical .character-float-inner {
  border-color: rgba(220, 38, 38, 0.35);
  box-shadow: 0 0 30px rgba(220, 38, 38, 0.25);
  animation: critical-pulse 2s ease-in-out infinite;
}

@keyframes critical-pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(220, 38, 38, 0.25); }
  50% { box-shadow: 0 0 50px rgba(220, 38, 38, 0.4); }
}

/* Story log entry labels */
.story-container.danger-peaceful .gm-label {
  color: var(--theme-peaceful);
}

.story-container.danger-calm .gm-label {
  color: var(--theme-calm);
}

.story-container.danger-tense .gm-label {
  color: var(--theme-tense);
}

.story-container.danger-dangerous .gm-label {
  color: var(--theme-dangerous);
}

.story-container.danger-critical .gm-label {
  color: var(--theme-critical);
}

/* Action bar accent */
.story-container.danger-peaceful ~ .action-bar,
.story-container.danger-peaceful .action-bar {
  border-top-color: rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm ~ .action-bar,
.story-container.danger-calm .action-bar {
  border-top-color: rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense ~ .action-bar,
.story-container.danger-tense .action-bar {
  border-top-color: rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous ~ .action-bar,
.story-container.danger-dangerous .action-bar {
  border-top-color: rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical ~ .action-bar,
.story-container.danger-critical .action-bar {
  border-top-color: rgba(220, 38, 38, 0.4);
}

/* Option buttons */
.story-container.danger-peaceful .option-btn:hover {
  border-color: var(--theme-peaceful);
  background: rgba(183, 108, 255, 0.1);
}

.story-container.danger-calm .option-btn:hover {
  border-color: var(--theme-calm);
  background: rgba(94, 234, 212, 0.1);
}

.story-container.danger-tense .option-btn:hover {
  border-color: var(--theme-tense);
  background: rgba(255, 184, 74, 0.1);
}

.story-container.danger-dangerous .option-btn:hover {
  border-color: var(--theme-dangerous);
  background: rgba(239, 68, 68, 0.1);
}

.story-container.danger-critical .option-btn:hover {
  border-color: var(--theme-critical);
  background: rgba(220, 38, 38, 0.15);
}

/* Submit button */
.story-container.danger-peaceful .action-submit {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.2), rgba(183, 108, 255, 0.1));
  border-color: rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .action-submit {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.2), rgba(94, 234, 212, 0.1));
  border-color: rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .action-submit {
  background: linear-gradient(135deg, rgba(255, 184, 74, 0.2), rgba(255, 184, 74, 0.1));
  border-color: rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .action-submit {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.1));
  border-color: rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .action-submit {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.25), rgba(220, 38, 38, 0.15));
  border-color: rgba(220, 38, 38, 0.5);
}

/* Journal overlay accent */
.story-container.danger-peaceful .journal-overlay {
  border-left-color: rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .journal-overlay {
  border-left-color: rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .journal-overlay {
  border-left-color: rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous .journal-overlay {
  border-left-color: rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical .journal-overlay {
  border-left-color: rgba(220, 38, 38, 0.4);
}

/* ============================================
   COMPREHENSIVE DANGER LEVEL THEMING
   ============================================ */

/* Override --accent variable for all elements within story container */
.story-container.danger-peaceful {
  --accent: var(--theme-peaceful) !important;
  --accent-rgb: 183, 108, 255 !important;
}

.story-container.danger-calm {
  --accent: var(--theme-calm) !important;
  --accent-rgb: 94, 234, 212 !important;
}

.story-container.danger-tense {
  --accent: var(--theme-tense) !important;
  --accent-rgb: 255, 184, 74 !important;
}

.story-container.danger-dangerous {
  --accent: var(--theme-dangerous) !important;
  --accent-rgb: 239, 68, 68 !important;
}

.story-container.danger-critical {
  --accent: var(--theme-critical) !important;
  --accent-rgb: 220, 38, 38 !important;
}

/* Background glow effects */
.story-container.danger-peaceful .story-ambient-bg {
  box-shadow: inset 0 0 200px rgba(183, 108, 255, 0.05);
}

.story-container.danger-calm .story-ambient-bg {
  box-shadow: inset 0 0 200px rgba(94, 234, 212, 0.05);
}

.story-container.danger-tense .story-ambient-bg {
  box-shadow: inset 0 0 300px rgba(255, 184, 74, 0.08);
  animation: tense-glow 3s ease-in-out infinite;
}

.story-container.danger-dangerous .story-ambient-bg {
  box-shadow: inset 0 0 400px rgba(239, 68, 68, 0.12);
  animation: dangerous-glow 2s ease-in-out infinite;
}

.story-container.danger-critical .story-ambient-bg {
  box-shadow: inset 0 0 500px rgba(220, 38, 38, 0.18);
  animation: critical-glow 1s ease-in-out infinite;
}

@keyframes tense-glow {
  0%, 100% { box-shadow: inset 0 0 300px rgba(255, 184, 74, 0.08); }
  50% { box-shadow: inset 0 0 350px rgba(255, 184, 74, 0.12); }
}

@keyframes dangerous-glow {
  0%, 100% { box-shadow: inset 0 0 400px rgba(239, 68, 68, 0.12); }
  50% { box-shadow: inset 0 0 500px rgba(239, 68, 68, 0.18); }
}

@keyframes critical-glow {
  0%, 100% { box-shadow: inset 0 0 500px rgba(220, 38, 38, 0.18); }
  50% { box-shadow: inset 0 0 600px rgba(220, 38, 38, 0.28); }
}

/* All accent-colored elements */
.story-container.danger-peaceful [style*="b76cff"],
.story-container.danger-peaceful [style*="#b76cff"] {
  color: var(--theme-peaceful) !important;
  border-color: var(--theme-peaceful) !important;
}

.story-container.danger-calm [style*="b76cff"],
.story-container.danger-calm [style*="#b76cff"] {
  color: var(--theme-calm) !important;
  border-color: var(--theme-calm) !important;
}

.story-container.danger-tense [style*="b76cff"],
.story-container.danger-tense [style*="#b76cff"] {
  color: var(--theme-tense) !important;
  border-color: var(--theme-tense) !important;
}

.story-container.danger-dangerous [style*="b76cff"],
.story-container.danger-dangerous [style*="#b76cff"] {
  color: var(--theme-dangerous) !important;
  border-color: var(--theme-dangerous) !important;
}

.story-container.danger-critical [style*="b76cff"],
.story-container.danger-critical [style*="#b76cff"] {
  color: var(--theme-critical) !important;
  border-color: var(--theme-critical) !important;
}

/* Stat pills */
.story-container.danger-peaceful .stat-pill {
  background: rgba(183, 108, 255, 0.12);
  border-color: rgba(183, 108, 255, 0.2);
}

.story-container.danger-calm .stat-pill {
  background: rgba(94, 234, 212, 0.12);
  border-color: rgba(94, 234, 212, 0.2);
}

.story-container.danger-tense .stat-pill {
  background: rgba(255, 184, 74, 0.12);
  border-color: rgba(255, 184, 74, 0.2);
}

.story-container.danger-dangerous .stat-pill {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.2);
}

.story-container.danger-critical .stat-pill {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.3);
}

/* You label */
.story-container.danger-peaceful .you-label {
  color: var(--theme-peaceful);
}

.story-container.danger-calm .you-label {
  color: var(--theme-calm);
}

.story-container.danger-tense .you-label {
  color: var(--theme-tense);
}

.story-container.danger-dangerous .you-label {
  color: var(--theme-dangerous);
}

.story-container.danger-critical .you-label {
  color: var(--theme-critical);
}

/* Roll badges */
.story-container.danger-peaceful .roll-badge.crit {
  background: rgba(183, 108, 255, 0.25);
  border-color: rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .roll-badge.crit {
  background: rgba(94, 234, 212, 0.25);
  border-color: rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .roll-badge.crit {
  background: rgba(255, 184, 74, 0.25);
  border-color: rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .roll-badge.crit {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .roll-badge.crit {
  background: rgba(220, 38, 38, 0.3);
  border-color: rgba(220, 38, 38, 0.5);
}

/* Spinner */
.story-container.danger-peaceful .spinner {
  border-top-color: var(--theme-peaceful);
}

.story-container.danger-calm .spinner {
  border-top-color: var(--theme-calm);
}

.story-container.danger-tense .spinner {
  border-top-color: var(--theme-tense);
}

.story-container.danger-dangerous .spinner {
  border-top-color: var(--theme-dangerous);
}

.story-container.danger-critical .spinner {
  border-top-color: var(--theme-critical);
}

/* Journal nav buttons active */
.story-container.danger-peaceful .journal-nav-btn.active {
  background: rgba(183, 108, 255, 0.2);
  border-color: rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .journal-nav-btn.active {
  background: rgba(94, 234, 212, 0.2);
  border-color: rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .journal-nav-btn.active {
  background: rgba(255, 184, 74, 0.2);
  border-color: rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .journal-nav-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .journal-nav-btn.active {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.5);
}

/* Tab buttons */
.story-container.danger-peaceful .tab-btn.active {
  background: rgba(183, 108, 255, 0.2);
  border-color: rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .tab-btn.active {
  background: rgba(94, 234, 212, 0.2);
  border-color: rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .tab-btn.active {
  background: rgba(255, 184, 74, 0.2);
  border-color: rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .tab-btn.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .tab-btn.active {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.5);
}

/* ============================================
   DRAMATIC DANGER LEVEL THEMING - FULL UI TRANSFORMATION
   ============================================ */

/* Root accent variable overrides - using :root to affect all children */
.story-container.danger-peaceful {
  --accent: #b76cff !important;
  --accent-rgb: 183, 108, 255 !important;
  --accent-soft: rgba(183, 108, 255, 0.2) !important;
  --accent-border: rgba(183, 108, 255, 0.3) !important;
  --accent-glow: rgba(183, 108, 255, 0.15) !important;
}

.story-container.danger-calm {
  --accent: #5eead4 !important;
  --accent-rgb: 94, 234, 212 !important;
  --accent-soft: rgba(94, 234, 212, 0.2) !important;
  --accent-border: rgba(94, 234, 212, 0.3) !important;
  --accent-glow: rgba(94, 234, 212, 0.15) !important;
}

.story-container.danger-tense {
  --accent: #ffb84a !important;
  --accent-rgb: 255, 184, 74 !important;
  --accent-soft: rgba(255, 184, 74, 0.2) !important;
  --accent-border: rgba(255, 184, 74, 0.3) !important;
  --accent-glow: rgba(255, 184, 74, 0.15) !important;
}

.story-container.danger-dangerous {
  --accent: #ef4444 !important;
  --accent-rgb: 239, 68, 68 !important;
  --accent-soft: rgba(239, 68, 68, 0.2) !important;
  --accent-border: rgba(239, 68, 68, 0.3) !important;
  --accent-glow: rgba(239, 68, 68, 0.15) !important;
}

.story-container.danger-critical {
  --accent: #dc2626 !important;
  --accent-rgb: 220, 38, 38 !important;
  --accent-soft: rgba(220, 38, 38, 0.2) !important;
  --accent-border: rgba(220, 38, 38, 0.3) !important;
  --accent-glow: rgba(220, 38, 38, 0.15) !important;
}

/* Smooth transition for all theme changes */
.story-container,
.story-container .story-ambient-bg,
.story-container .character-float-inner,
.story-container .stat-pill,
.story-container .gm-label,
.story-container .you-label,
.story-container .action-bar,
.story-container .option-btn,
.story-container .action-submit,
.story-container .journal-overlay,
.story-container .journal-nav-btn,
.story-container .tab-btn,
.story-container .roll-badge,
.story-container .spinner,
.story-container .char-stat,
.story-container .send-btn,
.story-container .llm-toggle-btn,
.story-container .input-tab,
.story-container .option-number,
.story-container .quick-btn {
  transition: all 0.5s ease-in-out;
}

/* Override ALL hardcoded purple rgba values within story container for ALL themes */
.story-container.danger-peaceful [style*="rgba(180,"],
.story-container.danger-peaceful [style*="rgba(183,"],
.story-container.danger-calm [style*="rgba(180,"],
.story-container.danger-calm [style*="rgba(183,"],
.story-container.danger-tense [style*="rgba(180,"],
.story-container.danger-tense [style*="rgba(183,"],
.story-container.danger-dangerous [style*="rgba(180,"],
.story-container.danger-dangerous [style*="rgba(183,"],
.story-container.danger-critical [style*="rgba(180,"],
.story-container.danger-critical [style*="rgba(183,"] {
  border-color: var(--accent-border) !important;
  background-color: var(--accent-soft) !important;
  color: var(--accent) !important;
}

/* Universal override for all purple-tinted elements in ALL states */
.story-container.danger-peaceful *,
.story-container.danger-calm *,
.story-container.danger-tense *,
.story-container.danger-dangerous *,
.story-container.danger-critical * {
  border-color: var(--accent-border) !important;
}

/* Option buttons - ALL themes */
.story-container.danger-peaceful .option-btn,
.story-container.danger-calm .option-btn,
.story-container.danger-tense .option-btn,
.story-container.danger-dangerous .option-btn,
.story-container.danger-critical .option-btn {
  border: 1px solid var(--accent-border) !important;
  background: rgba(20, 22, 35, 0.8) !important;
}

.story-container.danger-peaceful .option-btn:hover,
.story-container.danger-calm .option-btn:hover,
.story-container.danger-tense .option-btn:hover,
.story-container.danger-dangerous .option-btn:hover,
.story-container.danger-critical .option-btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
  box-shadow: 0 0 20px var(--accent-glow) !important;
}

/* Send button - ALL themes */
.story-container.danger-peaceful .send-btn,
.story-container.danger-calm .send-btn,
.story-container.danger-tense .send-btn,
.story-container.danger-dangerous .send-btn,
.story-container.danger-critical .send-btn {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-peaceful .send-btn:hover,
.story-container.danger-calm .send-btn:hover,
.story-container.danger-tense .send-btn:hover,
.story-container.danger-dangerous .send-btn:hover,
.story-container.danger-critical .send-btn:hover {
  background: var(--accent) !important;
}

/* LLM toggle buttons - ALL themes */
.story-container.danger-peaceful .llm-toggle-btn.active,
.story-container.danger-calm .llm-toggle-btn.active,
.story-container.danger-tense .llm-toggle-btn.active,
.story-container.danger-dangerous .llm-toggle-btn.active,
.story-container.danger-critical .llm-toggle-btn.active {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
  color: var(--text) !important;
}

/* Character stats - ALL themes */
.story-container.danger-peaceful .char-stat,
.story-container.danger-calm .char-stat,
.story-container.danger-tense .char-stat,
.story-container.danger-dangerous .char-stat,
.story-container.danger-critical .char-stat {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
  color: var(--accent) !important;
}

/* Action input - ALL themes */
.story-container.danger-peaceful .action-input,
.story-container.danger-calm .action-input,
.story-container.danger-tense .action-input,
.story-container.danger-dangerous .action-input,
.story-container.danger-critical .action-input {
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-peaceful .action-input:focus,
.story-container.danger-calm .action-input:focus,
.story-container.danger-tense .action-input:focus,
.story-container.danger-dangerous .action-input:focus,
.story-container.danger-critical .action-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
}

/* Quick buttons - ALL themes */
.story-container.danger-peaceful .quick-btn,
.story-container.danger-calm .quick-btn,
.story-container.danger-tense .quick-btn,
.story-container.danger-dangerous .quick-btn,
.story-container.danger-critical .quick-btn {
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-peaceful .quick-btn:hover,
.story-container.danger-calm .quick-btn:hover,
.story-container.danger-tense .quick-btn:hover,
.story-container.danger-dangerous .quick-btn:hover,
.story-container.danger-critical .quick-btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

/* Remove the left border I added to story entries */
.story-container .story-entry {
  border-left: none !important;
}

.story-container .story-entry.user {
  border-left: none !important;
}

/* Recolor the existing GM label instead - ALL themes */
.story-container.danger-peaceful .gm-label,
.story-container.danger-calm .gm-label,
.story-container.danger-tense .gm-label,
.story-container.danger-dangerous .gm-label,
.story-container.danger-critical .gm-label {
  color: var(--accent) !important;
  text-shadow: 0 0 15px var(--accent-glow) !important;
}

.story-container.danger-peaceful .you-label,
.story-container.danger-calm .you-label,
.story-container.danger-tense .you-label,
.story-container.danger-dangerous .you-label,
.story-container.danger-critical .you-label {
  color: var(--accent) !important;
}

/* Option number circles - ALL themes */
.story-container.danger-peaceful .option-number,
.story-container.danger-calm .option-number,
.story-container.danger-tense .option-number,
.story-container.danger-dangerous .option-number,
.story-container.danger-critical .option-number {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent-border) !important;
}

/* Remove the line between action buttons and input - ALL themes */
.story-container.danger-peaceful .input-container,
.story-container.danger-calm .input-container,
.story-container.danger-dangerous .input-container,
.story-container.danger-critical .input-container {
  border-top: none !important;
}

/* Explicitly remove border-top for danger-tense */
.story-container.danger-tense .input-container {
  border-top: none !important;
}

/* Input tabs - ALL themes */
.story-container.danger-peaceful .input-tab.active,
.story-container.danger-calm .input-tab.active,
.story-container.danger-tense .input-tab.active,
.story-container.danger-dangerous .input-tab.active,
.story-container.danger-critical .input-tab.active {
  background: var(--accent-soft) !important;
  border-color: var(--accent-border) !important;
  color: var(--text) !important;
}

/* Background themes - ALL non-calm states */
.story-container.danger-peaceful .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(183, 108, 255, 0.15) 0%, transparent 70%),
              radial-gradient(ellipse at 30% 30%, rgba(150, 80, 220, 0.2) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 70%, rgba(120, 60, 200, 0.15) 0%, transparent 50%) !important;
  box-shadow: inset 0 0 600px rgba(150, 80, 220, 0.2), inset 0 0 300px rgba(100, 50, 180, 0.15) !important;
  opacity: 0.12 !important;
}

.story-container.danger-tense .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(255, 184, 74, 0.2) 0%, transparent 70%),
              radial-gradient(ellipse at 30% 30%, rgba(220, 150, 50, 0.25) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 70%, rgba(180, 120, 40, 0.2) 0%, transparent 50%) !important;
  box-shadow: inset 0 0 700px rgba(220, 150, 50, 0.25), inset 0 0 350px rgba(150, 100, 30, 0.2) !important;
  opacity: 0.13 !important;
}

.story-container.danger-dangerous .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(239, 68, 68, 0.25) 0%, transparent 70%),
              radial-gradient(ellipse at 30% 30%, rgba(200, 40, 40, 0.3) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 70%, rgba(160, 30, 30, 0.25) 0%, transparent 50%) !important;
  box-shadow: inset 0 0 750px rgba(200, 40, 40, 0.3), inset 0 0 375px rgba(120, 20, 20, 0.25) !important;
  opacity: 0.14 !important;
}

.story-container.danger-critical .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(220, 38, 38, 0.3) 0%, transparent 70%),
              radial-gradient(ellipse at 30% 30%, rgba(180, 20, 20, 0.35) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 70%, rgba(140, 10, 10, 0.3) 0%, transparent 50%) !important;
  box-shadow: inset 0 0 800px rgba(180, 20, 20, 0.35), inset 0 0 400px rgba(100, 0, 0, 0.3) !important;
  opacity: 0.15 !important;
}

/* Universal override for all purple-tinted elements in dangerous/critical states */
.story-container.danger-dangerous *,
.story-container.danger-critical * {
  border-color: var(--accent-border) !important;
}

.story-container.danger-dangerous .option-btn,
.story-container.danger-critical .option-btn {
  border: 1px solid var(--accent-border) !important;
  background: rgba(20, 22, 35, 0.8) !important;
}

.story-container.danger-dangerous .option-btn:hover,
.story-container.danger-critical .option-btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
  box-shadow: 0 0 20px var(--accent-glow) !important;
}

.story-container.danger-dangerous .send-btn,
.story-container.danger-critical .send-btn {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-dangerous .send-btn:hover,
.story-container.danger-critical .send-btn:hover {
  background: var(--accent) !important;
}

.story-container.danger-dangerous .llm-toggle-btn.active,
.story-container.danger-critical .llm-toggle-btn.active {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
  color: var(--text) !important;
}

.story-container.danger-dangerous .char-stat,
.story-container.danger-critical .char-stat {
  background: var(--accent-soft) !important;
  border: 1px solid var(--accent-border) !important;
  color: var(--accent) !important;
}

.story-container.danger-dangerous .action-input,
.story-container.danger-critical .action-input {
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-dangerous .action-input:focus,
.story-container.danger-critical .action-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
}

.story-container.danger-dangerous .quick-btn,
.story-container.danger-critical .quick-btn {
  border: 1px solid var(--accent-border) !important;
}

.story-container.danger-dangerous .quick-btn:hover,
.story-container.danger-critical .quick-btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

/* Remove the left border I added to story entries */
.story-container .story-entry {
  border-left: none !important;
}

.story-container .story-entry.user {
  border-left: none !important;
}

/* Recolor the existing GM label instead */
.story-container.danger-dangerous .gm-label,
.story-container.danger-critical .gm-label {
  color: var(--accent) !important;
  text-shadow: 0 0 15px var(--accent-glow) !important;
}

.story-container.danger-dangerous .you-label,
.story-container.danger-critical .you-label {
  color: var(--accent) !important;
}

/* Option number circles - change the purple background */
.story-container.danger-dangerous .option-number,
.story-container.danger-critical .option-number {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent-border) !important;
}

/* Remove the line between action buttons and input */
.story-container.danger-dangerous .input-container,
.story-container.danger-critical .input-container {
  border-top: none !important;
}

/* Darken the background behind the story even more */
.story-container.danger-dangerous .story-ambient-bg,
.story-container.danger-critical .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(239, 68, 68, 0.35) 0%, transparent 70%),
              radial-gradient(ellipse at 30% 30%, rgba(180, 20, 20, 0.4) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 70%, rgba(150, 10, 10, 0.3) 0%, transparent 50%) !important;
  box-shadow: inset 0 0 800px rgba(180, 20, 20, 0.4), inset 0 0 400px rgba(100, 0, 0, 0.3) !important;
  opacity: 0.15 !important;
}

/* Input tabs - remove purple */
.story-container.danger-dangerous .input-tab.active,
.story-container.danger-critical .input-tab.active {
  background: var(--accent-soft) !important;
  border-color: var(--accent-border) !important;
  color: var(--text) !important;
}

/* Background atmosphere - dramatic color shifts */
.story-container.danger-peaceful .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(183, 108, 255, 0.15) 0%, transparent 70%);
  box-shadow: inset 0 0 300px rgba(183, 108, 255, 0.1);
}

.story-container.danger-calm .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(94, 234, 212, 0.15) 0%, transparent 70%);
  box-shadow: inset 0 0 300px rgba(94, 234, 212, 0.1);
}

.story-container.danger-tense .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(255, 184, 74, 0.2) 0%, transparent 70%);
  box-shadow: inset 0 0 400px rgba(255, 184, 74, 0.15);
  animation: tense-pulse 4s ease-in-out infinite;
}

.story-container.danger-dangerous .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(239, 68, 68, 0.25) 0%, transparent 70%);
  box-shadow: inset 0 0 500px rgba(239, 68, 68, 0.2);
  animation: dangerous-pulse 2s ease-in-out infinite;
}

.story-container.danger-critical .story-ambient-bg {
  background: radial-gradient(ellipse at center, rgba(220, 38, 38, 0.35) 0%, transparent 70%);
  box-shadow: inset 0 0 600px rgba(220, 38, 38, 0.3);
  animation: critical-pulse 1s ease-in-out infinite;
}

@keyframes tense-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

@keyframes dangerous-pulse {
  0%, 100% { opacity: 0.9; box-shadow: inset 0 0 500px rgba(239, 68, 68, 0.2); }
  50% { opacity: 1; box-shadow: inset 0 0 700px rgba(239, 68, 68, 0.35); }
}

@keyframes critical-pulse {
  0%, 100% { opacity: 1; box-shadow: inset 0 0 600px rgba(220, 38, 38, 0.3); }
  50% { opacity: 1; box-shadow: inset 0 0 900px rgba(220, 38, 38, 0.5); }
}

/* Character float - dramatic border and glow changes */
.story-container.danger-peaceful .character-float-inner {
  border: 2px solid rgba(183, 108, 255, 0.4);
  box-shadow: 0 0 30px rgba(183, 108, 255, 0.2), inset 0 0 20px rgba(183, 108, 255, 0.05);
}

.story-container.danger-calm .character-float-inner {
  border: 2px solid rgba(94, 234, 212, 0.4);
  box-shadow: 0 0 30px rgba(94, 234, 212, 0.2), inset 0 0 20px rgba(94, 234, 212, 0.05);
}

.story-container.danger-tense .character-float-inner {
  border: 2px solid rgba(255, 184, 74, 0.5);
  box-shadow: 0 0 40px rgba(255, 184, 74, 0.3), inset 0 0 20px rgba(255, 184, 74, 0.1);
}

.story-container.danger-dangerous .character-float-inner {
  border: 2px solid rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.4), inset 0 0 30px rgba(239, 68, 68, 0.15);
}

.story-container.danger-critical .character-float-inner {
  border: 3px solid rgba(220, 38, 38, 0.8);
  box-shadow: 0 0 70px rgba(220, 38, 38, 0.6), inset 0 0 40px rgba(220, 38, 38, 0.25);
  animation: critical-float 1.5s ease-in-out infinite;
}

@keyframes critical-float {
  0%, 100% { box-shadow: 0 0 70px rgba(220, 38, 38, 0.6), inset 0 0 40px rgba(220, 38, 38, 0.25); }
  50% { box-shadow: 0 0 100px rgba(220, 38, 38, 0.8), inset 0 0 60px rgba(220, 38, 38, 0.4); }
}

/* Stat pills - full color transformation */
.story-container.danger-peaceful .stat-pill {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.2), rgba(183, 108, 255, 0.1));
  border: 1px solid rgba(183, 108, 255, 0.4);
  box-shadow: 0 2px 8px rgba(183, 108, 255, 0.15);
}

.story-container.danger-calm .stat-pill {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.2), rgba(94, 234, 212, 0.1));
  border: 1px solid rgba(94, 234, 212, 0.4);
  box-shadow: 0 2px 8px rgba(94, 234, 212, 0.15);
}

.story-container.danger-tense .stat-pill {
  background: linear-gradient(135deg, rgba(255, 184, 74, 0.25), rgba(255, 184, 74, 0.15));
  border: 1px solid rgba(255, 184, 74, 0.5);
  box-shadow: 0 2px 10px rgba(255, 184, 74, 0.2);
}

.story-container.danger-dangerous .stat-pill {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.15));
  border: 1px solid rgba(239, 68, 68, 0.6);
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.25);
}

.story-container.danger-critical .stat-pill {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.4), rgba(220, 38, 38, 0.2));
  border: 2px solid rgba(220, 38, 38, 0.7);
  box-shadow: 0 2px 15px rgba(220, 38, 38, 0.35);
}

/* Labels and text - dramatic color changes */
.story-container.danger-peaceful .gm-label,
.story-container.danger-peaceful .you-label {
  color: #b76cff;
  text-shadow: 0 0 10px rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .gm-label,
.story-container.danger-calm .you-label {
  color: #5eead4;
  text-shadow: 0 0 10px rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .gm-label,
.story-container.danger-tense .you-label {
  color: #ffb84a;
  text-shadow: 0 0 12px rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .gm-label,
.story-container.danger-dangerous .you-label {
  color: #ef4444;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.story-container.danger-critical .gm-label,
.story-container.danger-critical .you-label {
  color: #dc2626;
  text-shadow: 0 0 20px rgba(220, 38, 38, 0.6);
  animation: critical-text 2s ease-in-out infinite;
}

@keyframes critical-text {
  0%, 100% { text-shadow: 0 0 20px rgba(220, 38, 38, 0.6); }
  50% { text-shadow: 0 0 30px rgba(220, 38, 38, 0.9); }
}

/* Action bar - full transformation */
.story-container.danger-peaceful .action-bar {
  border-top: 2px solid rgba(183, 108, 255, 0.4);
  background: linear-gradient(180deg, rgba(183, 108, 255, 0.08), transparent);
}

.story-container.danger-calm .action-bar {
  border-top: 2px solid rgba(94, 234, 212, 0.4);
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.08), transparent);
}

.story-container.danger-tense .action-bar {
  border-top: 2px solid rgba(255, 184, 74, 0.5);
  background: linear-gradient(180deg, rgba(255, 184, 74, 0.1), transparent);
}

.story-container.danger-dangerous .action-bar {
  border-top: 2px solid rgba(239, 68, 68, 0.6);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.12), transparent);
}

.story-container.danger-critical .action-bar {
  border-top: 3px solid rgba(220, 38, 38, 0.8);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.15), transparent);
}

/* Option buttons - dramatic hover states */
.story-container.danger-peaceful .option-btn:hover {
  border-color: rgba(183, 108, 255, 0.8);
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.2), rgba(183, 108, 255, 0.1));
  box-shadow: 0 4px 15px rgba(183, 108, 255, 0.25);
  transform: translateY(-2px);
}

.story-container.danger-calm .option-btn:hover {
  border-color: rgba(94, 234, 212, 0.8);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.2), rgba(94, 234, 212, 0.1));
  box-shadow: 0 4px 15px rgba(94, 234, 212, 0.25);
  transform: translateY(-2px);
}

.story-container.danger-tense .option-btn:hover {
  border-color: rgba(255, 184, 74, 0.9);
  background: linear-gradient(135deg, rgba(255, 184, 74, 0.25), rgba(255, 184, 74, 0.15));
  box-shadow: 0 4px 20px rgba(255, 184, 74, 0.3);
  transform: translateY(-2px);
}

.story-container.danger-dangerous .option-btn:hover {
  border-color: rgba(239, 68, 68, 0.9);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(239, 68, 68, 0.15));
  box-shadow: 0 4px 25px rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

.story-container.danger-critical .option-btn:hover {
  border-color: rgba(220, 38, 38, 1);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.4), rgba(220, 38, 38, 0.2));
  box-shadow: 0 4px 30px rgba(220, 38, 38, 0.5);
  transform: translateY(-2px);
}

/* Submit/Action buttons */
.story-container.danger-peaceful .action-submit {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.3), rgba(183, 108, 255, 0.15));
  border: 2px solid rgba(183, 108, 255, 0.5);
  box-shadow: 0 4px 15px rgba(183, 108, 255, 0.2);
}

.story-container.danger-calm .action-submit {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.3), rgba(94, 234, 212, 0.15));
  border: 2px solid rgba(94, 234, 212, 0.5);
  box-shadow: 0 4px 15px rgba(94, 234, 212, 0.2);
}

.story-container.danger-tense .action-submit {
  background: linear-gradient(135deg, rgba(255, 184, 74, 0.35), rgba(255, 184, 74, 0.2));
  border: 2px solid rgba(255, 184, 74, 0.6);
  box-shadow: 0 4px 20px rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous .action-submit {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(239, 68, 68, 0.2));
  border: 2px solid rgba(239, 68, 68, 0.7);
  box-shadow: 0 4px 25px rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .action-submit {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.5), rgba(220, 38, 38, 0.25));
  border: 2px solid rgba(220, 38, 38, 0.9);
  box-shadow: 0 4px 30px rgba(220, 38, 38, 0.5);
  animation: critical-button 1.5s ease-in-out infinite;
}

@keyframes critical-button {
  0%, 100% { box-shadow: 0 4px 30px rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 4px 50px rgba(220, 38, 38, 0.7); }
}

/* Journal overlay - dramatic left border */
.story-container.danger-peaceful .journal-overlay {
  border-left: 3px solid rgba(183, 108, 255, 0.4);
  background: linear-gradient(90deg, rgba(183, 108, 255, 0.05), transparent);
}

.story-container.danger-calm .journal-overlay {
  border-left: 3px solid rgba(94, 234, 212, 0.4);
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.05), transparent);
}

.story-container.danger-tense .journal-overlay {
  border-left: 3px solid rgba(255, 184, 74, 0.5);
  background: linear-gradient(90deg, rgba(255, 184, 74, 0.08), transparent);
}

.story-container.danger-dangerous .journal-overlay {
  border-left: 3px solid rgba(239, 68, 68, 0.6);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), transparent);
}

.story-container.danger-critical .journal-overlay {
  border-left: 4px solid rgba(220, 38, 38, 0.8);
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.15), transparent);
}

/* Journal nav buttons */
.story-container.danger-peaceful .journal-nav-btn.active {
  background: linear-gradient(90deg, rgba(183, 108, 255, 0.25), rgba(183, 108, 255, 0.1));
  border-left: 3px solid rgba(183, 108, 255, 0.6);
}

.story-container.danger-calm .journal-nav-btn.active {
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.25), rgba(94, 234, 212, 0.1));
  border-left: 3px solid rgba(94, 234, 212, 0.6);
}

.story-container.danger-tense .journal-nav-btn.active {
  background: linear-gradient(90deg, rgba(255, 184, 74, 0.3), rgba(255, 184, 74, 0.15));
  border-left: 3px solid rgba(255, 184, 74, 0.7);
}

.story-container.danger-dangerous .journal-nav-btn.active {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.35), rgba(239, 68, 68, 0.2));
  border-left: 3px solid rgba(239, 68, 68, 0.8);
}

.story-container.danger-critical .journal-nav-btn.active {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.4), rgba(220, 38, 38, 0.25));
  border-left: 4px solid rgba(220, 38, 38, 1);
}

/* Tab buttons */
.story-container.danger-peaceful .tab-btn.active {
  background: linear-gradient(180deg, rgba(183, 108, 255, 0.25), rgba(183, 108, 255, 0.1));
  border-bottom: 3px solid rgba(183, 108, 255, 0.6);
}

.story-container.danger-calm .tab-btn.active {
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.25), rgba(94, 234, 212, 0.1));
  border-bottom: 3px solid rgba(94, 234, 212, 0.6);
}

.story-container.danger-tense .tab-btn.active {
  background: linear-gradient(180deg, rgba(255, 184, 74, 0.3), rgba(255, 184, 74, 0.15));
  border-bottom: 3px solid rgba(255, 184, 74, 0.7);
}

.story-container.danger-dangerous .tab-btn.active {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.35), rgba(239, 68, 68, 0.2));
  border-bottom: 3px solid rgba(239, 68, 68, 0.8);
}

.story-container.danger-critical .tab-btn.active {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.4), rgba(220, 38, 38, 0.25));
  border-bottom: 4px solid rgba(220, 38, 38, 1);
}

/* Roll badges */
.story-container.danger-peaceful .roll-badge.crit {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.35), rgba(183, 108, 255, 0.2));
  border: 2px solid rgba(183, 108, 255, 0.5);
  box-shadow: 0 2px 10px rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .roll-badge.crit {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.35), rgba(94, 234, 212, 0.2));
  border: 2px solid rgba(94, 234, 212, 0.5);
  box-shadow: 0 2px 10px rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .roll-badge.crit {
  background: linear-gradient(135deg, rgba(255, 184, 74, 0.4), rgba(255, 184, 74, 0.25));
  border: 2px solid rgba(255, 184, 74, 0.6);
  box-shadow: 0 2px 15px rgba(255, 184, 74, 0.35);
}

.story-container.danger-dangerous .roll-badge.crit {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.45), rgba(239, 68, 68, 0.3));
  border: 2px solid rgba(239, 68, 68, 0.7);
  box-shadow: 0 2px 20px rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .roll-badge.crit {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.5), rgba(220, 38, 38, 0.35));
  border: 2px solid rgba(220, 38, 38, 0.9);
  box-shadow: 0 2px 25px rgba(220, 38, 38, 0.5);
}

/* Spinner */
.story-container.danger-peaceful .spinner {
  border-top-color: #b76cff;
  border-right-color: rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .spinner {
  border-top-color: #5eead4;
  border-right-color: rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .spinner {
  border-top-color: #ffb84a;
  border-right-color: rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous .spinner {
  border-top-color: #ef4444;
  border-right-color: rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical .spinner {
  border-top-color: #dc2626;
  border-right-color: rgba(220, 38, 38, 0.3);
}

/* Story log scrollbar */
.story-container.danger-peaceful .story-log::-webkit-scrollbar-thumb {
  background: rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .story-log::-webkit-scrollbar-thumb {
  background: rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .story-log::-webkit-scrollbar-thumb {
  background: rgba(255, 184, 74, 0.5);
}

.story-container.danger-dangerous .story-log::-webkit-scrollbar-thumb {
  background: rgba(239, 68, 68, 0.6);
}

.story-container.danger-critical .story-log::-webkit-scrollbar-thumb {
  background: rgba(220, 38, 38, 0.7);
}

/* Input fields */
.story-container.danger-peaceful .action-input:focus {
  border-color: rgba(183, 108, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(183, 108, 255, 0.2);
}

.story-container.danger-calm .action-input:focus {
  border-color: rgba(94, 234, 212, 0.6);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.2);
}

.story-container.danger-tense .action-input:focus {
  border-color: rgba(255, 184, 74, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 184, 74, 0.25);
}

.story-container.danger-dangerous .action-input:focus {
  border-color: rgba(239, 68, 68, 0.8);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical .action-input:focus {
  border-color: rgba(220, 38, 38, 0.9);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.35);
}

/* Character stats (HP, AC, etc.) - override purple defaults */
.story-container.danger-peaceful .char-stat {
  color: rgba(183, 108, 255, 0.95);
  background: rgba(183, 108, 255, 0.15);
  border: 1px solid rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .char-stat {
  color: rgba(94, 234, 212, 0.95);
  background: rgba(94, 234, 212, 0.15);
  border: 1px solid rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .char-stat {
  color: rgba(255, 184, 74, 0.95);
  background: rgba(255, 184, 74, 0.15);
  border: 1px solid rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous .char-stat {
  color: rgba(239, 68, 68, 0.95);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical .char-stat {
  color: rgba(220, 38, 38, 0.95);
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

/* Darkened background glow - more subtle and darker */
.story-container.danger-peaceful .story-ambient-bg {
  box-shadow: inset 0 0 200px rgba(183, 108, 255, 0.04);
  opacity: 0.06;
}

.story-container.danger-calm .story-ambient-bg {
  box-shadow: inset 0 0 200px rgba(94, 234, 212, 0.04);
  opacity: 0.06;
}

.story-container.danger-tense .story-ambient-bg {
  box-shadow: inset 0 0 250px rgba(255, 184, 74, 0.05);
  opacity: 0.07;
}

.story-container.danger-dangerous .story-ambient-bg {
  box-shadow: inset 0 0 300px rgba(239, 68, 68, 0.06);
  opacity: 0.08;
}

.story-container.danger-critical .story-ambient-bg {
  box-shadow: inset 0 0 350px rgba(220, 38, 38, 0.07);
  opacity: 0.09;
}

/* Additional danger level overrides for remaining purple elements */

/* Send button */
.story-container.danger-peaceful .send-btn {
  background: rgba(183, 108, 255, 0.2);
  border: 1px solid rgba(183, 108, 255, 0.3);
}

.story-container.danger-peaceful .send-btn:hover {
  background: rgba(183, 108, 255, 0.3);
}

.story-container.danger-calm .send-btn {
  background: rgba(94, 234, 212, 0.2);
  border: 1px solid rgba(94, 234, 212, 0.3);
}

.story-container.danger-calm .send-btn:hover {
  background: rgba(94, 234, 212, 0.3);
}

.story-container.danger-tense .send-btn {
  background: rgba(255, 184, 74, 0.2);
  border: 1px solid rgba(255, 184, 74, 0.3);
}

.story-container.danger-tense .send-btn:hover {
  background: rgba(255, 184, 74, 0.3);
}

.story-container.danger-dangerous .send-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.story-container.danger-dangerous .send-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.story-container.danger-critical .send-btn {
  background: rgba(220, 38, 38, 0.25);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

.story-container.danger-critical .send-btn:hover {
  background: rgba(220, 38, 38, 0.35);
}

/* LLM toggle buttons */
.story-container.danger-peaceful .llm-toggle-btn:hover {
  background: rgba(183, 108, 255, 0.1);
}

.story-container.danger-peaceful .llm-toggle-btn.active {
  background: rgba(183, 108, 255, 0.3);
  border: 1px solid rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .llm-toggle-btn:hover {
  background: rgba(94, 234, 212, 0.1);
}

.story-container.danger-calm .llm-toggle-btn.active {
  background: rgba(94, 234, 212, 0.3);
  border: 1px solid rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .llm-toggle-btn:hover {
  background: rgba(255, 184, 74, 0.1);
}

.story-container.danger-tense .llm-toggle-btn.active {
  background: rgba(255, 184, 74, 0.3);
  border: 1px solid rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .llm-toggle-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

.story-container.danger-dangerous .llm-toggle-btn.active {
  background: rgba(239, 68, 68, 0.3);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .llm-toggle-btn:hover {
  background: rgba(220, 38, 38, 0.1);
}

.story-container.danger-critical .llm-toggle-btn.active {
  background: rgba(220, 38, 38, 0.3);
  border: 1px solid rgba(220, 38, 38, 0.4);
}

/* Story entry borders */
.story-container.danger-peaceful .story-entry {
  border-left: 3px solid rgba(183, 108, 255, 0.4);
}

.story-container.danger-calm .story-entry {
  border-left: 3px solid rgba(94, 234, 212, 0.4);
}

.story-container.danger-tense .story-entry {
  border-left: 3px solid rgba(255, 184, 74, 0.4);
}

.story-container.danger-dangerous .story-entry {
  border-left: 3px solid rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .story-entry {
  border-left: 3px solid rgba(220, 38, 38, 0.4);
}

/* User entry specific */
.story-container.danger-peaceful .story-entry.user {
  border-left: 3px solid rgba(183, 108, 255, 0.6);
}

.story-container.danger-calm .story-entry.user {
  border-left: 3px solid rgba(94, 234, 212, 0.6);
}

.story-container.danger-tense .story-entry.user {
  border-left: 3px solid rgba(255, 184, 74, 0.6);
}

.story-container.danger-dangerous .story-entry.user {
  border-left: 3px solid rgba(239, 68, 68, 0.6);
}

.story-container.danger-critical .story-entry.user {
  border-left: 3px solid rgba(220, 38, 38, 0.6);
}

/* Strong and em tags within story content */
.story-container.danger-peaceful .story-entry strong {
  color: rgba(200, 150, 255, 1);
}

.story-container.danger-peaceful .story-entry em {
  color: rgba(200, 150, 255, 0.9);
}

.story-container.danger-calm .story-entry strong {
  color: rgba(120, 244, 232, 1);
}

.story-container.danger-calm .story-entry em {
  color: rgba(120, 244, 232, 0.9);
}

.story-container.danger-tense .story-entry strong {
  color: rgba(255, 200, 100, 1);
}

.story-container.danger-tense .story-entry em {
  color: rgba(255, 200, 100, 0.9);
}

.story-container.danger-dangerous .story-entry strong {
  color: rgba(255, 100, 100, 1);
}

.story-container.danger-dangerous .story-entry em {
  color: rgba(255, 100, 100, 0.9);
}

.story-container.danger-critical .story-entry strong {
  color: rgba(255, 80, 80, 1);
}

.story-container.danger-critical .story-entry em {
  color: rgba(255, 80, 80, 0.9);
}

/* ============================================
   IMMERSIVE STORY REDESIGN
   ============================================ */

/* Story Container - flex layout with action bar as sibling */
.story-container {
  position: fixed;
  top: 52px; /* Offset by header height */
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}

/* Story content takes remaining space, snaps to action bar */
.story-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 20px;
  scroll-behavior: smooth;
}

/* Story log - container for all entries */
.story-log {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 20px;
}

.recap-modal {
  position: fixed;
  inset: 0;
  z-index: 1004;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.recap-modal.hidden {
  display: none;
}

.recap-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.7);
  backdrop-filter: blur(10px);
}

.recap-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 92vw);
  background: rgba(12, 14, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  padding: 22px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.recap-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.recap-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.recap-meta {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(180, 188, 199, 0.7);
}

.recap-close {
  border: none;
  background: transparent;
  color: rgba(238, 240, 244, 0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}

.recap-body {
  color: rgba(238, 240, 244, 0.92);
  line-height: 1.7;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.recap-body p {
  margin: 0 0 12px;
}

.recap-body p:last-child {
  margin-bottom: 0;
}

.recap-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.recap-note {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
}

body.recap-open {
  overflow: hidden;
}

.story-recap {
  max-width: 680px;
  margin: 0 auto 18px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 18, 0.65);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.story-recap .recap-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.story-recap .recap-meta {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(180, 188, 199, 0.7);
}

.story-recap .recap-body {
  margin-top: 12px;
  color: rgba(238, 240, 244, 0.92);
  line-height: 1.7;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.story-recap .recap-body p {
  margin: 0 0 12px;
}

.story-recap .recap-body p:last-child {
  margin-bottom: 0;
}

/* Ambient Background */
.story-ambient-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.08;
  filter: blur(20px);
  z-index: 0;
  pointer-events: none;
}

/* Character Float (Top Right) - Bigger and better */
.character-float {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  max-width: 280px;
}

.character-float-inner {
  background: rgba(20, 22, 35, 0.95);
  border: 1px solid rgba(180, 111, 255, 0.25);
  border-radius: 14px;
  padding: 16px 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.character-name {
  font-weight: 700;
  font-size: 16px;
  color: rgba(238, 240, 244, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-sub {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
  margin-top: 4px;
}

.character-stats-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  background: rgba(180, 111, 255, 0.12);
  border: 1px solid rgba(180, 111, 255, 0.2);
  border-radius: 8px;
  min-width: 50px;
}

.pill-label {
  font-size: 9px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pill-value {
  font-size: 13px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
  margin-top: 2px;
}

.xp-container {
  margin-top: 12px;
}

.xp-bar {
  height: 4px;
  background: rgba(180, 188, 199, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(180, 111, 255, 0.8), rgba(200, 150, 255, 0.8));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.xp-text {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.5);
  text-align: center;
  margin-top: 6px;
}

/* Story Header */

.story-title {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(238, 240, 244, 0.95);
  margin: 0 auto;
  text-align: center;
  text-shadow: 0 2px 20px rgba(180, 111, 255, 0.3);
}

.story-title.centered {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
}

/* Story Content - fills entire container from top to bottom */
.story-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 5;
  padding: 20px 20px 20px 20px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.story-content::-webkit-scrollbar {
  width: 6px;
}

.story-content::-webkit-scrollbar-track {
  background: transparent;
}

.story-content::-webkit-scrollbar-thumb {
  background: rgba(180, 111, 255, 0.2);
  border-radius: 3px;
}

/* Story Log */
.story-log {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 0px;
  margin-top:32px;
  flex: 1;
}

.story-spacer {
  height: 16px;
  flex-shrink: 0;
}

/* Story Entries */
.story-entry {
  margin-bottom: 16px;
  animation: fadeInUp 0.4s ease;
}

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

.entry-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  padding-left: 4px;
}

/* YOU label on the right for user messages */
.you-label {
  text-align: right;
  padding-left: 0;
  padding-right: 4px;
}

/* Game Master label styling */
.gm-label {
  color: rgba(180, 111, 255, 0.6);
}

.entry-text {
  font-size: 15px;
  line-height: 1.8;
  color: rgba(238, 240, 244, 0.9);
}

.entry-text.narrative {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.9;
  color: rgba(238, 240, 244, 0.95);
  text-align: left;
  padding: 20px 24px;
  background: rgba(25, 26, 38, 0.6);
  border-left: 2px solid rgba(180, 111, 255, 0.3);
  border-radius: 0 12px 12px 0;
  backdrop-filter: blur(5px);
}

.story-container .story-loading {
  opacity: 0.6;
  text-align: left;
}

.story-container .loading-status {
  display: inline-block;
  white-space: nowrap;
}

.story-container .loading-text {
  display: inline;
  white-space: nowrap;
}

.story-container .loading-dots {
  display: inline-block;
  margin-left: 2px;
}

.story-container .loading-dots span {
  opacity: 0.25;
  animation: loadingDots 1.2s infinite;
  line-height: 1;
}

.story-container .loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.story-container .loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingDots {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.8;
  }
}

.entry-text.narrative strong {
  color: rgba(220, 200, 255, 0.95);
  font-weight: 600;
}

.entry-text.narrative em {
  color: rgba(200, 190, 220, 0.9);
  font-style: italic;
}

/* Paragraph spacing - NO gaps between paragraphs */
.entry-text.narrative p {
  margin: 0 !important;
  line-height: 1.6;
}

.entry-text.narrative p + p {
  margin-top: 0.5em !important;
}

.entry-text.narrative p:last-child {
  margin-bottom: 0 !important;
}

/* Aggressively hide empty paragraphs and elements */
.entry-text.narrative p:empty,
.entry-text.narrative p:blank,
.entry-text.narrative br:only-child {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Remove excessive line-height from narrative container */
.entry-text.narrative {
  line-height: 1.6;
}

/* User message on the right */
.story-entry.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.story-entry.user .entry-text.user-text {
  background: rgba(40, 42, 55, 0.6);
  padding: 12px 16px;
  border-radius: 12px 0 0 12px;
  border-right: 2px solid rgba(180, 188, 199, 0.3);
  max-width: 85%;
  text-align: right;
}

/* Roll Entry */
.roll-entry {
  max-width: 320px;
  margin: 0 auto 24px;
  padding: 16px 20px;
  background: rgba(25, 26, 38, 0.7);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 12px;
  text-align: center;
  backdrop-filter: blur(5px);
}

.roll-entry.crit {
  border-color: rgba(180, 111, 255, 0.4);
  background: rgba(180, 111, 255, 0.08);
}

.roll-entry.success {
  border-color: rgba(120, 200, 120, 0.3);
  background: rgba(120, 200, 120, 0.05);
}

.roll-entry.fail {
  border-color: rgba(200, 120, 120, 0.3);
  background: rgba(200, 120, 120, 0.05);
}

.roll-entry.rolling {
  border-color: rgba(180, 188, 199, 0.25);
  background: rgba(25, 26, 38, 0.5);
  animation: rollPulse 1.5s ease-in-out infinite;
}

@keyframes rollPulse {
  0%, 100% {
    border-color: rgba(180, 188, 199, 0.15);
    box-shadow: 0 0 0 rgba(180, 188, 199, 0);
  }
  50% {
    border-color: rgba(180, 188, 199, 0.35);
    box-shadow: 0 0 15px rgba(180, 188, 199, 0.1);
  }
}

.roll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.roll-who {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.roll-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.roll-badge.crit {
  background: rgba(180, 111, 255, 0.25);
  color: rgba(220, 200, 255, 0.95);
}

.roll-badge.success {
  background: rgba(120, 200, 120, 0.2);
  color: rgba(160, 230, 160, 0.9);
}

.roll-badge.fail {
  background: rgba(200, 120, 120, 0.2);
  color: rgba(230, 160, 160, 0.9);
}

.roll-badge.neutral {
  background: rgba(180, 188, 199, 0.15);
  color: rgba(180, 188, 199, 0.7);
}

.roll-check {
  font-size: 13px;
  color: rgba(238, 240, 244, 0.8);
  margin-bottom: 4px;
}

.roll-result {
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

/* Action Bar (Bottom) - part of flex layout */
.action-bar {
  flex-shrink: 0;
  background: linear-gradient(0deg, rgba(15, 16, 25, 0.98), rgba(15, 16, 25, 0.85));
  border-top: 1px solid rgba(180, 111, 255, 0.15);
  padding: 16px 20px 24px;
  z-index: 100;
  backdrop-filter: blur(20px);
  transition: padding 0.3s ease, width 0.3s ease, border-left 0.3s ease;
}

/* ============================================
   RESPONSIVE LAYOUT - Aspect Ratio Based
   ============================================ */

/* Landscape/Wide Layout (width > height) - Side by side */
/* Only applies to non-touch devices (desktops/laptops) with fine pointer */
@media (min-aspect-ratio: 1/1) and (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .story-container {
    flex-direction: row;
    align-items: stretch; /* Full height for children */
  }

  .story-content {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
    max-width: calc(100% - 450px); /* Account for action bar width */
    height: 100%;
    padding: 24px;
  }

  .action-bar {
    width: 450px;
    flex-shrink: 0;
    border-top: none;
    border-left: 1px solid rgba(180, 111, 255, 0.15);
    padding: 24px;
    height: 100%; /* Full height for border/gradient */
    overflow-y: auto;
    background: linear-gradient(90deg, rgba(15, 16, 25, 0.95), rgba(15, 16, 25, 0.98));
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
  }

  /* Adjust story log max-width for side-by-side */
  .story-log {
    max-width: 100%;
  }

  /* Make options and inputs fill the side panel */
  .options-container {
    max-width: 100%;
  }

  .input-container {
    max-width: 100%;
  }

  .character-summary-bar {
    max-width: 100%;
  }

  /* Better spacing for action bar content in landscape */
  .quick-access-bar {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .quick-access {
    justify-content: center;
    gap: 12px;
  }

  .quick-btn {
    width: 44px;
    height: 44px;
  }

  .llm-indicator-wrapper {
    justify-content: center;
    width: 100%;
  }

  .llm-indicator {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
  }

  .option-btn {
    padding: 14px 18px;
  }

  /* Fix GM mode input container border being cut off */
  .input-container.gm-mode {
    margin-top: 8px;
  }
}

/* Landscape/Wide Layout - Character Summary Bar */
/* Only applies to non-touch devices (desktops/laptops) with fine pointer */
@media (min-aspect-ratio: 1/1) and (min-width: 768px) and (hover: hover) and (pointer: fine) {
  /* Character summary bar - single row layout in landscape */
  .character-summary-bar {
    flex-direction: row;
    gap: 16px;
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
  }

  /* Header with name, stats, and cog - simple layout */
  .character-summary-bar .char-summary-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex: 1;
  }

  .character-summary-bar .char-summary-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;
  }

  /* Stats in a 2x2 grid */
  .character-summary-bar .char-summary-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex: 1;
  }

  /* Cog inline */
  .character-summary-bar #ambienceCogWrapper {
    flex-shrink: 0;
  }

  .character-summary-bar .char-summary-stats-row .char-stat {
    text-align: center;
    padding: 6px 4px;
    font-size: 11px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Fix GM mode input container border being cut off */
  .input-container.gm-mode {
    margin-top: 12px;
    padding-top: 4px;
  }

  /* Fix character stats boundary in GM mode - add spacing and ensure proper containment */
  .action-bar .input-container.gm-mode ~ .character-summary-bar,
  .action-bar:has(.input-container.gm-mode) .character-summary-bar {
    margin-top: 16px;
    position: relative;
    z-index: 1;
    overflow: visible;
  }

  /* Reduce stats width when GM ask window is open to prevent clipping */
  .action-bar:has(.input-container.gm-mode) .character-summary-bar .char-summary-stats-row {
    width: 118px;
  }
}

/* Portrait/Tall Layout (height >= width) - Vertical stack (default) */
@media (max-aspect-ratio: 1/1), (max-width: 767px) {
  .story-container {
    flex-direction: column;
  }

  .story-content {
    flex: 1;
    width: 100%;
    height: auto;
  }

  .action-bar {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(180, 111, 255, 0.15);
  }

  /* Character summary bar - centered layout when action bar is on bottom */
  .character-summary-bar .char-summary-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    position: relative;
    gap: 8px;
  }

  .character-summary-bar .char-summary-left {
    flex: 0 0 auto;
    min-width: 0;
  }

  .character-summary-bar .char-summary-stats-row {
    display: flex;
    flex: 1;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .character-summary-bar #ambienceCogWrapper {
    flex: 0 0 auto;
    position: relative;
    right: auto;
  }
}

/* Character Summary Bar (in Action Bar) */
.character-summary-bar {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  margin-top: 12px;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Default single-row layout for portrait */
.char-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-width: 0;
  width: 100%;
}

.char-summary-stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Cog positioned to the right of name in portrait */
#ambienceCogWrapper {
  flex-shrink: 0;
  margin-left: auto;
}

.char-summary-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.char-summary-name {
  font-weight: 600;
  font-size: 14px;
  color: rgba(238, 240, 244, 0.95);
}

.char-summary-details {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
}

.char-summary-stats {
  display: flex;
  gap: 12px;
}

/* Collapsed action bar state - when user submits an action */
body.action-bar-collapsed .options-container,
body.action-bar-collapsed .input-container {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0 auto;
  padding: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease, padding 0.3s ease;
}

.options-container,
.input-container {
  max-height: 500px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease, padding 0.3s ease;
}

body.action-bar-collapsed .action-bar {
  padding: 12px 20px 16px;
}

.action-bar {
  transition: padding 0.3s ease;
}

body.action-bar-collapsed .character-summary-bar {
  margin-top: 0;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.character-summary-bar {
  transition: margin-top 0.3s ease;
}

.char-stat {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent-border);
}

/* Quick Access Bar - container for buttons and AI toggle */
.quick-access-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 680px;
  margin: 0 auto 16px auto;
  padding: 0;
}

/* Quick Access Buttons with white icons */
.quick-access {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
}

.quick-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  background: rgba(25, 26, 38, 0.9);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.quick-icon {
  width: 24px;
  height: 24px;
  color: rgba(255, 255, 255, 0.95);
  stroke: rgba(255, 255, 255, 0.95);
}

/* LLM Mode Toggle - 3-way pill */
.llm-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
}

.llm-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(180, 188, 199, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.llm-toggle-pill {
  display: flex;
  background: rgba(25, 26, 38, 0.9);
  border: 1px solid var(--accent-border);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.llm-toggle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 16px;
  color: rgba(180, 188, 199, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 500;
}

.llm-toggle-btn:hover {
  color: rgba(238, 240, 244, 0.9);
  background: var(--accent-soft);
}

.llm-toggle-btn.active {
  background: var(--accent-soft);
  color: rgba(238, 240, 244, 0.95);
  border: 1px solid var(--accent);
}

.llm-toggle-btn.disabled,
.llm-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.llm-policy-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(255, 214, 153, 0.85);
}

.llm-icon-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.llm-text {
  font-size: 11px;
  font-weight: 600;
}

/* LLM Indicator (new simplified version) */
.llm-indicator-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
}

.llm-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}

.llm-indicator.free {
  background: rgba(94, 234, 212, 0.15);
  color: #5eead4;
  border-color: rgba(94, 234, 212, 0.3);
}

.llm-indicator.paid {
  background: rgba(180, 111, 255, 0.15);
  color: #b46fff;
  border-color: rgba(180, 111, 255, 0.3);
}

.llm-indicator .indicator-text-mobile {
  display: none;
}

.llm-indicator .indicator-text-full {
  display: inline;
}

/* Danger-level theming for LLM Indicator */
.story-container.danger-peaceful .llm-indicator.free {
  background: rgba(147, 197, 253, 0.2);
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.4);
}

.story-container.danger-peaceful .llm-indicator.paid {
  background: rgba(167, 139, 250, 0.2);
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.4);
}

.story-container.danger-calm .llm-indicator.free {
  background: rgba(110, 231, 183, 0.2);
  color: #6ee7b7;
  border-color: rgba(110, 231, 183, 0.4);
}

.story-container.danger-calm .llm-indicator.paid {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
}

.story-container.danger-tense .llm-indicator.free {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
}

.story-container.danger-tense .llm-indicator.paid {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
}

.story-container.danger-dangerous .llm-indicator.free {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}

.story-container.danger-dangerous .llm-indicator.paid {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.story-container.danger-critical .llm-indicator.free {
  background: rgba(225, 29, 72, 0.25);
  color: #e11d48;
  border-color: rgba(225, 29, 72, 0.5);
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.3);
}

.story-container.danger-critical .llm-indicator.paid {
  background: rgba(190, 18, 60, 0.25);
  color: #be123c;
  border-color: rgba(190, 18, 60, 0.5);
  box-shadow: 0 0 10px rgba(190, 18, 60, 0.3);
}

/* Options */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 8px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(25, 26, 38, 0.8);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: rgba(238, 240, 244, 0.95);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.option-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateX(4px);
}

.option-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.option-text {
  flex: 1;
}

/* Input Container with proper spacing from options */
.input-container {
  max-width: 680px;
  margin: 16px auto 0 auto;
  padding-top: 8px;
  border-top: 1px solid rgba(180, 111, 255, 0.1);
}

.input-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: center;
}

.input-tab {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--accent-border);
  border-radius: 20px;
  color: rgba(180, 188, 199, 0.7);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.input-tab:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.input-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: rgba(238, 240, 244, 0.95);
}

.input-row {
  display: flex;
  gap: 10px;
}

.story-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(25, 26, 38, 0.8);
  border: 1px solid rgba(180, 188, 199, 0.2);
  border-radius: 10px;
  color: rgba(238, 240, 244, 0.95);
  font-size: 14px;
  transition: all 0.2s ease;
}

.story-input:focus {
  outline: none;
  border-color: rgba(180, 111, 255, 0.4);
  background: rgba(30, 31, 45, 0.9);
}

.story-textarea {
  min-height: 80px;
  resize: vertical;
}

.send-btn {
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: scale(1.05);
}

.send-icon {
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.95);
  stroke: rgba(255, 255, 255, 0.95);
}

/* Overlays (Simplified) */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.overlay-panel {
  position: relative;
  margin: 0 auto;
  width: 90%;
  max-width: 600px;
  height: 500px;
  max-height: calc(100vh - 80px);
  background: linear-gradient(180deg, rgba(25, 26, 38, 0.98), rgba(20, 21, 32, 0.98));
  border: 1px solid rgba(180, 111, 255, 0.2);
  border-radius: 16px;
  overflow: hidden;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(0);
  transition: transform 0.3s ease;
  align-self: center;
}

.overlay.active .overlay-panel {
  transform: translateY(0);
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(180, 111, 255, 0.1);
}

.overlay-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.overlay-close {
  width: 32px;
  height: 32px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  color: rgba(180, 188, 199, 0.8);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.overlay-close:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: rgba(238, 240, 244, 0.95);
}

.overlay-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

/* Stat Block */
.stat-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(180, 188, 199, 0.1);
}

.stat-name {
  color: rgba(180, 188, 199, 0.7);
  font-size: 14px;
}

.stat-val {
  color: rgba(238, 240, 244, 0.95);
  font-weight: 600;
  font-size: 14px;
}

/* Abilities Grid */
.abilities-section {
  margin-top: 24px;
}

.abilities-section h3 {
  font-size: 14px;
  color: rgba(180, 188, 199, 0.7);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.abilities-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ability-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: rgba(180, 111, 255, 0.08);
  border: 1px solid rgba(180, 111, 255, 0.15);
  border-radius: 10px;
}

.ability-abbr {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ability-score {
  font-size: 20px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
  margin: 4px 0;
}

.ability-mod {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
}

/* Lists */
.list-section {
  margin-top: 24px;
}

.list-section h3 {
  font-size: 14px;
  color: rgba(180, 188, 199, 0.7);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 6px 12px;
  background: rgba(180, 111, 255, 0.1);
  border: 1px solid rgba(180, 111, 255, 0.2);
  border-radius: 20px;
  font-size: 12px;
  color: rgba(220, 200, 255, 0.9);
}

/* Compact Character Sheet */
.character-sheet-content {
  padding: 16px;
}

.char-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.char-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.char-header-class {
  font-size: 16px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.char-header-race {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.7);
}

.char-header-right {
  display: flex;
  gap: 16px;
}

.char-header-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.header-stat-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.char-secondary-stats {
  display: flex;
  justify-content: space-around;
  padding: 10px 16px;
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 8px;
  margin-bottom: 16px;
}

.secondary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.secondary-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.secondary-value {
  font-size: 14px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
}

.char-two-column {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  margin-bottom: 16px;
  align-items: start;
}

.char-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-start;
}

.char-col-right {
  gap: 10px;
  width: 90%;
  margin-top: -10px;
  margin-left: auto;
}

.abilities-compact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.ability-compact-box {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 8px;
  gap: 8px;
}

.ability-compact-name {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 28px;
}

.ability-compact-score {
  font-size: 16px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
  min-width: 24px;
}

.ability-compact-mod {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
  margin-left: auto;
}

.char-meta-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(25, 26, 38, 0.4);
  border-radius: 8px;
}

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

.meta-label {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.6);
}

.meta-value {
  font-size: 12px;
  color: rgba(238, 240, 244, 0.9);
  font-weight: 500;
  text-align: right;
}

.compact-section {
  background: transparent;
  padding: 4px 0;
}

.compact-section h4 {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px 0;
  text-align: center;
}

.compact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

/* Inline EXP Bar in Header */
.exp-bar-inline {
  flex: 1;
  max-width: 180px;
  margin: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.exp-bar-mini-track {
  width: 100%;
  height: 6px;
  background: rgba(180, 188, 199, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.exp-bar-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(180, 111, 255, 0.6), rgba(220, 180, 255, 0.8));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.exp-mini-text {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Character Sheet Tooltips */
.char-tag-with-tooltip {
  position: relative;
  padding: 4px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--accent);
  cursor: help;
  transition: all 0.2s ease;
}

.char-tag-with-tooltip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.char-tag-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 8px 12px;
  background: rgba(25, 26, 38, 0.98);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(238, 240, 244, 0.95);
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.char-tag-with-tooltip:hover .char-tag-tooltip,
.char-tag-with-tooltip.active .char-tag-tooltip {
  opacity: 1;
  visibility: visible;
}

.char-tag-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(180, 111, 255, 0.3);
}

.char-tooltip-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.char-tooltip-desc {
  color: rgba(180, 188, 199, 0.85);
}

.char-tooltip-mod {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(180, 188, 199, 0.1);
}

.compact-tag {
  padding: 4px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--accent);
}

.notes-section {
  margin-top: 8px;
}

.notes-text-compact {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(238, 240, 244, 0.85);
  font-style: italic;
}

/* Saving Throws Section */
.saving-throws-section {
  margin-top: 12px;
}

.saving-throws-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.saving-throw-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 8px;
  position: relative;
}

.saving-throw-box.proficient {
  background: rgba(180, 111, 255, 0.1);
  border-color: rgba(180, 111, 255, 0.3);
}

.saving-throw-ability {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.saving-throw-mod {
  font-size: 18px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.saving-throw-box.proficient .saving-throw-mod {
  color: rgba(180, 111, 255, 0.95);
}

.prof-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 8px;
  color: rgba(180, 111, 255, 0.8);
}

/* Languages Section */
.languages-section {
  margin-top: 12px;
}

.languages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.language-tag {
  padding: 4px 10px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 12px;
  font-size: 11px;
  color: rgba(238, 240, 244, 0.85);
}

/* Spell Slots Section */
.spell-slots-section {
  margin-top: 12px;
}

.spell-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.spell-slot-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  background: rgba(180, 111, 255, 0.1);
  border: 1px solid rgba(180, 111, 255, 0.2);
  border-radius: 8px;
  min-width: 50px;
}

.slot-level {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.slot-count {
  font-size: 20px;
  font-weight: 700;
  color: rgba(180, 111, 255, 0.95);
}

/* Better scaling for character sheet on tall screens */
@media (min-height: 900px) {
  .char-two-column {
    grid-template-columns: 220px 1fr;
    gap: 28px;
    margin-bottom: 20px;
  }
  
  .abilities-compact {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .ability-compact-box {
    padding: 12px 14px;
  }
  
  .ability-compact-name {
    font-size: 12px;
    width: 32px;
  }
  
  .ability-compact-score {
    font-size: 18px;
  }
  
  .ability-compact-mod {
    font-size: 13px;
  }
  
  .char-meta-info {
    padding: 14px 16px;
    gap: 10px;
  }
  
  .meta-label,
  .meta-value {
    font-size: 13px;
  }
  
  .saving-throws-grid {
    gap: 10px;
  }
  
  .saving-throw-box {
    padding: 14px 8px;
  }
  
  .saving-throw-mod {
    font-size: 22px;
  }
  
  .spell-slot-box {
    padding: 12px 16px;
    min-width: 60px;
  }
  
  .slot-count {
    font-size: 24px;
  }
  
  .compact-section {
    padding: 8px 0;
  }
  
  .compact-section h4 {
    font-size: 12px;
    margin-bottom: 10px;
  }
  
  .char-tag-with-tooltip,
  .language-tag {
    font-size: 12px;
    padding: 5px 12px;
  }
}

@media (min-height: 1100px) {
  .char-two-column {
    grid-template-columns: 260px 1fr;
    gap: 36px;
    margin-bottom: 28px;
  }
  
  .abilities-compact {
    gap: 10px;
  }
  
  .ability-compact-box {
    padding: 16px 18px;
  }
  
  .ability-compact-score {
    font-size: 22px;
  }
  
  .ability-compact-mod {
    font-size: 15px;
  }
  
  .char-meta-info {
    padding: 18px 20px;
    gap: 12px;
  }
  
  .meta-label,
  .meta-value {
    font-size: 14px;
  }
  
  .saving-throws-grid {
    gap: 12px;
  }
  
  .saving-throw-box {
    padding: 18px 12px;
  }
  
  .saving-throw-mod {
    font-size: 26px;
  }
  
  .spell-slot-box {
    padding: 16px 20px;
    min-width: 70px;
  }
  
  .slot-count {
    font-size: 28px;
  }
  
  .compact-section {
    padding: 12px 0;
  }
  
  .compact-section h4 {
    font-size: 13px;
    margin-bottom: 14px;
  }
  
  .char-tag-with-tooltip,
  .language-tag {
    font-size: 13px;
    padding: 6px 14px;
  }
  
  .notes-text-compact {
    font-size: 13px;
    line-height: 1.6;
  }
}

@media (max-width: 640px) {
  .char-two-column {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .abilities-compact {
    grid-template-columns: repeat(3, 1fr);
  }

  .char-header-bar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .exp-bar-inline {
    max-width: 100%;
    width: 100%;
    margin: 0;
    order: -1;
  }

  .char-secondary-stats {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
  }

  .secondary-stat {
    min-width: 70px;
  }

  .saving-throws-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .saving-throw-box {
    padding: 8px 4px;
  }

  .saving-throw-mod {
    font-size: 16px;
  }

  .spell-slots-grid {
    gap: 6px;
  }

  .spell-slot-box {
    padding: 6px 10px;
    min-width: 40px;
  }

  .slot-count {
    font-size: 16px;
  }
}

/* Items */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  padding: 14px 16px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 10px;
}

.item-name {
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 4px;
}

.item-desc {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
}

/* Equipment panel (story overlay) */
.equipment-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.equipment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.equipment-pill {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(25, 26, 38, 0.7);
  border: 1px solid rgba(180, 188, 199, 0.15);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.equipment-pill-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(180, 188, 199, 0.7);
}

.equipment-pill-value {
  font-size: 14px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.equipment-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.equipment-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: rgba(180, 188, 199, 0.85);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.equipment-tab:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.equipment-tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

.equipment-tab.active {
  color: rgba(238, 240, 244, 0.95);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.equipment-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(180, 188, 199, 0.15);
  background: rgba(16, 18, 26, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.equipment-card.equipped {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(20, 30, 24, 0.7);
}

.equipment-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.equipment-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.equipment-name {
  font-size: 14px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.equipment-qty {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.equipment-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(180, 188, 199, 0.6);
}

.equipment-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.equipment-meta-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(238, 240, 244, 0.8);
  background: rgba(255, 255, 255, 0.04);
}

.equipment-desc {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
}

.equipment-actions {
  margin-top: 4px;
}

.equip-toggle {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: rgba(180, 188, 199, 0.9);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.equip-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: rgba(238, 240, 244, 0.95);
}

.equip-toggle.equipped {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.15);
  color: rgba(190, 255, 215, 0.95);
}

.equipment-empty {
  padding: 16px;
}

@media (max-width: 720px) {
  .equipment-summary {
    grid-template-columns: 1fr;
  }

  .equipment-grid {
    grid-template-columns: 1fr;
  }
}

/* Spells */
.spell-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spell-card {
  padding: 14px 16px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 10px;
}

.spell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.spell-name {
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.spell-level {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  padding: 2px 8px;
  background: rgba(180, 111, 255, 0.15);
  border-radius: 4px;
}

.spell-meta {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.6);
  margin-bottom: 6px;
}

.spell-desc {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.8);
  line-height: 1.4;
}

/* Disabled Spell Styles */
.spell-disabled {
  opacity: 0.6;
  background: rgba(25, 26, 38, 0.4);
  border-color: rgba(180, 188, 199, 0.06);
}

.spell-disabled .spell-name {
  color: rgba(180, 188, 199, 0.5);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 107, 107, 0.5);
}

.spell-disabled .spell-level {
  background: rgba(180, 188, 199, 0.08);
  color: rgba(180, 188, 199, 0.4);
}

.spell-disabled-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 6px;
  font-size: 12px;
  color: rgba(255, 107, 107, 0.9);
}

.disabled-icon {
  font-size: 14px;
}

.disabled-text {
  font-weight: 500;
}

.disabled-meta {
  color: rgba(180, 188, 199, 0.4);
}

.disabled-desc {
  color: rgba(180, 188, 199, 0.5);
}

/* Journal */
.journal-section {
  margin-bottom: 20px;
}

.journal-now-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.journal-now-grid .journal-entry {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .journal-now-grid {
    grid-template-columns: 1fr;
  }
}

.journal-section h3 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.journal-entry {
  padding: 12px 14px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  margin-bottom: 8px;
  transition: border-color 0.2s ease;
}

.journal-entry:hover {
  border-color: var(--accent);
}

.journal-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.journal-detail {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.7);
}

/* Journal Navigation */
.journal-nav {
  padding: 12px 20px;
  border-bottom: 1px solid var(--accent-border);
  background: linear-gradient(180deg, rgba(25, 26, 38, 0.95), rgba(20, 21, 32, 0.9));
}

.journal-nav-desktop {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.journal-nav-mobile {
  display: none;
}

.journal-nav-btn {
  padding: 8px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  color: rgba(180, 188, 199, 0.8);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.journal-nav-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: rgba(238, 240, 244, 0.95);
}

.journal-nav-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: rgba(238, 240, 244, 0.95);
}

/* Journal content wrapper - ensure top alignment */
.journal-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
}

/* Journal Section Tabs */
.journal-content .journal-section {
  display: none;
  width: 100%;
}

.journal-content .journal-section.active {
  display: block;
  margin-top: 0;
  padding-top: 0;
  align-self: flex-start;
}

/* Compendium tab sections */
.overlay-content [data-compendium-section] {
  display: none;
}

.overlay-content [data-compendium-section].active {
  display: block;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(180, 188, 199, 0.5);
  font-style: italic;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
  .story-header {
    padding: 60px 16px 12px;
  }

  .story-title {
    font-size: 18px;
    letter-spacing: 0.05em;
  }

  .story-content {
    padding: 16px 16px 16px 16px;
  }

  .entry-text.narrative {
    font-size: 15px;
    padding: 14px 16px;
    line-height: 1.7;
  }

  /* Smaller action bar on mobile */
  .action-bar {
    padding: 10px 12px 16px;
  }
  
  .quick-access-bar {
    flex-direction: row;
    gap: 8px;
    justify-content: space-between;
  }

  .quick-access {
    gap: 8px;
    justify-content: flex-start;
  }

  .llm-indicator-wrapper {
    justify-content: flex-end;
    padding: 4px 0;
  }

  .llm-indicator {
    font-size: 11px;
    padding: 4px 8px;
    white-space: nowrap;
  }

  .llm-indicator span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .llm-indicator .indicator-text-mobile {
    display: inline;
  }

  .llm-indicator .indicator-text-full {
    display: none;
  }

  .llm-label {
    display: none;
  }
  
  .quick-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  
  .quick-icon {
    width: 18px;
    height: 18px;
  }
  
  .option-btn {
    padding: 10px 12px;
    font-size: 13px;
    gap: 8px;
  }
  
  .option-number {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }
  
  .input-container {
    margin-top: 10px;
  }
  
  .input-row {
    gap: 8px;
  }
  
  .story-input {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .send-btn {
    width: 40px;
    height: 40px;
  }
  
  .send-icon {
    width: 18px;
    height: 18px;
  }
  
  /* Smaller character summary bar on mobile */
  .character-summary-bar {
    padding: 8px 10px;
    margin-top: 8px;
    gap: 6px;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }
  
  /* In portrait/mobile: cog goes on the far right, after stats */
  .char-summary-header {
    flex: 0 1 auto;
    min-width: 0;
  }
  
  .char-summary-stats-row {
    flex: 1;
    justify-content: flex-end;
    gap: 4px;
  }
  
  #ambienceCogWrapper {
    margin-left: 4px;
  }
  
  .char-summary-name {
    font-size: 12px;
  }
  
  .char-summary-details {
    font-size: 10px;
  }
  
  .char-summary-stats {
    gap: 6px;
  }
  
  .char-stat {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* Mobile: show buttons directly, no hamburger menu */
  .journal-nav-desktop {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .journal-nav-mobile {
    display: none;
  }

  .journal-nav {
    padding: 12px 16px;
  }

  .journal-nav-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Mobile: full screen overlay panel */
  .overlay {
    z-index: 9999 !important;
    padding-top: 60px; /* Offset by header height */
    align-items: flex-start; /* Align to top instead of center */
  }

  .overlay-panel {
    margin: 0;
    height: calc(100vh - 60px); /* Account for header */
    max-height: calc(100vh - 60px);
    width: 100%;
    border-radius: 0;
    max-width: 100%;
    z-index: 10000;
    align-self: flex-start; /* Align to top */
  }
}

/* Hide old story layout elements on story view page only */
.story-container .story-hero,
.story-container .story-grid,
.story-container .story-pane,
.story-container .story-full-bg {
  display: none;
}

/* SRD Term Hover Tooltips */
.srd-term {
  border-bottom: none;
  cursor: text;
}

.srd-term:hover {
  background-color: transparent;
}

.srd-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  max-width: 90vw;
  padding: 12px 16px;
  background: var(--glass2);
  border: 1px solid var(--line2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  transform-origin: top center;
  margin-top: 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.srd-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(4px);
}

.srd-tooltip.above {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 8px;
  transform-origin: bottom center;
}

.srd-tooltip.above.visible {
  transform: translateX(-50%) translateY(-4px);
}

.srd-tooltip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  top: auto;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--glass2);
}

.srd-tooltip.above::after {
  bottom: auto;
  top: 100%;
  border-bottom-color: transparent;
  border-top-color: var(--glass2);
}

.srd-tooltip-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.srd-tooltip-type {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
  flex-shrink: 0;
}

.srd-tooltip-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.srd-tooltip-content {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.srd-tooltip-description {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.srd-tooltip-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.srd-tooltip-detail {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
}

.srd-tooltip-loading {
  font-style: italic;
  color: var(--muted);
  font-size: 12px;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .srd-tooltip {
    width: 240px;
    padding: 10px 12px;
  }
}

/* ============================================
   SOPHISTICATED STORIES LIST PAGE
   ============================================ */

/* Animated Ambient Background */
.stories-ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Floating ambient orbs */
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(183, 108, 255, 0.15) 0%, transparent 70%);
  top: -200px;
  left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.1) 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation-delay: -7s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 184, 74, 0.08) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(50px, -30px) scale(1.1);
  }
  50% {
    transform: translate(-30px, 50px) scale(0.95);
  }
  75% {
    transform: translate(-50px, -20px) scale(1.05);
  }
}

/* Subtle grid pattern overlay */
.ambient-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.5;
}

.stories-ambient-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/static/art/noise_128.png');
  background-repeat: repeat;
  background-size: 128px 128px;
  opacity: 0.03;
  mix-blend-mode: overlay;
}

/* Stories container */
.stories-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  flex: 1 0 auto;
}

/* Stories page layout - ensure footer stays at bottom */
html.stories-route body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

html.stories-route .wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0; /* Allow content to determine height */
}

html.stories-route .site-footer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  flex-shrink: 0;
}

/* Sophisticated Header */
.stories-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 48px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stories-header-content {
  flex: 1;
}

.header-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(180, 111, 255, 0.8);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stories-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 42px;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.title-word {
  color: rgba(238, 240, 244, 0.95);
  font-weight: 300;
}

.title-accent {
  background: linear-gradient(135deg, rgba(183, 108, 255, 1), rgba(180, 111, 255, 0.8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
  text-shadow: 0 0 40px rgba(183, 108, 255, 0.3);
}

.stories-subtitle {
  font-size: 15px;
  color: rgba(180, 188, 199, 0.6);
  margin: 12px 0 0 0;
  font-weight: 400;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Credits Display */
.credits-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(20, 22, 35, 0.6);
  border: 1px solid rgba(255, 184, 74, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.credits-icon {
  font-size: 18px;
}

.credits-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.credits-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(180, 188, 199, 0.5);
}

.credits-value {
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 184, 74, 0.95);
}

/* Sophisticated New Story Button */
.new-story-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.15), rgba(183, 108, 255, 0.05));
  border: 1px solid rgba(183, 108, 255, 0.3);
  border-radius: 16px;
  color: rgba(238, 240, 244, 0.95);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.new-story-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(183, 108, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.new-story-btn:hover {
  border-color: rgba(183, 108, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(183, 108, 255, 0.2),
    0 0 30px rgba(183, 108, 255, 0.15);
}

.new-story-btn:hover::before {
  opacity: 1;
}

.btn-glow {
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.4), transparent, rgba(94, 234, 212, 0.4));
  border-radius: 16px;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.3s ease;
  z-index: -1;
}

.new-story-btn:hover .btn-glow {
  opacity: 0.5;
}

.new-story-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.new-story-icon svg {
  width: 100%;
  height: 100%;
}

/* Stories section */
.stories-section {
  margin-bottom: 48px;
}

.stories-section.pinned-section {
  margin-bottom: 56px;
}

/* Enhanced Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(238, 240, 244, 0.8);
}

.section-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.section-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.95);
  margin: 0;
  letter-spacing: 0.03em;
}

.section-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.drag-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(180, 188, 199, 0.5);
  font-weight: 500;
}

.drag-hint svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.max-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(183, 108, 255, 0.8);
  padding: 4px 10px;
  background: rgba(183, 108, 255, 0.1);
  border: 1px solid rgba(183, 108, 255, 0.2);
  border-radius: 20px;
}

/* Section Filters */
.section-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: rgba(180, 188, 199, 0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(238, 240, 244, 0.9);
}

.filter-btn.active {
  background: rgba(183, 108, 255, 0.15);
  border-color: rgba(183, 108, 255, 0.3);
  color: rgba(183, 108, 255, 0.95);
}

.stories-count {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.5);
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* Featured Zone */
.featured-zone {
  border: 1px dashed rgba(183, 108, 255, 0.15);
  border-radius: 24px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.03), transparent);
  min-height: 280px;
  transition: all 0.3s ease;
}

.featured-zone:hover {
  border-color: rgba(183, 108, 255, 0.25);
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.05), transparent);
}

/* Featured Grid */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
}

/* Library Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* Sophisticated Featured Card */
.featured-card {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  min-height: 320px;
  background: rgba(12, 14, 20, 0.35);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.featured-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hero-url);
  background-size: 110%;
  background-position: center;
  filter: saturate(1.1) contrast(1.05) brightness(1);
  opacity: 1;
  z-index: 0;
  transition: all 0.5s ease;
}

.featured-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, 
    rgba(0, 0, 0, 0.06) 0%,
    rgba(0, 0, 0, 0.12) 45%,
    rgba(0, 0, 0, 0.28) 75%,
    rgba(0, 0, 0, 0.5) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.featured-card:hover {
  transform: translateY(-6px) rotateX(2deg);
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(183, 108, 255, 0.2),
    0 0 40px rgba(183, 108, 255, 0.1);
}

.featured-card:hover::before {
  background-size: 120%;
  filter: saturate(1.2) contrast(1.08) brightness(1.05);
  opacity: 1;
}

/* Animated Border */
.card-border {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  padding: 1px;
  background: linear-gradient(135deg, 
    rgba(183, 108, 255, 0.3),
    rgba(183, 108, 255, 0.1) 50%,
    rgba(94, 234, 212, 0.1)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.5;
  transition: opacity 0.3s ease;
  z-index: 10;
  pointer-events: none;
}

.featured-card:hover .card-border {
  opacity: 1;
}

/* Enhanced Glow Effect */
.card-glow {
  position: absolute;
  inset: -2px;
  background: radial-gradient(ellipse at 50% 0%, var(--card-accent, rgba(183, 108, 255, 0.3)), transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 2;
  pointer-events: none;
  border-radius: 24px;
  filter: blur(20px);
}

.featured-card:hover .card-glow {
  opacity: 0.6;
}

/* Vignette - very subtle */
.card-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.08) 100%);
  z-index: 1;
  pointer-events: none;
  border-radius: 24px;
}

/* Card Content */
.featured-card .card-content {
  position: relative;
  z-index: 50;
  padding: 28px 28px 90px 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Text backdrop for readability - DISABLED */
.featured-card .card-content::before {
  display: none;
}

/* Pinned Badge */
.pinned-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(183, 108, 255, 0.5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 1);
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.featured-card:hover .pinned-badge {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(183, 108, 255, 0.85);
  color: rgba(255, 255, 255, 1);
}

.pinned-badge svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

/* Title with underline animation */
.title-wrapper {
  position: relative;
  display: inline-block;
}

.card-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: rgba(255, 255, 255, 1);
  margin: 0 0 8px 0;
  line-height: 1.3;
  text-shadow: 
    0 0 2px rgba(0, 0, 0, 1),
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.8),
    0 4px 10px rgba(0, 0, 0, 0.7);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: all 0.3s ease;
}

.featured-card:hover .card-title {
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.title-underline {
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--card-accent, rgba(183, 108, 255, 0.8)), transparent);
  transition: width 0.4s ease;
}

.featured-card:hover .title-underline {
  width: 60%;
}

.theme-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 1);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.9);
  transition: all 0.3s ease;
}

.featured-card:hover .theme-tag {
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 6px rgba(0, 0, 0, 0.95);
}

/* Card Stats Row */
.card-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-radius: 12px;
  backdrop-filter: none;
  transition: all 0.3s ease;
}

.featured-card:hover .card-stats {
  background: transparent;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.9);
  transition: all 0.3s ease;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95), 0 4px 8px rgba(0, 0, 0, 0.9);
  transition: all 0.3s ease;
}

.level-value {
  color: rgba(255, 255, 255, 1);
  text-shadow: 
    0 0 10px var(--card-accent, rgba(183, 108, 255, 0.8)),
    0 1px 2px rgba(0, 0, 0, 1), 
    0 2px 4px rgba(0, 0, 0, 0.95);
}

.stat-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
}

/* Character Section */
.card-character {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-radius: 16px;
  backdrop-filter: none;
  transition: all 0.3s ease;
}

.featured-card:hover .card-character {
  background: transparent;
  border-color: transparent;
}

/* Character Portrait */
.char-portrait {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.portrait-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--card-accent, rgba(183, 108, 255, 0.8)), rgba(180, 188, 199, 0.3), var(--card-accent, rgba(183, 108, 255, 0.8)));
  padding: 2px;
  animation: rotateRing 8s linear infinite;
}

@keyframes rotateRing {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.portrait-inner {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(25, 27, 42, 0.95), rgba(15, 17, 28, 0.98));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.char-details {
  flex: 1;
  min-width: 0;
}

.char-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.char-name {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95), 0 4px 8px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
}

.featured-card:hover .char-name {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.98), 0 4px 10px rgba(0, 0, 0, 0.95);
}

.char-race {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.char-class-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95);
  padding: 4px 10px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border: 1px solid var(--class-color, rgba(183, 108, 255, 0.3));
  border-radius: 20px;
}

/* Enhanced Card Actions */
.card-actions {
  display: flex;
  gap: 12px;
}

.featured-card .card-actions {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  margin-top: 0;
}

.action-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  overflow: hidden;
  cursor: pointer;
}

.primary-action {
  flex: 1;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.55));
  border-color: rgba(183, 108, 255, 0.5);
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95), 0 4px 8px rgba(0, 0, 0, 0.9);
  font-weight: 700;
}

.primary-action:hover {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.35), rgba(183, 108, 255, 0.2));
  border-color: rgba(183, 108, 255, 0.7);
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(183, 108, 255, 0.25);
  color: rgba(255, 255, 255, 1);
}

.btn-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

.primary-action:hover .btn-icon {
  transform: translateX(3px);
}

.btn-ripple {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.primary-action:hover .btn-ripple {
  opacity: 1;
}

.secondary-action {
  width: 48px;
  height: 48px;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 1);
}

.secondary-action:hover {
  background: rgba(0, 0, 0, 0.75);
  border-color: rgba(255, 255, 255, 0.45);
  color: rgba(255, 255, 255, 1);
}

.secondary-action svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

/* Shine Effects */
.card-shine {
  position: absolute;
  top: -100%;
  left: -100%;
  width: 300%;
  height: 300%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.03) 50%,
    transparent 60%
  );
  transform: rotate(25deg) translateY(-100%);
  transition: transform 0.8s ease;
  z-index: 4;
  pointer-events: none;
}

.featured-card:hover .card-shine {
  transform: rotate(25deg) translateY(100%);
}

.card-glare {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 3;
  pointer-events: none;
  border-radius: 24px;
}

.featured-card:hover .card-glare {
  opacity: 1;
}

/* Compact Library Card */
.library-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  min-height: 220px;
  background: linear-gradient(180deg, rgba(25, 27, 42, 0.6), rgba(15, 17, 28, 0.8));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.library-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hero-url);
  background-size: 120%;
  background-position: center;
  filter: saturate(1.15) contrast(1.08) brightness(0.8);
  opacity: 1;
  z-index: 0;
  transition: all 0.4s ease;
}

.library-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, 
    rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0.05) 40%,
    rgba(0, 0, 0, 0.2) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.library-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.library-card:hover::before {
  background-size: 130%;
  filter: saturate(1.25) contrast(1.1) brightness(0.9);
  opacity: 1;
}

.library-card .card-border {
  border-radius: 16px;
}

.library-card .card-vignette {
  border-radius: 16px;
}

.library-card .card-content {
  position: relative;
  z-index: 50;
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Text backdrop for library cards - DISABLED */
.library-card .card-content::before {
  display: none;
}

.card-header-compact {
  margin-bottom: 16px;
}

.card-title-compact {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  color: rgba(255, 255, 255, 1);
  margin: 0 0 8px 0;
  line-height: 1.3;
  text-shadow: 
    0 0 2px rgba(0, 0, 0, 1),
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 2px 6px rgba(0, 0, 0, 0.8);
  transition: all 0.3s ease;
}



.library-card:hover .card-meta,
.library-card:hover .mini-stat,
.library-card:hover .mini-stat svg {
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.95);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95);
  transition: all 0.3s ease;
}

.meta-class {
  color: rgba(255, 255, 255, 1);
  font-weight: 700;
  text-shadow: 
    0 0 8px rgba(183, 108, 255, 0.8),
    0 1px 2px rgba(0, 0, 0, 1), 
    0 2px 4px rgba(0, 0, 0, 0.95);
}

.meta-separator {
  opacity: 0.4;
}

.mini-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.mini-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95);
  transition: all 0.3s ease;
}

.mini-stat svg {
  width: 14px;
  color: rgba(255, 255, 255, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.95));
  transition: all 0.3s ease;
}

.library-card .card-actions-compact {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 16px;
}

.compact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  position: relative;
  z-index: 100;
  pointer-events: auto;
}

.pin-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 184, 74, 0.4);
  color: rgba(255, 184, 74, 1);
}

.pin-btn:hover {
  background: rgba(255, 184, 74, 0.25);
  border-color: rgba(255, 184, 74, 0.6);
  color: rgba(255, 184, 74, 1);
}

.pin-btn[data-action="unpin"] {
  background: rgba(255, 184, 74, 0.3);
  border-color: rgba(255, 184, 74, 0.8);
}

.pin-btn[data-action="unpin"]:hover {
  background: rgba(255, 184, 74, 0.5);
  border-color: rgba(255, 184, 74, 1);
}

.pin-btn svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.95));
}

/* Desaturated pin button when max pins reached */
.pin-btn.disabled {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 184, 74, 0.2);
  color: rgba(255, 184, 74, 0.4);
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.pin-btn.disabled:hover {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 184, 74, 0.2);
  color: rgba(255, 184, 74, 0.4);
}

/* Pinned Card Layout - ensure proper structure */
.featured-card .card-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-main {
  flex: 1;
}

/* Pinned Card Actions - Bottom Right, Same Height */
.pinned-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 20px;
  position: relative;
  z-index: 10;
}

.pinned-actions .action-btn,
.pinned-actions .pin-btn,
.pinned-actions .delete-btn,
.pinned-actions .primary-action {
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 100 !important;
  pointer-events: auto !important;
}

.pinned-actions .pin-btn {
  width: 44px;
  padding: 0;
}

.pinned-actions .primary-action {
  padding: 0 20px;
}

.pinned-actions .delete-btn {
  width: 44px;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(239, 68, 68, 0.4);
  color: rgba(255, 150, 150, 1);
}

.pinned-actions .delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
}

.pinned-actions .delete-btn svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.95));
}

.enter-btn {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(183, 108, 255, 0.5);
  color: rgba(255, 255, 255, 1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 2px 4px rgba(0, 0, 0, 0.95);
  font-weight: 700;
}

.enter-btn:hover {
  background: rgba(183, 108, 255, 0.3);
  border-color: rgba(183, 108, 255, 0.7);
  color: rgba(255, 255, 255, 1);
}

.delete-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(239, 68, 68, 0.4);
  color: rgba(255, 150, 150, 1);
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: rgba(255, 150, 150, 1);
}

.delete-btn svg {
  width: 14px;
  height: 14px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.95));
}

.card-shine-compact {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.02) 50%,
    transparent 60%
  );
  transform: rotate(25deg) translateY(-100%);
  transition: transform 0.6s ease;
  z-index: 3;
  pointer-events: none;
}

.library-card:hover .card-shine-compact {
  transform: rotate(25deg) translateY(100%);
}

/* Empty State */
.empty-stories {
  text-align: center;
  padding: 100px 20px;
}

.empty-illustration {
  position: relative;
  display: inline-block;
  margin-bottom: 32px;
}

.book-icon {
  width: 80px;
  height: 80px;
  color: rgba(180, 188, 199, 0.3);
}

.book-icon svg {
  width: 100%;
  height: 100%;
}

.floating-runes {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 20px;
}

.rune {
  font-size: 24px;
  color: rgba(183, 108, 255, 0.4);
  animation: floatRune 3s ease-in-out infinite;
}

.rune:nth-child(2) {
  animation-delay: -1s;
}

.rune:nth-child(3) {
  animation-delay: -2s;
}

@keyframes floatRune {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-10px);
    opacity: 0.7;
  }
}

.empty-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.9);
  margin: 0 0 12px 0;
}

.empty-subtitle {
  font-size: 15px;
  color: rgba(180, 188, 199, 0.5);
  margin: 0 0 32px 0;
}

.empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.2), rgba(183, 108, 255, 0.08));
  border: 1px solid rgba(183, 108, 255, 0.35);
  border-radius: 12px;
  color: rgba(238, 240, 244, 0.95);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
}

.empty-cta:hover {
  background: linear-gradient(135deg, rgba(183, 108, 255, 0.3), rgba(183, 108, 255, 0.12));
  border-color: rgba(183, 108, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(183, 108, 255, 0.2);
}

.empty-cta svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.empty-cta:hover svg {
  transform: translateX(4px);
}

/* Enhanced Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.9);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.loading-overlay.active {
  display: flex;
  opacity: 1;
}

.loading-content {
  text-align: center;
}

.loading-sigil {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 32px;
}

.sigil-ring {
  position: absolute;
  border: 2px solid rgba(183, 108, 255, 0.3);
  border-radius: 50%;
  border-top-color: rgba(183, 108, 255, 0.8);
  border-right-color: transparent;
}

.ring-1 {
  inset: 0;
  animation: rotateSigil 3s linear infinite;
}

.ring-2 {
  inset: 15px;
  border-color: rgba(94, 234, 212, 0.2);
  border-top-color: rgba(94, 234, 212, 0.6);
  animation: rotateSigil 4s linear infinite reverse;
}

.ring-3 {
  inset: 30px;
  border-color: rgba(255, 184, 74, 0.15);
  border-top-color: rgba(255, 184, 74, 0.5);
  animation: rotateSigil 5s linear infinite;
}

@keyframes rotateSigil {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sigil-core {
  position: absolute;
  inset: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: rgba(183, 108, 255, 0.9);
  animation: pulseCore 2s ease-in-out infinite;
}

@keyframes pulseCore {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.loading-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.loading-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  color: rgba(238, 240, 244, 0.98);
  text-shadow: 0 0 20px rgba(183, 108, 255, 0.3);
}

.loading-subtitle {
  font-size: 14px;
  color: rgba(180, 188, 199, 0.5);
}

.loading-bar {
  width: 300px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, rgba(183, 108, 255, 0.8), rgba(94, 234, 212, 0.8));
  border-radius: 3px;
  animation: loadingProgress 2s ease-in-out infinite;
}

@keyframes loadingProgress {
  0% { width: 0%; transform: translateX(-100%); }
  50% { width: 70%; }
  100% { width: 100%; transform: translateX(100%); }
}

/* Simple pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Audio Settings Menu (Ambience/Music) */
.audio-settings-menu #ambienceMenu,
#ambienceMenu {
  font-family: inherit;
}

#ambienceMenu .audio-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#ambienceMenu .audio-section-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.92);
}

#ambienceMenu .audio-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 10px 0;
}

#ambienceMenu .audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#ambienceMenu .audio-row-space {
  justify-content: space-between;
}

#ambienceMenu .audio-toggle-btn {
  background: #101521;
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(238, 240, 244, 0.9);
  min-width: 40px;
  min-height: 40px;
  touch-action: manipulation;
}

#ambienceMenu .audio-toggle-btn:hover {
  border-color: var(--accent);
}

#ambienceMenu .audio-slider {
  flex: 1;
  height: 18px;
  cursor: pointer;
  background: transparent;
  touch-action: manipulation;
}

#ambienceMenu .audio-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 11px;
  color: rgba(180, 188, 199, 0.9);
}

#ambienceMenu .audio-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

#ambienceMenu .audio-toggle-track {
  width: 36px;
  height: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#ambienceMenu .audio-toggle-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(238, 240, 244, 0.95);
  transition: transform 0.2s ease, background 0.2s ease;
}

#ambienceMenu .audio-toggle input[type="checkbox"]:checked + .audio-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

#ambienceMenu .audio-toggle input[type="checkbox"]:checked + .audio-toggle-track .audio-toggle-thumb {
  transform: translateX(20px);
  background: rgba(255, 255, 255, 0.98);
}

#ambienceMenu .audio-state {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.85);
}

#ambienceMenu .audio-caption {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(180, 188, 199, 0.7);
}

#ambienceMenu .audio-value {
  font-size: 11px;
  color: rgba(238, 240, 244, 0.9);
}

#ambienceMenu input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  outline: none;
  background: transparent;
}

#ambienceMenu input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--accent-border);
}

#ambienceMenu input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 24px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  box-shadow: none;
  margin-top: -9px;
}

#ambienceMenu input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--accent-border);
}

#ambienceMenu input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 24px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  box-shadow: none;
}

@media (max-width: 768px) {
  #ambienceMenu {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    z-index: 12000 !important;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #ambienceMenu .audio-section-title {
    font-size: 13px;
  }
  #ambienceMenu .audio-toggle-label,
  #ambienceMenu .audio-state,
  #ambienceMenu .audio-caption,
  #ambienceMenu .audio-value {
    font-size: 12px;
  }
  #ambienceMenu .audio-toggle-btn {
    min-width: 46px;
    min-height: 46px;
  }
}

/* Story Menu (Hidden by default) */
.story-menu {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.story-menu.active {
  display: block;
  opacity: 1;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.menu-panel {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: calc(100% - 40px);
  max-width: 400px;
  background: rgba(20, 22, 35, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 12px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-menu.active .menu-panel {
  transform: translateX(-50%) translateY(0);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: rgba(238, 240, 244, 0.95);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.menu-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.menu-item.delete-item {
  color: rgba(239, 68, 68, 0.9);
}

.menu-item.delete-item:hover {
  background: rgba(239, 68, 68, 0.1);
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 0;
}

/* Drag States */
.featured-card.dragging,
.library-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  cursor: grabbing;
}

.featured-card.story-drop,
.library-card.story-drop {
  border: 2px dashed rgba(183, 108, 255, 0.5);
  background: rgba(183, 108, 255, 0.1);
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* Empty state */
.empty-stories {
  text-align: center;
  padding: 80px 20px;
  color: rgba(180, 188, 199, 0.6);
}

.empty-stories-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-stories-text {
  font-size: 20px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.8);
  margin-bottom: 8px;
}

.empty-stories-hint {
  font-size: 14px;
  color: rgba(180, 188, 199, 0.5);
}

/* Dragging state */
.modern-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  cursor: grabbing;
}

.modern-card.story-drop {
  border: 2px solid rgba(183, 108, 255, 0.8);
  background: rgba(183, 108, 255, 0.15);
  box-shadow: 0 0 40px rgba(183, 108, 255, 0.3);
}

/* Pinned stories - mobile scaling */
@media (max-width: 900px) {
  .featured-zone {
    padding: 18px;
  }

  .featured-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .featured-card {
    min-height: 280px;
  }

  .featured-card .card-content {
    padding: 22px 22px 84px 22px;
  }
}

@media (max-width: 640px) {
  .featured-zone {
    padding: 14px;
    border-radius: 18px;
  }

  .featured-card {
    min-height: 240px;
    border-radius: 18px;
  }

  .featured-card .card-content {
    padding: 18px 18px 74px 18px;
  }

  .card-title {
    font-size: 22px;
  }

  .card-stats {
    gap: 12px;
    flex-wrap: wrap;
  }

  .pinned-actions {
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .journal-now-grid {
    grid-template-columns: 1fr;
  }
  .stories-container {
    padding: 16px 16px 32px;
  }
  
  .stories-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .stories-title {
    font-size: 26px;
  }
  
  .modern-grid {
    grid-template-columns: 1fr;
  }
  
  .new-story-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .card-content {
    padding: 16px;
  }
  
  .card-title {
    font-size: 16px;
  }
  
  .char-avatar {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* Animated Background System - for use across all pages */
.animated-bg-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -10;
  pointer-events: none;
}

/* Animated gradient background */
.animated-bg-gradient {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(101, 51, 238, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(51, 102, 238, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.15) 0%, transparent 70%),
    linear-gradient(180deg, #0a0a0f 0%, #0d0d14 50%, #0a0a0f 100%);
  animation: bg-shift 20s ease-in-out infinite;
  background-attachment: fixed;
}

@keyframes bg-shift {
  0%, 100% { 
    background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;
    filter: hue-rotate(0deg);
  }
  50% { 
    background-position: 10% 10%, 90% 90%, 55% 45%, 0% 0%;
    filter: hue-rotate(5deg);
  }
}

/* Noise texture overlay */
.animated-bg-noise {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Floating particles */
.animated-bg-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.animated-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.8) 0%, transparent 70%);
  border-radius: 50%;
  animation: float-up linear infinite;
}

.animated-particle:nth-child(1) { left: 10%; animation-duration: 25s; animation-delay: 0s; }
.animated-particle:nth-child(2) { left: 20%; animation-duration: 30s; animation-delay: 2s; width: 6px; height: 6px; }
.animated-particle:nth-child(3) { left: 35%; animation-duration: 22s; animation-delay: 4s; }
.animated-particle:nth-child(4) { left: 50%; animation-duration: 28s; animation-delay: 1s; width: 3px; height: 3px; }
.animated-particle:nth-child(5) { left: 65%; animation-duration: 32s; animation-delay: 3s; }
.animated-particle:nth-child(6) { left: 75%; animation-duration: 24s; animation-delay: 5s; width: 5px; height: 5px; }
.animated-particle:nth-child(7) { left: 85%; animation-duration: 26s; animation-delay: 2.5s; }
.animated-particle:nth-child(8) { left: 95%; animation-duration: 29s; animation-delay: 1.5s; width: 4px; height: 4px; }
.animated-particle:nth-child(9) { left: 5%; animation-duration: 35s; animation-delay: 0.5s; }
.animated-particle:nth-child(10) { left: 45%; animation-duration: 27s; animation-delay: 3.5s; width: 7px; height: 7px; }

@keyframes float-up {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-20px) scale(1);
    opacity: 0;
  }
}

.beta-feedback-btn{
  padding: 8px 12px;
  font-size: 12px;
  border-color: rgba(94, 234, 212, 0.35);
  color: rgba(238, 240, 244, 0.95);
}

.beta-feedback-btn:hover{
  background: linear-gradient(180deg, rgba(94, 234, 212, 0.18), rgba(255, 255, 255, 0.04));
  border-color: rgba(94, 234, 212, 0.6);
}

.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 1002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.feedback-modal.hidden {
  display: none;
}

.feedback-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.6);
  backdrop-filter: blur(10px);
}

.feedback-panel {
  position: relative;
  z-index: 1;
  width: min(640px, 92vw);
  background: rgba(16, 18, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
}

.feedback-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.feedback-title {
  font-size: 18px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.feedback-sub {
  font-size: 13px;
  color: rgba(180, 188, 199, 0.7);
  margin-top: 6px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback-label {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.8);
}

.feedback-textarea {
  min-height: 140px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  resize: vertical;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.feedback-textarea:focus {
  outline: none;
  border-color: rgba(94, 234, 212, 0.6);
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.2);
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Updates modal */
.updates-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.updates-modal.hidden {
  display: none;
}

.updates-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.6);
  backdrop-filter: blur(10px);
}

.updates-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 92vw);
  max-height: 80vh;
  overflow: hidden;
  background: rgba(16, 18, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.updates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.updates-title {
  font-size: 18px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.updates-sub {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.6);
}

.updates-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: rgba(238, 240, 244, 0.7);
  cursor: pointer;
}

.updates-body {
  padding: 18px 22px;
  overflow-y: auto;
}

.updates-item {
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.updates-item:last-child {
  border-bottom: none;
}

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

.updates-item-date {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(183, 108, 255, 0.9);
}

.updates-item-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.updates-item-content {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(220, 226, 234, 0.75);
}

.updates-item-content p {
  margin: 0 0 8px;
}

.updates-item-content p:last-child {
  margin-bottom: 0;
}

.updates-item-content ul,
.updates-item-content ol {
  margin: 8px 0 10px 18px;
  padding: 0;
}

.updates-item-content li {
  margin: 4px 0;
}

.updates-item-content h3,
.updates-item-content h4,
.updates-item-content h5,
.updates-item-content h6 {
  margin: 12px 0 6px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
}

.updates-item-content h3 {
  font-size: 15px;
}

.updates-item-content h4 {
  font-size: 14px;
}

.updates-item-content h5 {
  font-size: 13px;
}

.updates-item-content h6 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.updates-item-content code {
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 12px;
  background: rgba(15, 18, 26, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 1px 6px;
}

.updates-item-content a {
  color: rgba(183, 108, 255, 0.9);
  text-decoration: underline;
}

/* Badge styles for updates modal */
.updates-item-content .update-badge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0;
}

.updates-item-content .update-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 110px;
  justify-content: flex-start;
  align-self: center;
}

.updates-item-content .badge-icon {
  font-size: 12px;
  line-height: 1;
  margin-right: 4px;
}

.updates-item-content .badge-icon svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.updates-item-content .update-badge-text {
  padding: 0;
}

.updates-item-content .badge-content {
  flex: 1;
  line-height: 1.5;
}

.updates-item-content .update-badge.tag-new {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.updates-item-content .update-badge.tag-improvement {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.updates-item-content .update-badge.tag-fix {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.updates-item-content .update-badge.tag-breaking {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.updates-item-content .update-badge.tag-info {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.updates-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 20, 0.8);
}

body.updates-open {
  overflow: hidden;
}

body.feedback-open {
  overflow: hidden;
}

/* ============================================
   D&D STYLE CHARACTER SHEET WITH TABS
   ============================================ */

/* Character Sheet Tabs */
.char-sheet-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.1);
  background: rgba(25, 26, 38, 0.4);
}

.char-tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: rgba(180, 188, 199, 0.6);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.char-tab:hover {
  color: rgba(238, 240, 244, 0.9);
}

.char-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Tab Content */
.char-tab-content {
  display: none;
}

.char-tab-content.active {
  display: block;
}

/* D&D Header */
.dd-header {
  background: rgba(25, 26, 38, 0.6);
  border: 2px solid var(--accent-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.dd-header-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.dd-char-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-char-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.dd-char-meta span {
  color: rgba(180, 188, 199, 0.8);
}

.dd-char-meta .dd-class {
  color: var(--accent);
  font-weight: 600;
}

.dd-exp {
  margin-top: 8px;
}

/* D&D Grid Layout */
.dd-grid {
  display: grid;
  grid-template-columns: 140px 200px 1fr;
  gap: 16px;
}

/* Left Column - Abilities */
.dd-abilities {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dd-ability-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  position: relative;
}

.dd-ability-header {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.dd-ability-mod {
  font-size: 20px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-ability-score {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  margin-top: 2px;
}

/* Proficiency Bonus Box */
.dd-prof-bonus-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  margin-top: 8px;
}

.dd-prof-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.dd-prof-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Saving Throws Box */
.dd-saves-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}

.dd-box-title {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  text-align: center;
}

.dd-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.dd-save-prof {
  font-size: 10px;
  color: var(--accent);
}

.dd-save-name {
  color: rgba(238, 240, 244, 0.9);
}

.dd-save-mod {
  color: rgba(238, 240, 244, 0.9);
  font-weight: 600;
}

/* Middle Column - Skills */
.dd-skills-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.dd-skill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.05);
}

.dd-skill-row:last-child {
  border-bottom: none;
}

.dd-skill-prof {
  font-size: 8px;
  color: var(--accent);
  width: 16px;
}

.dd-skill-name {
  flex: 1;
  color: rgba(238, 240, 244, 0.9);
}

.dd-skill-ability {
  color: rgba(180, 188, 199, 0.5);
  font-size: 10px;
  margin-right: 8px;
}

.dd-skill-mod {
  color: rgba(238, 240, 244, 0.9);
  font-weight: 600;
  min-width: 28px;
  text-align: right;
}

/* Right Column - Combat & Features */
.dd-combat-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.dd-combat-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.1);
}

.dd-combat-stat {
  text-align: center;
}

.dd-combat-value {
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-combat-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  margin-top: 4px;
}

.dd-hp-box {
  text-align: center;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.dd-hp-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.dd-hp-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.dd-passive-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(25, 26, 38, 0.8);
  border-radius: 6px;
}

.dd-passive-label {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.7);
}

.dd-passive-value {
  font-size: 16px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

/* Features Box */
.dd-features-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.dd-features-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Feature items now styled in newer section below */

/* Languages Box */
.dd-languages-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.dd-languages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dd-language-tag {
  background: rgba(25, 26, 38, 0.8);
  border: 1px solid rgba(180, 188, 199, 0.2);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: rgba(180, 188, 199, 0.9);
}

/* Spell Slots Box */
.dd-spell-slots-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.dd-slots-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dd-slot-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(25, 26, 38, 0.8);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 40px;
}

.dd-slot-level {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
}

.dd-slot-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

/* Alignment Box */
.dd-alignment-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dd-alignment-label {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
}

.dd-alignment-value {
  font-size: 13px;
  color: rgba(238, 240, 244, 0.9);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .dd-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .dd-abilities {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .dd-ability-box {
    flex: 1;
    min-width: 80px;
  }
  
  .dd-char-name {
    font-size: 20px;
  }
  
  .dd-char-meta {
    font-size: 12px;
  }
}

/* ============================================
   REDESIGNED CHARACTER SHEET LAYOUT
   ============================================ */

/* Top Section - Header + Combat Stats */
.dd-top-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dd-header-info {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 16px;
}

.dd-char-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 8px;
}

.dd-header-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.dd-header-row .dd-class {
  color: var(--accent);
  font-weight: 600;
}

.dd-header-row span {
  color: rgba(180, 188, 199, 0.8);
}

/* Combat Stats Row */
.dd-combat-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.dd-stat-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.dd-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-stat-label {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  margin-top: 4px;
}

/* HP Box Specific */
.dd-hp {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dd-hp-values {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 20px;
  font-weight: 700;
}

.dd-hp-current {
  color: var(--accent);
}

.dd-hp-temp {
  color: #5eead4;
  font-size: 14px;
}

.dd-hp-max {
  color: rgba(180, 188, 199, 0.7);
}

.dd-hp-separator {
  color: rgba(180, 188, 199, 0.4);
}

/* Death Saves */
.dd-death-saves {
  padding: 8px;
}

.dd-death-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dd-death-success,
.dd-death-fail {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.dd-death-label {
  color: rgba(180, 188, 199, 0.6);
  min-width: 45px;
}

.dd-death-dot {
  color: rgba(180, 188, 199, 0.2);
  font-size: 14px;
}

.dd-death-dot.filled {
  color: var(--accent);
}

.dd-death-fail .dd-death-dot.filled {
  color: #ef4444;
}

/* Secondary Stats Row */
.dd-secondary-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.dd-stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 20px;
  padding: 8px 16px;
}

.dd-pill-label {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
}

.dd-pill-value {
  font-size: 14px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

/* Main Content Grid */
.dd-main-content {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* Abilities Section */
.dd-abilities-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dd-ability-section {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
}

.dd-ability-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.1);
}

.dd-ability-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dd-ability-code {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.dd-ability-mod {
  font-size: 20px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-ability-score-large {
  font-size: 28px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--accent-border);
  border-radius: 8px;
}

.dd-save-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.05);
}

.dd-save-indicator {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.3);
  width: 16px;
}

.dd-save-indicator.proficient {
  color: var(--accent);
}

.dd-save-text {
  flex: 1;
  color: rgba(238, 240, 244, 0.7);
  font-size: 12px;
}

.dd-save-value {
  color: rgba(238, 240, 244, 0.9);
  font-weight: 600;
}

.dd-ability-skills {
  margin-top: 8px;
}

.dd-skill-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.dd-skill-indicator {
  font-size: 8px;
  color: var(--accent);
  width: 14px;
}

.dd-skill-text {
  flex: 1;
  color: rgba(238, 240, 244, 0.8);
}

.dd-skill-value {
  color: rgba(238, 240, 244, 0.9);
  font-weight: 600;
  min-width: 24px;
  text-align: right;
}

/* Equipment Section */
.dd-equipment-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dd-weapons-box,
.dd-armor-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 12px;
}

.dd-weapon-item,
.dd-armor-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(180, 188, 199, 0.05);
}

.dd-weapon-item:last-child,
.dd-armor-item:last-child {
  border-bottom: none;
}

.dd-weapon-header,
.dd-armor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.dd-weapon-name,
.dd-armor-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
}

.dd-equipped-badge {
  font-size: 9px;
  color: var(--accent);
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid var(--accent-border);
  border-radius: 4px;
}

.dd-weapon-stats,
.dd-armor-stats {
  display: flex;
  gap: 8px;
  font-size: 11px;
}

.dd-weapon-damage {
  color: #ef4444;
  font-weight: 600;
}

.dd-weapon-props {
  color: rgba(180, 188, 199, 0.6);
}

.dd-armor-ac {
  color: var(--accent);
  font-weight: 600;
}

.dd-armor-stealth {
  color: rgba(180, 188, 199, 0.6);
}

.dd-empty-item {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.4);
  text-align: center;
  padding: 16px;
}

/* Bottom Row - Features & Traits */
.dd-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dd-features-box,
.dd-traits-box {
  background: rgba(25, 26, 38, 0.6);
  border: 1px solid rgba(180, 188, 199, 0.15);
  border-radius: 8px;
  padding: 16px;
}

.dd-features-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dd-feature-category {
  margin-bottom: 12px;
}

.dd-feature-cat-title {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.dd-slots-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dd-slot-badge {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(180, 111, 255, 0.15);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  color: rgba(238, 240, 244, 0.9);
}

/* Trait items now styled in newer section below */

.dd-trait-label {
  color: rgba(180, 188, 199, 0.6);
}

.dd-trait-value {
  color: rgba(238, 240, 244, 0.9);
}

.dd-traits-list {
  margin-top: 8px;
}

.dd-languages-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(180, 188, 199, 0.1);
}

.dd-languages-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .dd-top-section {
    grid-template-columns: 1fr;
  }
  
  .dd-combat-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .dd-main-content {
    grid-template-columns: 1fr 1fr;
  }
  
  .dd-equipment-section {
    grid-column: 1 / -1;
    flex-direction: row;
  }
  
  .dd-weapons-box,
  .dd-armor-box {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .dd-combat-stats-row {
    grid-template-columns: 1fr 1fr;
  }
  
  .dd-main-content {
    grid-template-columns: 1fr;
  }
  
  .dd-equipment-section {
    flex-direction: column;
  }
  
  .dd-bottom-row {
    grid-template-columns: 1fr;
  }
  
  .dd-secondary-row {
    gap: 8px;
  }
  
  .dd-stat-pill {
    padding: 6px 12px;
  }
}
/* =====================================================
   REDESIGNED CHARACTER SHEET STYLES
   ===================================================== */

/* Level Badge - Upper Left */
.dd-level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent) 0%, rgba(0,0,0,0.6) 100%);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 60px;
  position: relative;
}

.dd-level-num {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.dd-level-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
}

.dd-exp-bar {
  width: 100%;
  height: 3px;
  background: rgba(0,0,0,0.3);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.dd-exp-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.dd-exp-text {
  font-size: 8px;
  color: rgba(255,255,255,0.7);
  margin-top: 3px;
}

/* Compact Header Info */
.dd-header-info-compact {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 16px;
}

.dd-char-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(180, 188, 199, 0.9);
  margin-top: 4px;
}

.dd-divider {
  color: rgba(180, 188, 199, 0.4);
}

/* Updated Top Section Layout */
.dd-top-section {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  background: rgba(25, 26, 38, 0.6);
  border: 2px solid var(--accent-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

/* Updated HP Box */
.dd-hp-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 24px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-hp-current {
  color: #4ade80;
}

.dd-hp-temp {
  color: #60a5fa;
  font-size: 16px;
}

.dd-hp-max {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.7);
  font-weight: 500;
}

/* Updated Death Saves */
.dd-death-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dd-death-dot.filled.fail {
  color: #ef4444;
}

/* Main Content Columns */
.dd-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dd-abilities-column {
  flex: 1;
}

.dd-features-column {
  flex: 1.2;
}

/* Ability Block */
.dd-ability-block {
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 6px;
  padding: 10px;
}

.dd-ability-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.1);
}

.dd-ability-code {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  min-width: 32px;
}

.dd-ability-mod {
  font-size: 18px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.dd-ability-score {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  margin-left: auto;
}

/* Save Row */
.dd-save-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
}

.dd-save-row.not-proficient {
  opacity: 0.5;
}

.dd-save-indicator {
  font-size: 10px;
  color: var(--accent);
}

.dd-save-name {
  flex: 1;
  color: rgba(238, 240, 244, 0.9);
}

.dd-save-mod {
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  font-family: "Cinzel", ui-serif, Georgia, serif;
}

/* Skill Row */
.dd-skill-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
}

.dd-skill-row.not-proficient {
  opacity: 0.4;
}

.dd-skill-indicator {
  font-size: 8px;
  color: var(--accent);
  width: 12px;
}

.dd-skill-name {
  flex: 1;
  color: rgba(238, 240, 244, 0.85);
}

.dd-skill-mod {
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  font-family: "Cinzel", ui-serif, Georgia, serif;
}

/* Section Boxes */
.dd-section-box {
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 6px;
  padding: 12px;
}

.dd-section-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.15);
}

/* Features */
.dd-feature-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(180, 188, 199, 0.08);
}

.dd-feature-item:last-child {
  border-bottom: none;
}

.dd-feature-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 3px;
}

.dd-feature-desc {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
}

/* Languages */
.dd-languages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dd-language-tag {
  background: rgba(180, 188, 199, 0.15);
  border: 1px solid rgba(180, 188, 199, 0.2);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: rgba(238, 240, 244, 0.9);
}

/* Species Traits */
.dd-trait-item {
  padding: 6px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.08);
}

.dd-trait-item:last-child {
  border-bottom: none;
}

.dd-trait-name {
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
}

.dd-trait-value {
  color: rgba(180, 188, 199, 0.8);
}

/* Responsive */
@media (max-width: 900px) {
  .dd-top-section {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  
  .dd-combat-stats-row {
    grid-column: 1 / -1;
  }
  
  .dd-main-content {
    grid-template-columns: 1fr 1fr;
  }
  
  .dd-features-column {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .dd-main-content {
    grid-template-columns: 1fr;
  }
  
  .dd-combat-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .dd-level-badge {
    min-width: 50px;
    padding: 6px 8px;
  }
  
  .dd-level-num {
    font-size: 22px;
  }
}
/* Skills Tab Styles */
.dd-skills-tab-content {
  padding: 16px;
}

.dd-skills-intro {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.8);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(25, 26, 38, 0.4);
  border-radius: 6px;
}

.dd-skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.dd-skill-category {
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.dd-skill-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(180, 188, 199, 0.1);
  border-bottom: 1px solid rgba(180, 188, 199, 0.15);
}

.dd-skill-cat-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}

.dd-skill-cat-mod {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  font-size: 14px;
}

.dd-skill-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.05);
  font-size: 12px;
}

.dd-skill-detail-row:last-child {
  border-bottom: none;
}

.dd-skill-detail-row.proficient {
  background: rgba(180, 188, 199, 0.05);
}

.dd-skill-detail-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(238, 240, 244, 0.9);
}

.dd-skill-detail-row.proficient .dd-skill-detail-name {
  color: rgba(238, 240, 244, 1);
  font-weight: 500;
}

.dd-skill-detail-mod {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
}

.dd-skill-detail-desc {
  grid-column: 1 / -1;
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
  margin-top: 2px;
}

/* Updated Character Sheet Styles */

/* HP Display on same line */
.dd-hp-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 20px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-hp-current {
  color: #4ade80;
}

.dd-hp-separator {
  color: rgba(180, 188, 199, 0.5);
}

.dd-hp-max {
  color: rgba(238, 240, 244, 0.8);
}

.dd-hp-temp-badge {
  background: #60a5fa;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Full attribute names */
.dd-ability-fullname {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}

/* Aligned rows for saves and skills */
.dd-save-row,
.dd-skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
}

.dd-save-row.not-proficient,
.dd-skill-row.not-proficient {
  opacity: 0.4;
}

.dd-row-indicator {
  width: 12px;
  text-align: center;
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

.dd-row-name {
  flex: 1;
  color: rgba(238, 240, 244, 0.9);
}

.dd-row-mod {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  min-width: 24px;
  text-align: right;
}

/* Trait descriptions */
.dd-trait-desc {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
  margin-top: 4px;
}
/* Updated Character Sheet Styles */

/* Thicker line between saving throw and skills */
.dd-save-row {
  border-bottom: 2px solid rgba(180, 188, 199, 0.2);
  margin-bottom: 6px;
  padding-bottom: 8px;
}

/* Centered HP display */
.dd-hp-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 700;
  color: rgba(238, 240, 244, 0.95);
}

.dd-hp-current {
  color: #4ade80;
}

.dd-hp-separator {
  color: rgba(180, 188, 199, 0.5);
  font-weight: 500;
}

.dd-hp-max {
  color: rgba(238, 240, 244, 0.8);
}

.dd-hp-temp-badge {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 600;
}

/* Feature box improvements */
.dd-features-box {
  margin-bottom: 8px;
}

.dd-traits-box {
  margin-top: 0;
}

.dd-feature-item,
.dd-trait-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(180, 188, 199, 0.08);
}

.dd-feature-item:first-child,
.dd-trait-item:first-child {
  padding-top: 4px;
}

.dd-feature-item:last-child,
.dd-trait-item:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

.dd-feature-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 4px;
}

.dd-feature-desc,
.dd-trait-desc {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.75);
  line-height: 1.4;
}

.dd-trait-name {
  font-size: 12px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
  margin-bottom: 3px;
}

/* Languages in ability column */
.dd-languages-in-abilities {
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
}

.dd-languages-in-abilities .dd-section-title {
  margin-bottom: 8px;
}

/* Mobile view adjustments */
@media (max-width: 900px) {
  .dd-languages-in-abilities {
    margin-top: 12px;
  }
}

/* Abilities Tab Content - New Layout */
.dd-abilities-tab-content {
  padding: 16px;
}

.dd-abilities-intro {
  font-size: 12px;
  color: rgba(180, 188, 199, 0.8);
  margin-bottom: 16px;
  padding: 10px 12px;
  background: rgba(25, 26, 38, 0.4);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.dd-abilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.dd-ability-category {
  background: rgba(25, 26, 38, 0.4);
  border: 1px solid rgba(180, 188, 199, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.dd-ability-cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(180, 188, 199, 0.1);
  border-bottom: 1px solid rgba(180, 188, 199, 0.15);
}

.dd-ability-cat-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
}

.dd-ability-item {
  padding: 12px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.05);
}

.dd-ability-item:last-child {
  border-bottom: none;
}

.dd-ability-item-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dd-ability-item-desc {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
}

.dd-ability-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(180, 188, 199, 0.15);
  color: rgba(180, 188, 199, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dd-ability-tag.racial {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.dd-ability-tag.class {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.dd-ability-tag.fighting-style {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
/* Mobile-only and Desktop-only utilities */
.mobile-only {
  display: none;
}

@media (max-width: 900px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
}
/* Fixed Class Features and Species Traits Spacing */

/* Class Features Box */
.dd-features-box {
  margin-bottom: 16px;
}

.dd-features-box .dd-section-title {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.15);
}

.dd-features-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dd-feature-item {
  background: rgba(25, 26, 38, 0.3);
  border: 1px solid rgba(180, 188, 199, 0.08);
  border-radius: 6px;
  padding: 12px;
}

.dd-feature-item:first-child {
  margin-top: 0;
}

.dd-feature-item:last-child {
  margin-bottom: 0;
}

.dd-feature-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.95);
  margin-bottom: 6px;
}

.dd-feature-desc {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.75);
  line-height: 1.5;
}

/* Species Traits Box */
.dd-traits-box {
  margin-top: 16px;
}

.dd-traits-box .dd-section-title {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(180, 188, 199, 0.15);
}

.dd-traits-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dd-trait-item {
  background: rgba(25, 26, 38, 0.3);
  border: 1px solid rgba(180, 188, 199, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
}

.dd-trait-item:first-child {
  margin-top: 0;
}

.dd-trait-item:last-child {
  margin-bottom: 0;
}

.dd-trait-name {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(238, 240, 244, 0.9);
  margin-bottom: 4px;
}

.dd-trait-desc {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  line-height: 1.4;
}

/* Languages - No Background */
.dd-languages-in-abilities {
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 16px;
}

.dd-languages-in-abilities .dd-section-title {
  font-family: "Cinzel", ui-serif, Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.dd-languages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Remove background from language description */
.dd-abilities-tab-content .dd-ability-item-desc .dd-languages-list + div {
  background: transparent !important;
  padding: 0 !important;
  margin-top: 8px;
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
}
/* Highlighted Ability Items */
.dd-ability-item-highlighted {
  background: rgba(251, 191, 36, 0.1) !important;
  border: 1px solid rgba(251, 191, 36, 0.3) !important;
}

.dd-ability-item-highlighted .dd-ability-item-name {
  color: #fbbf24;
}

/* Compact Ability Items */
.dd-ability-item-compact {
  padding: 8px 12px !important;
}

.dd-ability-item-compact .dd-ability-item-desc {
  font-size: 10px;
  line-height: 1.4;
}
/* Updated Abilities Tab Styles - Active/Passive Separation */

.dd-ability-active {
  border-left: 3px solid #fbbf24;
}

.dd-ability-active .dd-ability-cat-header {
  background: rgba(251, 191, 36, 0.1);
}

.dd-ability-active .dd-ability-cat-name {
  color: #fbbf24;
}

.dd-ability-passive {
  border-left: 3px solid rgba(180, 188, 199, 0.3);
}

.dd-ability-passive .dd-ability-cat-header {
  background: rgba(180, 188, 199, 0.05);
}

.dd-ability-cat-subtitle {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  font-weight: 400;
  margin-left: auto;
}

.dd-ability-item-active {
  border-left: 2px solid rgba(251, 191, 36, 0.3);
  padding-left: 10px;
}

.dd-ability-item-passive {
  opacity: 0.9;
}

/* Remove gap between features and traits in main character sheet */
.dd-features-box {
  margin-bottom: 8px;
}

.dd-traits-box {
  margin-top: 0;
}

/* Compact layout for skills tab */
.dd-abilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

@media (max-width: 900px) {
  .dd-abilities-grid {
    grid-template-columns: 1fr;
  }
}

/* ================================
   GM MODE STYLES - Ask the GM Feature
   ================================ */

/* GM Mode Toggle Button - Uses theme accent color */
.ask-gm-btn {
  background: rgba(180, 188, 199, 0.1);
  border: 1px solid rgba(180, 188, 199, 0.3);
  color: rgba(180, 188, 199, 0.9);
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-left: 0px;
  white-space: nowrap;
  min-width: 44px;
  height: 44px;
}

.ask-gm-btn:hover {
  background: rgba(180, 188, 199, 0.15);
  border-color: rgba(180, 188, 199, 0.5);
}

.ask-gm-btn.active {
  background: rgba(180, 188, 199, 0.25);
  border-color: rgba(180, 188, 199, 0.7);
  color: rgba(238, 240, 244, 0.95);
}

/* GM Mode Input Container - Default neutral (overridden by theme classes below) */
.input-container.gm-mode {
  border: 2px dashed rgba(180, 188, 199, 0.3);
  background: rgba(40, 42, 55, 0.4);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  margin-top: 4px;
  margin-bottom: 4px;
}

/* Theme-colored Ask GM button and container */
.story-container.danger-peaceful .ask-gm-btn {
  background: rgba(183, 108, 255, 0.1);
  border-color: rgba(183, 108, 255, 0.3);
  color: rgba(183, 108, 255, 0.9);
}

.story-container.danger-peaceful .ask-gm-btn:hover {
  background: rgba(183, 108, 255, 0.2);
  border-color: rgba(183, 108, 255, 0.5);
}

.story-container.danger-peaceful .ask-gm-btn.active {
  background: rgba(183, 108, 255, 0.3);
  border-color: rgba(183, 108, 255, 0.7);
  color: rgba(238, 240, 244, 0.95);
}

.story-container.danger-calm .ask-gm-btn {
  background: rgba(94, 234, 212, 0.1);
  border-color: rgba(94, 234, 212, 0.3);
  color: rgba(94, 234, 212, 0.9);
}

.story-container.danger-calm .ask-gm-btn:hover {
  background: rgba(94, 234, 212, 0.2);
  border-color: rgba(94, 234, 212, 0.5);
}

.story-container.danger-calm .ask-gm-btn.active {
  background: rgba(94, 234, 212, 0.3);
  border-color: rgba(94, 234, 212, 0.7);
  color: rgba(238, 240, 244, 0.95);
}

.story-container.danger-tense .ask-gm-btn {
  background: rgba(255, 184, 74, 0.1);
  border-color: rgba(255, 184, 74, 0.3);
  color: rgba(255, 184, 74, 0.9);
}

.story-container.danger-tense .ask-gm-btn:hover {
  background: rgba(255, 184, 74, 0.2);
  border-color: rgba(255, 184, 74, 0.5);
}

.story-container.danger-tense .ask-gm-btn.active {
  background: rgba(255, 184, 74, 0.3);
  border-color: rgba(255, 184, 74, 0.7);
  color: rgba(238, 240, 244, 0.95);
}

.story-container.danger-dangerous .ask-gm-btn {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: rgba(239, 68, 68, 0.9);
}

.story-container.danger-dangerous .ask-gm-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.story-container.danger-dangerous .ask-gm-btn.active {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.7);
  color: rgba(238, 240, 244, 0.95);
}

.story-container.danger-critical .ask-gm-btn {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
  color: rgba(220, 38, 38, 0.95);
}

.story-container.danger-critical .ask-gm-btn:hover {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.6);
}

.story-container.danger-critical .ask-gm-btn.active {
  background: rgba(220, 38, 38, 0.35);
  border-color: rgba(220, 38, 38, 0.8);
  color: rgba(238, 240, 244, 0.95);
}

/* Theme-colored GM mode input container */
.story-container.danger-peaceful .input-container.gm-mode {
  border-color: rgba(183, 108, 255, 0.4);
  background: rgba(183, 108, 255, 0.08);
  border-top: none !important;
}

.story-container.danger-calm .input-container.gm-mode {
  border-color: rgba(94, 234, 212, 0.4);
  background: rgba(94, 234, 212, 0.08);
  border-top: none !important;
}

.story-container.danger-tense .input-container.gm-mode {
  border-color: rgba(255, 184, 74, 0.4);
  background: rgba(255, 184, 74, 0.08);
  border-top: none !important;
}

.story-container.danger-dangerous .input-container.gm-mode {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
  border-top: none !important;
}

.story-container.danger-critical .input-container.gm-mode {
  border-color: rgba(220, 38, 38, 0.6);
  background: rgba(220, 38, 38, 0.12);
  border-top: none !important;
}

/* GM Mode Badge - Default neutral styling (overridden by theme classes below) */
.gm-badge {
  background: rgba(40, 42, 55, 0.95);
  border: 1px solid rgba(180, 188, 199, 0.4);
  color: rgba(238, 240, 244, 0.95);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.gm-badge::before {
  content: "?";
  font-size: 12px;
  font-weight: 700;
}

/* GM Input Styling - Default neutral (overridden by theme classes below) */
.gm-input {
  background: rgba(20, 22, 35, 0.9) !important;
  border: 1px solid rgba(180, 188, 199, 0.3) !important;
  color: rgba(238, 240, 244, 0.95) !important;
}

.gm-input::placeholder {
  color: rgba(180, 188, 199, 0.6) !important;
}

.gm-input:focus {
  border-color: rgba(180, 188, 199, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(180, 188, 199, 0.1) !important;
}

/* Theme-colored GM badge and input */
.story-container.danger-peaceful .gm-badge {
  background: rgba(183, 108, 255, 0.15);
  border-color: rgba(183, 108, 255, 0.4);
  color: rgba(183, 108, 255, 0.95);
}

.story-container.danger-calm .gm-badge {
  background: rgba(94, 234, 212, 0.15);
  border-color: rgba(94, 234, 212, 0.4);
  color: rgba(94, 234, 212, 0.95);
}

.story-container.danger-tense .gm-badge {
  background: rgba(255, 184, 74, 0.15);
  border-color: rgba(255, 184, 74, 0.4);
  color: rgba(255, 184, 74, 0.95);
}

.story-container.danger-dangerous .gm-badge {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: rgba(239, 68, 68, 0.95);
}

.story-container.danger-critical .gm-badge {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.6);
  color: rgba(220, 38, 38, 0.95);
}

/* Theme-colored GM input */
.story-container.danger-peaceful .gm-input {
  border-color: rgba(183, 108, 255, 0.4) !important;
}

.story-container.danger-peaceful .gm-input:focus {
  border-color: rgba(183, 108, 255, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(183, 108, 255, 0.2) !important;
}

.story-container.danger-calm .gm-input {
  border-color: rgba(94, 234, 212, 0.4) !important;
}

.story-container.danger-calm .gm-input:focus {
  border-color: rgba(94, 234, 212, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.2) !important;
}

.story-container.danger-tense .gm-input {
  border-color: rgba(255, 184, 74, 0.4) !important;
}

.story-container.danger-tense .gm-input:focus {
  border-color: rgba(255, 184, 74, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(255, 184, 74, 0.2) !important;
}

.story-container.danger-dangerous .gm-input {
  border-color: rgba(239, 68, 68, 0.5) !important;
}

.story-container.danger-dangerous .gm-input:focus {
  border-color: rgba(239, 68, 68, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.story-container.danger-critical .gm-input {
  border-color: rgba(220, 38, 38, 0.5) !important;
}

.story-container.danger-critical .gm-input:focus {
  border-color: rgba(220, 38, 38, 0.9) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25) !important;
}

/* GM Response Display - Themed styling */
.gm-response {
  border-left: 3px solid rgba(180, 188, 199, 0.4);
  border-radius: 0 12px 12px 12px;
  position: relative;
}

.story-container.danger-peaceful .gm-response {
  border-left-color: rgba(183, 108, 255, 0.5);
}

.story-container.danger-calm .gm-response {
  border-left-color: rgba(94, 234, 212, 0.5);
}

.story-container.danger-tense .gm-response {
  border-left-color: rgba(255, 184, 74, 0.5);
}

.story-container.danger-dangerous .gm-response {
  border-left-color: rgba(239, 68, 68, 0.6);
}

.story-container.danger-critical .gm-response {
  border-left-color: rgba(220, 38, 38, 0.7);
}

.gm-response-text {
  color: rgba(238, 240, 244, 0.95);
  line-height: 1.6;
  font-size: 14px;
}

.gm-response-text p {
  margin-bottom: 8px;
}

.gm-response-text p:last-child {
  margin-bottom: 0;
}

/* Loading State for GM Response - Themed */
.gm-text.gm-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(180, 188, 199, 0.8);
  font-style: italic;
}

.gm-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(180, 188, 199, 0.2);
  border-top: 2px solid rgba(180, 188, 199, 0.8);
  border-radius: 50%;
  animation: gm-spin 1s linear infinite;
}

.story-container.danger-peaceful .gm-loading-spinner {
  border-color: rgba(183, 108, 255, 0.2);
  border-top-color: rgba(183, 108, 255, 0.8);
}

.story-container.danger-calm .gm-loading-spinner {
  border-color: rgba(94, 234, 212, 0.2);
  border-top-color: rgba(94, 234, 212, 0.8);
}

.story-container.danger-tense .gm-loading-spinner {
  border-color: rgba(255, 184, 74, 0.2);
  border-top-color: rgba(255, 184, 74, 0.8);
}

.story-container.danger-dangerous .gm-loading-spinner {
  border-color: rgba(239, 68, 68, 0.2);
  border-top-color: rgba(239, 68, 68, 0.8);
}

.story-container.danger-critical .gm-loading-spinner {
  border-color: rgba(220, 38, 38, 0.2);
  border-top-color: rgba(220, 38, 38, 0.9);
}

@keyframes gm-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* GM Mode Transition Animation */
.input-container {
  transition: all 0.3s ease;
}

.gm-mode-transition {
  animation: gm-mode-fade-in 0.3s ease;
}

@keyframes gm-mode-fade-in {
  from {
    opacity: 0.7;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Action Preservation Notice - Themed */
.action-preserved-notice {
  font-size: 11px;
  color: rgba(180, 188, 199, 0.6);
  margin-top: 8px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-preserved-notice::before {
  content: "💾";
}

.story-container.danger-peaceful .action-preserved-notice {
  color: rgba(183, 108, 255, 0.7);
}

.story-container.danger-calm .action-preserved-notice {
  color: rgba(94, 234, 212, 0.7);
}

.story-container.danger-tense .action-preserved-notice {
  color: rgba(255, 184, 74, 0.7);
}

.story-container.danger-dangerous .action-preserved-notice {
  color: rgba(239, 68, 68, 0.7);
}

.story-container.danger-critical .action-preserved-notice {
  color: rgba(220, 38, 38, 0.8);
}

/* Input row layout for GM mode - buttons aligned with input */
.input-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.input-row .story-input,
.input-row .story-textarea {
  flex: 1;
}

/* Send button and Ask GM button sizing - match each other */
.send-btn,
.ask-gm-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* GM Input wrapper with embedded word count */
.gm-input-wrapper {
  position: relative;
  flex: 1;
  display: none;
}

.gm-input-wrapper .gm-input {
  padding-bottom: 24px !important;
}

/* Show GM input wrapper when GM mode is active */
.input-container.gm-mode .gm-input-wrapper {
  display: block;
}

.word-count-embedded,
.story-container.danger-peaceful .word-count-embedded,
.story-container.danger-calm .word-count-embedded,
.story-container.danger-tense .word-count-embedded,
.story-container.danger-dangerous .word-count-embedded,
.story-container.danger-critical .word-count-embedded {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  color: rgba(180, 188, 199, 0.5);
  background: transparent !important;
  background-color: transparent !important;
  pointer-events: none;
}

/* GM Q&A wrapper - surrounds both messages */
.gm-qa-wrapper {
  border: 2px dashed rgba(180, 188, 199, 0.3);
  border-radius: 16px;
  padding: 16px 16px 8px 16px;
  margin-bottom: 20px;
  background: transparent;
}

/* Player question display in GM mode */
.story-entry.gm-player {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 12px;
}

.story-entry.gm-player .gm-text {
  background: rgba(40, 42, 55, 0.6);
  padding: 12px 16px;
  border-radius: 12px 12px 0 12px;
  border-right: 3px solid rgba(180, 188, 199, 0.4);
  max-width: 85%;
  text-align: right;
}

.story-entry.gm-player .gm-header {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  opacity: 0.7;
}

/* GM response entry - mirrored player style */
.story-entry.gm-response {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 8px;
}

.story-entry.gm-response .gm-text {
  background: rgba(40, 42, 55, 0.6);
  padding: 12px 16px;
  border-radius: 12px 12px 12px 0;
  border-left: 3px solid rgba(180, 188, 199, 0.4);
  max-width: 85%;
  text-align: left;
}

.story-entry.gm-response .gm-header {
  font-size: 10px;
  color: rgba(180, 188, 199, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  opacity: 0.7;
}

/* Theme-colored GM entries - all neutral gray */
.story-container.danger-peaceful .story-entry.gm-player .gm-text,
.story-container.danger-calm .story-entry.gm-player .gm-text,
.story-container.danger-tense .story-entry.gm-player .gm-text,
.story-container.danger-dangerous .story-entry.gm-player .gm-text,
.story-container.danger-critical .story-entry.gm-player .gm-text {
  border-right-color: rgba(180, 188, 199, 0.4);
}

.story-container.danger-peaceful .story-entry.gm-response .gm-text,
.story-container.danger-calm .story-entry.gm-response .gm-text,
.story-container.danger-tense .story-entry.gm-response .gm-text,
.story-container.danger-dangerous .story-entry.gm-response .gm-text,
.story-container.danger-critical .story-entry.gm-response .gm-text {
  border-left-color: rgba(180, 188, 199, 0.4);
}

.story-container.danger-peaceful .story-entry.gm-player .gm-header,
.story-container.danger-peaceful .story-entry.gm-response .gm-header,
.story-container.danger-calm .story-entry.gm-player .gm-header,
.story-container.danger-calm .story-entry.gm-response .gm-header,
.story-container.danger-tense .story-entry.gm-player .gm-header,
.story-container.danger-tense .story-entry.gm-response .gm-header,
.story-container.danger-dangerous .story-entry.gm-player .gm-header,
.story-container.danger-dangerous .story-entry.gm-response .gm-header,
.story-container.danger-critical .story-entry.gm-player .gm-header,
.story-container.danger-critical .story-entry.gm-response .gm-header {
  color: rgba(180, 188, 199, 0.7);
}

/* Theme-colored GM wrapper borders - all neutral gray */
.story-container.danger-peaceful .gm-qa-wrapper,
.story-container.danger-calm .gm-qa-wrapper,
.story-container.danger-tense .gm-qa-wrapper,
.story-container.danger-dangerous .gm-qa-wrapper,
.story-container.danger-critical .gm-qa-wrapper {
  border-color: rgba(180, 188, 199, 0.3);
  background: transparent;
}

/* Button stack - buttons side by side, word count below */
.button-stack {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.button-stack .word-count-display {
  width: 100%;
  text-align: right;
  margin-top: 4px;
}

/* Responsive GM Mode */
@media (max-width: 768px) {
  .ask-gm-btn {
    padding: 6px;
    font-size: 12px;
    min-width: 44px;
    width: 44px;
  }
  
  .ask-gm-btn .ask-text {
    display: none;
  }
  
  .ask-gm-btn .ask-icon {
    display: block !important;
  }
  
  .ask-gm-btn .back-icon {
    display: none !important;
  }
  
  .ask-gm-btn.active .ask-icon {
    display: none !important;
  }
  
  .ask-gm-btn.active .back-icon {
    display: block !important;
  }
  
  .input-container.gm-mode {
    padding: 12px;
  }
  
  .gm-response {
    padding: 16px;
    margin: 12px 0;
  }
}
