/* GameMaster Text Element Font Sizes - CSS Variables */

:root {
  /* Base sizes - using rem for scalability with text size control */
  --text-base: 1rem; /* Regular paragraphs and narrative (16px default) */
  --text-small: 0.875rem; /* List items, system messages, stat blocks (14px default) */
  --text-large: 1.0625rem; /* Questions, dice notation, emphasis (17px default) */
  --text-heading: 1.125rem; /* Scene headings (18px default) */

  /* Specific element sizes */
  --text-paragraph: var(--text-base);
  --text-list-item: var(--text-small);
  --text-question: var(--text-large);
  --text-dialogue: var(--text-base);
  --text-system: var(--text-small);
  --text-mechanics: var(--text-base);
  --text-choice-button: var(--text-base);
  --text-stat-block: var(--text-small);
  --text-dice: var(--text-large);
  --text-condition: var(--text-base);
  --text-skill-check: var(--text-base);
  --text-damage: var(--text-base);
  --text-heading: var(--text-heading);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  --text-scale: 1; /* Default text scale multiplier */
}

body {
  font-family: "Georgia", serif;
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 50%,
    var(--bg-primary) 100%
  );
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(
    6px,
    1vh,
    12px
  ); /* Keep main window near viewport edges while preserving breathing room */
  overflow-x: hidden;
  color: var(--text-primary); /* Default text color for all unformatted text */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Modern fluid typography using clamp() - no more text-scale bugs! */
html {
  /* Base font size scales fluidly between 14px-20px based on viewport width */
  font-size: clamp(0.875rem, 0.5rem + 1vw, 1.25rem);
}

body {
  font-size: inherit; /* Inherits fluid sizing from html */
  line-height: 1.5;
}

/* Keep interactive surfaces selectable so Tome and inputs stay usable */
input,
textarea,
select,
button,
[contenteditable="true"],
.tome-menu,
.tome-menu *,
.tome-modal,
.tome-modal *,
.allow-text-selection {
  -webkit-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Fluid heading sizes - scale proportionally with viewport */
h1 {
  font-size: clamp(1.75rem, 1.5rem + 2vw, 3rem);
  /* 28px min → 48px max */
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.5rem, 1.25rem + 1.5vw, 2.5rem);
  /* 24px min → 40px max */
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  font-size: clamp(1.25rem, 1rem + 1vw, 2rem);
  /* 20px min → 32px max */
  font-weight: 600;
  line-height: 1.4;
}

h4 {
  font-size: clamp(1.125rem, 0.9rem + 0.75vw, 1.5rem);
  /* 18px min → 24px max */
  font-weight: 600;
  line-height: 1.4;
}

h5 {
  font-size: clamp(1rem, 0.85rem + 0.5vw, 1.25rem);
  /* 16px min → 20px max */
  font-weight: 600;
  line-height: 1.5;
}

h6 {
  font-size: clamp(0.875rem, 0.75rem + 0.4vw, 1.125rem);
  /* 14px min → 18px max */
  font-weight: 600;
  line-height: 1.5;
}

/* Fixed sizing for UI controls - prevents layout breaking */
button,
.btn,
input,
select,
textarea,
label {
  font-size: 0.875rem !important; /* Fixed 14px - no scaling */
}

/* Explicitly lock emoji and icon sizes to base size (16px) */
.settings-icon,
.input-icon,
.class-icon,
.settings-menu-item .settings-icon,
button .settings-icon,
.emoji {
  font-size: 16px !important; /* Fixed size, no scaling */
  display: inline-block;
}

/* Global Scrollbar Styling */
* ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-primary) 50%, transparent);
  border-radius: 5px;
}

*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--dice) 50%, transparent);
  border-radius: 5px;
  border: 2px solid color-mix(in srgb, var(--bg-primary) 50%, transparent);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--dice);
}

*::-webkit-scrollbar-thumb:active {
  background: color-mix(in srgb, var(--dice) 120%, #fff);
}

/* Container styling */
.container {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg-primary) 85%, transparent) 0%,
    color-mix(in srgb, var(--bg-secondary) 85%, transparent) 100%
  );
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
    0 0 1px color-mix(in srgb, var(--dice) 30%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--dice) 10%, transparent);
  max-width: 900px;
  width: 100%;
  height: calc(100vh - 24px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  position: relative;
  overflow: hidden;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 100; /* Above bookmarks (z-index: 50) */
}

/* Header styling */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 1100;
  overflow: visible;
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header h1 {
  font-size: 28px;
  margin-bottom: 5px;
  color: var(--heading);
  text-shadow: 0 2px 10px color-mix(in srgb, var(--dice) 30%, transparent);
  letter-spacing: 0.5px;
}

.header p {
  font-size: 14px;
  opacity: 0.7;
  font-style: italic;
  color: var(--text-secondary);
}

/* Header and Footer slide-out animations */
.header.slide-out {
  animation: slideOutUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

footer.slide-out {
  animation: slideOutDown 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100px);
    opacity: 0;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100px);
    opacity: 0;
  }
}

/* Settings container - no longer positioned in corner */
.settings-container {
  /* Buttons are now fixed position on right side as bookmark tabs */
  display: contents;
}

/* Slide settings button animation - deprecated but kept for compatibility */
.settings-container.slide-to-corner {
  /* No effect - buttons are always visible as bookmark tabs */
}

/* Icosahedron dice symbol on the right */
.dice-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.dice-icon:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.dice-icon svg {
  width: 40px;
  height: 40px;
}

.dice-icon svg line {
  stroke: var(--text-primary);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
  transition: all 0.3s ease;
}

.dice-icon svg text {
  fill: var(--text-primary);
  font-family: "Georgia", serif;
  font-size: 16px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: middle;
}

.dice-icon:hover svg line {
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
}

/* Floating Buttons (Dice Roller & Character Sheet) */
.floating-button {
  position: fixed;
  bottom: 20px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 10%, transparent) 100%
  );
  border: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 50px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-primary);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 1050;
  font-family: "Cinzel", serif;
}

.floating-button:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 15%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--dice) 40%, transparent);
}

/* Dice Button - Bottom Right */
.dice-button {
  right: 20px;
}

/* Character Button - Bottom Left */
.character-button {
  left: 20px;
}

.floating-icon {
  width: 36px;
  height: 36px;
  transition: transform 0.3s ease;
  font-size: 28px;
}

.dice-button:hover .floating-icon {
  transform: rotate(180deg);
}

.character-button:hover .floating-icon {
  transform: scale(1.1);
}

.floating-icon line {
  stroke: var(--dice);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--dice) 50%, transparent));
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
  position: fixed;
  bottom: 90px;
  right: 50%;
  transform: translateX(50%);
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.3s ease, background 0.3s ease,
    border-color 0.3s ease, box-shadow 0.3s ease;
  color: color-mix(in srgb, var(--dice) 80%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
}

.scroll-to-bottom-btn:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.scroll-to-bottom-btn:hover {
  background: color-mix(in srgb, var(--dice) 20%, transparent);
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  color: var(--dice);
  transform: translateX(50%) translateY(-2px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--dice) 40%, transparent);
}

.scroll-to-bottom-btn svg {
  width: 24px;
  height: 24px;
}

/* Scroll to Top Button */
.scroll-to-top-btn {
  position: fixed;
  top: 90px;
  right: 50%;
  transform: translateX(50%);
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.3s ease, background 0.3s ease,
    border-color 0.3s ease, box-shadow 0.3s ease;
  color: color-mix(in srgb, var(--dice) 80%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
}

.scroll-to-top-btn:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.scroll-to-top-btn:hover {
  background: color-mix(in srgb, var(--dice) 20%, transparent);
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  color: var(--dice);
  transform: translateX(50%) translateY(2px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--dice) 40%, transparent);
}

.scroll-to-top-btn svg {
  width: 24px;
  height: 24px;
}

.floating-label {
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

/* Welcome screen */
.welcome-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 50%,
    var(--bg-primary) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(
    15px,
    3vh,
    25px
  ); /* Fluid padding from 15px to 25px based on viewport height */
  z-index: 1300;
  max-height: 100%; /* Ensure content doesn't overflow container */
  overflow-y: auto; /* Allow scrolling if content is too tall */
  border-radius: 24px;
  overflow: visible; /* Allow 3D canvas to render */
}

/* 3D Book Canvas - behind welcome screen content */
#bookCanvas {
  pointer-events: none; /* Don't interfere with button clicks */
}

/* Welcome screen content - above book canvas */
.welcome-icon,
.welcome-title,
.welcome-version,
.welcome-buttons {
  position: relative;
  z-index: 2; /* Above book canvas (z-index: 1) */
}

.welcome-screen.hidden {
  display: none;
}

.welcome-icon {
  margin-bottom: clamp(20px, 4vh, 40px); /* Fluid margin from 20px to 40px */
  opacity: 0.9;
  display: flex;
  justify-content: center;
  align-items: center;
}

.welcome-icon svg {
  width: clamp(70px, 12vw, 100px); /* Fluid size from 70px to 100px */
  height: clamp(70px, 12vw, 100px);
  max-width: 100px;
  max-height: 100px;
  display: block;
  color: var(--gold);
  stroke: currentColor;
  filter: drop-shadow(0 0 18px rgba(250, 204, 21, 0.35));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.35))
      drop-shadow(0 0 18px rgba(250, 204, 21, 0.2));
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(250, 204, 21, 0.6))
      drop-shadow(0 0 28px rgba(250, 204, 21, 0.35));
  }
}

.welcome-icon svg line {
  animation: line-glow 3s ease-in-out infinite;
  stroke: currentColor;
}

@keyframes line-glow {
  0%,
  100% {
    stroke: color-mix(in srgb, var(--gold) 80%, #ffffff 20%);
    opacity: 0.9;
  }
  50% {
    stroke: color-mix(in srgb, var(--gold) 95%, #ffffff 5%);
    opacity: 1;
  }
}

.welcome-title {
  font-size: clamp(32px, 5vw, 42px); /* Fluid scaling from 32px to 42px */
  color: var(--heading);
  margin-bottom: clamp(6px, 1vh, 8px); /* Fluid margin */
  text-align: center;
  text-shadow: 0 2px 20px color-mix(in srgb, var(--dice) 30%, transparent);
  font-weight: bold;
}

.welcome-tagline {
  font-size: clamp(16px, 2.5vw, 18px); /* Fluid scaling from 16px to 18px */
  color: rgba(203, 213, 225, 0.75);
  text-align: center;
  letter-spacing: 0.4px;
  margin-bottom: clamp(8px, 1.5vh, 12px); /* Fluid margin */
  font-style: italic;
}

.welcome-creator {
  font-size: clamp(12px, 2vw, 14px); /* Fluid scaling from 12px to 14px */
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: clamp(12px, 2vh, 18px); /* Fluid margin */
  letter-spacing: 0.35px;
}

.welcome-version {
  font-size: clamp(12px, 2vw, 14px); /* Fluid scaling from 12px to 14px */
  color: rgba(203, 213, 225, 0.6);
  margin-bottom: clamp(20px, 3vh, 30px); /* Fluid margin */
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.welcome-message {
  font-size: 18px;
  color: rgba(203, 213, 225, 0.9);
  margin-bottom: 40px;
  text-align: center;
  max-width: 500px;
  line-height: 1.6;
  font-style: italic;
  text-shadow: 0 1px 10px color-mix(in srgb, var(--dice) 20%, transparent);
}

.welcome-subtitle {
  font-size: 18px;
  color: rgba(203, 213, 225, 0.8);
  margin-bottom: 40px;
  text-align: center;
  max-width: 500px;
  line-height: 1.6;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 15px); /* Fluid gap from 10px to 15px */
  width: 100%;
  max-width: clamp(
    350px,
    50vw,
    400px
  ); /* Fluid max-width from 350px to 400px */
}

.welcome-button {
  background: color-mix(in srgb, var(--dice) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  color: var(--heading);
  padding: clamp(16px, 2.5vh, 20px); /* Fluid padding from 16px to 20px */
  border-radius: 12px;
  font-size: clamp(14px, 2.2vw, 16px); /* Fluid font size from 14px to 16px */
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Georgia", serif;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 8px); /* Fluid gap from 6px to 8px */
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  touch-action: manipulation; /* Optimize touch events */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

.welcome-button:hover {
  background: color-mix(in srgb, var(--dice) 15%, transparent);
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--dice) 20%, transparent);
}

.welcome-button-primary {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 85%, transparent) 0%,
    color-mix(in srgb, var(--dice) 85%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 90%, transparent);
  border-width: 2px;
  box-shadow: 0 4px 15px color-mix(in srgb, var(--dice) 40%, transparent);
  position: relative;
  overflow: hidden;
}

.welcome-button-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.welcome-button-primary:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 95%, transparent) 0%,
    color-mix(in srgb, var(--dice) 95%, transparent) 100%
  );
  border-color: var(--dice);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px color-mix(in srgb, var(--dice) 60%, transparent);
}

.welcome-button-primary:hover::before {
  left: 100%;
}

.welcome-button-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
}

/* Google auth panel styling */
.welcome-auth-panel {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.welcome-auth-status {
  font-size: 14px;
  color: rgba(203, 213, 225, 0.7);
  letter-spacing: 0.25px;
}

.welcome-auth-error {
  font-size: 13px;
  color: color-mix(in srgb, var(--danger, #f87171) 140%, #7f1d1d);
  background: color-mix(in srgb, var(--danger, #f87171) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #f87171) 30%, transparent);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: inset 0 0 10px
    color-mix(in srgb, var(--danger, #f87171) 35%, transparent);
}

.welcome-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--dice) 25%, transparent);
  background: color-mix(in srgb, var(--bg-secondary) 20%, transparent);
  color: rgba(203, 213, 225, 0.8);
  font-size: 15px;
  font-family: "Georgia", serif;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: none;
  gap: 10px;
}

.welcome-auth-button:hover {
  background: color-mix(in srgb, var(--bg-secondary) 35%, transparent);
  border-color: color-mix(in srgb, var(--dice) 35%, transparent);
  color: rgba(255, 255, 255, 0.85);
}

.welcome-auth-button:active {
  transform: translateY(0);
  background: color-mix(in srgb, var(--bg-secondary) 45%, transparent);
}

.welcome-auth-icon {
  display: block;
}

/* Secondary button - more subtle, lower priority */
.welcome-button-secondary {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 20%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  border-width: 1px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--dice) 15%, transparent);
  opacity: 0.85;
}

.welcome-button-secondary:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 30%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 60%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--dice) 25%, transparent);
  opacity: 1;
}

