:root {
  --obsidian: #0d0b0f;
  --void: #130f17;
  --deep: #1a1525;
  --surface: #231c30;
  --elevated: #2d2440;
  --border: #3d3358;
  --gold: #c9a227;
  --gold-light: #e8c060;
  --gold-dim: #6b5512;
  --crimson: #8b1a1a;
  --crimson-bright: #c0392b;
  --arcane: #7b4fa6;
  --arcane-bright: #a855f7;
  --sage: #2d5a27;
  --sage-bright: #4ade80;
  --steel: #94a3b8;
  --parchment: #e8d5a3;
  --parchment-dark: #c4a96b;
  --text-main: #e8d5c4;
  --text-muted: #8a7a6a;
  --text-dim: #5a4f44;
  --hp-green: #22c55e;
  --hp-yellow: #eab308;
  --hp-red: #ef4444;
  --glow-gold: 0 0 20px rgba(201, 162, 39, 0.4);
  --glow-arcane: 0 0 20px rgba(168, 85, 247, 0.4);
  --bs-body-color: var(--text-main);

  /* Mobile Safe Areas */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

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

body {
  font-family: 'EB Garamond', serif;
  background: var(--obsidian);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(123, 79, 166, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 26, 26, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(201, 162, 39, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='none'/%3E%3Crect x='0' y='0' width='1' height='1' fill='rgba(255,255,255,0.015)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ─── SIDEBAR COLLAPSIBLE ─── */
.sidebar {
  width: 72px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  border-right: none;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  background: var(--void);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  gap: 4px;
  position: relative;
  flex-shrink: 0;
}

.sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--gold-dim), transparent);
}

.app-logo {
  width: 44px;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.app-logo:hover {
  border-color: var(--gold);
  box-shadow: var(--glow-gold);
}

.app-logo svg {
  width: 24px;
  height: 24px;
  fill: var(--gold);
}

.nav-item {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  color: var(--text-muted);
  border: 1px solid transparent;
  gap: 3px;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--parchment);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--surface);
  color: var(--gold);
  border-color: var(--gold-dim);
  box-shadow: inset 0 0 20px rgba(201, 162, 39, 0.1);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-label {
  font-size: 7px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.dnd-icon {
  display: inline-block;
  vertical-align: middle;
  background-color: currentColor;
  -webkit-mask-image: var(--icon-url);
  mask-image: var(--icon-url);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  flex-shrink: 0;
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── TOPBAR ─── */
.topbar {
  min-height: 60px;
  height: calc(60px + env(safe-area-inset-top, 0px));
  background: rgba(19, 15, 23, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  padding-top: env(safe-area-inset-top, 0px);
  gap: 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  color: var(--parchment);
  letter-spacing: 1px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title span {
  color: var(--gold);
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  gap: 8px;
  width: 220px;
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.1);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: 'EB Garamond', serif;
  font-size: 14px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  color: var(--text-muted);
  font-size: 14px;
}

.topbar-btn {
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.2s;
}

.topbar-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--arcane), var(--crimson));
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--gold-light);
  cursor: pointer;
  font-weight: 700;
}

/* ─── SCREEN CONTAINER ─── */
.screen {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--void);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ─── SECTION HEADER ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title span {
  color: var(--gold);
}

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
}

.card:hover {
  border-color: rgba(201, 162, 39, 0.3);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card-divider {
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
  margin: 12px 0;
}

/* ─── DASHBOARD SCREEN ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.character-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  grid-row: span 2;
  position: relative;
  overflow: hidden;
}

.character-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold), var(--gold-dim));
}

.char-portrait {
  width: 100%;
  height: 180px;
  background: linear-gradient(160deg, var(--deep) 0%, var(--void) 100%);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.char-portrait::after {
  content: '⚔';
  font-size: 64px;
  opacity: 0.15;
  position: absolute;
  right: 10px;
  bottom: 5px;
  transform: rotate(25deg);
}

.portrait-placeholder {
  font-size: 72px;
  filter: drop-shadow(0 0 20px rgba(201, 162, 39, 0.3));
}

.char-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 20px;
  color: var(--parchment);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.char-subtitle {
  font-size: 13px;
  color: var(--gold);
  font-style: italic;
  margin-bottom: 20px;
}

.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
  border: 1px solid;
}

.tag-class {
  background: rgba(139, 26, 26, 0.2);
  border-color: var(--crimson);
  color: #f87171;
}

.tag-race {
  background: rgba(45, 90, 39, 0.2);
  border-color: var(--sage);
  color: var(--sage-bright);
}

.tag-level {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold-dim);
  color: var(--gold-light);
}

.tag-bg {
  background: rgba(123, 79, 166, 0.2);
  border-color: var(--arcane);
  color: var(--arcane-bright);
}

.hp-section {
  margin-bottom: 20px;
}

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

.hp-label-text {
  font-size: 11px;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hp-value {
  font-size: 16px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--hp-green);
}

.hp-bar {
  height: 8px;
  background: var(--deep);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--hp-green), #86efac);
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
}

.hp-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), transparent);
}

.stats-grid-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-mini {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.stat-mini:hover {
  border-color: var(--gold-dim);
  background: var(--elevated);
}

.stat-mini-name {
  font-size: 9px;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-mini-score {
  font-size: 18px;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--parchment);
}

.stat-mini-mod {
  font-size: 11px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
}

.ac-speed-row {
  display: flex;
  gap: 8px;
}

.badge-stat {
  flex: 1;
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.badge-stat-icon {
  font-size: 16px;
  margin-bottom: 2px;
}

.badge-stat-val {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

.badge-stat-lbl {
  font-size: 9px;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Right side dashboard */
.dash-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quick-actions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

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

.action-btn {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold-dim);
}

