/* ===== Pen & Paper – Dark Fantasy Theme ===== */
:root {
  --bg-deep: #0a0a0f;
  --bg-dark: #0f0f1a;
  --bg-card: #161624;
  --bg-card2: #1e1e30;
  --bg-hover: #252540;
  --border: #2a2a45;
  --border-glow: #4a3f8a;
  --gold: #c9a84c;
  --gold-light: #f0d080;
  --gold-dim: #7a6020;
  --accent: #7c3aed;
  --accent2: #a855f7;
  --red: #dc2626;
  --red-light: #ef4444;
  --green: #16a34a;
  --green-light: #22c55e;
  --blue: #2563eb;
  --blue-light: #60a5fa;
  --cyan: #0891b2;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.6);
  --glow-gold: 0 0 20px rgba(201,168,76,0.3);
  --glow-purple: 0 0 20px rgba(124,58,237,0.4);
  --radius: 8px;
  --radius-sm: 5px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Crimson Text', Georgia, serif; background: var(--bg-deep); color: var(--text); overflow: hidden; height: 100vh; }
input, textarea, select, button { font-family: inherit; }
input, textarea, select {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,0.2); }
textarea { resize: vertical; }
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
h1, h2, h3 { font-family: 'Cinzel', serif; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

/* ===== SCREENS ===== */
.screen { width: 100vw; height: 100vh; }
.screen.hidden { display: none !important; }
.screen.active { display: flex; }

/* ===== LOBBY ===== */
#lobby {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
}
.lobby-bg {
  position: fixed; inset: 0; z-index: 0;
  background-image: url('/lobby-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: brightness(0.45) saturate(0.85);
}
.lobby-bg::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.25) 0%, transparent 60%),
    linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(10,8,20,0.75) 100%);
}
.lobby-content { position: relative; z-index: 1; width: 100%; max-width: 1100px; padding: 2rem 1rem; }
.logo { text-align: center; margin-bottom: 2.5rem; }
.logo-emblem {
  width: 160px; height: 160px; margin: 0 auto 1rem;
  border-radius: 50%;
  background-image: url('/pnp-logo.png');
  background-size: cover; background-position: center;
  filter: drop-shadow(0 0 30px rgba(201,168,76,0.5)) drop-shadow(0 0 60px rgba(124,58,237,0.4));
  animation: floatLogo 4s ease-in-out infinite;
}
@keyframes floatLogo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.logo h1 {
  font-size: 3.2rem; letter-spacing: 0.18em;
  background: linear-gradient(135deg, #f0d080 0%, #c9a84c 40%, #fff8dc 60%, #a07828 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 12px rgba(201,168,76,0.6));
  position: relative;
}
.logo h1::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0; width: 100%;
  background: none; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(201,168,76,0.3);
  filter: blur(8px); z-index: -1;
}
.logo .subtitle {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem; letter-spacing: 0.5em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 0.3rem;
}
.logo .tagline {
  color: rgba(200,185,140,0.7); font-size: 1rem; font-style: italic;
  margin-top: 0.2rem;
  text-shadow: 0 0 20px rgba(201,168,76,0.3);
}
.logo-divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 0.75rem auto 0; max-width: 340px;
}
.logo-divider-line { flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--gold-dim), transparent); }
.logo-divider-icon { color: var(--gold-dim); font-size: 14px; }
.lobby-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media(max-width:900px) { .lobby-cards { grid-template-columns: 1fr; } }
.lobby-card {
  background: rgba(15, 12, 28, 0.82);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(120, 90, 200, 0.3);
  border-radius: 14px;
  padding: 1.8rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.lobby-card:hover {
  border-color: rgba(201,168,76,0.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.7), 0 0 30px rgba(201,168,76,0.1), inset 0 1px 0 rgba(255,255,255,0.05);
}
.lobby-card h2 {
  color: var(--gold); margin-bottom: 1.2rem; font-size: 1.2rem;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(201,168,76,0.2);
  padding-bottom: 0.6rem;
}
.form-group { margin-bottom: 1rem; }
.divider { text-align: center; color: var(--text-muted); margin: 1rem 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.room-list { margin-top: 0.5rem; max-height: 200px; overflow-y: auto; }
.room-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); margin-bottom: 4px; transition: all 0.15s;
}
.room-list-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.save-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 0.5rem; padding: 0.6rem 0.75rem; background: var(--bg-dark); border-radius: var(--radius-sm); border-left: 3px solid var(--gold-dim); }
.save-option-group { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.save-option-group:last-of-type { border-bottom: none; }
.save-option-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: 'Cinzel',serif; margin-bottom: 6px; }
.lobby-error { color: var(--red-light); text-align: center; padding: 0.75rem; margin-top: 1rem; background: rgba(220,38,38,0.1); border-radius: var(--radius-sm); }
.lobby-error.hidden { display: none; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; font-size: 14px;
  font-family: 'Cinzel', serif; letter-spacing: 0.05em;
  transition: all 0.15s; user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent2); }
