:root {
  --font-display: 'Cinzel', serif;
  --font-medieval: 'MedievalSharp', cursive, serif;
  --font-body: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Rustic D&D Palette */
  --bg-app: #0c0805;
  --bg-canvas: #070503;
  --bg-wood-panel: rgba(26, 17, 12, 0.88);
  --bg-wood-hover: rgba(38, 25, 17, 0.94);
  --bg-wood-active: rgba(54, 35, 24, 0.98);
  --bg-parchment-card: rgba(28, 19, 13, 0.94);
  --bg-parchment-light: #f7f1e1;

  --border-gold: #d4af37;
  --border-gold-subtle: rgba(212, 175, 55, 0.35);
  --border-brass: #854d0e;
  --border-wood: #452b19;
  --border-wood-subtle: rgba(69, 43, 25, 0.6);

  /* Gold & Ember Accents */
  --primary: #d4af37;
  --primary-hover: #f59e0b;
  --primary-glow: rgba(212, 175, 55, 0.45);
  --accent: #b45309;
  --accent-glow: rgba(180, 83, 9, 0.4);

  --success: #15803d;
  --warning: #d97706;
  --danger: #b91c1c;

  --text-primary: #fef3c7;
  --text-secondary: #d6bc97;
  --text-muted: #9c8265;
  --text-ink: #1c130d;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.75), inset 0 0 12px rgba(0, 0, 0, 0.5);
  --shadow-gold-glow: 0 0 20px var(--primary-glow);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --glass-blur: blur(14px);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Canvas Container */
#vtt-canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: radial-gradient(circle at center, #150f0a 0%, #050302 100%);
  cursor: default;
}

/* HUD Overlay Layer */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;
  padding: 16px;
  gap: 16px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Rustic Carved Wood & Parchment Foundation */
.glass {
  background: var(--bg-wood-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 2px solid var(--border-wood);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-gold-subtle);
  border-radius: var(--radius-md);
  pointer-events: auto;
  position: relative;
}

.glass::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: calc(var(--radius-md) - 2px);
  pointer-events: none;
}

.hud-panel {
  transition: all var(--transition-fast);
}

/* Top Navigation Bar */
#top-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  height: 56px;
  gap: 10px;
  overflow: visible;
  max-width: 100%;
  animation: slideDown var(--transition-spring);
  position: relative;
  z-index: 60;
}

@keyframes slideDown {
  from {
    transform: translateY(-40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 24px;
  color: var(--primary);
  display: flex;
  align-items: center;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.brand-accent {
  color: var(--primary);
  margin-left: 4px;
  background: linear-gradient(135deg, #fbbf24 0%, #d4af37 50%, #b45309 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.scene-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
  position: relative;
}

.player-presence-toggle:hover {
  border-color: var(--border-gold) !important;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.3) !important;
}

.party-member-row:hover {
  background: rgba(251, 191, 36, 0.1) !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
  transform: translateY(-1px);
}

@keyframes fadeInSlideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.scene-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-badge {
  font-family: var(--font-medieval);
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-gold-subtle);
  white-space: nowrap;
  flex-shrink: 0;
}

.top-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Antique Buttons */
.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  font-family: var(--font-medieval);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: linear-gradient(180deg, #2d1d13 0%, #1a110b 100%);
  border: 1px solid var(--border-gold-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all var(--transition-fast);
}

.hud-btn:hover {
  background: linear-gradient(180deg, #3d281a 0%, #261910 100%);
  border-color: var(--border-gold);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(0);
}

.hud-btn.primary {
  background: linear-gradient(180deg, #92400e 0%, #78350f 50%, #451a03 100%);
  border-color: var(--border-gold);
  color: #fef3c7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 12px var(--primary-glow);
}

.hud-btn.primary:hover {
  background: linear-gradient(180deg, #b45309 0%, #92400e 50%, #78350f 100%);
  box-shadow: 0 0 18px var(--primary-glow);
}

/* Left Toolbar */
#toolbar {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  width: 52px;
  animation: slideRight var(--transition-spring);
}

@keyframes slideRight {
  from {
    transform: translateX(-40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-wood-subtle);
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.tool-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--border-gold);
  color: #fff;
  transform: scale(1.06);
}

.tool-btn.active {
  background: linear-gradient(135deg, #78350f 0%, #451a03 100%);
  color: #fef3c7;
  border-color: var(--border-gold);
  box-shadow: 0 0 14px var(--primary-glow), inset 0 0 6px rgba(212, 175, 55, 0.4);
  transform: scale(1.08);
}

.tool-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: var(--bg-parchment-card);
  font-family: var(--font-body);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--border-gold-subtle);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  z-index: 100;
}

.tool-btn:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Viewport Stats */
#viewport-stats {
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  animation: slideUp var(--transition-spring);
}

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

.stat-divider {
  color: var(--border-gold-subtle);
}

/* Sidebar */
#sidebar {
  grid-column: 3;
  grid-row: 2 / span 2;
  width: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 100px);
  animation: slideLeft var(--transition-spring);
}

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

.sidebar-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-wood);
  background: rgba(0, 0, 0, 0.4);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-medieval);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(212, 175, 55, 0.06);
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--border-gold);
  background: rgba(212, 175, 55, 0.12);
  text-shadow: 0 0 8px var(--primary-glow);
}

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px;
}