.action-btn:hover::before {
  opacity: 1;
}

.action-btn.btn-crimson:hover {
  border-color: var(--crimson);
  background: rgba(139, 26, 26, 0.15);
}

.action-btn.btn-arcane:hover {
  border-color: var(--arcane);
  background: rgba(123, 79, 166, 0.15);
}

.action-btn.btn-sage:hover {
  border-color: var(--sage);
  background: rgba(45, 90, 39, 0.15);
}

.action-btn.btn-gold:hover {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}

.action-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.action-label {
  font-size: 10px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Spells section */
.spells-quick {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  flex: 1;
}

.spell-slots {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.spell-level-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.spell-level-num {
  font-size: 9px;
  font-family: 'Cinzel', serif;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.slot-dots {
  display: flex;
  gap: 3px;
}

.slot-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--arcane);
  background: var(--arcane);
  transition: all 0.2s;
  cursor: pointer;
}

.slot-dot.used {
  background: transparent;
  border-color: var(--border);
}

.spell-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-item {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.spell-item:hover {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(123, 79, 166, 0.1);
}

.spell-school {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.school-evoc {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.school-abjur {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.school-trans {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.school-conj {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.school-illu {
  background: rgba(20, 184, 166, 0.15);
  border: 1px solid rgba(20, 184, 166, 0.3);
}

.spell-info {
  flex: 1;
}

.spell-name {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  color: var(--parchment);
}

.spell-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.spell-slot-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-family: 'Cinzel', serif;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--arcane-bright);
}

/* Recent activity */
.activity-feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(61, 51, 88, 0.5);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.4;
}

.activity-time {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* ─── CHARACTER SHEET SCREEN ─── */
.sheet-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
}

.ability-scores-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ability-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.ability-card:hover {
  border-color: var(--gold-dim);
  transform: translateX(4px);
}

.ability-card.selected {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.05);
  box-shadow: inset 0 0 20px rgba(201, 162, 39, 0.05);
}

.ability-name {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ability-score {
  font-family: 'Cinzel Decorative', serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--parchment);
  line-height: 1;
}

.ability-mod {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--gold);
  font-weight: 600;
}

.ability-saves {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 6px;
}

.save-pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
}

.save-pip.proficient {
  background: var(--gold);
  border-color: var(--gold);
}

.sheet-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.skill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}

.skill-item:hover {
  background: var(--elevated);
}

.skill-prof-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}

.skill-prof-dot.prof {
  background: var(--gold);
  border-color: var(--gold);
}

.skill-prof-dot.expertise {
  background: var(--arcane-bright);
  border-color: var(--arcane-bright);
}

.skill-half-prof {
  width: 8px;
  height: 8px;
  background: rgba(201, 162, 39, 0.3);
  border: 1.5px solid var(--gold-dim);
  border-radius: 2px;
  flex-shrink: 0;
}

.skill-name {
  flex: 1;
  color: var(--text-main);
}