.btn-primary:hover { background: var(--accent2); box-shadow: var(--glow-purple); }
.btn-secondary { background: var(--bg-card2); color: var(--gold); border-color: var(--gold-dim); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--gold); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red-light); }
.btn-danger:hover { background: var(--red-light); }
.btn-xs { padding: 4px 10px; font-size: 11px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== TOP BAR ===== */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  z-index: 100;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.room-badge { font-family: 'Cinzel', serif; color: var(--gold); font-size: 15px; font-weight: 600; }
.room-id-badge { font-size: 11px; color: var(--text-muted); background: var(--bg-dark); padding: 2px 8px; border-radius: 3px; font-family: monospace; }
.host-badge { background: var(--gold); color: #000; font-size: 11px; padding: 2px 8px; border-radius: 3px; font-family: 'Cinzel', serif; }
.player-list-top { display: flex; gap: 6px; flex-wrap: wrap; }
.player-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; background: var(--bg-dark); border: 1px solid var(--border);
}
.player-chip-dot { width: 8px; height: 8px; border-radius: 50%; }
.tb-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--bg-dark); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 16px;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--bg-hover); border-color: var(--border-glow); }
.tb-btn.danger:hover { background: var(--red); border-color: var(--red-light); }

/* ===== MAIN LAYOUT ===== */
#game { flex-direction: column; }
#main-layout { display: flex; flex: 1; overflow: hidden; }

/* ===== LEFT SIDEBAR ===== */
#sidebar-left {
  width: 70px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; gap: 4px; flex-shrink: 0; overflow-y: auto;
}
.tab-btn {
  width: 56px; height: 56px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; transition: all 0.15s; position: relative;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent2); box-shadow: var(--glow-purple); }
.tab-icon { font-size: 20px; }
.tab-label { font-size: 9px; font-family: 'Cinzel', serif; text-align: center; text-transform: uppercase; letter-spacing: 0.03em; }
.sidebar-spacer { flex: 1; }

/* ===== TAB CONTENT ===== */
#tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-pane { position: absolute; inset: 0; overflow-y: auto; }
.tab-pane.hidden { display: none; }
.tab-pane.active { display: block; }

/* ===== RIGHT SIDEBAR ===== */
#sidebar-right {
  width: 280px; background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-right-header { display: flex; border-bottom: 1px solid var(--border); }
.sr-tab {
  flex: 1; padding: 10px; background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 12px; font-family: 'Cinzel', serif; transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.sr-tab:hover { color: var(--text); }
.sr-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.sr-panel { flex: 1; overflow-y: auto; padding: 8px; }
.sr-panel.hidden { display: none; }

/* ===== WORLD / CANVAS ===== */
#tab-world { display: flex; flex-direction: column; overflow: hidden; }
#world-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tool-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--bg-dark); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 15px;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.tool-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.tool-btn.active { background: var(--accent); border-color: var(--accent2); box-shadow: var(--glow-purple); }
.tool-sep { width: 1px; height: 26px; background: var(--border); margin: 0 4px; }
.tool-label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.tool-label input[type="number"] { width: 55px; }
.tool-label input[type="checkbox"] { width: auto; }
.measure-display { font-size: 13px; color: var(--blue-light); margin-left: 8px; }
.steps-display { font-size: 13px; color: var(--green-light); }
.world-time-wrap {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-right: auto; padding: 0 4px;
}
.world-clock-pill { font-size: 12px; color: var(--text-muted); }
.world-clock-display {
  font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--gold-light); white-space: nowrap;
}
#world-container { flex: 1; overflow: hidden; position: relative; background: #08080f; cursor: crosshair; touch-action: none; }
#world-container .world-trade-overlay { position: absolute; }
#world-container .world-inv-overlay { position: absolute; inset: 0; }
#world-canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }

/* ===== CHARACTER SHEET ===== */
#tab-character { padding: 1rem; }
.sheet-header { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; align-items: flex-start; }
.char-portrait-area { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
.char-portrait {
  width: 120px; height: 120px; border-radius: 50%;
  border: 3px solid var(--gold-dim);
  background: var(--bg-dark);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden;
  transition: border-color 0.2s;
}
.char-portrait:hover { border-color: var(--gold); box-shadow: var(--glow-gold); }
.char-portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-placeholder { text-align: center; color: var(--text-muted); font-size: 28px; }
.char-basic-info { flex: 1; }
.sheet-title {
  font-size: 1.8rem; font-family: 'Cinzel', serif; color: var(--gold);
  border: none; border-bottom: 2px solid var(--gold-dim); background: transparent;
  width: 100%; margin-bottom: 0.8rem; padding: 4px 0;
}
.sheet-title:focus { outline: none; border-bottom-color: var(--gold); }
.char-meta-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.5rem; }
.form-group-inline { display: flex; flex-direction: column; }
.form-group-inline label { font-size: 11px; color: var(--text-muted); }
.form-group-inline input { font-size: 13px; padding: 4px 6px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 0.75rem; margin-bottom: 1rem; }
.stat-block {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 6px; text-align: center;
  transition: border-color 0.2s;
}
.stat-block:hover { border-color: var(--gold-dim); }
.stat-name { font-family: 'Cinzel', serif; font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.1em; }
.stat-value { font-size: 1.8rem; font-weight: bold; text-align: center; border: none; background: transparent; color: var(--text); width: 100%; padding: 2px 0; }
.stat-mod { font-size: 1.1rem; color: var(--accent2); font-weight: bold; margin-top: 2px; }