.welcome-button-secondary:active {
  transform: translateY(0px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--dice) 15%, transparent);
}

.welcome-button-subtitle {
  font-size: 14px;
  opacity: 0.7;
  font-style: italic;
}

/* Quick Play Button Styling - Subtle secondary option */
.quick-play-btn {
  background: color-mix(in srgb, var(--dice) 8%, transparent);
  color: var(--text-secondary);
  border: 1px solid rgba(212, 165, 116, 0.3);
  padding: 12px 24px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  font-family: "Georgia", serif;
  font-weight: normal;
  margin-top: 8px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.quick-play-btn:hover {
  background: color-mix(in srgb, var(--dice) 12%, transparent);
  border-color: rgba(212, 165, 116, 0.5);
  transform: translateY(-1px);
}

.quick-play-btn:active {
  transform: translateY(0);
}

.quick-play-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(212, 165, 116, 0.2);
}

.quick-play-btn:disabled:hover {
  transform: none;
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(212, 165, 116, 0.2);
}

.quick-play-icon {
  font-size: 16px;
  opacity: 0.8;
}

.quick-play-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.quick-play-text {
  font-size: 14px;
  font-weight: 500;
}

.quick-play-subtitle {
  font-size: 12px;
  opacity: 0.7;
  font-weight: normal;
  font-style: italic;
}

.welcome-continue-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcome-character-name {
  font-weight: bold;
  color: var(--question);
  font-size: 15px;
  text-shadow: 0 0 10px rgba(147, 197, 253, 0.3);
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(
    180deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 100%
  );
  min-height: 0;
  position: relative;
}

/* Custom Scrollbar Styling - Theme-Aware with Auto-Hide */
.chat-messages::-webkit-scrollbar {
  width: 12px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
  margin: 4px 0;
  transition: background 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.chat-messages.scrolling::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

.chat-messages.scrolling::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--dice) 40%, transparent) 0%,
    color-mix(in srgb, var(--dice) 50%, transparent) 100%
  );
  border: 2px solid color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--dice) 60%, transparent) 0%,
    color-mix(in srgb, var(--dice) 70%, transparent) 100%
  ) !important;
  border-color: color-mix(in srgb, var(--dice) 30%, transparent) !important;
  box-shadow: 0 0 10px color-mix(in srgb, var(--dice) 30%, transparent);
}

.chat-messages::-webkit-scrollbar-thumb:active {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--dice) 70%, transparent) 0%,
    color-mix(in srgb, var(--dice) 80%, transparent) 100%
  ) !important;
}

/* Firefox scrollbar styling */
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--dice) 40%, transparent)
    color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

/* Message styling */
.message {
  margin-bottom: 15px;
  display: flex;
}

.message.assistant {
  width: 100%;
}

.message.assistant > div {
  width: 100%;
}

.message.missing-choices .message-content {
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.25);
}

.message.missing-choices .message-label {
  color: rgba(255, 215, 0, 0.85);
}

.message.user {
  justify-content: flex-end;
}

.message-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  opacity: 0.8;
  color: var(--text-secondary);
}

.message-content {
  max-width: 100%;
  width: 100%;
  min-width: fit-content;
  padding: 16px 20px;
  border-radius: 10px;
  word-wrap: break-word; /* Allows long words to break */
  overflow-wrap: break-word; /* Modern standard for word breaking */
  word-break: normal; /* Don't break words unnecessarily */
  hyphens: none; /* Disable hyphenation - never split words with hyphens */
  line-height: 1.4;
  font-size: var(--text-paragraph);
  white-space: pre-line; /* Preserve line breaks from \n characters */
  display: block;
  color: var(--text-primary); /* Explicitly use theme text color */
}

/* Horizontal rule dividers (---) */
.message-content hr {
  width: 100%;
  border: none;
  border-top: 2px solid rgba(148, 163, 184, 0.4);
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Accessibility: Proper paragraph spacing for readability */
.message-content p {
  margin: 0;
  line-height: 1.4; /* Reduced from 1.6 for tighter spacing */
}

/* Text element type styling - using CSS variables */
.message-content .indented-list-item {
  display: block;
  padding-left: 20px;
  font-size: var(--text-body); /* Use standard body text size */
  font-style: normal; /* Override any italic styling for consistency */
  margin-top: 2px; /* Tight spacing between list items */
  margin-bottom: 2px;
  position: relative;
}

/* Add visual bullet point for list items */
.message-content .indented-list-item::before {
  content: "•";
  position: absolute;
  left: 6px;
  color: var(--dice);
  opacity: 0.7;
}

/* Remove italic from em/i tags within list items for uniform appearance */
.message-content .indented-list-item em,
.message-content .indented-list-item i {
  font-style: normal;
}

/* No top margin on first list item after a heading */
.message-content .heading + .indented-list-item {
  margin-top: 0;
}

.message-content .item-gained {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 2px 10px;
  margin: 2px 0;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.2;
  background: color-mix(in srgb, var(--dice) 18%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--dice) 45%, transparent);
  color: var(--text-primary);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message-content .item-gained::before {
  content: "➕";
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--dice) 80%, #fff);
}

.message-content .item-gained:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.message-content .roll-final-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  margin: 16px 0;
  border-left: 4px solid color-mix(in srgb, var(--dice) 40%, transparent);
  background: color-mix(in srgb, var(--dice) 12%, transparent);
  font-size: var(--text-paragraph);
  font-weight: 600;
  color: var(--text-primary);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  transition: background 0.25s ease, border-color 0.25s ease,
    transform 0.2s ease;
}

.message-content .roll-final-line.roll-success {
  border-left-color: color-mix(
    in srgb,
    var(--success, #34d399) 80%,
    transparent
  );
  background: color-mix(in srgb, var(--success, #34d399) 16%, transparent);
}

.message-content .roll-final-line.roll-failure {
  border-left-color: color-mix(
    in srgb,
    var(--danger, #f87171) 80%,
    transparent
  );
  background: color-mix(in srgb, var(--danger, #f87171) 16%, transparent);
}

.message-content .roll-final-line.roll-unknown {
  border-left-color: color-mix(
    in srgb,
    var(--question, #60a5fa) 80%,
    transparent
  );
  background: color-mix(in srgb, var(--question, #60a5fa) 12%, transparent);
}

.message-content .roll-final-line .roll-content {
  width: 100%;
  font-weight: 500;
  line-height: 1.45;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.message-content .roll-final-line .roll-summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.message-content .roll-final-line .roll-label {
  color: #cd853f;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.message-content .roll-final-line .roll-final-value {
  font-weight: 700;
  color: var(--dice);
  font-size: 1.6rem;
  line-height: 1;
}

.message-content .roll-final-line.roll-success .roll-final-value {
  color: color-mix(in srgb, var(--success, #34d399) 160%, #052e16);
}

.message-content .roll-final-line.roll-failure .roll-final-value {
  color: color-mix(in srgb, var(--danger, #f87171) 160%, #7f1d1d);
}

.message-content .roll-outcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.message-content .roll-outcome-badge.badge-success {
  background: color-mix(in srgb, var(--success, #34d399) 65%, transparent);
  color: color-mix(in srgb, var(--success, #34d399) 20%, #052e16);
}

.message-content .roll-outcome-badge.badge-failure {
  background: color-mix(in srgb, var(--danger, #f87171) 65%, transparent);
  color: color-mix(in srgb, var(--danger, #f87171) 25%, #7f1d1d);
}

.message-content .roll-outcome-badge.badge-neutral {
  background: color-mix(in srgb, var(--question, #60a5fa) 55%, transparent);
  color: color-mix(in srgb, var(--question, #60a5fa) 18%, #0f172a);
}

.message-content .roll-outcome-badge.badge-critical {
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.message-content .roll-outcome-badge .roll-d20-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.message-content .roll-final-line .roll-dc {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--question, #60a5fa) 20%, transparent);
  color: color-mix(in srgb, var(--question, #60a5fa) 18%, #0f172a);
  letter-spacing: 0.04em;
}

.message-content .roll-final-line .roll-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary, rgba(226, 232, 240, 0.8));
}

.message-content .roll-final-line .roll-breakdown-part {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.message-content .roll-final-line .roll-breakdown-label {
  font-weight: 500;
  opacity: 0.9;
}

.message-content .roll-final-line .roll-breakdown-value {
  font-weight: 600;
}

.message-content .roll-final-line .roll-breakdown-dot {
  opacity: 0.45;
  font-weight: 600;
}

.message-content .roll-outcome-detail {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary, rgba(226, 232, 240, 0.85));
  opacity: 0.95;
}

/* Only make specific text types block-level, not all spans */
.message-content .heading,
.message-content h1,
.message-content h2,
.message-content h3,
.message-content .question,
.message-content .system-message {
  display: block;
  margin-bottom: 6px; /* Tighten spacing after block elements */
}

.message.assistant .message-content .dialogue {
  font-size: var(--text-dialogue);
  font-style: italic;
  color: var(--dialogue) !important;
}

.message.assistant .message-content .system-message {
  font-size: var(--text-system);
  color: var(--system) !important; /* cyan for visibility */
}

.message-content .stat-block {
  font-size: var(--text-stat-block);
  /* Removed monospace - use default serif font for consistency */
}

/* Enhanced heading styles - prominent section headers */
.message-content .heading,
.message-content h1,
.message-content h2,
.message-content h3 {
  font-size: 1.2rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--heading);
  margin-top: 12px;
  margin-bottom: 0; /* No space after headings - content follows immediately */
  padding-bottom: 3px;
  border-bottom: 1px solid color-mix(in srgb, var(--dice) 25%, transparent);
  letter-spacing: 0.4px;
  text-transform: none;
}

/* First heading in message - less top margin */
.message-content .heading:first-child,
.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
  margin-top: 0;
}

/* Enhanced question styles - eye-catching action prompts */
.message-content .question {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--question) !important;
  font-style: italic;
  margin-top: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: none;
  border-left: none;
  border-radius: 6px;
}

/* Keep dice notation formatting active */
.message-content .dice-notation {
  /* Use default .dice-notation styling */
}

/* ========================================
   MARKDOWN FORMATTING STYLES
   ======================================== */

/* Headings */
.message-content h1,
.message-content h2,
.message-content h3 {
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--heading);
}

/* Inline formatting */
.message-content strong {
  font-weight: bold;
  color: var(--text-primary);
}

/* Section headers (e.g., **Location:**, **Reward:**) */
.message-content strong.section-header {
  font-weight: bold;
  color: var(--npc-name); /* Use the NPC name color for section headers */
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
}

/* Markdown headings (## Heading) */
.message-content h2.message-heading {
  font-size: 1.4em;
  font-weight: bold;
  margin: 16px 0 8px 0;
  color: var(--location); /* Use location color for headings */
  border-bottom: 2px solid rgba(148, 163, 184, 0.3);
  padding-bottom: 4px;
}

.message-content em {
  font-style: italic;
  color: var(--text-primary);
}

.message-content code {
  font-family: "Courier New", monospace;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Code blocks */
.message-content pre {
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}

.message-content pre code {
  background-color: transparent;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.4;
  display: block;
}

/* Blockquote */
.message-content blockquote {
  border-left: 3px solid var(--gold);
  padding-left: 12px;
  margin: 8px 0;
  font-style: italic;
  color: rgba(255, 255, 255, 0.85);
}

/* Horizontal rule */
.message-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 12px 0;
}

/* Links */
.message-content a {
  color: var(--sapphire);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.message-content a:hover {
  color: var(--gold);
}

/* Images */
.message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 8px 0;
}

/* Choice Buttons */
.choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.choice-btn {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 12%, transparent) 100%
  );
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 12px;
  color: var(--text-primary);
  padding: 16px 20px;
  font-size: var(--text-choice-button);
  font-family: "Georgia", serif;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.choice-btn:hover:not(:disabled) {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 22%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  transform: translateX(6px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 40%, transparent);
}

.choice-btn:active:not(:disabled) {
  transform: translateX(4px);
}

.choice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Keep existing auto-formatted elements (DISABLED - minimal formatting) */
.message-content .condition {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
}

.message-content .skill-check {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}

.message-content .ability-check {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}

.message-content .saving-throw {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}

.message-content .damage-type {
  font-size: inherit;
  color: inherit;
  font-weight: inherit;
}

.message-content .difficulty-class {
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

.message-content p + p {
  margin-top: 0.75em; /* Reduced from 1.6 for tighter spacing */
}

/* User message bubble */
.message.user .message-content {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 20%, transparent) 0%,
    color-mix(in srgb, var(--dice) 25%, transparent) 100%
  );
  /* Color inherited from body - no need to set here */
  box-shadow: 0 4px 12px color-mix(in srgb, var(--dice) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Assistant message bubble */
.message.assistant .message-content {
  background: linear-gradient(
    135deg,
    color-mix(
        in srgb,
        var(--dice) 8%,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent)
      )
      0%,
    color-mix(
        in srgb,
        var(--dice) 5%,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent)
      )
      100%
  );
  /* Removed color override - let semantic formatters control text colors */
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--dice) 10%, rgba(0, 0, 0, 0.2));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Choice styling within messages */
.message.assistant .message-content ul.choices,
.message.assistant .message-content ol.choices {
  list-style: none;
  padding-left: 0;
  margin-top: 16px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message.assistant .message-content ul.choices li,
.message.assistant .message-content ol.choices li {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 12%, transparent) 100%
  );
  color: var(--text-primary);
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1.5px solid color-mix(in srgb, var(--dice) 30%, transparent);
  font-weight: 500;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  /* Ensure text wraps properly and doesn't get truncated */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-overflow: clip;
  overflow: visible;
}

.message.assistant .message-content ul.choices li:hover,
.message.assistant .message-content ol.choices li:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 22%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 60%, transparent);
  transform: translateX(6px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 40%, transparent);
  color: var(--text-primary);
}

.message.assistant .message-content ul.choices li:active,
.message.assistant .message-content ol.choices li:active {
  transform: translateX(4px);
}

/* Disabled state for old choices */
.message.assistant .message-content ul.choices li.disabled,
.message.assistant .message-content ol.choices li.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Choice button styling (for dynamically generated buttons in message text) */
.choice-button {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.5) 0%,
    rgba(202, 138, 4, 0.45) 100%
  );
  color: var(--choice-text);
  border: 1.5px solid rgba(234, 179, 8, 0.7);
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  font-size: 16px;
  width: 100%;
  text-align: center;
  transition: all 0.3s ease;
  font-family: "Georgia", serif;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Remove all DnD formatting inside choice buttons */
.choice-button .attack-roll,
.choice-button .dice-notation,
.choice-button .damage,
.choice-button .skill-check,
.choice-button .saving-throw,
.choice-button .ability-name,
.choice-button .condition {
  color: inherit !important;
  font-weight: inherit !important;
  background: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* Remove any ::before content from DnD classes in choice buttons */
.choice-button *::before {
  content: none !important;
}

.choice-button:hover {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.65) 0%,
    rgba(202, 138, 4, 0.6) 100%
  );
  border-color: rgba(234, 179, 8, 0.9);
  transform: translateX(6px);
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.5);
  color: var(--choice-text);
}

.choice-button:active {
  transform: translateX(4px);
}

.choice-button:disabled,
.choice-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Custom "Choose your own" button styling */
.choice-button.choice-custom {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.15) 0%,
    rgba(202, 138, 4, 0.12) 100%
  );
  border-color: rgba(234, 179, 8, 0.4);
  color: var(--choice-text);
  margin-top: 10px;
}

body.hide-choice-buttons
  .message
  .message-choices
  .choice-button:not(.system-choice-button),
body.hide-choice-buttons
  .message
  .message-choices
  .choices
  li:not(.system-choice-button) {
  display: none !important;
}

body.hide-choice-buttons
  .message
  .message-choices:not(:has(.system-choice-button)) {
  display: none !important;
}

/* Error message styling (for request cancellation, etc.) */
.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--critical-failure);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  margin: 10px 0;
  font-size: 14px;
  font-style: italic;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

/* Chronicle of Adventures prompt styling */
.message.chronicle-prompt {
  margin: 20px 0;
  padding: 0;
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.15) 0%,
    rgba(202, 138, 4, 0.08) 100%
  );
  border: 2px solid rgba(234, 179, 8, 0.4);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(234, 179, 8, 0.3);
  animation: chronicleSlideIn 0.5s ease-out;
}

@keyframes chronicleSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chronicle-prompt-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
}

.chronicle-icon {
  font-size: 48px;
  flex-shrink: 0;
  animation: chroniclePulse 2s ease-in-out infinite;
}

@keyframes chroniclePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.chronicle-text {
  flex: 1;
  color: var(--choice-text);
}

.chronicle-text strong {
  display: block;
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--choice-text);
  font-family: "Georgia", serif;
}

.chronicle-text p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--choice-text);
}

.chronicle-download-btn {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.3) 0%,
    rgba(202, 138, 4, 0.25) 100%
  );
  color: var(--choice-text);
  border: 2px solid rgba(234, 179, 8, 0.6);
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  font-family: "Georgia", serif;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chronicle-download-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.5) 0%,
    rgba(202, 138, 4, 0.4) 100%
  );
  border-color: rgba(234, 179, 8, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.5);
}

.chronicle-download-btn:active {
  transform: translateY(0);
}

.choice-button.choice-custom:hover {
  background: linear-gradient(
    135deg,
    rgba(234, 179, 8, 0.25) 0%,
    rgba(202, 138, 4, 0.22) 100%
  );
  border-color: rgba(234, 179, 8, 0.7);
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.4);
  color: var(--choice-text);
}