/* Chat & Dice Roller */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-wood);
  border-radius: 4px;
}

.chat-msg {
  position: relative;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-wood-subtle);
  font-size: 0.95rem;
  font-family: var(--font-body);
}

.chat-msg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-msg-header .sender {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
  margin-bottom: 0;
  letter-spacing: 0.03em;
  min-width: 0;
  flex: 1;
}

.chat-timestamp {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  color: var(--text-muted, rgba(212, 175, 55, 0.55));
  opacity: 0.75;
  white-space: nowrap;
  letter-spacing: 0.02em;
  user-select: none;
  flex-shrink: 0;
  margin-left: auto;
  line-height: 1.3;
  padding-top: 1px;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.chat-msg:hover .chat-timestamp {
  opacity: 1;
  color: var(--border-gold, #fbbf24);
}

.chat-msg .sender {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
  margin-bottom: 2px;
  letter-spacing: 0.03em;
}

.chat-msg.dice-roll {
  background: linear-gradient(135deg, rgba(45, 29, 19, 0.6) 0%, rgba(20, 12, 7, 0.8) 100%);
  border-color: var(--border-gold-subtle);
  animation: diceMsgFly 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes diceMsgFly {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dice-result-bubble {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px dashed rgba(212, 175, 55, 0.2);
}

.dice-total {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.dice-total.crit {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.9);
  animation: critPulse 1s infinite alternate;
}

@keyframes critPulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

.dice-total.fumble {
  color: #f87171;
  text-shadow: 0 0 8px rgba(248, 113, 113, 0.8);
}

.dice-breakdown {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chat-input::placeholder {
  color: #8c7e72;
  opacity: 0.85;
}

.chat-input:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 8px var(--primary-glow);
}

/* Quick Dice Bar */
.quick-dice-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-dice-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  background: linear-gradient(180deg, #261910 0%, #150d08 100%);
  border: 1px solid var(--border-wood);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-medieval);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-dice-btn:hover {
  background: linear-gradient(180deg, #3d281a 0%, #261910 100%);
  border-color: var(--border-gold);
  color: #fff;
  box-shadow: 0 0 8px var(--primary-glow);
  transform: translateY(-2px);
}

/* Initiative Tracker */
.initiative-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.initiative-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-wood-subtle);
  transition: all var(--transition-spring);
}

.initiative-card.active-turn {
  background: linear-gradient(90deg, rgba(120, 53, 15, 0.4) 0%, rgba(69, 26, 3, 0.6) 100%);
  border-color: var(--border-gold);
  box-shadow: 0 0 16px var(--primary-glow), inset 0 0 6px rgba(212, 175, 55, 0.3);
  transform: scale(1.02);
}

.init-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: #1a110b;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.init-info {
  flex: 1;
}

.init-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.init-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

.init-score-input {
  width: 44px;
  padding: 3px 4px;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: #fbbf24;
  font-family: var(--font-mono);
  font-weight: bold;
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.init-score-input:focus {
  border-color: #fef08a;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
  background: rgba(20, 10, 5, 0.9);
}

.init-score-input::-webkit-inner-spin-button,
.init-score-input::-webkit-outer-spin-button {
  opacity: 0.7;
}

.init-score-input.is-dirty {
  border-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.55) !important;
  background: rgba(35, 20, 5, 0.95) !important;
  color: #fef08a !important;
}

.init-confirm-btn {
  height: 24px;
  min-width: 22px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid #4ade80;
  border-radius: var(--radius-sm);
  color: #4ade80;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: bold;
  line-height: 1;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.35);
  transition: all var(--transition-fast);
}

.init-confirm-btn:hover {
  background: rgba(34, 197, 94, 0.45);
  border-color: #86efac;
  color: #86efac;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
  transform: scale(1.05);
}

.init-confirm-btn:active {
  transform: scale(0.95);
}

/* Scene Modal Thumbnail Stacking Buttons */
.stack-scene-btn {
  position: absolute;
  bottom: 4px;
  left: 4px;
  z-index: 5;
  padding: 2px 6px;
  background: rgba(10, 8, 5, 0.88);
  border: 1px solid rgba(234, 179, 8, 0.65);
  border-radius: 4px;
  color: #fbbf24;
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  transition: all var(--transition-fast);
  backdrop-filter: blur(4px);
  line-height: 1.2;
}

.stack-scene-btn:hover {
  background: rgba(234, 179, 8, 0.35);
  border-color: #fef08a;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
}

.stack-scene-btn.is-stacked {
  background: rgba(168, 85, 247, 0.4);
  border-color: #c084fc;
  color: #f3e8ff;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

.stack-scene-btn.is-stacked:hover {
  background: rgba(239, 68, 68, 0.4);
  border-color: #f87171;
  color: #fee2e2;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 5, 12, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: auto;
  animation: modalFadeIn 200ms ease-out;
}

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

.modal-content {
  background: var(--bg-wood-panel);
  border: 2px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 25px rgba(212, 175, 55, 0.3);
  width: 90%;
  max-width: 480px;
  max-height: 94vh;
  overflow-y: auto;
  padding: 24px;
  animation: modalPopIn var(--transition-spring);
}

/* Suppress .glass::before absolute border and redundant backdrop-filter on modal dialogs.
   .modal-backdrop already provides full-screen blur over the canvas; re-filtering on the modal
   card itself triggers intense GPU fragment shader thrashing and scroll lag. */
.modal-content::before,
.modal-content.glass::before {
  display: none !important;
}

.modal-content.glass,
.modal-content,
.settings-modal-card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

@keyframes modalPopIn {
  from {
    transform: scale(0.85) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-gold-subtle);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════
   🎲 3D FLIGHT DRAGON DICE ANIMATION OVERLAY
   ═══════════════════════════════════════════════════════════ */
.flight-dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 20, 13, 0.65) 0%, rgba(0, 0, 0, 0.85) 100%);
  backdrop-filter: blur(6px);
  cursor: pointer;
  animation: overlayFadeIn 250ms ease-out;
  transition: opacity 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.flight-dice-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

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

.flight-dice-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  cursor: default;
}