/* Combat */
.combat-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.combat-block {
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px; text-align: center;
}
.combat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.combat-value { font-size: 1.4rem; font-weight: bold; border: none; background: transparent; color: var(--text); width: 100%; text-align: center; padding: 2px; }
.combat-value.hp-current { color: var(--green-light); }
.combat-value.computed { color: var(--accent2); cursor: default; }

/* Skills & Saves */
.skills-saves-row { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; margin-bottom: 1rem; }
.saves-section h3, .char-skills-section h3 { font-size: 13px; color: var(--gold); margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.saves-list, .skills-list-char { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.save-item, .skill-item-char {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px;
  border-radius: 4px; font-size: 13px; cursor: pointer; transition: background 0.1s;
}
.save-item:hover, .skill-item-char:hover { background: var(--bg-hover); }
.proficiency-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--text-muted); flex-shrink: 0; }
.proficiency-dot.filled { background: var(--accent2); border-color: var(--accent2); }
.skill-bonus { margin-left: auto; font-size: 12px; color: var(--accent2); font-weight: bold; }

/* Attacks */
.attacks-section { margin-bottom: 1rem; }
.attacks-section h3 { font-size: 14px; color: var(--gold); margin-bottom: 0.5rem; }
.attack-row { display: grid; grid-template-columns: 2fr 1fr 2fr 1fr; gap: 6px; align-items: center; padding: 6px; background: var(--bg-dark); border-radius: var(--radius-sm); margin-bottom: 4px; }
.attack-name { font-weight: 600; }
.attack-hit { color: var(--green-light); }
.attack-dmg { color: var(--red-light); }

/* Personality */
.personality-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 0.5rem; margin-bottom: 1rem; }
.extra-row { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: center; }
.computed-inline { font-size: 1.2rem; color: var(--accent2); font-weight: bold; }
.char-action-row { display: flex; gap: 0.75rem; margin-top: 1rem; }

/* ===== INVENTORY ===== */
#tab-inventory { padding: 1rem; }
.inventory-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.inventory-header h2 { color: var(--gold); font-size: 1.4rem; }
.inventory-stats { display: flex; gap: 1rem; font-size: 13px; flex: 1; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.inv-item {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem; cursor: pointer;
  transition: all 0.15s; position: relative;
}
.inv-item:hover { border-color: var(--gold-dim); background: var(--bg-hover); }
.inv-item.selected { border-color: var(--gold); box-shadow: var(--glow-gold); }
.inv-item-icon { font-size: 24px; margin-bottom: 6px; }
.inv-item-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.inv-item-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.inv-item-weight { font-size: 11px; color: var(--text-dim); }
.inv-item-value { position: absolute; top: 8px; right: 8px; font-size: 11px; color: var(--gold); }
.trade-section { background: var(--bg-card2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.trade-section h3 { color: var(--gold); margin-bottom: 0.75rem; font-size: 1rem; }
.trade-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.trade-controls select { flex: 1; min-width: 140px; }

/* ===== SKILLS TAB ===== */
#tab-skills { padding: 1rem; overflow: hidden; display: flex; flex-direction: column; }
.skills-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.skills-header h2 { color: var(--gold); font-size: 1.4rem; }
.skills-actions { display: flex; gap: 0.5rem; margin-left: auto; }
#skill-tree-container {
  flex: 1; position: relative; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; min-height: 350px;
}
#skill-tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#skill-tree-nodes { position: absolute; inset: 0; overflow: hidden; }
.skill-node {
  position: absolute; width: 100px; height: 100px;
  border-radius: 50%; border: 3px solid var(--border-glow);
  background: var(--bg-card2); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: all 0.2s; user-select: none; transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.skill-node:hover { border-color: var(--accent2); box-shadow: var(--glow-purple), 0 4px 12px rgba(0,0,0,0.5); z-index: 10; }
.skill-node.unlocked { border-color: var(--gold); background: linear-gradient(135deg, var(--bg-card2), rgba(201,168,76,0.1)); }
.skill-node.on-cooldown { border-color: var(--red); opacity: 0.8; }
.skill-node-icon { font-size: 28px; }
.skill-node-name { font-size: 10px; font-family: 'Cinzel', serif; text-align: center; padding: 0 4px; color: var(--text-dim); }
.skill-node-uses { font-size: 10px; color: var(--gold); }
.active-skills { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.75rem; border-top: 1px solid var(--border); margin-top: 0.75rem; }
.active-skill-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  background: var(--bg-card2); border: 1px solid var(--border-glow);
  color: var(--text); cursor: pointer; transition: all 0.15s;
  font-size: 13px;
}
.active-skill-btn:hover { border-color: var(--accent2); background: var(--bg-hover); }
.active-skill-btn.on-cooldown { opacity: 0.5; cursor: not-allowed; border-color: var(--red); }
.active-skill-btn.no-uses { opacity: 0.4; cursor: not-allowed; }
.skill-cd-timer { font-size: 10px; color: var(--red-light); }

/* ===== NOTES ===== */
#tab-notes { padding: 1rem; display: flex; flex-direction: column; }
.notes-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.notes-header h2 { color: var(--gold); font-size: 1.4rem; }
.notes-tools { display: flex; gap: 4px; align-items: center; flex: 1; }
.notes-fmt-btn {
  width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--border);
  background: var(--bg-dark); color: var(--text); cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.notes-fmt-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.notes-editor {
  flex: 1; background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; font-size: 15px;
  line-height: 1.7; min-height: 400px; outline: none; overflow-y: auto;
  color: var(--text);
}
.notes-editor:empty::before { content: attr(placeholder); color: var(--text-muted); pointer-events: none; }
.notes-editor h1, .notes-editor h2 { color: var(--gold); font-family: 'Cinzel', serif; }

/* ===== ENEMIES ===== */
#tab-enemies { padding: 1rem; }
.enemies-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.enemies-header h2 { color: var(--gold); flex: 1; font-size: 1.4rem; }
.enemies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 0.75rem; }
.enemy-card {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; cursor: pointer;
  transition: all 0.15s;
}
.enemy-card:hover { border-color: var(--red); box-shadow: 0 0 15px rgba(220,38,38,0.2); }
.enemy-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.enemy-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.enemy-card-name { font-family: 'Cinzel', serif; color: var(--red-light); font-size: 15px; }
.enemy-card-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.enemy-card-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; font-size: 12px; }
.enemy-stat { text-align: center; }
.enemy-stat-label { color: var(--text-muted); font-size: 10px; }
.enemy-stat-val { color: var(--text); font-weight: 600; }
.enemy-card-actions { display: flex; gap: 6px; margin-top: 8px; }
.enemy-form-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.75rem; margin-bottom: 1rem; }
.enemy-form-grid .form-group.full-width { grid-column: 1 / -1; }