/* Input area styling */
.input-area {
  padding: 20px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 8%, transparent) 0%,
    color-mix(in srgb, var(--dice) 5%, transparent) 100%
  );
  border-top: 1px solid color-mix(in srgb, var(--dice) 15%, transparent);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  border-radius: 0 0 24px 24px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Scroll buttons - Combination of thin border + glass morphism */
.scroll-button {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.05);
  color: color-mix(in srgb, var(--dice) 90%, transparent);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.scroll-button svg {
  width: 16px;
  height: 16px;
  color: color-mix(in srgb, var(--dice) 90%, transparent);
  transition: color 0.3s ease;
}

.scroll-button.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scroll-button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 20px color-mix(in srgb, var(--dice) 20%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.scroll-button:hover svg {
  color: var(--dice);
}

.scroll-to-top {
  top: 20px;
}

.scroll-to-bottom {
  bottom: 90px;
}

.auth-gate-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 20px 10px 20px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 12%, transparent) 0%,
    color-mix(in srgb, var(--dice) 6%, transparent) 100%
  );
  color: var(--text-primary);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: opacity 0.3s ease;
}

.auth-gate-banner.hidden {
  display: none;
}

.auth-gate-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.auth-gate-button {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 35%, transparent) 0%,
    color-mix(in srgb, var(--dice) 45%, transparent) 100%
  );
  color: var(--heading);
  font-family: "Cinzel", serif;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-gate-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

.input-container {
  padding: 20px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 8%, transparent) 0%,
    color-mix(in srgb, var(--dice) 5%, transparent) 100%
  );
  border-top: 1px solid color-mix(in srgb, var(--dice) 15%, transparent);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  border-radius: 0 0 24px 24px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 15px;
  color: color-mix(in srgb, var(--text-primary) 40%, transparent);
  pointer-events: none;
  z-index: 1;
  transition: color 0.3s ease;
}

#messageInput {
  flex: 1;
  width: 100%;
  padding: 12px 15px 12px 45px; /* Extra left padding for icon */
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-primary) 50%, transparent);
  color: var(--heading);
  font-family: "Georgia", serif;
  font-size: 16px;
  transition: all 0.3s ease;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#messageInput::placeholder {
  color: color-mix(in srgb, var(--text-primary) 50%, transparent);
}

#messageInput:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  background: color-mix(in srgb, var(--bg-primary) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dice) 10%, transparent);
}

#messageInput:focus ~ .input-icon,
.input-wrapper:focus-within .input-icon {
  color: color-mix(in srgb, var(--dice) 80%, transparent);
}

/* Animated focus effect for input (triggered by "Choose your own" button) */
#messageInput.input-animate-focus {
  animation: inputPulse 1s ease-in-out;
}

@keyframes inputPulse {
  0% {
    border-color: color-mix(in srgb, var(--dice) 20%, transparent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--dice) 40%, transparent);
  }
  25% {
    border-color: rgba(234, 179, 8, 0.8);
    box-shadow: 0 0 0 8px rgba(234, 179, 8, 0.2);
  }
  50% {
    border-color: rgba(234, 179, 8, 1);
    box-shadow: 0 0 0 12px rgba(234, 179, 8, 0);
  }
  75% {
    border-color: rgba(234, 179, 8, 0.8);
    box-shadow: 0 0 0 8px rgba(234, 179, 8, 0.2);
  }
  100% {
    border-color: color-mix(in srgb, var(--dice) 50%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dice) 10%, transparent);
  }
}

#sendButton {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 30%, transparent) 100%
  );
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-family: "Georgia", serif;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.3s ease;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#sendButton:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 35%, transparent) 0%,
    color-mix(in srgb, var(--dice) 40%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--dice) 30%, transparent);
}

#sendButton:active {
  transform: translateY(0);
}

#sendButton:disabled {
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border-color: color-mix(in srgb, var(--dice) 15%, transparent);
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

/* Retry mode styling */
#sendButton.retry-mode {
  background: linear-gradient(
    135deg,
    rgba(251, 146, 60, 0.25) 0%,
    rgba(249, 115, 22, 0.3) 100%
  );
  border-color: rgba(251, 146, 60, 0.4);
  color: #fff;
  opacity: 1;
  cursor: pointer;
  animation: pulse-retry 2s ease-in-out infinite;
}

#sendButton.retry-mode:hover {
  background: linear-gradient(
    135deg,
    rgba(251, 146, 60, 0.35) 0%,
    rgba(249, 115, 22, 0.4) 100%
  );
  border-color: rgba(251, 146, 60, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(251, 146, 60, 0.3);
}

@keyframes pulse-retry {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Clear button - top-right of viewport (INDEPENDENT - outside container) */
.clear-button {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--heading);
  border: 1px solid rgba(96, 165, 250, 0.25);
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: "Georgia", serif;
  font-size: 13px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 1300;
  pointer-events: auto;
  transform: translateX(100px);
  opacity: 0;
}

/* Slide clear button in from right */
.clear-button.slide-to-corner {
  position: fixed;
  right: 10px;
  top: 10px;
  transform: translateX(0);
  opacity: 1;
  z-index: 1300;
}

.clear-button:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Stage indicator */
.stage-indicator {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-style: normal;
  font-weight: 600;
  margin-left: 8px;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

/* Loading animation */
.loading {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 4px;
  background: var(--dice);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading:nth-child(1) {
  animation-delay: -0.32s;
}

.loading:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Loading overlay - centered in empty space */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  margin: 20px 0;
}

/* Enhanced loading container with status updates */
.loading-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 30px 40px;
  text-align: center;
  background: rgba(15, 20, 25, 0.4);
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 60px;
  height: 60px;
}

.loading-d20 {
  width: 50px;
  height: 50px;
  color: var(--question);
  animation: spin 2s linear infinite;
}

/* Three-dot loading animation */
.loading-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

/* Progress bar styling */
.loading-progress-bar {
  width: 100%;
  max-width: 300px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0 8px 0;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--question) 0%,
    color-mix(in srgb, var(--question) 80%, white) 50%,
    var(--question) 100%
  );
  border-radius: 3px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 10px color-mix(in srgb, var(--question) 50%, transparent);
  position: relative;
  overflow: hidden;
}

/* Animated shimmer effect on progress bar */
.loading-progress-fill::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.loading-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 300px;
  font-size: 12px;
  color: color-mix(in srgb, var(--text-primary) 70%, transparent);
  margin-bottom: 4px;
}

.loading-status-text {
  font-weight: 400;
}

.loading-status-percent {
  font-weight: 600;
  color: var(--question);
  font-variant-numeric: tabular-nums;
  min-width: 35px;
  text-align: right;
}

.loading-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background-color: color-mix(in srgb, var(--dice) 70%, transparent);
  border-radius: 50%;
  animation: loading-dot-pulse 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0s;
}

@keyframes loading-dot-pulse {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  color: color-mix(in srgb, var(--dice) 70%, transparent);
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
  font-weight: 400;
}

.loading-timer {
  color: var(--text-secondary);
  font-size: 12px;
  font-family: "Courier New", monospace;
  margin-top: 4px;
  text-align: center;
}

.loading-tip {
  color: var(--text-secondary);
  font-size: 11px;
  font-style: italic;
  margin-top: 8px;
  max-width: 300px;
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.cancel-request-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--damage);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 8px;
  transition: all 0.2s ease;
}

.cancel-request-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

/* Network error styling */
.network-error {
  background: rgba(239, 68, 68, 0.1) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  margin: 10px 0;
}

.network-error .error-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.network-error .error-title {
  color: var(--damage);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.network-error .error-detail {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.network-error .error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-action-btn {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--dice);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.error-action-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
}

/* Incomplete message warning - Subtle and subdued */
.incomplete-warning {
  background: rgba(100, 100, 100, 0.08) !important;
  border: 1px solid rgba(150, 150, 150, 0.2) !important;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 8px 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.incomplete-warning .warning-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
}

.incomplete-warning .warning-icon {
  font-size: 18px;
  color: rgba(255, 215, 0, 0.9);
}

.incomplete-warning .warning-detail {
  color: rgba(180, 180, 180, 0.9);
  font-size: 12px;
  font-style: italic;
  flex: 1;
}

.incomplete-warning .warning-action-btn {
  background: rgba(120, 120, 120, 0.1);
  border: 1px solid rgba(150, 150, 150, 0.3);
  color: rgba(200, 200, 200, 0.9);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.incomplete-warning .warning-action-btn:hover {
  background: rgba(120, 120, 120, 0.2);
  border-color: rgba(150, 150, 150, 0.5);
  color: rgba(220, 220, 220, 1);
}

.choice-missing-warning {
  margin-top: 10px;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    border-radius: 0;
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile keyboards */
    max-height: 100vh;
    max-height: 100dvh;
    border: none;
  }

  /* Ensure chat messages area is scrollable and doesn't get covered by keyboard */
  #chatMessages {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Allow flexbox to shrink below content size */
  }

  .header h1 {
    font-size: 22px;
  }

  .header p {
    font-size: 12px;
  }

  .welcome-title {
    font-size: 28px;
  }

  .welcome-subtitle {
    font-size: 16px;
  }

  .welcome-button {
    font-size: 14px;
  }

  .message-content {
    max-width: 90%;
    font-size: 14px;
  }

  #messageInput {
    font-size: 14px;
  }

  #sendButton {
    font-size: 14px;
    padding: 10px 20px;
  }
}

/* Responsive design for tablets */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 750px;
    height: 700px;
  }

  .header h1 {
    font-size: 24px;
  }

  .welcome-title {
    font-size: 32px;
  }
}

/* Text formatting - DISABLED (plain text only) */
.message-content strong {
  color: #e5e7eb;
  font-weight: 400;
}

.message-content em {
  color: #e5e7eb;
  font-style: normal;
}

.message-content .action {
  color: #e5e7eb;
  font-weight: 400;
}