.skill-attr {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

.skill-bonus {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  min-width: 24px;
  text-align: right;
}

/* Combat stats */
.combat-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.combat-stat {
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.combat-stat-val {
  font-family: 'Cinzel Decorative', serif;
  font-size: 28px;
  color: var(--parchment);
  line-height: 1;
}

.combat-stat-lbl {
  font-size: 9px;
  font-family: 'Cinzel', serif;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── SPELLS SCREEN ─── */
.spells-layout {
  display: flex;
  gap: 20px;
}

.spells-sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
  color: var(--text-muted);
}

.spell-filter.active {
  border-color: var(--arcane);
  background: rgba(123, 79, 166, 0.15);
  color: var(--arcane-bright);
}

.spell-filter:hover {
  border-color: var(--border);
  color: var(--parchment);
}

.spell-filter-count {
  background: var(--elevated);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  color: var(--text-dim);
}

.spells-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* .spell-level-section empty ruleset removed */

.spell-level-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.spell-level-label {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.spell-level-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
}

.spell-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.spell-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.spell-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.spell-card.evoc::before {
  background: linear-gradient(90deg, var(--crimson-bright), transparent);
}

.spell-card.abjur::before {
  background: linear-gradient(90deg, #3b82f6, transparent);
}

.spell-card.trans::before {
  background: linear-gradient(90deg, #eab308, transparent);
}

.spell-card.conj::before {
  background: linear-gradient(90deg, var(--arcane-bright), transparent);
}

.spell-card.illu::before {
  background: linear-gradient(90deg, #14b8a6, transparent);
}

.spell-card.nec::before {
  background: linear-gradient(90deg, #84cc16, transparent);
}

.spell-card:hover {
  transform: translateY(-2px);
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.spell-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.spell-card-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--parchment);
  font-weight: 600;
}

.spell-ritual {
  color: var(--gold);
  font-size: 12px;
}

.spell-card-school {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}

.spell-card-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.spell-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.spell-stat-label {
  color: var(--text-dim);
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.spell-stat-val {
  color: var(--parchment);
}

/* ─── DICE ROLLER SCREEN ─── */
.dice-layout {
  max-width: 700px;
  margin: 0 auto;
}

.dice-result-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.dice-result-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(201, 162, 39, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.dice-roll-result {
  font-family: 'Cinzel Decorative', serif;
  font-size: 88px;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 40px rgba(201, 162, 39, 0.4);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dice-roll-result.rolling {
  animation: rollAnim 0.5s ease;
}

@keyframes rollAnim {
  0% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }

  50% {
    transform: scale(0.8) rotate(180deg);
    opacity: 0.5;
  }

  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

.dice-roll-desc {
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
}

.dice-roll-formula {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--gold-dim);
  margin-top: 4px;
  letter-spacing: 1px;
}

.dice-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.die-button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.die-button:hover {
  border-color: var(--gold-dim);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.die-button.active {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
  box-shadow: var(--glow-gold);
}

.die-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.die-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dice-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.qty-btn {
  width: 36px;
  height: 36px;
  background: var(--deep);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.qty-btn:hover {
  background: var(--elevated);
  color: var(--parchment);
}

.qty-value {
  width: 40px;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 15px;
  color: var(--parchment);
  border: none;
  background: none;
  outline: none;
}

.modifier-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
}

.modifier-input label {
  font-size: 11px;
  font-family: 'Cinzel', serif;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.modifier-input input {
  width: 40px;
  background: none;
  border: none;
  outline: none;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 15px;
  text-align: center;
}

.roll-btn {
  flex: 1;
  height: 44px;
  background: linear-gradient(135deg, var(--gold-dim), rgba(201, 162, 39, 0.8));
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--obsidian);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 700;
}

.roll-btn:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  box-shadow: var(--glow-gold);
  transform: translateY(-1px);
}

.roll-btn:active {
  transform: translateY(1px);
}

.dice-history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(61, 51, 88, 0.4);
  font-size: 13px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-dice {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 60px;
}

.history-result {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  min-width: 30px;
}

.history-detail {
  color: var(--text-dim);
  flex: 1;
  font-size: 12px;
}

.history-time {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* ─── INVENTORY ─── */
.inventory-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.inventory-slots {
  width: 100%;
  max-width: 240px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .inventory-slots {
    max-width: none;
  }
}

.equip-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.equip-slot {
  background: var(--deep);
  border: 1px dashed var(--border);
  border-radius: 8px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--text-muted);
}

.equip-slot.filled {
  border-style: solid;
  border-color: var(--border);
  color: var(--text-main);
}

.equip-slot:hover {
  border-color: var(--gold-dim);
}

.equip-icon {
  font-size: 18px;
}

.weight-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.weight-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: 'Cinzel', serif;
}

.weight-bar {
  height: 6px;
  background: var(--deep);
  border-radius: 3px;
  overflow: hidden;
}

.weight-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage-bright), #86efac);
  border-radius: 3px;
  width: 45%;
}

.inventory-main {
  flex: 1;
}

.item-category {
  margin-bottom: 20px;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.item-row:hover {
  border-color: var(--gold-dim);
  background: var(--elevated);
}

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

.item-name-wrap {
  flex: 1;
}

.item-name {
  font-size: 14px;
  color: var(--text-main);
}

.item-desc {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.item-qty {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--text-muted);
}

.item-weight {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 40px;
  text-align: right;
}

.item-tag {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-family: 'Cinzel', serif;
}

.item-magic {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--arcane-bright);
}

.item-common {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--steel);
}

.item-weapon {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ─── CURRENCY ─── */
.currency-row {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.coin {
  flex: 1;
  text-align: center;
}

.coin-symbol {
  font-size: 18px;
  margin-bottom: 2px;
}

.coin-val {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
}

.coin-lbl {
  font-size: 9px;
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.coin.gold .coin-val {
  color: var(--gold);
}

.coin.silver .coin-val {
  color: #94a3b8;
}

.coin.copper .coin-val {
  color: #b45309;
}

.coin.platinum .coin-val {
  color: #e2e8f0;
}

.coin.electrum .coin-val {
  color: #a3e635;
}

/* Buttons */
.btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-dim), rgba(201, 162, 39, 0.7));
  border-color: var(--gold);
  color: var(--obsidian);
  font-weight: 700;
}

.btn-gold:hover {
  box-shadow: var(--glow-gold);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--gold-dim);
  color: var(--parchment);
}

/* Tooltip / Badges */
.xp-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.xp-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.xp-label {
  font-family: 'Cinzel', serif;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.xp-value {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-weight: 600;
}

.xp-bar {
  height: 8px;
  background: var(--deep);
  border-radius: 4px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--arcane), var(--arcane-bright));
  border-radius: 4px;
  width: 72%;
  position: relative;
}

.xp-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.15), transparent);
}