/* ===== CHAT ===== */
#chat-messages { display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; }
.chat-msg { font-size: 13px; line-height: 1.4; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--bg-dark); }
.chat-msg-name { font-weight: 600; font-size: 12px; }
.chat-msg-text { color: var(--text-dim); }
.chat-msg-time { font-size: 10px; color: var(--text-muted); float: right; }
.chat-input-row { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; font-size: 13px; }

/* ===== NOTIFICATIONS ===== */
#notification-list { display: flex; flex-direction: column; gap: 6px; }
.notification-item {
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg-dark); border-left: 3px solid var(--accent);
  font-size: 13px; line-height: 1.4;
  animation: slideIn 0.3s ease;
}
.notification-item.skill { border-left-color: var(--accent2); }
.notification-item.trade { border-left-color: var(--gold); }
.notification-item.move { border-left-color: var(--blue-light); }
.notification-item.system { border-left-color: var(--text-muted); }
.notification-item.roll { border-left-color: var(--green-light); }
.notification-item.host-trade { border-left-color: var(--gold); background: rgba(201,168,76,0.08); }
.notif-trade-msg { margin-bottom: 8px; padding-right: 4px; }
.notif-trade-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.notif-time { font-size: 10px; color: var(--text-muted); float: right; }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ===== DICE ===== */
.dice-panel { display: flex; flex-direction: column; gap: 1rem; }
.dice-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.die-btn {
  padding: 12px 8px; border-radius: var(--radius-sm);
  background: var(--bg-dark); border: 2px solid var(--border);
  color: var(--text); cursor: pointer; font-family: 'Cinzel', serif;
  font-size: 14px; font-weight: 600; transition: all 0.15s; text-align: center;
}
.die-btn:hover { border-color: var(--gold-dim); background: var(--bg-hover); }
.die-btn.active { border-color: var(--gold); background: rgba(201,168,76,0.15); color: var(--gold); box-shadow: var(--glow-gold); }
.dice-config { display: flex; gap: 1rem; align-items: center; font-size: 13px; }
.dice-formula { text-align: center; font-size: 18px; font-family: 'Cinzel', serif; color: var(--gold); }
.dice-roll-btn { width: 100%; padding: 12px; font-size: 1.1rem; }
.dice-result {
  min-height: 80px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-dark); border-radius: var(--radius); border: 1px solid var(--border);
}
.dice-result-total { font-size: 3rem; font-family: 'Cinzel', serif; color: var(--gold); text-align: center; }
.dice-result-breakdown { font-size: 12px; color: var(--text-dim); text-align: center; margin-top: 4px; }
.dice-history { max-height: 150px; overflow-y: auto; }
.dice-history-item { font-size: 12px; color: var(--text-dim); padding: 4px 0; border-bottom: 1px solid var(--border); }

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border-glow);
  border-radius: 12px; padding: 1.5rem;
  width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow), var(--glow-purple);
  animation: scaleIn 0.2s ease;
}
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-content.modal-sm { max-width: 420px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; }
.modal-header h3 { font-family: 'Cinzel', serif; color: var(--gold); font-size: 1.2rem; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--bg-hover); }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1rem; justify-content: flex-end; }
.modal-hint { font-size: 13px; color: var(--text-dim); line-height: 1.45; margin: 0 0 1rem 0; }
.rest-player-hint { margin-top: -0.5rem; }
.rest-party-block { display: flex; flex-direction: column; gap: 0.5rem; }
.rest-party-check-row {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text);
  text-transform: none; letter-spacing: normal;
}
.rest-party-check-row input { margin-top: 3px; flex-shrink: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.rest-party-detail {
  margin: 0; padding-left: 28px; font-size: 12px; line-height: 1.45; color: var(--text-muted);
}
.set-clock-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed; z-index: 2000;
  background: var(--bg-card); border: 1px solid var(--border-glow);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 180px; overflow: hidden;
  animation: scaleIn 0.1s ease;
}
.context-menu.hidden { display: none; }
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; cursor: pointer; font-size: 13px;
  transition: background 0.1s;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--red-light); }