.message-content .dialogue {
  color: #fbbf24; /* Amber-400 for dialogue */
  font-style: italic;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.message-content .question {
  color: #e5e7eb;
  font-weight: 400;
}

.message-content .quest-title {
  color: #e5e7eb;
  font-weight: 400;
}

.message-content .scene-label {
  color: #e5e7eb;
  font-weight: 400;
}

/* User messages - plain text only */
.message.user .message-content strong {
  color: #e5e7eb;
  font-weight: 400;
  text-shadow: none;
}

.message.user .message-content em {
  color: #e5e7eb;
  font-style: normal;
}

/* ====================================
           D&D 5e TEXT FORMATTING STYLES
           ====================================
           Applied to AI responses for game mechanics
           Based on DESIGN_SYSTEM.md color palette
        */

/* Critical Rolls - Option 1 (bold + color with glow) */
.critical-success {
  color: #32cd32;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(50, 205, 50, 0.4);
  animation: none;
  letter-spacing: inherit;
}

@keyframes pulse-success {
  0%,
  100% {
    opacity: 1;
    text-shadow: 0 0 12px currentColor;
  }
  50% {
    opacity: 0.8;
    text-shadow: 0 0 20px currentColor;
  }
}

.critical-failure {
  color: #dc143c;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(220, 20, 60, 0.4);
  letter-spacing: inherit;
}

/* Damage Rolls - Red color for damage */
.damage-roll {
  display: inline;
  color: #dc143c;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(220, 20, 60, 0.3);
}

.dice-notation {
  color: #daa520;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-shadow: 0 0 8px rgba(218, 165, 32, 0.3);
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(218, 165, 32, 0.1);
}

.damage-type {
  font-weight: 600;
  text-transform: lowercase;
  font-size: inherit;
  letter-spacing: 0.3px;
}

/* Damage type color classes - Different colors for each type */
.damage-type.fire {
  color: #ff4500;
}
.damage-type.cold {
  color: #4169e1;
}
.damage-type.lightning {
  color: #ffd700;
}
.damage-type.thunder {
  color: #9370db;
}
.damage-type.acid {
  color: #adff2f;
}
.damage-type.poison {
  color: #9acd32;
}
.damage-type.psychic {
  color: #ff69b4;
}
.damage-type.necrotic {
  color: #8b008b;
}
.damage-type.radiant {
  color: #ffd700;
}
.damage-type.force {
  color: #9370db;
}
.damage-type.slashing {
  color: #c0c0c0;
}
.damage-type.piercing {
  color: #dcdcdc;
}
.damage-type.bludgeoning {
  color: #a9a9a9;
}

/* Saving Throws - Blue shield theme */
.saving-throw {
  color: #4169e1;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
  letter-spacing: inherit;
}

/* Attack Rolls - Action theme */
.attack-roll {
  color: #ff6347;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
  letter-spacing: inherit;
}

/* Ability Names - Primary D&D ability scores (Strength, Dexterity, etc.) - NOT bold */
.ability-name {
  color: #cd853f; /* Peru/bronze - ability color from config */
  font-weight: normal;
  letter-spacing: 0.3px;
}

/* Individual ability name colors (matching character sheet) */
.ability-name[data-ability="strength"] {
  color: #cd853f;
}

.ability-name[data-ability="dexterity"] {
  color: #cd853f;
}

.ability-name[data-ability="constitution"] {
  color: #cd853f;
}

.ability-name[data-ability="intelligence"] {
  color: #cd853f;
}

.ability-name[data-ability="wisdom"] {
  color: #cd853f;
}

.ability-name[data-ability="charisma"] {
  color: #cd853f;
}

/* Ability Checks - When ability + "check" is used (NOT bold, just colored) */
.ability-check {
  color: #cd853f; /* Peru/bronze - ability color from config */
  font-weight: normal;
  letter-spacing: 0.3px;
}

/* Individual ability check colors (matching character sheet) */
.ability-check[data-ability="strength"] {
  color: #cd853f;
}

.ability-check[data-ability="dexterity"] {
  color: #cd853f;
}

.ability-check[data-ability="constitution"] {
  color: #cd853f;
}

.ability-check[data-ability="intelligence"] {
  color: #cd853f;
}

.ability-check[data-ability="wisdom"] {
  color: #cd853f;
}

.ability-check[data-ability="charisma"] {
  color: #cd853f;
}

/* Conditions - Status effects (non-bold) */
.condition {
  color: #9acd32;
  font-weight: normal;
  text-transform: none;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  letter-spacing: inherit;
  font-size: inherit;
}

/* Spell Casting - Magical actions (DISABLED - minimal formatting) */
.spell-cast {
  color: inherit;
  font-weight: inherit;
}

.spell-name {
  font-style: inherit;
  font-weight: inherit;
  color: inherit;
  text-shadow: none;
}

/* Magical/Atmospheric Terms (DISABLED - minimal formatting) */
em.magical {
  color: inherit;
  font-style: italic;
  text-shadow: none;
}

/* Section Headers - Bold text ending with colon (combat/narrative sections) */
.section-header {
  color: var(--accent-gold, #ffa500);
  font-weight: bold;
  font-size: 1.1em;
  display: block;
  margin: 15px 0 10px 0;
}

/* Difficulty Class - Same blue as saving throws */
.difficulty-class {
  display: inline;
  background: none;
  color: #4169e1;
  padding: 0;
  border-radius: 0;
  border: none;
  font-weight: 700;
  font-size: inherit;
  letter-spacing: 0.5px;
  box-shadow: none;
}

/* Hit Points - Red damage, green healing */
.hp-change {
  font-weight: 700;
  padding: 0;
  border-radius: 0;
}

.hp-change.damage,
.hp-damage {
  color: #dc143c;
  background: none;
  border: none;
}

.hp-change.healing,
.hp-heal {
  color: #32cd32;
  background: none;
  border: none;
}

/* Armor Class - Same as DC color */
.armor-class {
  display: inline;
  color: #4169e1;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  border: none;
  font-weight: inherit;
  box-shadow: none;
}

/* Initiative - Non-bold, action orange */
.initiative {
  color: #ff8c00;
  font-weight: normal;
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Experience Points - Reward gold */
.experience-points {
  color: #daa520;
  font-weight: 700;
  text-shadow: none;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

/* Treasure - Treasure gold */
.treasure {
  color: #ffd700;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
}

/* ========================================
   DEATH SAVING THROWS - Life green, death dark red
   ======================================== */

.death-save-prompt {
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  text-shadow: none;
}

.death-save {
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
}

.death-save-success {
  color: #32cd32;
  font-weight: 700;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

.death-save-success::before {
  content: "";
  color: inherit;
}

.death-save-failure {
  color: #8b0000;
  font-weight: 700;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

.death-save-failure::before {
  content: "";
  color: inherit;
}

.death-save-crit-success {
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  text-shadow: none;
  animation: none;
}

.death-save-crit-success::before {
  content: "";
  font-size: inherit;
}

.death-save-crit-failure {
  color: inherit;
  font-weight: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  text-shadow: none;
  animation: none;
}

.death-save-crit-failure::before {
  content: "";
  font-size: inherit;
}

@keyframes pulse-failure {
  0%,
  100% {
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
  }
  50% {
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
  }
}

.stabilized {
  color: inherit;
  font-weight: inherit;
  text-shadow: none;
}

.dead {
  color: inherit;
  font-weight: inherit;
  text-shadow: none;
  background: none;
  padding: 0;
  border-radius: 0;
}

/* ========================================
   PROFICIENCY BONUS - Subtle bronze
   ======================================== */

.proficiency-bonus {
  color: #cd853f;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

.proficiency-bonus::before {
  content: "";
  font-weight: inherit;
}

.proficiency-hint {
  color: inherit;
  font-size: inherit;
  font-style: inherit;
  font-weight: inherit;
}

/* Ensure D&D formatting works well in both user and assistant messages */
.message.user .message-content .critical-success,
.message.user .message-content .critical-failure,
.message.user .message-content .experience-points {
  text-shadow: none;
}

/* End D&D 5e Formatting Styles */

/* Development Log Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal-content {
  background: var(--bg-secondary);
  border: 2px solid color-mix(in srgb, var(--dice) 50%, transparent);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 900px;
  width: 95%;
  max-height: 95vh;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
  margin: 2.5vh auto;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* Modal closing animation */
.modal-overlay.modal-closing {
  animation: fadeOut 0.4s ease-out forwards;
}

.modal-overlay.modal-closing .modal-content {
  animation: slideDown 0.4s ease-out forwards;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1.25rem !important; /* Fixed 20px - no scaling */
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--heading);
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: color-mix(in srgb, var(--dice) 15%, transparent);
  color: var(--dice);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
  font-size: 16px;
}

.version-block {
  background: rgba(139, 69, 19, 0.15);
  border: 1px solid #8b4513;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.version-block:last-child {
  margin-bottom: 0;
}

.version-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.version-badge {
  background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
  color: #f5deb3;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid rgba(245, 222, 179, 0.3);
}

.version-badge.in-progress {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #1a0f08;
  animation: pulse-version 2s ease-in-out infinite;
}

@keyframes pulse-version {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(251, 191, 36, 0);
  }
}

.version-date {
  color: var(--text-secondary);
  font-size: 14px;
}

.version-highlights {
  color: #f5deb3;
  font-size: 15px;
  margin-bottom: 16px;
  font-style: italic;
}

.change-category {
  margin-bottom: 16px;
}

.change-category:last-child {
  margin-bottom: 0;
}

.category-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-title.features {
  color: #fbbf24;
}

.category-title.improvements {
  color: var(--dice);
}

.category-title.fixes {
  color: #4ade80;
}

.category-title.breaking {
  color: #ef4444;
}

.category-title.documentation {
  color: #a78bfa;
}

.category-title.technical {
  color: var(--text-secondary);
}

.change-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.change-list li {
  color: var(--text-secondary);
  padding: 4px 0;
  padding-left: 20px;
  position: relative;
  font-size: 14px;
  line-height: 1.6;
}

.change-list li::before {
  content: "•";
  position: absolute;
  left: 8px;
  color: inherit;
}

.roadmap-section {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.roadmap-title {
  color: var(--question);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.roadmap-version {
  margin-bottom: 16px;
}

.roadmap-version:last-child {
  margin-bottom: 0;
}

.roadmap-version-title {
  color: var(--dice);
  font-weight: 600;
  margin-bottom: 8px;
}

.roadmap-version ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.roadmap-version li {
  color: var(--text-secondary);
  padding: 4px 0;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
}

.roadmap-version li::before {
  content: "→";
  position: absolute;
  left: 8px;
  color: var(--dice);
}

/* Donation Modal Styles */
.donation-modal {
  max-width: 600px;
}

.donation-intro {
  text-align: center;
  margin-bottom: 24px;
}

.donation-intro p {
  color: var(--text-secondary);
  font-size: 16px;
  margin: 8px 0;
}

.cost-breakdown {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
}

.cost-breakdown h3 {
  color: #a78bfa;
  font-size: 18px;
  margin: 0 0 16px 0;
}

.cost-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.cost-item:last-child {
  border-bottom: none;
}

.cost-item.cost-total {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid rgba(139, 92, 246, 0.4);
}

.cost-name {
  color: var(--text-secondary);
}

.cost-amount {
  color: #fbbf24;
  font-weight: 600;
}

.donation-benefits {
  margin: 20px 0;
}

.donation-benefits h3 {
  color: var(--question);
  font-size: 16px;
  margin-bottom: 12px;
}

.donation-benefits ul {
  list-style: none;
  padding: 0;
}

.donation-benefits li {
  color: var(--text-secondary);
  padding: 6px 0;
  padding-left: 24px;
  position: relative;
}

.donation-benefits li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #4ade80;
  font-weight: bold;
}

.donation-amounts {
  margin: 24px 0;
}

.donation-amounts h3 {
  color: #fbbf24;
  font-size: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.amount-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.amount-btn {
  background: rgba(251, 191, 36, 0.1);
  border: 2px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  padding: 16px 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.amount-btn:hover {
  background: rgba(251, 191, 36, 0.2);
  border-color: rgba(251, 191, 36, 0.5);
  transform: translateY(-2px);
}

.amount-emoji {
  font-size: 32px;
}

.amount-value {
  color: #fbbf24;
  font-size: 18px;
  font-weight: bold;
}

.amount-label {
  color: var(--text-secondary);
  font-size: 12px;
}

.donation-footer {
  text-align: center;
  margin: 24px 0;
}

.donation-quote {
  color: var(--question);
  font-style: italic;
  margin: 12px 0;
}

.donation-note {
  color: var(--text-secondary);
  font-size: 13px;
}

.community-stats {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.community-stats h3 {
  color: var(--question);
  font-size: 16px;
  margin: 0 0 16px 0;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  color: #fbbf24;
  font-weight: 600;
}

/* Feedback Modal Styles */
.feedback-modal {
  max-width: 500px;
}

#feedbackIntro {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 16px;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.feedback-comment label {
  display: block;
  color: var(--question);
  margin-bottom: 8px;
  font-size: 14px;
}

#feedbackText {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 165, 116, 0.3);
  border-radius: 8px;
  padding: 12px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

#feedbackText:focus {
  outline: none;
  border-color: rgba(212, 165, 116, 0.5);
}

.feedback-tags label {
  display: block;
  color: var(--question);
  margin-bottom: 12px;
  font-size: 14px;
}

.tag-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-btn {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 16px;
  padding: 6px 12px;
  color: var(--question);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tag-btn:hover {
  background: rgba(96, 165, 250, 0.2);
}

.tag-btn.selected {
  background: rgba(96, 165, 250, 0.3);
  border-color: rgba(96, 165, 250, 0.5);
  color: #fff;
}

.feedback-context label {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.feedback-context input[type="checkbox"] {
  cursor: pointer;
}

.feedback-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}

.btn-primary {
  background: rgba(74, 222, 128, 0.2);
  border: 2px solid rgba(74, 222, 128, 0.4);
  color: #4ade80;
}

.btn-primary:hover {
  background: rgba(74, 222, 128, 0.3);
  border-color: rgba(74, 222, 128, 0.6);
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.1);
  border: 2px solid rgba(148, 163, 184, 0.3);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.2);
}

.success-message {
  text-align: center;
  padding: 40px 20px;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.success-message h3 {
  color: #4ade80;
  margin: 16px 0;
}

.success-message p {
  color: var(--text-secondary);
  margin: 8px 0;
}

.success-message button {
  margin-top: 24px;
}

/* Feedback buttons on messages */
.feedback-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.message-content:hover .feedback-buttons {
  opacity: 1;
}

.feedback-btn {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--question);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.feedback-btn:hover {
  background: rgba(96, 165, 250, 0.2);
  border-color: rgba(96, 165, 250, 0.5);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .amount-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .donation-modal {
    max-width: 95%;
  }
}

/* End Development Log Modal Styles */

/* ============================== */
/* TEXT PROCESSING SETTINGS MODAL */
/* ============================== */

.text-processing-modal {
  max-width: 700px;
}

.text-processing-settings {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-section {
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 20px;
}

.settings-section h3 {
  color: var(--dice);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-section h3::before {
  content: "⚙️";
  font-size: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-description {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
  font-style: italic;
}

.setting-select {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.setting-select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.setting-select:hover {
  border-color: rgba(59, 130, 246, 0.5);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.toggle-item:hover {
  background: rgba(15, 20, 25, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
}

.toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--dice);
}

.toggle-label {
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  flex: 1;
}

.toggle-description {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
  font-style: italic;
}

.settings-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-secondary,
.btn-primary {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.5);
}

.btn-primary {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: var(--dice);
}

.btn-primary:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.6);
}

/* Responsive adjustments for text processing settings */
@media (max-width: 640px) {
  .text-processing-modal {
    max-width: 95%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    flex-direction: column;
  }

  .btn-secondary,
  .btn-primary {
    width: 100%;
  }
}

/* ============================== */
/* RIGHT SIDE MENU BUTTONS */
/* ============================== */

.character-sheet-panel {
  display: none !important;
}

.character-sheet-panel:hover {
  width: 55px;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.18) 0%,
    rgba(37, 99, 235, 0.12) 100%
  );
  box-shadow: -6px 0 20px rgba(59, 130, 246, 0.25);
}

/* Hide all collapsed state styles - not needed anymore */
.character-sheet-panel.collapsed {
  /* No collapsed state - always visible */
}

.character-sheet-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 0;
  gap: 8px;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation; /* Optimize touch events */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

.character-sheet-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-weight: 600;
  color: var(--dice);
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 1px;
}

.character-sheet-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

/* Hide unused elements */
.character-sheet-content,
.character-sheet-toggle,
.coming-soon-badge,
.character-selector {
  display: none !important;
}

/* ============================== */
/* DONATION BUTTON - Bottom Right Corner (Left of Dice Button) */
/* ============================== */

.donation-tab-panel {
  position: fixed;
  bottom: 20px;
  right: 200px;
  width: auto;
  height: 50px;
  background: linear-gradient(
    135deg,
    rgba(248, 215, 120, 0.12) 0%,
    rgba(234, 179, 8, 0.08) 100%
  );
  border: 1px solid rgba(248, 215, 120, 0.25);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(248, 215, 120, 0.15);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 950;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
  padding: 0 20px;
}

.donation-tab-panel:hover {
  background: linear-gradient(
    135deg,
    rgba(248, 215, 120, 0.18) 0%,
    rgba(234, 179, 8, 0.12) 100%
  );
  box-shadow: 0 6px 20px rgba(248, 215, 120, 0.25);
}

.donation-tab-panel:not(.slide-out):hover {
  transform: translateY(-3px);
}

/* Slide out animation - moves completely off screen to the right */
.donation-tab-panel.slide-out {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Footer slide-out animation - slides down off screen */
#legalFooter {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
}

#legalFooter.slide-out {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.donation-tab-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.donation-tab-title {
  font-weight: 600;
  color: #f8d778;
  font-size: 14px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.donation-tab-icon {
  font-size: 20px;
}

/* Hide unused elements */
.donation-tab-content,
.donation-tab-toggle,
.donation-message,
.donation-cta-button,
.donation-note {
  display: none !important;
}

/* Character Selector for Multiple Characters */
.character-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
  overflow-x: auto;
  overflow-y: hidden;
}

.character-selector-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.character-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
}

.character-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  position: relative;
}

.character-tab:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.character-tab.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.character-tab-icon {
  font-size: 18px;
  line-height: 1;
}

.character-tab-info {
  flex: 1;
  min-width: 0;
}

.character-tab-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-tab-details {
  display: flex;
  gap: 8px;
  font-size: 11px;
  margin-top: 2px;
}

.character-tab-class {
  color: var(--text-secondary);
}

.character-tab-hp {
  font-weight: 600;
}

.character-tab-hp.hp-good {
  color: #10b981;
}

.character-tab-hp.hp-low {
  color: #f59e0b;
}

.character-tab-hp.hp-critical {
  color: #ef4444;
}

.character-sheet-content {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: linear-gradient(
    180deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 100%
  );
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

/* Custom scrollbar for character sheet - Theme-Aware with Auto-Hide */
.character-sheet-content::-webkit-scrollbar {
  width: 8px;
}

.character-sheet-content::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
  transition: background 0.3s ease;
}

.character-sheet-content::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.character-sheet-content.scrolling::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

.character-sheet-content.scrolling::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--dice) 40%, transparent),
    color-mix(in srgb, var(--dice) 50%, transparent)
  );
}