/* ─── NOTES SCREEN ─── */
.notes-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  height: calc(100vh - 120px);
}

@media (max-width: 768px) {
  .notes-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .notes-list-panel {
    height: 300px;
  }
}

.notes-list-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notes-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-list-title {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.notes-list-body {
  flex: 1;
  overflow-y: auto;
}

.note-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(61, 51, 88, 0.4);
  cursor: pointer;
  transition: background 0.15s;
}

.note-item:hover {
  background: var(--elevated);
}

.note-item.active {
  background: rgba(201, 162, 39, 0.08);
  border-left: 2px solid var(--gold);
}

.note-item-title {
  font-family: 'Cinzel', serif;
  font-size: 13px;
  color: var(--parchment);
  margin-bottom: 3px;
}

.note-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
}

.note-editor-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.note-editor-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.note-editor-title-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Cinzel', serif;
  font-size: 18px;
  color: var(--parchment);
}

.note-editor-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.note-editor-content {
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  outline: none;
  font-family: 'EB Garamond', serif;
  font-size: 16px;
  color: var(--text-main);
  line-height: 1.8;
  resize: none;
}

.note-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-family: 'Cinzel', serif;
  border: 1px solid;
  margin-right: 4px;
  cursor: pointer;
}

.tag-npc {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.3);
  color: #fbbf24;
}

.tag-loc {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.tag-quest {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.tag-lore {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

/* Rune decorations */
.rune-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.rune-divider::before,
.rune-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border));
}

.rune-divider::after {
  background: linear-gradient(to left, transparent, var(--border));
}

.rune-sym {
  color: var(--gold-dim);
  font-size: 12px;
  opacity: 0.6;
}

/* ─── WIZARD UI ─── */
.wizard-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 160px);
}

.wizard-steps {
  display: flex;
  gap: 12px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.step {
  flex: 1;
  text-align: center;
  padding: 12px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: 1px;
  position: relative;
  transition: all 0.3s ease;
}

.step.active {
  background: rgba(201, 162, 39, 0.1);
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: var(--glow-gold);
}

.step.active::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--gold);
}

.wizard-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.step-panel {
  animation: fadeIn 0.4s ease forwards;
}

/* ─── CHOICE CARDS & HORIZONTAL SCROLL ─── */
.horizontal-scroll-container {
  display: flex;
  overflow-x: auto;
  gap: 20px;
  padding: 10px 5px 25px 5px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.horizontal-scroll-container::-webkit-scrollbar {
  height: 6px;
}

.horizontal-scroll-container::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}