.ctx-item.danger:hover { background: rgba(220,38,38,0.15); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }
.ctx-label { padding: 6px 14px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; cursor: default; }

/* ===== WORLD TOKENS ===== */
.token-hp-bar { position: absolute; bottom: -6px; left: 0; right: 0; height: 4px; background: rgba(0,0,0,0.5); border-radius: 2px; }
.token-hp-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: var(--radius);
  background: var(--bg-card2); border: 1px solid var(--border-glow);
  font-size: 13px; box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green-light); }
.toast.error { border-left: 3px solid var(--red-light); }
.toast.info { border-left: 3px solid var(--blue-light); }
.toast.trade { border-left: 3px solid var(--gold); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== KEY DISPLAY ===== */
.key-display {
  font-family: monospace; font-size: 1.4rem; font-weight: bold;
  padding: 1rem; background: var(--bg-dark); border-radius: var(--radius);
  text-align: center; color: var(--gold); letter-spacing: 0.2em;
  border: 1px solid var(--gold-dim); margin: 0.75rem 0;
}

/* ===== TOKEN DETAIL ===== */
#token-detail-body { display: flex; flex-direction: column; gap: 0.75rem; }
.token-detail-portrait { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-dim); }
.token-detail-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.5rem; }
.token-detail-stat { background: var(--bg-dark); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.token-detail-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-use-chip {
  padding: 6px 12px; border-radius: 20px;
  background: var(--bg-dark); border: 1px solid var(--border-glow);
  font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.skill-use-chip:hover { border-color: var(--accent2); background: var(--bg-hover); }
.skill-use-chip.cd { opacity: 0.5; cursor: not-allowed; }

/* ===== POLLINATIONS BADGE ===== */
.pollinations-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--gold); background: rgba(201,168,76,0.1);
  border: 1px solid var(--gold-dim); border-radius: 20px;
  padding: 4px 12px; margin-bottom: 1rem;
}
.gen-options-row {
  display: flex; gap: 1rem; font-size: 13px; color: var(--text-dim);
  margin-top: 0.5rem;
}
.gen-options-row label { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; cursor: pointer; }
.gen-options-row input[type="checkbox"] { width: auto; }

/* ===== SCROLLBAR for specific elements ===== */
#tab-character { overflow-y: auto; }

/* ===== BIBLIOTHEK ===== */
#tab-library { padding: 1rem; display: flex; flex-direction: column; }
.library-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.library-header h2 { color: var(--gold); font-size: 1.4rem; }
.library-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.lib-cat-btn {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-dark); color: var(--text-dim); cursor: pointer;
  font-size: 13px; transition: all 0.15s; font-family: inherit;
}
.lib-cat-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.lib-cat-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.1); }
.library-grid { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.lib-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  transition: border-color 0.15s;
}
.lib-card:hover { border-color: var(--border-glow); }
.lib-card-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--bg-dark); border: 1px solid var(--border);
}
.lib-card-body { flex: 1; min-width: 0; }
.lib-card-name { font-weight: 600; font-size: 14px; font-family: 'Cinzel',serif; color: var(--text); }
.lib-card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; margin-top: 2px; }
.lib-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== GEGNER AVATAR ===== */
.enemy-avatar-group { grid-column: 1 / -1; }
.enemy-avatar-preview {
  width: 100%; height: 120px; border: 2px dashed var(--border);
  border-radius: var(--radius); background: var(--bg-dark);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; transition: border-color 0.2s;
}
.enemy-avatar-preview:hover { border-color: var(--accent); }
#enemy-avatar-placeholder { color: var(--text-muted); font-size: 14px; }

/* ===== KARTEN-OBJEKTE ===== */
.obj-quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 0.75rem; max-height: 180px; overflow-y: auto; }
.obj-quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-dark); cursor: pointer; transition: all 0.15s;
  font-size: 11px; color: var(--text-dim);
}
.obj-quick-btn:hover { border-color: var(--gold); background: var(--bg-hover); color: var(--text); }