.character-sheet-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--dice) 60%, transparent),
    color-mix(in srgb, var(--dice) 70%, transparent)
  ) !important;
}

.character-section {
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.15);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.section-label {
  display: block;
  color: var(--dice);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.character-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.character-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.character-info-item label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.character-value {
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 500;
}

.hp-ac-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-box {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}

.stat-box label {
  display: block;
  color: var(--text-secondary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  font-weight: 600;
}

.hp-display {
  text-align: center;
  margin-bottom: 10px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hp-current {
  color: #4ade80;
  font-size: 28px;
  font-weight: 700;
}

.hp-separator {
  color: var(--text-secondary);
  font-size: 22px;
  margin: 0 6px;
}

.hp-max {
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 600;
}

.hp-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(15, 20, 25, 0.8);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}

.hp-bar.low {
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
}

.hp-bar.critical {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.hp-controls {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.hp-button {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--dice);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.hp-button:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.5);
}

.hp-button.heal {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.hp-button.heal:hover {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.5);
}

/* ============================================
   HP PROMINENCE SECTION (NEW)
   ============================================ */
.hp-prominence-section {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--bg-primary) 95%, transparent),
    color-mix(in srgb, var(--bg-secondary) 95%, transparent)
  );
  border: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.hp-display-large {
  text-align: center;
  margin-bottom: 16px;
}

.hp-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.hp-value-large {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.hp-value-large .hp-current {
  color: #4ade80;
  font-size: 42px;
}

.hp-value-large .hp-separator {
  color: var(--text-secondary);
  font-size: 32px;
}

.hp-value-large .hp-max {
  color: var(--text-secondary);
  font-size: 32px;
  font-weight: 600;
}

/* HP Bar with color coding */
.hp-prominence-section .hp-bar-container {
  width: 100%;
  height: 16px;
  background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hp-prominence-section .hp-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.3s ease, background 0.3s ease;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

/* HP Color States */
.hp-bar-fill.hp-high {
  background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.hp-bar-fill.hp-medium {
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.hp-bar-fill.hp-low {
  background: linear-gradient(90deg, #fb923c 0%, #f97316 100%);
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.5);
}

.hp-bar-fill.hp-critical {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Long Rest Button */
.long-rest-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 20%, transparent),
    color-mix(in srgb, var(--dice) 10%, transparent)
  );
  border: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 8px;
  color: var(--dice);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.long-rest-btn:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 30%, transparent),
    color-mix(in srgb, var(--dice) 20%, transparent)
  );
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--dice) 30%, transparent);
}

.long-rest-btn:active {
  transform: scale(0.98);
}

/* Secondary Stats Grid */
.secondary-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.secondary-stat-box {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--bg-primary) 90%, transparent),
    color-mix(in srgb, var(--bg-secondary) 90%, transparent)
  );
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  transition: all 0.2s ease;
}

.secondary-stat-box:hover {
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--dice) 20%, transparent);
}

.secondary-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.secondary-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--dice);
}

/* ============================================
   END HP PROMINENCE SECTION
   ============================================ */

.gold-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  flex: 1;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.gold-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
}

.gold-value {
  color: #fbbf24;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  width: 100%;
  text-align: center;
  line-height: 1.2;
}

.gold-label {
  color: var(--text-secondary);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  line-height: 1;
}

.inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.gold-display-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  padding: 6px 12px;
}

.gold-display-inline .gold-icon {
  font-size: 18px;
  line-height: 1;
}

.gold-display-inline .gold-value {
  color: #fbbf24;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
  line-height: 1;
}

.gold-display-inline .gold-label {
  color: var(--text-secondary);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.abilities-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ability-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  transition: all 0.2s ease;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}

.ability-item:hover {
  background: rgba(15, 20, 25, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.ability-label {
  color: var(--text-secondary);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 1px;
  font-weight: 600;
  line-height: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
}

.character-sheet .ability-score {
  color: #e5e7eb;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.character-sheet .ability-modifier {
  color: var(--dice);
  font-size: 11px;
  margin-top: 1px;
  font-weight: 600;
  line-height: 1;
}

/* Saving Throws Styles */
.saves-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.save-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.save-item:hover {
  background: rgba(15, 20, 25, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
}

.save-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-proficiency {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(59, 130, 246, 0.4);
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-proficiency.proficient {
  background: var(--dice);
  border-color: var(--dice);
}

.save-proficiency.proficient::after {
  content: "?";
  color: white;
  display: block;
  text-align: center;
  font-size: 10px;
  line-height: 12px;
}

.save-bonus {
  color: var(--dice);
  font-size: 12px;
  font-weight: 600;
  min-width: 30px;
  text-align: right;
}

/* Skills Styles */
.skill-note {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 400;
  margin-left: 8px;
}

.skills-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 300px;
  overflow-y: auto;
}

.skill-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 4px;
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.skill-item:hover {
  background: rgba(15, 20, 25, 0.8);
  border-color: rgba(59, 130, 246, 0.3);
}

.skill-name-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.skill-proficiency-markers {
  display: flex;
  gap: 3px;
}

.skill-prof-marker {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(59, 130, 246, 0.4);
  display: inline-block;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skill-prof-marker.proficient {
  background: var(--dice);
  border-color: var(--dice);
  border-radius: 50%;
}

.skill-prof-marker.proficient::after {
  content: "�";
  color: white;
  display: block;
  text-align: center;
  font-size: 16px;
  line-height: 10px;
}

.skill-prof-marker.expertise {
  background: #8b5cf6;
  border-color: #8b5cf6;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.skill-prof-marker.expertise::after {
  content: "?";
  color: white;
  display: block;
  text-align: center;
  font-size: 10px;
  line-height: 10px;
}

.skill-name {
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 500;
}

.skill-ability {
  color: var(--text-secondary);
  font-size: 9px;
  text-transform: uppercase;
}

.skill-bonus {
  color: var(--dice);
  font-size: 12px;
  font-weight: 600;
  min-width: 28px;
  text-align: right;
}

.passive-perception {
  margin-top: 12px;
  padding: 10px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.passive-perception label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.passive-value {
  color: var(--dice);
  font-size: 16px;
  font-weight: 700;
}

/* Combat Stats Styles */
.combat-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.combat-stat-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.combat-stat-item label {
  color: var(--text-secondary);
  font-size: 11px;
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.temp-hp-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.temp-hp-box label {
  color: #10b981;
  font-size: 12px;
  font-weight: 500;
}

.death-saves-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  padding: 12px;
}

.death-saves-box label {
  color: #ef4444;
  font-size: 12px;
  font-weight: 600;
  display: block;
  margin-bottom: 10px;
}

.death-saves {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.death-save-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.death-save-row span:first-child {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.death-save-boxes {
  display: flex;
  gap: 6px;
}

.death-save-box {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(239, 68, 68, 0.5);
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  transition: all 0.2s ease;
}

.death-save-box.filled {
  background: #ef4444;
  border-color: #ef4444;
}

.death-save-box.filled::after {
  content: "?";
  color: white;
  display: block;
  text-align: center;
  font-size: 12px;
  line-height: 14px;
  font-weight: bold;
}

.death-save-row:first-child .death-save-box.filled {
  background: #10b981;
  border-color: #10b981;
}

.death-save-row:first-child .death-save-box.filled::after {
  content: "?";
}

/* Attacks & Spellcasting Styles */
.add-attack-btn {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 4px;
  color: var(--dice);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
}

.add-attack-btn:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(59, 130, 246, 0.6);
}

.attacks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attack-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s ease;
}

.attack-item:hover {
  background: rgba(15, 20, 25, 0.8);
  border-color: rgba(59, 130, 246, 0.4);
}

.attack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.attack-name-input {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 8px;
  flex: 1;
  margin-right: 8px;
}

.attack-name-input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.6);
}

.remove-attack-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 4px;
  color: #ef4444;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-attack-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
}

.attack-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.attack-stat-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.attack-stat-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.attack-bonus-input,
.attack-damage-input {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  color: var(--dice);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px;
  text-align: center;
}

.attack-bonus-input:focus,
.attack-damage-input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.6);
}

.attack-roll-btn {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 4px;
  color: #10b981;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
  width: 100%;
}

.attack-roll-btn:hover {
  background: rgba(16, 185, 129, 0.3);
  border-color: rgba(16, 185, 129, 0.6);
}