.flight-sender-badge {
  animation: badgeDrop 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgeDrop {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.flight-die-mesh {
  width: 130px;
  height: 130px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
}

.flight-dice-container.tumbling .flight-die-mesh {
  animation: diceTumble 700ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes diceTumble {
  0% {
    transform: scale(0.35) translate3d(0, 180px, -200px) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    opacity: 0.2;
  }
  40% {
    transform: scale(1.35) translate3d(0, -45px, 80px) rotateX(360deg) rotateY(270deg) rotateZ(180deg);
    opacity: 1;
  }
  75% {
    transform: scale(1.05) translate3d(0, 12px, 0px) rotateX(720deg) rotateY(540deg) rotateZ(360deg);
  }
  100% {
    transform: scale(1) translate3d(0, 0, 0) rotateX(720deg) rotateY(720deg) rotateZ(720deg);
  }
}

.flight-dice-container.landed .flight-die-mesh {
  animation: diceLandImpact 450ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes diceLandImpact {
  0% {
    transform: scale(1.28);
    filter: drop-shadow(0 0 45px var(--primary-glow));
  }
  45% {
    transform: scale(0.94);
  }
  75% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.flight-die-face {
  width: 115px;
  height: 115px;
  background: linear-gradient(145deg, #92400e 0%, #5a2307 45%, #240d02 100%);
  border: 3px solid var(--border-gold);
  border-radius: 24px;
  box-shadow: 0 0 50px var(--primary-glow), inset 0 0 25px rgba(212, 175, 55, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  transition: all 250ms ease;
}

.flight-die-total.crit {
  color: #34d399;
  text-shadow: 0 0 30px rgba(52, 211, 153, 1), 0 0 10px #34d399;
  animation: critGlowPulse 1.2s infinite alternate;
}

@keyframes critGlowPulse {
  from { transform: scale(1); filter: drop-shadow(0 0 8px #34d399); }
  to { transform: scale(1.08); filter: drop-shadow(0 0 20px #34d399); }
}

.flight-die-total.fumble {
  color: #f87171;
  text-shadow: 0 0 30px rgba(248, 113, 113, 1), 0 0 10px #f87171;
}

.flight-result-details {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: detailsPopUp 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes detailsPopUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.flight-formula {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.flight-breakdown {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-gold-subtle);
}

.flight-banner {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 7px 20px;
  border-radius: var(--radius-full);
}

.flight-banner.crit {
  background: rgba(16, 185, 129, 0.3);
  border: 2px solid #10b981;
  color: #34d399;
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.8);
  animation: bannerPulse 1.2s infinite alternate;
}

.flight-banner.fumble {
  background: rgba(239, 68, 68, 0.3);
  border: 2px solid #ef4444;
  color: #f87171;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.8);
}

.flight-crit-glow .flight-die-face {
  background: linear-gradient(145deg, #065f46 0%, #047857 50%, #022c22 100%);
  border-color: #34d399;
  box-shadow: 0 0 70px rgba(52, 211, 153, 0.95), inset 0 0 25px rgba(52, 211, 153, 0.6);
}

.flight-fumble-glow .flight-die-face {
  background: linear-gradient(145deg, #991b1b 0%, #7f1d1d 50%, #450a0a 100%);
  border-color: #f87171;
  box-shadow: 0 0 70px rgba(248, 113, 113, 0.95), inset 0 0 25px rgba(248, 113, 113, 0.6);
}

/* ⚡ Critical Hit & Fumble Screen FX */
@keyframes screenFumbleShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  12% { transform: translate(-7px, 5px) rotate(-1.2deg); }
  24% { transform: translate(7px, -4px) rotate(1.2deg); }
  36% { transform: translate(-6px, 4px) rotate(-0.8deg); }
  48% { transform: translate(5px, -3px) rotate(0.8deg); }
  60% { transform: translate(-3px, 2px) rotate(-0.4deg); }
  75% { transform: translate(2px, -1px) rotate(0.2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.flight-fumble-shake {
  animation: screenFumbleShake 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes critSunburstSpin {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(0.9); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) rotate(180deg) scale(1.1); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) rotate(360deg) scale(0.9); opacity: 0.6; }
}

.flight-crit-sunburst-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.35) 0%, rgba(52, 211, 153, 0.25) 40%, transparent 70%);
  filter: blur(25px);
  pointer-events: none;
  z-index: 1;
  animation: critSunburstSpin 6s linear infinite;
}

.flight-fumble-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 35%, rgba(185, 28, 28, 0.45) 85%, rgba(127, 29, 29, 0.75) 100%);
  box-shadow: inset 0 0 100px rgba(220, 38, 38, 0.8);
  z-index: 1;
}

/* Advantage & Disadvantage Dual Dice Animations */
.flight-dual-dice-mesh {
  perspective: 1200px;
}

.flight-die-mesh.kept-die {
  animation: keptDiePop 600ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  z-index: 10;
}

@keyframes keptDiePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.22); filter: drop-shadow(0 0 45px rgba(52, 211, 153, 0.9)); }
  100% { transform: scale(1.15); filter: drop-shadow(0 0 35px rgba(52, 211, 153, 0.75)); }
}

.flight-die-face.kept-face {
  border-color: #34d399 !important;
  box-shadow: 0 0 50px rgba(52, 211, 153, 0.85), inset 0 0 25px rgba(52, 211, 153, 0.5) !important;
}

.flight-die-mesh.kicked-die-left {
  animation: kickDieLeft 750ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes kickDieLeft {
  0% {
    transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: scale(1.08) translate3d(-30px, -20px, 20px) rotate(-15deg);
  }
  100% {
    transform: scale(0.65) translate3d(-140px, 80px, -150px) rotate(-45deg);
    opacity: 0.22;
    filter: grayscale(1) blur(1px);
  }
}

.flight-die-mesh.kicked-die-right {
  animation: kickDieRight 750ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes kickDieRight {
  0% {
    transform: scale(1) translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: scale(1.08) translate3d(30px, -20px, 20px) rotate(15deg);
  }
  100% {
    transform: scale(0.65) translate3d(140px, 80px, -150px) rotate(45deg);
    opacity: 0.22;
    filter: grayscale(1) blur(1px);
  }
}

/* ⚔️ On-Deck Notification Popup */
.on-deck-popup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  z-index: 70;
}

.on-deck-popup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  background: linear-gradient(135deg, rgba(30, 20, 10, 0.96) 0%, rgba(18, 10, 5, 0.98) 100%);
  border: 1.5px solid #fbbf24;
  border-radius: 10px;
  box-shadow: 0 0 25px rgba(251, 191, 36, 0.45), 0 10px 30px rgba(0, 0, 0, 0.85);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.88rem;
  white-space: nowrap;
  animation: onDeckPopIn 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(12px);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.on-deck-popup:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(251, 191, 36, 0.6), 0 12px 35px rgba(0, 0, 0, 0.9);
}

.on-deck-stem {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #fbbf24;
  margin-top: -1px;
}

@keyframes onDeckPopIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.on-deck-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: rgba(251, 191, 36, 0.25);
  border: 1px solid #fbbf24;
  border-radius: 5px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ==========================================================================
   🔴 Unread Chat & Roll Counter Badge
   ========================================================================== */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(254, 202, 202, 0.6);
  animation: unreadBadgePulse 2s infinite ease-in-out;
  margin-left: 6px;
  pointer-events: none;
  vertical-align: middle;
}

@keyframes unreadBadgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 16px rgba(239, 68, 68, 1);
  }
}

/* ==========================================================================
   📍 Real-Time Interactive Map Pings
   ========================================================================== */
.map-ping-container {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.map-ping-core {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  transform: translate(-50%, -50%);
  animation: pingCorePulse 3.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.map-ping-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border-style: solid;
  border-width: 2.5px;
  box-sizing: border-box;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}

.map-ping-ring.ring-1 {
  animation: pingRipple 1.8s cubic-bezier(0.1, 0.7, 0.1, 1) infinite;
}

.map-ping-ring.ring-2 {
  animation: pingRipple 1.8s cubic-bezier(0.1, 0.7, 0.1, 1) 0.5s infinite;
}

.map-ping-ring.ring-3 {
  animation: pingRipple 1.8s cubic-bezier(0.1, 0.7, 0.1, 1) 1s infinite;
}

@keyframes pingRipple {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.08);
  }
  75% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes pingCorePulse {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  85% {
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
}

.map-ping-tag {
  position: absolute;
  top: -16px;
  left: 0;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  font-family: var(--font-display, sans-serif);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.03em;
  backdrop-filter: blur(8px);
  animation: pingTagFade 3.5s ease-out forwards;
}

.map-ping-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

@keyframes pingTagFade {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-100% + 6px));
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -100%);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 8px));
  }
}