/* ===== KAMPFSYSTEM ===== */
.combat-fullscreen { align-items: flex-start; justify-content: stretch; padding: 0; background: rgba(0,0,0,0.85); }
.combat-window {
  width: 100%; max-width: 1200px; height: 92vh; margin: 4vh auto;
  background: var(--bg-card); border: 1px solid var(--border-glow);
  border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 0 60px rgba(124,58,237,0.3), var(--shadow);
  overflow: hidden;
}
.combat-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--bg-dark);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.combat-title { font-family: 'Cinzel',serif; color: var(--red-light); font-size: 1.3rem; }
.combat-round-info { font-size: 13px; color: var(--gold); }
.round-badge { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-family: 'Cinzel',serif; }
.combat-layout { display: grid; grid-template-columns: 220px 1fr 280px; flex: 1; overflow: hidden; }
.combat-left { background: var(--bg-dark); border-right: 1px solid var(--border); padding: 0.75rem; overflow-y: auto; display: flex; flex-direction: column; }
.combat-center { display: flex; flex-direction: column; overflow: hidden; }
.combat-right { background: var(--bg-dark); border-left: 1px solid var(--border); padding: 0.75rem; overflow-y: auto; display: flex; flex-direction: column; }
.combat-section-title { font-family: 'Cinzel',serif; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.combat-initiative-list { display: flex; flex-direction: column; gap: 6px; }
.combat-participant {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-left: 4px solid var(--border); border-radius: 8px;
  padding: 8px; transition: all 0.2s;
}
.combat-participant.current-turn {
  background: rgba(124,58,237,0.15); border-color: var(--accent2);
  box-shadow: 0 0 15px rgba(124,58,237,0.3);
}
.combat-participant.my-char { border-color: var(--gold-dim); }
.cp-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cp-ini { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 12px; flex-shrink: 0; }
.cp-name { font-size: 13px; font-weight: 600; flex: 1; }
.cp-hp-bar { height: 4px; background: rgba(0,0,0,0.4); border-radius: 2px; margin: 4px 0; }
.cp-hp-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.cp-stats { display: flex; gap: 6px; font-size: 11px; color: var(--text-dim); flex-wrap: wrap; }
.cp-conditions { font-size: 14px; }
.used-action { color: var(--red-light); font-size: 11px; text-decoration: line-through; }
.not-my-turn { text-align: center; color: var(--text-dim); padding: 2rem 1rem; font-style: italic; }

.combat-log { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 4px; }
.combat-log-entry { font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--bg-dark); border-left: 3px solid var(--border); line-height: 1.4; }
.combat-log-entry.log-system { border-left-color: var(--text-muted); color: var(--text-dim); font-style: italic; }
.combat-log-entry.log-attack { border-left-color: var(--red-light); }
.combat-log-entry.log-defeat { border-left-color: #8b5e8b; background: rgba(139,94,139,0.15); font-weight: bold; }
.combat-log-entry.log-combined { border-left-color: var(--gold); background: rgba(201,168,76,0.1); }
.log-time { float: right; font-size: 10px; color: var(--text-muted); }

.combat-action-panel { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; }
.action-panel-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.action-resources { display: flex; gap: 4px; flex-wrap: wrap; }
.resource-chip { padding: 3px 8px; border-radius: 10px; font-size: 11px; background: var(--accent); color: #fff; }
.resource-chip.used { background: var(--bg-card2); color: var(--text-muted); text-decoration: line-through; }
.action-section { background: var(--bg-card2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.action-section-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; font-family: 'Cinzel',serif; }
.action-targets { display: flex; flex-direction: column; gap: 4px; }
.action-target-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-dark); cursor: pointer; transition: all 0.15s; font-size: 13px;
  font-family: inherit;
}
.action-target-btn:hover:not(:disabled) { border-color: var(--red); background: rgba(220,38,38,0.1); }
.action-target-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.target-hp { font-size: 11px; }
.maneuver-btn {
  padding: 7px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-dark); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 13px; transition: all 0.15s;
}
.maneuver-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--bg-hover); }
.maneuver-btn.danger:hover:not(:disabled) { border-color: var(--red); background: rgba(220,38,38,0.1); }
.maneuver-btn.combined { border-color: var(--gold-dim); color: var(--gold); }
.maneuver-btn.combined:hover:not(:disabled) { border-color: var(--gold); background: rgba(201,168,76,0.1); }
.maneuver-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.skill-action-btn {
  padding: 6px 12px; border-radius: 16px; border: 1px solid var(--border-glow);
  background: var(--bg-dark); color: var(--text); cursor: pointer;
  font-size: 12px; transition: all 0.15s; font-family: inherit;
}
.skill-action-btn:hover:not(:disabled) { border-color: var(--accent2); background: var(--bg-hover); }
.skill-action-btn.disabled, .skill-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.combat-dice-strip { display: flex; gap: 4px; flex-wrap: wrap; }
.cdice-btn {
  flex: 1; min-width: 35px; padding: 7px 4px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-card2);
  color: var(--text); cursor: pointer; font-size: 12px; font-family: 'Cinzel',serif;
  font-weight: 600; transition: all 0.15s; text-align: center;
}
.cdice-btn:hover { border-color: var(--gold); color: var(--gold); }
.cdice-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(201,168,76,0.1); }

.combat-participant-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; border: 2px solid var(--border);
  cursor: pointer; transition: all 0.15s; background: var(--bg-dark);
}
.combat-participant-option:hover { background: var(--bg-hover); }
.combat-participant-option.selected { border-color: var(--gold); background: rgba(201,168,76,0.1); }
.tok-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ===== ANIMIERTE WÜRFEL ===== */
.dice-visual-overlay {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: diceAppear 0.2s ease;
}
.dice-visual-overlay.multi { top: 30%; }
.dice-visual-overlay.fading { animation: diceFade 0.4s ease forwards; }
@keyframes diceAppear { from { opacity:0; transform: translate(-50%,-60%) scale(0.5); } to { opacity:1; transform: translate(-50%,-50%) scale(1); } }
@keyframes diceFade { to { opacity:0; transform: translate(-50%,-40%) scale(0.8); } }