.no-attacks {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* ========================================
           SPELLCASTING STYLES
           ======================================== */

.spellcasting-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.toggle-spellcasting-btn {
  background: rgba(147, 51, 234, 0.2);
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 4px;
  color: #a855f7;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
  touch-action: manipulation; /* Optimize touch events */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

.toggle-spellcasting-btn:hover {
  background: rgba(147, 51, 234, 0.3);
  border-color: rgba(147, 51, 234, 0.6);
}

.toggle-spellcasting-btn:active {
  background: rgba(147, 51, 234, 0.4);
  transform: scale(0.98);
}

.spellcasting-info {
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid rgba(147, 51, 234, 0.2);
  border-radius: 8px;
  padding: 12px;
}

.spellcasting-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.spellcasting-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spellcasting-info-item label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.spellcasting-select {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 4px;
  color: #a855f7;
  font-size: 12px;
  padding: 6px 8px;
}

.spellcasting-select:focus {
  outline: none;
  border-color: rgba(147, 51, 234, 0.6);
}

.spellcasting-value {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 4px;
  color: #a855f7;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 8px;
  text-align: center;
}

.spell-section-label {
  color: #d1d5db;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.add-spell-btn {
  background: rgba(147, 51, 234, 0.2);
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 4px;
  color: #a855f7;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-spell-btn:hover {
  background: rgba(147, 51, 234, 0.3);
  border-color: rgba(147, 51, 234, 0.6);
}

/* Spell Slots */
.spell-slots-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-slot-level {
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid rgba(147, 51, 234, 0.2);
  border-radius: 6px;
  padding: 8px;
}

.spell-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.spell-slot-level-number {
  background: rgba(147, 51, 234, 0.3);
  border-radius: 50%;
  color: #a855f7;
  font-size: 11px;
  font-weight: 600;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-slot-remaining {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.spell-slot-circles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.spell-slot-circle {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 50%;
  color: #a855f7;
  font-size: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.spell-slot-circle.available {
  background: rgba(147, 51, 234, 0.2);
  border-color: rgba(147, 51, 234, 0.6);
}

.spell-slot-circle.expended {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.spell-slot-circle:hover {
  transform: scale(1.1);
}

.no-spell-slots {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* Cantrips */
.cantrips-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cantrip-entry {
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid rgba(147, 51, 234, 0.2);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.cantrip-name-input {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 4px;
  color: #e5e7eb;
  font-size: 12px;
  padding: 6px 8px;
  flex: 1;
}

.cantrip-name-input:focus {
  outline: none;
  border-color: rgba(147, 51, 234, 0.6);
}

.remove-cantrip-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 4px;
  color: #ef4444;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-cantrip-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
}

.no-cantrips {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* Prepared Spells */
.spell-levels-accordion {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spell-level-section {
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid rgba(147, 51, 234, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.spell-level-header {
  background: rgba(147, 51, 234, 0.1);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.spell-level-header:hover {
  background: rgba(147, 51, 234, 0.2);
}

.spell-level-title {
  color: #d1d5db;
  font-size: 12px;
  font-weight: 500;
}

.spell-level-toggle {
  color: #a855f7;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.spell-level-content {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prepared-spell-entry {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(147, 51, 234, 0.2);
  border-radius: 4px;
  padding: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.spell-name-input {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 4px;
  color: #e5e7eb;
  font-size: 12px;
  padding: 4px 6px;
  flex: 1;
}

.spell-name-input:focus {
  outline: none;
  border-color: rgba(147, 51, 234, 0.6);
}

.spell-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.spell-prepared-toggle {
  background: rgba(15, 20, 25, 0.8);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.spell-prepared-toggle.prepared {
  background: rgba(147, 51, 234, 0.3);
  border-color: rgba(147, 51, 234, 0.6);
  color: #a855f7;
}

.spell-prepared-toggle:hover {
  transform: scale(1.1);
}

.remove-spell-btn {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 4px;
  color: #ef4444;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-spell-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
}

.add-spell-level-btn {
  background: rgba(147, 51, 234, 0.2);
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 4px;
  color: #a855f7;
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.add-spell-level-btn:hover {
  background: rgba(147, 51, 234, 0.3);
  border-color: rgba(147, 51, 234, 0.6);
}

.no-spells {
  color: var(--text-secondary);
  font-size: 11px;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* ========================================
           END SPELLCASTING STYLES
           ======================================== */

.conditions-container,
.inventory-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.condition-item,
.inventory-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.condition-item:hover,
.inventory-item:hover {
  background: rgba(15, 20, 25, 0.8);
}

.condition-name,
.inventory-name {
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 500;
}

.condition-duration {
  color: var(--text-secondary);
  font-size: 10px;
}

.inventory-type {
  color: var(--text-secondary);
  font-size: 10px;
}

.no-conditions,
.no-inventory,
.no-skills,
.no-features,
.no-spells {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

.condition-count,
.inventory-count,
.skills-count,
.features-count,
.spells-count {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}

/* Skills Container */
.skills-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.skill-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.skill-item:hover {
  background: rgba(15, 20, 25, 0.8);
}

.skill-name {
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 500;
}

.skill-bonus {
  color: #d97706;
  font-size: 11px;
  font-weight: 600;
}

/* Features Container */
.features-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.feature-group-label {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.feature-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 6px;
  padding: 5px 8px;
  transition: background 0.2s ease;
}

.feature-item:hover {
  background: rgba(15, 20, 25, 0.8);
}

.feature-name {
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 500;
}

/* Spells Container */
.spells-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spell-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spell-group-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spell-slots {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
}

.spell-item {
  background: rgba(15, 20, 25, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  transition: background 0.2s ease;
}

.spell-item:hover {
  background: rgba(15, 20, 25, 0.8);
}

.spell-name {
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 500;
  font-style: italic;
}

.spell-level {
  color: var(--text-secondary);
  font-size: 11px;
}

/* Game Master Message Formatting - ALL REMOVED except choice buttons */
.gm-question {
  /* No special styling - plain text */
}

.gm-content {
  /* No special styling - plain text */
}

.stat-inline {
  /* No special styling - plain text */
}

.stat-inline strong {
  /* No special styling - plain text */
}

/* Theme Badge */
.theme-badge {
  display: inline-block;
  padding: 4px 12px;
  margin: 8px 0;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--dice);
  font-size: 12px;
  font-weight: 500;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.theme-badge::before {
  content: "🎨 ";
  margin-right: 4px;
}

/* Settings Menu Styles - Ribbon Bookmark Design */
.settings-button {
  position: fixed;
  right: 0px; /* Fully visible icon by default */
  top: 100px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--dice) 50%, transparent) 0%,
    color-mix(in srgb, var(--dice) 35%, transparent) 100%
  );
  border: 1px solid color-mix(in srgb, var(--dice) 40%, transparent);
  border-right: none;
  border-radius: 8px 0 0 8px;
  width: 48px; /* Compact icon size */
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Changed from center */
  gap: 10px;
  padding: 0 0 0 12px; /* Left padding only for icon */
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--dice);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px color-mix(in srgb, var(--dice) 20%, transparent);
  overflow: hidden;
  white-space: nowrap;
  z-index: 1200; /* Above header (1100) and container (100) */
}

.settings-button svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Text label - hidden by default */
.settings-button::after {
  content: "Settings";
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Only expand when menu is open - target via parent container */
.settings-container:has(.settings-menu.show) .settings-button {
  width: min(320px, calc(100vw - 20px)); /* Match settings menu width */
  padding-right: 12px; /* Add right padding when expanded */
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--dice) 60%, transparent) 0%,
    color-mix(in srgb, var(--dice) 45%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 60%, transparent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6),
    0 0 25px color-mix(in srgb, var(--dice) 50%, transparent),
    inset 2px 0 6px color-mix(in srgb, var(--dice) 15%, transparent);
  border-bottom-left-radius: 0; /* Seamless connection with menu below */
  border-bottom-right-radius: 0;
}

.settings-container:has(.settings-menu.show) .settings-button svg {
  transform: rotate(90deg);
}

.settings-container:has(.settings-menu.show) .settings-button::after {
  opacity: 1;
  transform: translateX(0);
}

/* Tome Button - Ribbon Bookmark Design */
.tome-button {
  position: fixed;
  right: 0px; /* Flush with viewport edge */
  top: 160px;
  width: 48px; /* Collapsed width */
  height: 48px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--dice) 50%, transparent) 0%,
    color-mix(in srgb, var(--dice) 35%, transparent) 100%
  );
  border: 1px solid color-mix(in srgb, var(--dice) 40%, transparent);
  border-right: none;
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 0 0 12px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--dice);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px color-mix(in srgb, var(--dice) 20%, transparent);
  overflow: hidden;
  white-space: nowrap;
  z-index: 1200; /* Above header (1100) and container (100) */
}

/* Hide Tome button when settings menu is open - only one button extended at a time */
.settings-container:has(.settings-menu.show) .tome-button {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

.tome-button svg {
  width: 32px; /* Larger icon */
  height: 32px;
  flex-shrink: 0;
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Book spine - stays fixed */
.book-spine {
  transition: opacity 0.3s ease;
}

/* Book pages - animate on hover */
.book-page-left,
.book-page-right {
  transition: transform 0.3s ease;
  transform-origin: center;
}

/* Book detail lines - fade slightly on hover */
.book-detail {
  transition: stroke-opacity 0.3s ease;
}

/* Text label - hidden by default */
.tome-button::after {
  content: "My Tome";
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Tome button expansion when menu is open */
.settings-container:has(.tome-menu.show) .tome-button {
  width: 280px; /* Match expanded settings button */
  padding-right: 12px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--dice) 60%, transparent) 0%,
    color-mix(in srgb, var(--dice) 45%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 60%, transparent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6),
    0 0 25px color-mix(in srgb, var(--dice) 50%, transparent),
    inset 2px 0 6px color-mix(in srgb, var(--dice) 15%, transparent);
  border-bottom-left-radius: 0; /* Seamless connection with menu */
  border-bottom-right-radius: 0;
}

.settings-container:has(.tome-menu.show) .tome-button::after {
  opacity: 1;
  transform: translateX(0);
}

/* Hide Settings button when Tome menu is open */
.settings-container:has(.tome-menu.show) .settings-button {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

/* Tome Menu - same styling as Settings menu */
.tome-menu {
  position: fixed;
  top: 208px; /* Directly below the tome button (160px + 48px height) */
  right: 0px; /* Match tome button right position */
  width: 280px;
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 50%,
    var(--bg-primary) 100%
  );
  border-radius: 0 0 12px 12px; /* Only bottom corners rounded */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7),
    0 0 1px color-mix(in srgb, var(--dice) 50%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-top: none; /* No top border - seamless with button */
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  z-index: 2000;
  overflow: hidden;
}

.tome-menu.show {
  display: flex;
  animation: slideDown 0.2s ease;
}

.settings-menu {
  position: fixed;
  top: 148px; /* Directly below the settings button (100px + 48px height) */
  right: 0px; /* Match settings button right position */
  width: min(320px, calc(100vw - 20px)); /* Responsive width with max 320px */
  max-height: calc(100vh - 168px); /* Leave room for button + padding */
  background: linear-gradient(
    135deg,
    var(--bg-primary) 0%,
    var(--bg-secondary) 50%,
    var(--bg-primary) 100%
  );
  border-radius: 0 0 12px 12px; /* Only bottom corners rounded */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7),
    0 0 1px color-mix(in srgb, var(--dice) 50%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-top: none; /* No top border - seamless with button */
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  z-index: 2000;
  overflow-y: auto; /* Allow vertical scrolling when content overflows */
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

.settings-menu.show {
  display: flex;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-menu-header {
  padding: 14px 16px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 8%, transparent) 0%,
    color-mix(in srgb, var(--dice) 5%, transparent) 100%
  );
  border-bottom: 1px solid color-mix(in srgb, var(--dice) 15%, transparent);
  color: var(--heading);
  font-weight: 600;
  font-size: 0.875rem !important; /* Fixed 14px - no scaling */
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-menu-item {
  display: grid;
  grid-template-columns: 28px 1fr auto; /* Icon | Text | Control */
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--dice) 8%, transparent);
  color: #e5e7eb;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  min-height: 52px; /* Ensure minimum height for touch targets */
}

.settings-menu-item.toggle-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.settings-menu-item:last-child {
  border-bottom: none;
}

.settings-menu-item:hover {
  background: color-mix(in srgb, var(--dice) 10%, transparent);
}

.settings-menu-item:focus-visible {
  outline: 2px solid var(--dice);
  outline-offset: 4px;
}

.settings-menu-item.settings-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.settings-menu-item.settings-danger .settings-title {
  color: #ef4444;
}

.settings-menu-item.settings-dev {
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  background: color-mix(in srgb, var(--dice) 5%, transparent);
}

.settings-menu-item.settings-dev:hover {
  background: color-mix(in srgb, var(--dice) 15%, transparent);
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
}

.settings-menu-item.settings-dev .settings-title {
  color: var(--dice);
  font-weight: 600;
}

.settings-menu-item.settings-dev .settings-subtitle {
  color: color-mix(in srgb, var(--dice) 70%, var(--text));
  font-size: 11px;
}

.settings-icon {
  font-size: 1.25rem !important; /* Fixed 20px */
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-column: 1; /* First column */
}

.settings-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.settings-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  grid-column: 2; /* Second column */
}

.settings-title {
  font-size: 0.875rem !important; /* Fixed 14px - no scaling */
  font-weight: 600;
  color: #e5e7eb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif; /* Unified font */
}

.settings-subtitle {
  font-size: 0.75rem !important; /* Fixed 12px - no scaling */
  color: var(--text-secondary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif; /* Unified font */
}

/* Theme Selector in Settings Menu */
.settings-menu-item.settings-theme-selector {
  display: grid;
  grid-template-columns: 28px 1fr auto; /* Match parent grid */
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.settings-menu-item.settings-theme-selector .settings-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  grid-column: 2; /* Second column */
}

.settings-menu-item.settings-theme-selector #settings-theme-switcher {
  grid-column: 3; /* Third column */
  margin-top: 0;
  display: flex;
  justify-content: flex-end;
}

/* Theme Switcher - Color Circles (Modern Design) */
.theme-switcher-circles {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 12px;
  align-items: center;
  justify-content: flex-end; /* Right-align with other controls */
}

.theme-circle {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}

.theme-circle:hover,
.theme-circle:active {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.theme-circle-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.theme-circle:hover .theme-circle-inner,
.theme-circle:active .theme-circle-inner {
  width: 32px;
  height: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.theme-circle-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.theme-circle.active {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 15%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dice) 20%, transparent);
}

.theme-circle.active .theme-circle-inner {
  width: 32px;
  height: 32px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.theme-circle.active .theme-circle-check {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Ripple effect animation */
.theme-circle-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--dice);
  opacity: 0.6;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple {
  to {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

/* Text Size Controls */
.settings-menu-item.settings-text-size {
  flex-direction: row;
  align-items: flex-end; /* Align to bottom baseline */
  gap: 16px; /* More room between elements */
  padding: 12px 16px;
}

.text-size-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  grid-column: 3; /* Third column */
  justify-self: end;
}

/* Text size buttons styling */
.text-size-btn {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 10%, transparent) 100%
  );
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--dice) 25%, transparent);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
  transition: all 0.2s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  min-width: 32px;
}

.text-size-btn:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 20%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px color-mix(in srgb, var(--dice) 20%, transparent);
}

.text-size-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Special styling for Reset button */
.text-size-btn:nth-child(2) {
  font-size: 12px;
} /* Text size icon styling - Stacked A's */
.settings-text-size .settings-icon {
  font-size: 18px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
  display: inline-flex;
  flex-direction: column; /* Stack vertically */
  align-items: center;
  justify-content: center;
  gap: 1px; /* Small gap between stacked elements to prevent touching */
  flex-shrink: 0;
  width: auto;
  line-height: 1; /* Tight line height */
  padding-bottom: 4px; /* Push entire icon up more */
}

.settings-text-size .text-size-small {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

.settings-text-size .text-size-large {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 2px; /* More space below large A to push it and arrow up */
}

.settings-text-size .text-size-arrow {
  font-size: 16px; /* Bigger arrow */
  font-weight: 400;
  line-height: 0.7; /* Even tighter line height */
  opacity: 1; /* Flat white - full opacity */
  color: #ffffff; /* Explicit white */
  margin: 2px 0; /* Slightly more margin for better separation */
}

.text-size-button {
  flex: 1;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 15%, transparent) 0%,
    color-mix(in srgb, var(--dice) 10%, transparent) 100%
  );
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  font-family: "Georgia", serif;
  transition: all 0.2s ease;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.text-size-button:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 25%, transparent) 0%,
    color-mix(in srgb, var(--dice) 20%, transparent) 100%
  );
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--dice) 20%, transparent);
}

.text-size-button:active {
  transform: translateY(0);
}

#textSizeStatus {
  color: color-mix(in srgb, var(--text-primary) 80%, transparent);
  font-size: 13px;
}

/* Theme Switcher - Dropdown (Legacy) */
.theme-switcher-dropdown {
  width: 100%;
}

.theme-select {
  width: 100%;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-select:hover {
  background: color-mix(in srgb, var(--dice) 15%, transparent);
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
}

.theme-select:focus {
  outline: none;
  border-color: var(--dice);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dice) 20%, transparent);
}