/* ==========================================================================
   💓 Low HP Critical Heartbeat Screen Vignette
   ========================================================================== */
.low-hp-vignette {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 6;
  transition: opacity 0.5s ease;
}

.low-hp-vignette.critical {
  animation: heartbeatVignette 1.4s infinite cubic-bezier(0.25, 0.1, 0.25, 1);
}

.low-hp-vignette.unconscious {
  animation: unconsciousHeartbeat 1.1s infinite cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes heartbeatVignette {
  0% {
    box-shadow: inset 0 0 50px rgba(185, 28, 28, 0.35), inset 0 0 100px rgba(127, 29, 29, 0.2);
    opacity: 0.5;
  }
  15% {
    box-shadow: inset 0 0 110px rgba(239, 68, 68, 0.75), inset 0 0 180px rgba(153, 27, 27, 0.5);
    opacity: 0.95;
  }
  28% {
    box-shadow: inset 0 0 65px rgba(185, 28, 28, 0.45), inset 0 0 110px rgba(127, 29, 29, 0.25);
    opacity: 0.65;
  }
  42% {
    box-shadow: inset 0 0 120px rgba(220, 38, 38, 0.8), inset 0 0 200px rgba(185, 28, 28, 0.55);
    opacity: 1;
  }
  100% {
    box-shadow: inset 0 0 50px rgba(185, 28, 28, 0.35), inset 0 0 100px rgba(127, 29, 29, 0.2);
    opacity: 0.5;
  }
}

@keyframes unconsciousHeartbeat {
  0% {
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.85), inset 0 0 140px rgba(153, 27, 27, 0.5);
    opacity: 0.8;
  }
  18% {
    box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.95), inset 0 0 220px rgba(220, 38, 38, 0.75);
    opacity: 1;
  }
  30% {
    box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.88), inset 0 0 160px rgba(185, 28, 28, 0.55);
    opacity: 0.85;
  }
  45% {
    box-shadow: inset 0 0 170px rgba(0, 0, 0, 0.98), inset 0 0 240px rgba(239, 68, 68, 0.85);
    opacity: 1;
  }
  100% {
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.85), inset 0 0 140px rgba(153, 27, 27, 0.5);
    opacity: 0.8;
  }
}

@keyframes spinSlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════════════════════════════════════
   ⚙️ SETTINGS MODAL & NAVIGATION SYSTEM
   ═══════════════════════════════════════════════════════════ */
.settings-nav-item:hover {
  background: rgba(212, 175, 55, 0.1) !important;
  color: #fff !important;
  border-color: rgba(212, 175, 55, 0.3) !important;
}

.settings-nav-item.active {
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.18);
}

@media (max-width: 680px) {
  .settings-modal-card {
    height: 94vh !important;
    max-height: unset !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   🚀 HARDWARE-ACCELERATED GPU SCROLL OPTIMIZATIONS
   ═══════════════════════════════════════════════════════════ */
.settings-scroll-nav,
.settings-scroll-pane,
.modal-scroll-pane,
.token-scroll-body,
.tokens-scroll-list {
  transform: translateZ(0);
  scroll-behavior: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}