.choice-card {
  min-width: 260px;
  max-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-snap-align: start;
}

.choice-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.choice-card.selected {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.05);
  box-shadow: var(--glow-gold), inset 0 0 15px rgba(201, 162, 39, 0.1);
}

.choice-card-image {
  height: 200px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.choice-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.choice-card:hover .choice-card-image img {
  transform: scale(1.05);
}

.choice-card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, var(--surface));
}

.choice-card-content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.choice-title {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  color: var(--parchment);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.choice-card.selected .choice-title {
  color: var(--gold);
}

.choice-details {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.choice-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.choice-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--deep);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
}

.grid-2col {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.clickable:hover {
  border-color: var(--gold-dim);
  background: var(--elevated);
  transform: translateY(-2px);
}

.clickable.selected {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.05);
  box-shadow: inset 0 0 20px rgba(201, 162, 39, 0.1);
}

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

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-box label {
  display: block;
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 8px;
}

.stat-box input {
  width: 100%;
  text-align: center;
  font-size: 24px;
  font-family: 'EB Garamond', serif;
  background: var(--deep);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px;
  border-radius: 6px;
}

.stat-box input:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.2);
}

.wizard-footer {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
}

/* Responsive touches */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .character-hero {
    grid-row: auto;
  }

  .sheet-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-search {
    width: 40px;
    padding: 0;
    justify-content: center;
    border: none;
    background: transparent;
  }

  .topbar-search input {
    display: none;
  }

  .search-icon {
    font-size: 18px;
  }

  .wizard-steps {
    overflow-x: auto;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
  }

  .step {
    min-width: 100px;
    font-size: 11px;
    padding: 8px 4px;
  }
}