/* Theme Switcher - Buttons (Alternative) */
.theme-switcher-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-switch-btn {
  padding: 6px 12px;
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-switch-btn:hover {
  background: color-mix(in srgb, var(--dice) 20%, transparent);
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
}

.theme-switch-btn.active {
  background: var(--dice);
  border-color: var(--dice);
  color: #000;
  font-weight: 600;
}

/* Toggle Switch Styling */
.toggle-switch {
  position: relative;
  width: 42px;
  height: 22px;
  background: rgba(239, 68, 68, 0.3);
  border-radius: 11px;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
  border: 1.5px solid rgba(239, 68, 68, 0.5);
  grid-column: 3; /* Third column */
  justify-self: end;
}

.toggle-switch.active {
  background: rgba(34, 197, 94, 0.3);
  border-color: rgba(34, 197, 94, 0.5);
}

.toggle-slider {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active .toggle-slider {
  transform: translateX(20px);
  background: #22c55e;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .character-sheet-panel {
    right: 15px;
    width: 320px;
  }
}

@media (max-width: 1200px) {
  .character-sheet-panel {
    right: 10px;
    width: 300px;
  }

  .abilities-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .character-sheet-panel {
    display: none;
  }
}

/* =================================================================
   GAMEMASTER RESPONSE FORMATTING - PHASE 1 & 2 IMPLEMENTATION
   Based on automated analysis of agent response patterns
   ================================================================= */

/* Choice Button Styling - ONLY formatting kept for GM responses */
.gm-choice {
  color: #e5e7eb;
  font-weight: 500;
  font-size: var(--text-choice-button);
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.12) 0%,
    rgba(37, 99, 235, 0.08) 100%
  );
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  border-left: 3px solid rgba(59, 130, 246, 0.5);
  padding: 12px 16px;
  margin: 8px 0;
  transition: all 0.2s ease;
  cursor: pointer;
  display: block;
}

.gm-choice:hover {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.18) 0%,
    rgba(37, 99, 235, 0.12) 100%
  );
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateX(4px);
}

/* Interactive elements focus states */
.gm-choice:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .gm-choice {
    padding: 10px 12px;
  }
}

/* ============================================
   UTILITY CLASSES FOR INLINE STYLE CLEANUP
   ============================================ */

/* Hidden state utility */
.hidden {
  display: none !important;
}

/* Continue Button Hidden State */
#continueButton.hidden {
  display: none;
}

/* Restart App Button Icon */
.restart-icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Floating Buttons Hidden State */
.floating-button.hidden {
  display: none;
}

/* Character Sheet Content Hidden */
.character-sheet-content.hidden {
  display: none;
}

footer .footer-credit {
  color: var(--dice);
  text-decoration: none;
  border-bottom: 1px dotted rgba(96, 165, 250, 0.6);
  transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

footer .footer-credit:visited {
  color: var(--dice);
  border-bottom-color: rgba(96, 165, 250, 0.6);
}

footer .footer-credit:hover {
  color: #8ec5ff;
  border-bottom-color: #8ec5ff;
}

/* Legal Footer */
#legalFooter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 26, 26, 0.95);
  border-top: 1px solid #3a3a3a;
  padding: 8px 20px;
  font-size: 11px;
  color: #b0b0b0;
  text-align: center;
  z-index: 9999;
  -webkit-backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  transition: transform 0.5s ease-in-out;
}

#legalFooter .footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

#legalFooter .footer-text {
  white-space: nowrap;
}

#legalFooter a {
  color: var(--dice);
  text-decoration: none;
  border-bottom: 1px dotted rgba(96, 165, 250, 0.6);
  transition: color 0.2s ease, border-bottom-color 0.2s ease;
}

#legalFooter a:visited {
  color: var(--dice);
  border-bottom-color: rgba(96, 165, 250, 0.6);
}

#legalFooter a:hover {
  color: #8ec5ff;
  border-bottom-color: #8ec5ff;
}

#legalFooter .footer-separator {
  white-space: nowrap;
  color: rgba(148, 163, 184, 0.8);
}

#legalFooter .footer-credit {
  white-space: nowrap;
  color: var(--dice);
  font-weight: 600;
}

/* Modal Overlay Hidden State */
.modal-overlay.hidden {
  display: none;
}

/* Feedback Success Hidden State */
#feedbackSuccess.hidden {
  display: none;
}

/* ==================== QUICK PLAY MODAL ==================== */

.quickplay-modal {
  max-width: 900px;
  width: 95%;
  transition: max-width 0.3s ease;
}

.quickplay-modal.expanded {
  max-width: 1600px;
  width: 98%;
}

.quickplay-randomize-btn {
  margin-left: auto;
  margin-right: 12px;
  padding: 8px 20px;
  background: linear-gradient(
    135deg,
    var(--dice),
    color-mix(in srgb, var(--dice) 85%, #fff)
  );
  color: white;
  border: 2px solid var(--dice);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--dice) 30%, transparent);
}

.quickplay-randomize-btn:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 120%, #fff),
    var(--dice)
  );
  transform: translateY(-2px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--dice) 50%, transparent);
}

.quickplay-randomize-btn:active {
  transform: translateY(0);
}

.quest-shuffle-btn {
  background: color-mix(in srgb, var(--glass-bg) 40%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0.8;
}

.quest-shuffle-btn::before {
  content: "⟳";
  font-size: 14px;
  color: var(--dice);
  transition: transform 0.3s ease;
  display: inline-block;
}

.quest-shuffle-btn:hover {
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 16px color-mix(in srgb, var(--dice) 20%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  opacity: 1;
  transform: translateY(-1px);
}

.quest-shuffle-btn:hover::before {
  /* No rotation animation */
}

.quest-shuffle-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.quest-shuffle-btn:active::before {
  /* No rotation animation */
}

.quickplay-body {
  max-height: 70vh;
}

.quickplay-intro {
  color: var(--text-secondary);
  margin-bottom: 24px;
  text-align: center;
  font-size: 14px;
}

.quickplay-section {
  background: color-mix(in srgb, var(--bg-primary) 50%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  transition: opacity 0.3s, filter 0.3s;
}

.quickplay-section.disabled {
  opacity: 0.5;
  filter: grayscale(50%);
  pointer-events: none;
}

.quickplay-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.quickplay-section-header h3 {
  margin: 0;
  color: var(--heading);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quickplay-section-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.quickplay-custom-input-inline {
  flex: 0 0 auto;
  min-width: 200px;
  max-width: 300px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--glass-bg) 35%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.quickplay-custom-input-inline::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
  font-style: italic;
  font-size: 12px;
}

.quickplay-custom-input-inline:focus {
  outline: none;
  border-color: var(--dice);
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dice) 15%, transparent);
}

.quickplay-section-icon {
  font-size: 18px;
}

.quickplay-toggle {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid currentColor;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 48px;
}

.quickplay-toggle.enabled {
  background: color-mix(in srgb, var(--dice) 20%, transparent);
  color: var(--dice);
  border-color: var(--dice);
}

.quickplay-toggle:hover {
  background: color-mix(in srgb, var(--dice) 30%, transparent);
  transform: scale(1.05);
}

.quickplay-section-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 12px 0;
}

.quickplay-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  pointer-events: auto; /* Ensure options container allows interactions */
}

.quickplay-option {
  background: color-mix(in srgb, var(--glass-bg) 45%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 25%, transparent);
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  min-height: 90px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  pointer-events: auto !important; /* Ensure options are always clickable */
  z-index: 10;
}

.quickplay-option::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
}

.quickplay-option:hover {
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  background: color-mix(in srgb, var(--glass-bg) 55%, transparent);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35),
    0 0 20px color-mix(in srgb, var(--dice) 25%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.quickplay-option:active {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3),
    0 0 12px color-mix(in srgb, var(--dice) 20%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.quickplay-option.selected {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 25%, var(--glass-bg) 50%);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--dice) 40%, transparent),
    0 0 30px color-mix(in srgb, var(--dice) 30%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 20px color-mix(in srgb, var(--dice) 15%, transparent);
  transform: translateY(-2px);
}

.quickplay-option-emoji {
  font-size: 32px;
  margin-bottom: 4px;
}

.quickplay-option-name {
  font-weight: 600;
  color: var(--heading);
  font-size: 14px;
}

.quickplay-option-desc {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

/* Checkbox-style options for multi-select */
.quickplay-option-checkbox {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quickplay-checkbox-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.quickplay-checkbox-indicator {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--dice);
  transition: all 0.2s ease;
}

.quickplay-option-checkbox.selected .quickplay-checkbox-indicator {
  background: var(--dice);
  border-color: var(--dice);
  color: #fff;
  box-shadow: 0 0 12px color-mix(in srgb, var(--dice) 50%, transparent);
}

/* Custom text input */
.quickplay-custom-input-container {
  margin-top: 12px;
  width: 100%;
  grid-column: 1 / -1; /* Span all columns in the grid */
}

.quickplay-custom-input {
  width: 100%;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--glass-bg) 30%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.quickplay-custom-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--glass-bg) 30%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  resize: vertical;
}

.quickplay-custom-input::placeholder,
.quickplay-custom-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
  font-size: 14px; /* Fixed size for placeholder, prevents emoji from scaling */
}

.quickplay-custom-input:focus,
.quickplay-custom-textarea:focus {
  outline: none;
  border-color: var(--dice);
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--dice) 30%, transparent);
}

.quickplay-custom-input:not(:placeholder-shown),
.quickplay-custom-textarea:not(:placeholder-shown) {
  border-color: color-mix(in srgb, var(--dice) 60%, transparent);
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
}

/* Normal button styling for character creation options (no tabs) */
.quickplay-tab-option {
  /* Remove tab-specific styling, use standard button appearance */
  position: relative;
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 12px; /* Fully rounded corners, not just top */
  transition: all 0.3s ease;
  background: color-mix(in srgb, var(--glass-bg) 40%, transparent);
}

.quickplay-tab-option.selected {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--glass-bg) 60%, transparent);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 30%, transparent);
}

/* Remove the underline effect from tabs */
.quickplay-tab-option.selected::after {
  display: none;
}

/* Theme Grid Layout - 2x2 grid with Lighthearted and Cozy on bottom */
.quickplay-theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  width: 100%;
  grid-column: 1 / -1; /* Span full width of parent grid */
}

.quickplay-theme-option {
  min-height: 140px;
  padding: 20px 16px;
  background: color-mix(in srgb, var(--bg-secondary) 45%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 4px rgba(0, 0, 0, 0.15);
  width: 100%;
}

/* Character Creation Form */
.character-creation-form {
  margin-top: 24px;
  padding: 24px;
  background: color-mix(in srgb, var(--bg-primary) 70%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 12px;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--dice) 20%, transparent);
  pointer-events: auto !important; /* Ensure form is always interactive */
}

.character-creation-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.character-creation-header h3 {
  margin: 0;
  color: var(--heading);
  font-size: 24px;
  flex: 1;
  text-align: center;
}

.character-creation-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

.character-creation-scroll {
  /* No max-height or scrollbar - extends fully */
  padding-right: 0;
}

.char-create-section {
  margin-bottom: 20px;
  pointer-events: auto; /* Ensure section allows interactions */
}

.char-create-label {
  display: block;
  color: var(--heading);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

/* Class Icon Grid */
.class-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  position: relative;
  z-index: 5; /* Ensure grid is above any background elements */
  pointer-events: auto; /* Ensure grid allows interactions */
}

.class-icon-btn {
  background: color-mix(in srgb, var(--glass-bg) 40%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 10; /* Ensure buttons are clickable */
  pointer-events: auto !important; /* Force enable pointer events even if parent is disabled */
}

.class-icon-btn:hover {
  border-color: color-mix(in srgb, var(--dice) 50%, transparent);
  background: color-mix(in srgb, var(--glass-bg) 50%, transparent);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 20px color-mix(in srgb, var(--dice) 30%, transparent),
    0 0 40px color-mix(in srgb, var(--dice) 15%, transparent);
}

.class-icon-btn.selected {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 25%, var(--glass-bg) 50%);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 40%, transparent),
    0 0 24px color-mix(in srgb, var(--dice) 30%, transparent),
    inset 0 0 20px color-mix(in srgb, var(--dice) 10%, transparent);
  transform: translateY(-1px);
}

.class-icon-btn .class-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.class-icon-btn .class-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.class-icon-btn:active {
  transform: translateY(0);
}

/* Multiclass name display */
.multiclass-name-display {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 8px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.multiclass-name-display.visible {
  opacity: 1;
  transform: translateY(0);
}

.multiclass-arrow {
  font-size: 16px;
  color: var(--dice);
  margin-right: 8px;
  font-weight: bold;
}

.multiclass-name-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--dice);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.char-create-input,
.char-create-select,
.char-create-textarea {
  width: 100%;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg-secondary) 30%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px; /* Increased from 14px to match larger inputs */
  font-family: inherit;
  transition: all 0.2s ease;
  pointer-events: auto !important; /* Ensure inputs are always interactive */
}

/* Dropdown-specific styling to override browser defaults */
.char-create-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 40px;
  cursor: pointer;
  color-scheme: dark; /* Forces dark dropdown menu in modern browsers */
}

/* Dropdown options */
.char-create-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px;
}

.char-create-input:focus,
.char-create-select:focus,
.char-create-textarea:focus {
  outline: none;
  border-color: var(--dice);
  background: color-mix(in srgb, var(--bg-secondary) 50%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--dice) 30%, transparent);
}

.char-create-select:hover,
.char-create-select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 3L1 8h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

.char-create-textarea {
  min-height: 160px;
  resize: vertical;
}

.ability-scores-method {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  pointer-events: auto; /* Ensure method buttons container allows interactions */
}

.ability-reroll-container {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  margin-top: -4px; /* Bring closer to top buttons */
}

.ability-reroll-container .quest-shuffle-btn {
  min-width: 140px;
  padding: 8px 20px;
}

.ability-method-btn {
  flex: 1;
  padding: 10px;
  background: color-mix(in srgb, var(--glass-bg) 30%, transparent);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 8px;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto !important; /* Force enable even if parent is disabled */
  position: relative;
  z-index: 10; /* Ensure buttons are clickable */
}

.ability-method-btn.hidden {
  display: none;
}

.ability-method-btn:hover {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 10%, transparent);
}

.ability-method-btn.active {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 20%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--dice) 30%, transparent);
}

.points-remaining {
  font-size: 0.9em;
  font-weight: 600;
  opacity: 0.9;
}

/* Auto-assign info display */
.auto-assign-info {
  padding: 8px 12px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--mystic-blue) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--mystic-blue) 30%, transparent);
  border-radius: 8px;
  text-align: center;
}

.auto-assign-text {
  font-size: 0.9em;
  color: var(--text-primary);
  font-weight: 500;
}

#autoAssignClass {
  font-weight: 700;
  color: var(--mystic-blue);
}

.ability-scores-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  pointer-events: auto; /* Ensure grid allows interactions */
}