.dice-visual-die {
  width: 90px; height: 90px;
  background: linear-gradient(135deg, #1e1e30, #0f0f1a);
  border: 3px solid var(--gold); border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem; font-weight: bold; font-family: 'Cinzel', serif;
  color: var(--text); box-shadow: 0 0 40px rgba(201,168,76,0.5), 0 12px 40px rgba(0,0,0,0.9);
  animation: diceRoll 0.8s ease;
}
.dice-visual-die.small { width: 60px; height: 60px; font-size: 1.8rem; border-radius: 12px; }
.dice-visual-die.settled { animation: diceSettle 0.3s ease; }
.dice-visual-die.crit { box-shadow: 0 0 50px #ffd93d, 0 12px 40px rgba(0,0,0,0.9); }
.dice-visual-die.fail { box-shadow: 0 0 50px #ef4444, 0 12px 40px rgba(0,0,0,0.9); }
@keyframes diceRoll { 0%{transform:rotate(-15deg) scale(0.7)} 30%{transform:rotate(10deg) scale(1.1)} 60%{transform:rotate(-5deg) scale(0.95)} 100%{transform:rotate(0) scale(1)} }
@keyframes diceSettle { 0%{transform:scale(1.15)} 100%{transform:scale(1)} }
.dice-visual-info { font-size: 13px; color: var(--text-dim); background: rgba(0,0,0,0.8); padding: 4px 12px; border-radius: 10px; text-align: center; white-space: nowrap; }
.dice-visual-row { display: flex; gap: 12px; }
.dice-crit-label { font-family: 'Cinzel',serif; color: var(--gold); font-size: 1.2rem; font-weight: bold; text-shadow: 0 0 20px #ffd93d; animation: pulse 0.5s ease infinite alternate; }
.dice-fail-label { font-family: 'Cinzel',serif; color: var(--red-light); font-size: 1.2rem; font-weight: bold; }
@keyframes pulse { from { opacity:0.7; } to { opacity: 1; } }

/* ===== WELT-TRADE OVERLAY ===== */
.world-trade-overlay {
  position: absolute; inset: 0; z-index: 300;
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.world-trade-overlay.hidden { display: none; }
.world-trade-box {
  pointer-events: all;
  background: rgba(10,8,20,0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  width: 420px; max-width: 95%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8), 0 0 30px rgba(201,168,76,0.15);
  animation: scaleIn 0.2s ease;
  overflow: hidden;
}
.world-trade-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(201,168,76,0.08);
  border-bottom: 1px solid var(--border); font-family: 'Cinzel',serif;
  font-size: 15px; color: var(--gold);
}
.world-trade-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 2px 6px;
  border-radius: 4px;
}
.world-trade-close:hover { background: var(--bg-hover); color: var(--text); }
.world-trade-body { padding: 1rem; max-height: 320px; overflow-y: auto; }
.world-trade-actions {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.wt-section { margin-bottom: 0.75rem; }
.wt-section-title { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.4rem; font-family: 'Cinzel',serif; }
.wt-items { display: flex; flex-direction: column; gap: 4px; }
.wt-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-dark); border-radius: 6px; font-size: 13px; }
.wt-item label { flex: 1; cursor: pointer; }
.wt-check { width: auto; min-height: auto; accent-color: var(--gold); }
.wt-item-big { display: flex; align-items: center; gap: 1rem; padding: 0.75rem; background: var(--bg-dark); border-radius: 8px; margin-bottom: 0.5rem; }
.wt-message { font-style: italic; color: var(--text-dim); font-size: 13px; padding: 0.5rem; border-left: 3px solid var(--gold-dim); margin-top: 0.5rem; }
.wt-own-gold {
  font-size: 14px; color: var(--gold); margin-bottom: 0.75rem; padding: 8px 10px;
  background: rgba(201,168,76,0.1); border-radius: 8px; border: 1px solid var(--gold-dim);
  font-family: 'Cinzel', serif;
}
.world-inv-overlay {
  position: absolute;
  inset: 0;
  z-index: 280;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 10px;
}
.world-inv-overlay.hidden { display: none; }
.world-inv-panel {
  pointer-events: all;
  width: 320px;
  max-width: min(95vw, 360px);
  max-height: min(70vh, 480px);
  background: rgba(10, 8, 20, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn 0.2s ease;
}
.world-inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(78, 205, 196, 0.08);
  border-bottom: 1px solid var(--border);
  font-family: 'Cinzel', serif;
  font-size: 14px;
  color: var(--accent);
}
.world-inv-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.world-inv-close:hover { background: var(--bg-hover); color: var(--text); }
.world-inv-body { padding: 10px 12px; overflow-y: auto; flex: 1; font-size: 13px; }
.wi-item-list { display: flex; flex-direction: column; gap: 6px; }
.wi-inv-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-dark);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.wi-inv-icon { font-size: 20px; flex-shrink: 0; line-height: 1.2; }
.wi-inv-main { flex: 1; min-width: 0; }
.wi-inv-name { font-weight: 600; color: var(--text); }
.wi-inv-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.35; }
.wi-inv-meta { flex-shrink: 0; font-size: 11px; color: var(--gold); text-align: right; display: flex; flex-direction: column; gap: 2px; }