.dice-grid {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 600px) {
  .topbar {
    padding: 0 16px !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    gap: 8px !important;
  }

  .topbar-title {
    font-size: 15px !important;
  }

  .topbar-search {
    display: none !important;
  }

  .screen {
    padding: 12px !important;
  }

  .action-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .char-portrait {
    height: 140px !important;
  }

  .nav-label {
    display: none !important;
  }

  .nav-item {
    font-size: 14px !important;
    height: 44px !important;
    width: 44px !important;
  }

  .stats-grid-mini {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Wizard Spell Selection Mobile Overrides */
  .spell-selection-grid {
    grid-template-columns: 1fr !important;
  }

  .spell-details {
    border-left: none !important;
    padding-left: 0 !important;
    margin-top: 20px;
    width: 100%;
  }

  .spell-details .sticky-top {
    position: static !important;
  }
}

/* Page Transitions */
.page-transition {
  animation: fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── DICE RESULT TOAST ─── */
.dice-result-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dice-toast {
  background: rgba(26, 21, 37, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--gold-dim);
  border-radius: 16px;
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), var(--glow-gold);
  animation: diceToastIn 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
  position: relative;
  overflow: hidden;
}

.dice-toast.crit-success {
  border-color: var(--gold);
  box-shadow: 0 0 50px rgba(201, 162, 39, 0.4);
}

.dice-toast.crit-fail {
  border-color: var(--crimson);
  box-shadow: 0 0 50px rgba(139, 26, 26, 0.4);
}

.dice-toast-label {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--gold-light);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.dice-toast-value {
  font-family: 'Cinzel Decorative', serif;
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.dice-toast-sub {
  font-family: 'EB Garamond', serif;
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

.crit-text {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: bold;
  margin-top: 8px;
}

.dice-toast.crit-success .crit-text {
  color: var(--gold);
}

.dice-toast.crit-fail .crit-text {
  color: var(--crimson-bright);
}

@keyframes diceToastIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(40px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dice-toast-out {
  animation: diceToastOut 0.4s cubic-bezier(0.19, 1, 0.22, 1) forwards !important;
}

@keyframes diceToastOut {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(1.1) translateY(-20px);
  }
}

/* ─── MOBILE RESPONSIVENESS OVERRIDE ─── */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: calc(64px + var(--safe-area-bottom));
    flex-direction: row !important;
    padding: 0 16px var(--safe-area-bottom) 16px;
    border-right: none;
    border-top: 1px solid var(--border);
    order: 2;
    justify-content: space-around;
    align-items: center;
    gap: 0;
  }

  .sidebar::after {
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    height: 1px;
    width: auto;
    background: linear-gradient(to right, transparent, var(--gold-dim), transparent);
  }

  .app-logo {
    display: none;
  }

  .nav-menu {
    display: flex;
    flex-direction: row !important;
    width: 100%;
    justify-content: space-around;
  }

  .nav-item {
    width: 60px;
    height: 50px;
    display: flex !important;
  }

  .nav-item.active::before {
    left: 8px;
    right: 8px;
    top: -1px;
    bottom: auto;
    width: auto;
    height: 2px;
    border-radius: 0 0 2px 2px;
  }

  .sidebar-bottom {
    display: none;
  }

  .topbar {
    padding: var(--safe-area-top) 16px 0 16px !important;
    height: calc(60px + var(--safe-area-top)) !important;
  }

  .topbar-title {
    font-size: 16px !important;
  }

  .topbar-search {
    width: 40px;
    padding: 0;
    justify-content: center;
    border: none;
    background: none;
  }

  .topbar-search input {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .screen {
    padding: 16px !important;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: 100% !important;
    opacity: 1 !important;
    pointer-events: all !important;
    height: calc(64px + var(--safe-area-bottom)) !important;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar {
    position: fixed;
    inset: 0;
    width: 100% !important;
    height: 100vh !important;
    z-index: 1000;
    flex-direction: column !important;
    background: var(--void);
    opacity: 1 !important;
    pointer-events: all !important;
    padding: 40px 24px;
    justify-content: center;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar .nav-menu {
    flex-direction: column !important;
    gap: 16px;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar .nav-item {
    width: 100%;
    height: 60px;
    justify-content: flex-start;
    padding: 0 20px;
    gap: 16px;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar .nav-label {
    font-size: 14px;
    display: block !important;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar .nav-icon {
    font-size: 24px;
  }

  /* ─── WIZARD MOBILE FIXES ─── */
  .wizard-steps {
    display: flex !important;
    overflow-x: auto !important;
    gap: 8px !important;
    padding-bottom: 12px !important;
    margin-bottom: 16px !important;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .wizard-steps::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
  }

  .step {
    flex: 0 0 auto !important;
    min-width: 120px;
    padding: 8px 12px !important;
    font-size: 11px !important;
    scroll-snap-align: center;
  }

  .step.active::after {
    bottom: -14px !important;
  }
}

/* ─── FILTERS & CHIPS ─── */
.filter-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .section-header .search-box {
    width: 100%;
  }
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  padding: 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-chip:hover {
  border-color: var(--gold-dim);
  color: var(--parchment);
}

.filter-chip.active {
  background: rgba(201, 162, 39, 0.1);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.2);
}

/* ─── SPELL CARD ENHANCEMENTS ─── */
.spell-card {
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.spell-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
}

.fav-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  padding: 4px;
}

.fav-btn:hover {
  color: var(--gold-light);
  transform: scale(1.2);
}

.fav-btn.active {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(201, 162, 39, 0.5);
}

.spell-name {
  max-width: calc(100% - 30px);
}

/* ─── ENHANCED SPELL SELECTION (ACCORDION) ─── */
.spell-list-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.spell-accordion-item:hover {
  border-color: var(--gold-dim);
}

.spell-accordion-item.selected {
  border-color: var(--arcane);
  background: rgba(123, 79, 166, 0.05);
}

.spell-accordion-item.expanded {
  border-color: var(--gold);
  background: var(--elevated);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.spell-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.spell-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.spell-header .spell-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.spell-header .expand-icon {
  font-size: 12px;
  color: var(--text-dim);
  transition: transform 0.3s ease;
}

.spell-accordion-item.expanded .expand-icon {
  transform: rotate(180deg);
  color: var(--gold);
}

.spell-drawer {
  padding: 0 16px 16px 44px;
  /* Align with name text */
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
  animation: slideDown 0.3s ease-out;
}

.spell-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-main);
  /* Lighter than muted */
}

.spell-description-inline {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--parchment);
  /* High contrast and thematic */
  white-space: pre-wrap;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .spell-details {
    display: none;
    /* Hide old panel if any instances remain */
  }
}

 # d i c e - b o x - c o n t a i n e r    {
         p o s i t i o n :    f i x e d ;
         i n s e t :    0 ;
         z - i n d e x :    9 9 9 9 ;
         p o i n t e r - e v e n t s :    n o n e ;
     
}

     # d i c e - b o x - c o n t a i n e r   c a n v a s    {
         w i d t h :    1 0 0 %    ! i m p o r t a n t ;
         h e i g h t :    1 0 0 %    ! i m p o r t a n t ;
         p o i n t e r - e v e n t s :    n o n e ;
     
}

     