.ability-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  pointer-events: auto; /* Ensure item allows interactions */
}

.ability-score-item:hover {
  background: color-mix(in srgb, var(--glass-bg) 15%, transparent);
}

.ability-score-item label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.ability-score-control {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  pointer-events: auto; /* Ensure control allows interactions */
}

.ability-arrow {
  padding: 0;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 4px;
  color: color-mix(in srgb, var(--dice) 70%, transparent);
  font-size: 18px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: auto !important; /* Ensure buttons are always clickable */
  position: relative;
  z-index: 10;
}

.ability-arrow:hover,
.ability-arrow:active {
  opacity: 1;
  background: color-mix(in srgb, var(--dice) 8%, transparent);
  border-color: color-mix(in srgb, var(--dice) 40%, transparent);
  color: var(--dice);
}

.ability-arrow:active {
  transform: scale(0.92);
}

.ability-score-input {
  flex: 1;
  padding: 8px 6px;
  background: color-mix(in srgb, var(--glass-bg) 30%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 25%, transparent);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s ease;
  pointer-events: auto !important; /* Ensure input is always editable */
}

/* Hide number input arrows */
.ability-score-input::-webkit-inner-spin-button,
.ability-score-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ability-score-input[type="number"] {
  -moz-appearance: textfield;
}

.ability-score-input:focus {
  outline: none;
  border-color: var(--dice);
  background: color-mix(in srgb, var(--glass-bg) 40%, transparent);
}

.quickplay-footer {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  display: flex;
  gap: 12px;
  justify-content: center;
}

.quickplay-start-btn {
  font-size: 16px;
  padding: 14px 32px;
  font-weight: 700;
  pointer-events: auto !important; /* Ensure start button is always clickable */
}

/* Welcome Button for Quick Play */
.welcome-button-quick-play {
  background: linear-gradient(
    135deg,
    var(--dice),
    color-mix(in srgb, var(--dice) 85%, #fff)
  );
  border: 2px solid var(--dice);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 50%, transparent),
    0 0 24px color-mix(in srgb, var(--dice) 30%, transparent);
  animation: quickPlayPulse 2s ease-in-out infinite;
}

.welcome-button-quick-play:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--dice) 120%, #fff),
    var(--dice)
  );
  border-color: color-mix(in srgb, var(--dice) 120%, #fff);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--dice) 70%, transparent),
    0 0 40px color-mix(in srgb, var(--dice) 50%, transparent);
  filter: brightness(1.15);
}

.welcome-button-quick-play:active {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 50%, transparent),
    0 0 24px color-mix(in srgb, var(--dice) 30%, transparent);
  filter: brightness(1.1);
}

@keyframes quickPlayPulse {
  0%,
  100% {
    box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 50%, transparent),
      0 0 24px color-mix(in srgb, var(--dice) 30%, transparent);
  }
  50% {
    box-shadow: 0 4px 16px color-mix(in srgb, var(--dice) 60%, transparent),
      0 0 32px color-mix(in srgb, var(--dice) 40%, transparent);
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .quickplay-options {
    grid-template-columns: 1fr;
  }

  .quickplay-theme-grid {
    grid-template-columns: 1fr;
  }

  .quickplay-modal {
    width: 100%;
    max-width: none;
    margin: 10px;
  }

  .quickplay-modal.expanded {
    max-width: none;
  }

  .quickplay-body {
    max-height: calc(90vh - 100px);
  }

  .quickplay-footer {
    flex-direction: column;
  }

  .quickplay-start-btn {
    width: 100%;
  }

  .ability-scores-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Fix class icon grid overflow on mobile */
  .class-icon-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .class-icon-btn {
    padding: 10px 6px;
  }

  .class-icon-btn .class-icon {
    font-size: 24px;
  }

  .class-icon-btn .class-name {
    font-size: 10px;
  }
}

/* Mobile-specific: Hide donation tab panel on mobile, show in settings menu */
@media (max-width: 768px) {
  .donation-tab-panel {
    display: none !important;
  }
}

/* Desktop-specific: Hide mobile donate menu item on desktop */
@media (min-width: 769px) {
  .mobile-only-donate {
    display: none !important;
  }
}

/* ========================================
   TOME MODAL
   ======================================== */

.tome-modal {
  max-width: 800px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.tome-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tome-intro {
  background: color-mix(in srgb, var(--dice) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 8px;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.tome-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
}

.tome-save-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  padding: 12px 24px;
}

.tome-btn-icon {
  font-size: 18px;
}

.tome-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tome-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.tome-stat-icon {
  font-size: 18px;
}

/* Tome List */
.tome-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  padding-top: 6px;
}

.tome-list::-webkit-scrollbar {
  width: 10px;
}

.tome-list::-webkit-scrollbar-track {
  background: transparent;
}

.tome-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--dice) 30%, transparent);
  border-radius: 10px;
}

.tome-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--dice) 45%, transparent);
}

.tome-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  text-align: center;
  padding: 40px 20px;
}

.tome-empty-icon {
  font-size: 64px;
  opacity: 0.5;
}

.tome-empty-subtitle {
  font-size: 14px;
  opacity: 0.7;
}

/* Tome Entry Card */
.tome-entry {
  --tome-actions-space: 0px;
  background: var(--bg-secondary);
  border: 2px solid color-mix(in srgb, var(--dice) 20%, transparent);
  border-radius: 12px;
  padding: 18px 16px 20px;
  padding-bottom: calc(20px + var(--tome-actions-space, 0px));
  transition: all 0.2s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 0;
  min-height: calc(160px + var(--tome-actions-space, 0px));
}

.tome-entry:hover:not(.is-active) {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 8%, transparent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--dice) 30%, transparent);
  z-index: 2;
}

.tome-entry.is-active {
  border-color: var(--dice);
  background: color-mix(in srgb, var(--dice) 12%, transparent);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--dice) 32%, transparent);
  overflow: visible;
  z-index: 3;
}

.tome-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tome-entry-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.tome-entry-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--dice);
  margin: 0;
}

/* Character Info */
.tome-entry-header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.tome-entry-character-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.08);
  border: 1px solid rgba(var(--dice-rgb, 255, 107, 53), 0.2);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
  box-sizing: border-box;
}

.tome-character-name,
.tome-character-class,
.tome-character-level {
  font-size: 13px;
  line-height: 1;
}

.tome-entry-character-inline--fallback {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.06);
  border-color: rgba(var(--dice-rgb, 255, 107, 53), 0.18);
}

.tome-character-icon {
  font-size: 14px;
}

.tome-character-name {
  font-weight: 600;
  color: var(--text-primary);
}

.tome-character-class,
.tome-character-level {
  color: var(--text-secondary);
  font-weight: 500;
  padding-left: 6px;
  border-left: 1px solid rgba(var(--dice-rgb, 255, 107, 53), 0.3);
}

.tome-entry-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tome-inline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border-radius: 999px;
  font-size: 12px;
  background: color-mix(in srgb, var(--dice) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--dice) 20%, transparent);
  color: var(--text-primary);
  box-sizing: border-box;
}

.tome-inline-badge__icon {
  font-size: 14px;
}

.tome-inline-badge__label {
  font-weight: 500;
}

.tome-inline-badge--theme {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.tome-inline-badge--messages {
  background: color-mix(in srgb, var(--dice) 8%, transparent);
  border-color: color-mix(in srgb, var(--dice) 18%, transparent);
}

.tome-inline-badge--words {
  background: color-mix(in srgb, var(--mystic-blue) 12%, transparent);
  border-color: color-mix(in srgb, var(--mystic-blue) 26%, transparent);
}

/* Game Type Badge (NEW) */
.tome-entry-gametype {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
}

.tome-gametype-icon {
  font-size: 13px;
}

.tome-gametype-label {
  color: var(--text-primary);
  font-weight: 500;
}

.tome-entry-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tome-entry-preview {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.6em * 3 + 6px);
}

.tome-entry.is-active .tome-entry-preview {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
  display: block;
  margin-bottom: 16px;
  min-height: initial;
}

.tome-entry-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tome-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid color-mix(in srgb, var(--dice) 25%, transparent);
  background: color-mix(in srgb, var(--dice) 12%, transparent);
  color: var(--text-primary);
}

.tome-chip__label {
  font-weight: 500;
}

.tome-chip__icon {
  font-size: 14px;
}

.tome-chip--goal {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.tome-chip--character {
  background: color-mix(in srgb, var(--dice) 16%, transparent);
  border-color: color-mix(in srgb, var(--dice) 32%, transparent);
}

.tome-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
  padding-top: 0;
  border-top: 1px solid transparent;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-12px);
  transition: max-height 0.3s ease, opacity 0.2s ease, transform 0.2s ease,
    margin-top 0.2s ease, padding-top 0.2s ease, border-top-color 0.2s ease;
}

.tome-entry.is-active .tome-entry-actions {
  max-height: 320px;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  margin-top: 12px;
  padding-top: 12px;
  border-top-color: color-mix(in srgb, var(--dice) 15%, transparent);
}

.tome-entry-btn {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.1);
  border: 1px solid rgba(var(--dice-rgb, 255, 107, 53), 0.3);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 110px;
  min-height: 42px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tome-entry-btn span {
  font-size: 18px;
}

.tome-entry-btn:hover {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.2);
  border-color: var(--dice);
  transform: scale(1.05);
}

.tome-entry-btn:active {
  transform: scale(0.95);
}

.tome-entry-btn-primary {
  flex: 1 1 180px;
  font-weight: 600;
  background: linear-gradient(
    135deg,
    rgba(var(--dice-rgb, 255, 107, 53), 0.18) 0%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.26) 100%
  );
  border-color: rgba(var(--dice-rgb, 255, 107, 53), 0.45);
}

.tome-entry-btn-primary:hover {
  background: linear-gradient(
    135deg,
    rgba(var(--dice-rgb, 255, 107, 53), 0.24) 0%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.34) 100%
  );
  border-color: var(--dice);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(var(--dice-rgb, 255, 107, 53), 0.2);
}

.tome-entry-btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--dice-rgb, 255, 107, 53), 0.18);
}

.tome-entry-btn-read {
  flex: 1 1 150px;
  border-color: color-mix(in srgb, var(--mystic-blue) 30%, transparent);
}

.tome-entry-btn-read:hover {
  background: color-mix(in srgb, var(--mystic-blue) 20%, transparent);
  border-color: var(--mystic-blue);
}

.tome-entry-btn-download {
  flex: 1;
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.tome-entry-btn-download:hover {
  background: color-mix(in srgb, var(--success) 20%, transparent);
  border-color: var(--success);
}

.tome-entry-btn-danger {
  flex: 0 0 auto;
  padding: 8px 12px;
  min-width: 72px;
  max-width: 104px;
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
  margin-left: auto;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.tome-entry-btn-danger span {
  font-size: 16px;
}

.tome-entry-btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #ef4444;
}

.tome-entry-btn-danger:active {
  transform: scale(0.93);
}

.tome-dialog {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(6, 11, 23, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 11000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tome-dialog.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tome-dialog__panel {
  background: var(--bg-secondary);
  border: 1px solid rgba(var(--dice-rgb, 255, 107, 53), 0.35);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(4, 6, 16, 0.55);
  width: min(100%, 420px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: translateY(12px);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.tome-dialog.is-visible .tome-dialog__panel {
  transform: translateY(0);
}

.tome-dialog__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--heading);
}

.tome-dialog__title--center {
  text-align: center;
}

.tome-dialog__body {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.tome-dialog__description {
  margin: 0;
}

.tome-dialog__description--center {
  text-align: center;
}

.tome-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.tome-dialog__actions--separated {
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  flex-wrap: wrap;
}

.tome-dialog__actions--separated .tome-dialog__button:first-child {
  margin-right: auto;
}

.tome-dialog__button {
  border: 1px solid transparent;
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.08);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  min-width: 110px;
}

.tome-dialog__button:hover {
  transform: translateY(-1px);
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.14);
}

.tome-dialog__button:active {
  transform: translateY(0);
}

.tome-dialog__button--primary {
  background: linear-gradient(
    135deg,
    rgba(var(--dice-rgb, 255, 107, 53), 0.18) 0%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.32) 100%
  );
  border-color: rgba(var(--dice-rgb, 255, 107, 53), 0.45);
}

.tome-dialog__button--primary:hover {
  background: linear-gradient(
    135deg,
    rgba(var(--dice-rgb, 255, 107, 53), 0.24) 0%,
    rgba(var(--dice-rgb, 255, 107, 53), 0.38) 100%
  );
}

.tome-dialog__button--ghost {
  background: transparent;
  border-color: rgba(var(--dice-rgb, 255, 107, 53), 0.22);
}

.tome-dialog__button--ghost:hover {
  background: rgba(var(--dice-rgb, 255, 107, 53), 0.12);
}

.tome-dialog__button--danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ff6961;
}

.tome-dialog__button--danger:hover {
  background: rgba(239, 68, 68, 0.24);
  border-color: #ef4444;
}

.tome-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tome-dialog__input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(var(--dice-rgb, 255, 107, 53), 0.28);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.tome-dialog__input:focus {
  outline: none;
  border-color: var(--dice);
  box-shadow: 0 0 0 2px rgba(var(--dice-rgb, 255, 107, 53), 0.3);
}

.tome-dialog__error {
  color: var(--damage-fire);
  font-size: 0.85rem;
  min-height: 1.2em;
}

@media (max-width: 600px) {
  .tome-dialog {
    padding: 16px;
  }

  .tome-dialog__panel {
    width: min(100%, 360px);
    padding: 20px;
  }

  .tome-dialog__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .tome-dialog__button {
    width: 100%;
    min-width: 0;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .tome-modal {
    width: 100%;
    max-width: none;
    margin: 10px;
    max-height: calc(100vh - 20px);
  }

  .tome-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .tome-save-btn {
    width: 100%;
    justify-content: center;
  }

  .tome-stats {
    justify-content: center;
  }

  .tome-entry-header {
    flex-direction: column;
    gap: 8px;
  }

  .tome-entry-date {
    align-self: flex-start;
  }
}

/* ============================================
   TEXT PROCESSING SETTINGS MODAL
   ============================================ */

.unimplemented-option {
  opacity: 0.5;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.unimplemented-option input[type="checkbox"],
.unimplemented-option input[type="radio"] {
  cursor: not-allowed;
}

.unimplemented-option span {
  color: #888;
}

/* ============================================
   ACCOUNT PILL - HIDDEN
   ============================================ */

.account-pill {
  display: none !important;
}

/* ============================================
   END OF STYLES
   ============================================ */