/* NPC-Form */
.npc-form-grid { display: grid; grid-template-columns: 160px 1fr 1fr; gap: 0.75rem; }
@media(max-width:600px) { .npc-form-grid { grid-template-columns: 1fr; } }

/* ===== MOBILE / RESPONSIVE ===== */
@media (max-width: 768px) {

  /* Topbar kompakt */
  #topbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .room-badge { font-size: 13px; }
  .room-id-badge { display: none; }
  .topbar-center { display: none; } /* Spielerliste ausblenden auf Mobil */
  .topbar-right { gap: 4px; }
  .tb-btn { width: 40px; height: 40px; font-size: 18px; }

  /* Haupt-Layout: Sidebar weg, Inhalt voll */
  #main-layout {
    flex-direction: column;
    position: relative;
    overflow: hidden;
  }

  /* Linke Sidebar → Untere Tab-Leiste */
  #sidebar-left {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 62px;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 6px;
    z-index: 200;
    background: var(--bg-card);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    overflow-x: auto;
    gap: 2px;
  }
  .sidebar-spacer { display: none; }
  .tab-btn {
    width: 52px; height: 52px;
    border-radius: 12px;
    flex-shrink: 0;
  }
  .tab-icon { font-size: 22px; }
  .tab-label { font-size: 8px; }

  /* Tab-Content: Platz für Bottom-Bar lassen */
  #tab-content {
    margin-bottom: 62px;
  }

  /* Rechte Sidebar → Overlay-Panel */
  #sidebar-right {
    position: fixed;
    bottom: 62px; right: 0;
    width: 100%;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
    display: none; /* standardmäßig versteckt */
    z-index: 150;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  }
  #sidebar-right.mobile-open { display: flex; flex-direction: column; }

  /* Karten-Toolbar: horizontal scrollbar, kompakter */
  #world-toolbar {
    gap: 4px;
    padding: 6px 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #world-toolbar::-webkit-scrollbar { display: none; }
  .tool-btn { width: 38px; height: 38px; flex-shrink: 0; font-size: 16px; }
  .tool-label { font-size: 11px; white-space: nowrap; }
  .tool-label input[type="number"] { width: 44px; }
  .measure-display, .steps-display { font-size: 11px; white-space: nowrap; }

  /* Welt: volle Höhe */
  #tab-world {
    height: calc(100vh - 52px - 62px - 50px); /* topbar + bottom-tabs + toolbar */
  }
  #world-container {
    touch-action: none;
  }

  /* Charakter-Bogen: single-column */
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .combat-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .char-meta-row { grid-template-columns: 1fr 1fr; }
  .personality-row { grid-template-columns: 1fr 1fr; }
  .skills-saves-row { grid-template-columns: 1fr; }
  .sheet-header { flex-direction: column; align-items: center; }
  .char-basic-info { width: 100%; }
  .sheet-title { font-size: 1.4rem; }

  /* Inventar */
  .inventory-grid { grid-template-columns: repeat(2, 1fr); }
  .trade-controls { flex-direction: column; }

  /* Modals: volle Breite auf Mobil */
  .modal-content {
    width: 96%;
    max-width: none;
    max-height: 88vh;
    margin: 0;
    border-radius: 16px 16px 0 0;
  }
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  /* Kampf-Modal */
  .combat-window {
    width: 100%; height: 95vh; margin: 5vh 0 0;
    border-radius: 16px 16px 0 0;
  }
  .combat-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .combat-left {
    border-right: none; border-bottom: 1px solid var(--border);
    max-height: 150px;
  }
  .combat-initiative-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .combat-participant { min-width: 120px; }
  .combat-right { border-left: none; border-top: 1px solid var(--border); }

  /* Bibliothek: cards full width */
  .lib-card { flex-direction: column; align-items: flex-start; }

  /* Lobby */
  .lobby-cards { grid-template-columns: 1fr; }
  .logo h1 { font-size: 2rem; }

  /* Schnell-Würfel FloatButton */
  #dice-fab {
    position: fixed;
    bottom: 72px; right: 16px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--accent2);
    color: #fff; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 201;
    box-shadow: 0 4px 20px rgba(124,58,237,0.5);
    touch-action: manipulation;
  }
}

/* Touch-Targets: min 44px für alle interaktiven Elemente */
@media (hover: none) and (pointer: coarse) {
  .btn, .tab-btn, .tb-btn, .tool-btn, .die-btn, .maneuver-btn {
    min-height: 44px;
    min-width: 44px;
  }
  .inv-item { padding: 1rem; }
  .lib-card { padding: 14px; }
  input, select, textarea {
    font-size: 16px !important; /* verhindert iOS Auto-Zoom */
    min-height: 44px;
  }
  .combat-participant { padding: 10px; }
  .ctx-item { padding: 13px 16px; }
  .skill-node { width: 80px; height: 80px; }
  .skill-node-icon { font-size: 26px; }
}

/* ===== MISC ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.mt-1 { margin-top: 0.5rem; }
.text-gold { color: var(--gold); }
.text-red { color: var(--red-light); }
.text-green { color: var(--green-light); }
.text-dim { color: var(--text-dim); }
