/* ════════════════════════════════════════
   RESET & VARIABLES
════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #0c0a07;
  --bg-accent: #14100a;
  --card-bg: rgba(22, 15, 9, 0.92);
  --card-border: rgba(212, 175, 55, 0.18);
  --card-border-hover: rgba(212, 175, 55, 0.55);
  --text-light: #f0e8d5;
  --text-muted: #9e876a;
  --gold: #d4af37;
  --gold-dim: #9a7d20;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --crimson: #922020;
  --crimson-bright: #c0392b;
  --success: #27ae60;
  --speaking: #00e676;
  --dm-color: #9b59b6;
  --dm-glow: rgba(155, 89, 182, 0.4);
  --font-title: 'Cinzel', serif;
  --font-sans: 'Inter', sans-serif;
  --radius: 10px;
  --tr: 0.2s ease;
}

body {
  background: radial-gradient(ellipse at 50% 0%, #1e1108 0%, var(--bg-dark) 65%);
  color: var(--text-light);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* Typography */
h1,h2,h3,h4 { font-family: var(--font-title); color: var(--gold); letter-spacing: 0.5px; }
p { line-height: 1.6; }

.ambient-glow {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at 15% 20%, rgba(212,175,55,0.03) 0%, transparent 40%),
              radial-gradient(circle at 85% 80%, rgba(146,32,32,0.04) 0%, transparent 40%);
  pointer-events: none; z-index: -1;
}

/* ── LAYOUT ─── */
#app { width: 100%; min-height: 100vh; transition: filter 2s ease; }
#app.wasted-screen { filter: grayscale(100%) contrast(1.2) brightness(0.6); }

.screen { display: none; width: 100%; min-height: 100vh; padding: 2rem; animation: fadeIn 0.4s ease; }
.screen.active { display: flex; justify-content: center; align-items: center; }
#screen-game.active { display: block; padding: 0; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes shakeScreen { 
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.shake-active { animation: shakeScreen 0.5s; }

/* ── CARD ─── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
}

/* ── FORMS ─── */
.form-group { margin-bottom: 1.2rem; display: flex; flex-direction: column; }
.form-group label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.4rem; font-weight: 600; }
.form-group label i { color: var(--gold); margin-right: 0.4rem; }

input[type="text"], input[type="number"], select, .input-sm {
  background: rgba(0,0,0,0.5); border: 1px solid rgba(212,175,55,0.2);
  color: var(--text-light); padding: 0.7rem 0.9rem; border-radius: 6px;
  font-family: var(--font-sans); font-size: 0.95rem; transition: all var(--tr); width: 100%;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 8px var(--gold-glow);
}
.input-sm { padding: 0.45rem 0.7rem; font-size: 0.85rem; }
select option { background: #1a1005; color: var(--text-light); }

/* ── BUTTONS ─── */
.btn {
  font-family: var(--font-title); font-size: 1rem; letter-spacing: 0.5px;
  padding: 0.75rem 1.6rem; border-radius: 6px; cursor: pointer;
  transition: all var(--tr); border: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary {
  background: linear-gradient(135deg, #c9a227 0%, #8b6914 100%);
  color: #fff; border: 1px solid var(--gold);
  box-shadow: 0 4px 14px rgba(201,162,39,0.2);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--gold-glow); background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%); }
.btn-secondary { background: rgba(30,20,10,0.6); border: 1px solid var(--text-muted); color: var(--text-muted); }
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: rgba(146,32,32,0.7); border: 1px solid var(--crimson-bright); color: #fff; }
.btn-danger:hover { background: rgba(192,57,43,0.8); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.82rem; }

/* ════════════════════════════════════════
   LOBBY SCREEN
════════════════════════════════════════ */
.lobby-card { width: 100%; max-width: 520px; text-align: center; }

.logo-text {
  font-size: 3.5rem; font-weight: 900;
  background: linear-gradient(to bottom, #fff 30%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 0.1rem;
}
.sublogo-text { font-family: var(--font-title); font-size: 1.6rem; color: var(--crimson-bright); margin-bottom: 1rem; letter-spacing: 2px; }
.lobby-description { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.8rem; }
.lobby-actions { margin-top: 1.5rem; }

/* Role Selector */
.role-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.role-btn {
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
  color: var(--text-muted); padding: 1rem; cursor: pointer; transition: all var(--tr);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem; text-align: center;
}
.role-btn i { font-size: 1.4rem; }
.role-btn-title { font-family: var(--font-title); font-size: 0.95rem; font-weight: 700; }
.role-btn-desc { font-size: 0.72rem; line-height: 1.3; opacity: 0.7; }
.role-btn.active { border-color: var(--gold); background: rgba(212,175,55,0.1); color: var(--gold); }
.role-btn[data-role="dm"].active { border-color: var(--dm-color); background: rgba(155,89,182,0.1); color: #c39bd3; }
.role-btn:hover:not(.active) { border-color: rgba(255,255,255,0.25); color: var(--text-light); }

/* ════════════════════════════════════════
   CHARACTER CREATION
════════════════════════════════════════ */
#screen-char-create { display: none; padding: 1.5rem; }
#screen-char-create.active { display: block; }

.char-create-container { max-width: 1260px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.2rem; }
.char-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--card-border); padding-bottom: 0.8rem; }
.char-header h2 { font-size: 1.6rem; }
.room-indicator { background: rgba(212,175,55,0.1); border: 1px solid var(--gold); color: var(--gold); padding: 0.3rem 0.9rem; border-radius: 20px; font-family: var(--font-title); font-size: 0.85rem; }

.char-content { display: grid; grid-template-columns: 1fr 1.1fr 1fr; gap: 1.2rem; }
.char-column { display: flex; flex-direction: column; }
.char-column h3 { font-family: var(--font-title); font-size: 1.1rem; border-bottom: 1px solid rgba(255,255,255,0.06); padding-bottom: 0.5rem; margin-bottom: 0.8rem; }
.section-hint { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.8rem; }

.race-selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.race-details {
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.04); border-radius: 8px;
  padding: 0.9rem; margin-top: 0.8rem; flex-grow: 1; overflow-y: auto; max-height: 340px;
}
.mixed-badge { background: linear-gradient(135deg, var(--gold) 0%, var(--crimson-bright)); color:#fff; font-size:0.7rem; padding:0.2rem 0.5rem; border-radius: 10px; display:inline-block; margin-bottom:0.4rem; }
.race-desc-text { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.6rem; font-style: italic; }
.race-perk { background: rgba(212,175,55,0.05); border-left: 3px solid var(--gold); padding: 0.5rem 0.7rem; border-radius: 0 4px 4px 0; font-size: 0.82rem; margin-bottom: 0.6rem; }
.race-perk strong { color: var(--gold); }
.race-traits-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.race-trait-tag { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); padding: 0.15rem 0.45rem; border-radius: 3px; font-size: 0.72rem; }

/* Stat tabs */
.stat-method-selector { display: flex; border: 1px solid rgba(255,255,255,0.08); border-radius: 6px; overflow: hidden; margin-bottom: 0.8rem; }
.btn-sub-tab { flex: 1; background: rgba(0,0,0,0.4); border: none; color: var(--text-muted); padding: 0.45rem; cursor: pointer; font-family: var(--font-title); font-size: 0.78rem; transition: all var(--tr); }
.btn-sub-tab.active { background: rgba(212,175,55,0.12); color: var(--gold); }

/* Stat row & distributor */
.stat-row { display: grid; grid-template-columns: 2fr 1.5fr; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; }
.stat-label-col { display: flex; flex-direction: column; }
.stat-name { font-weight: 600; font-size: 0.88rem; }
.stat-desc { font-size: 0.7rem; color: var(--text-muted); }
.stat-ctrl-col { display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,0.3); border-radius: 6px; border: 1px solid rgba(255,255,255,0.04); padding: 0.15rem 0.4rem; }
.btn-stat-adjust { background: transparent; border: none; color: var(--gold); cursor: pointer; padding: 0.25rem 0.5rem; font-size: 1rem; font-weight: bold; }
.stat-val-display { font-family: var(--font-title); font-size: 1rem; width: 22px; text-align: center; }
.points-pool-container { background: rgba(212,175,55,0.07); border: 1px dashed var(--gold); border-radius: 6px; padding: 0.6rem; text-align: center; margin-bottom: 0.8rem; font-size: 0.85rem; }
#points-left-count { font-weight: bold; color: var(--gold); }
.dice-roll-stats-container { background: rgba(0,0,0,0.25); border-radius: 8px; padding: 0.8rem; margin-bottom: 0.8rem; }
.rolled-values-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.rolled-value-tag { background: var(--gold); color: #000; font-family: var(--font-title); font-weight: bold; padding: 0.3rem 0.7rem; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.rolled-value-tag.used { opacity: 0.3; cursor: default; }

/* Stats preview */
.final-stats-preview { margin-top: 0.8rem; }
.final-stats-preview h4 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.stats-grid-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.stat-preview-card { background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.04); border-radius: 6px; padding: 0.45rem; text-align: center; }
.stat-preview-name { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.stat-preview-val { font-family: var(--font-title); font-size: 1.15rem; }
.stat-preview-mod { font-size: 0.75rem; color: var(--gold); font-weight: bold; }

/* Proficiency checkboxes */
.proficiency-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; max-height: 160px; overflow-y: auto; }
.prof-item { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.4rem; border-radius: 4px; cursor: pointer; font-size: 0.78rem; border: 1px solid transparent; transition: all var(--tr); }
.prof-item:hover { background: rgba(212,175,55,0.08); }
.prof-item.checked { background: rgba(212,175,55,0.1); border-color: var(--gold); color: var(--gold); }
.prof-item input[type="checkbox"] { display: none; }

/* Character summary */
.input-with-random { display: flex; gap: 0.4rem; }
.input-with-random input { flex-grow: 1; }
.character-preview-summary { background: rgba(0,0,0,0.25); border-radius: 8px; padding: 0.8rem; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.preview-item { display: flex; justify-content: space-between; font-size: 0.85rem; }
.preview-item .label { color: var(--text-muted); }
.preview-item .val { font-weight: bold; color: var(--gold); }

/* ════════════════════════════════════════
   GAME SCREEN
════════════════════════════════════════ */
.game-container { display: grid; grid-template-columns: 280px 1fr 320px; height: 100vh; background: #080604; }

.game-sidebar {
  border-radius: 0; border: none; border-right: 1px solid var(--card-border);
  height: 100%; display: flex; flex-direction: column; padding: 0.8rem;
  overflow: hidden; background: var(--bg-accent);
}
#sidebar-right { border-right: none; border-left: 1px solid var(--card-border); }

.sidebar-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.06); padding-bottom: 0.6rem; margin-bottom: 0.8rem; }
.sidebar-header h3 { font-size: 1rem; }
.badge { font-size: 0.72rem; background: rgba(212,175,55,0.12); color: var(--gold); border: 1px solid var(--gold); padding: 0.15rem 0.4rem; border-radius: 4px; }

/* DM Indicator */
.dm-badge { background: rgba(155,89,182,0.15); border: 1px solid var(--dm-color); color: #c39bd3; padding: 0.4rem 0.7rem; border-radius: 6px; font-size: 0.8rem; margin-bottom: 0.8rem; text-align: center; }

/* Voice controls */
.local-voice-controls { display: flex; align-items: center; gap: 0.6rem; background: rgba(0,0,0,0.25); border-radius: 8px; padding: 0.5rem; margin-bottom: 0.8rem; border: 1px solid rgba(255,255,255,0.04); }
.btn-voice { background: var(--crimson); border: none; width: 36px; height: 36px; border-radius: 50%; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--tr); }
.btn-voice.active { background: var(--success); box-shadow: 0 0 8px rgba(39,174,96,0.4); }
.voice-status-text { font-size: 0.8rem; color: var(--text-muted); }

/* Players list */
.players-list { display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto; flex-grow: 1; }
.player-item { display: flex; align-items: center; gap: 0.6rem; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.03); border-radius: 8px; padding: 0.5rem; transition: all var(--tr); }
.player-item.is-speaking { box-shadow: 0 0 10px rgba(0,230,118,0.5); border-color: var(--speaking); }
.player-item.is-dm { border-color: rgba(155,89,182,0.4); }

.player-avatar-wrapper { position: relative; flex-shrink: 0; }
.player-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-title); font-weight: bold; font-size: 1rem; border: 2px solid transparent; }
.player-item.is-speaking .player-avatar { border-color: var(--speaking); animation: voicePulse 1.5s infinite; }
.player-item.is-dm .player-avatar { border-color: var(--dm-color); }
.player-mute-badge { position: absolute; bottom: -3px; right: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--crimson-bright); color: #fff; font-size: 0.6rem; display: flex; align-items: center; justify-content: center; }
.player-dm-badge { position: absolute; top: -3px; right: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--dm-color); color: #fff; font-size: 0.6rem; display: flex; align-items: center; justify-content: center; }

.player-info { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }
.player-user-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-hero-name { font-size: 0.72rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub-info { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--text-muted); }

/* ── INITIATIVE TRACKER ─── */
.initiative-tracker { margin-top: 1rem; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 0.8rem; display: flex; flex-direction: column; }
.initiative-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.initiative-header h4 { font-size: 0.85rem; color: var(--gold); }
.round-badge { font-size: 0.72rem; background: rgba(146,32,32,0.3); color: #e87070; border: 1px solid var(--crimson); padding: 0.15rem 0.4rem; border-radius: 4px; }
.initiative-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 180px; overflow-y: auto; }
.initiative-entry { display: flex; align-items: center; gap: 0.5rem; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.04); border-radius: 6px; padding: 0.35rem 0.5rem; font-size: 0.8rem; }
.initiative-entry.current-turn { border-color: var(--gold); background: rgba(212,175,55,0.07); }
.initiative-entry.is-monster { border-left: 3px solid var(--crimson-bright); }
.initiative-entry.is-player { border-left: 3px solid var(--gold); }
.init-roll-badge { font-family: var(--font-title); font-weight: bold; color: var(--gold); font-size: 0.9rem; width: 24px; text-align: center; }
.init-name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.init-remove-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.7rem; padding: 0.1rem 0.2rem; }
.init-remove-btn:hover { color: var(--crimson-bright); }
.no-initiative { color: var(--text-muted); font-size: 0.8rem; text-align: center; padding: 0.6rem; }

.dm-controls { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.dm-add-initiative-row { display: flex; gap: 0.4rem; }
.dm-btn-row { display: flex; gap: 0.4rem; }
.dm-btn-row .btn { flex: 1; }

/* ════════════════════════════════════════
   GAME MAIN PANEL
════════════════════════════════════════ */
.game-main-panel { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* DM SCENE PANEL */
.dm-scene-panel { background: rgba(155,89,182,0.08); border-bottom: 1px solid rgba(155,89,182,0.3); padding: 0.6rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; flex-shrink: 0; }
.dm-scene-header { font-family: var(--font-title); color: #c39bd3; font-size: 0.85rem; }
.dm-scene-row { display: flex; align-items: center; gap: 0.5rem; }
.dm-request-roll-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* CHAT */
.chat-area { border-radius: 0; border: none; flex-grow: 1; display: flex; flex-direction: column; padding: 0.8rem; overflow: hidden; background: rgba(10,7,4,0.97); }
.chat-header { border-bottom: 1px solid rgba(255,255,255,0.06); padding-bottom: 0.4rem; margin-bottom: 0.6rem; }
.chat-messages { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; padding: 0.3rem; }

/* Chat msg bubbles */
.chat-msg { background: rgba(0,0,0,0.3); border-left: 3px solid var(--text-muted); border-radius: 0 6px 6px 0; padding: 0.5rem 0.7rem; max-width: 85%; font-size: 0.88rem; flex-shrink: 0; }
.chat-msg.self { border-left-color: var(--gold); background: rgba(212,175,55,0.05); align-self: flex-end; }
.chat-msg.dm-msg { border-left-color: var(--dm-color); background: rgba(155,89,182,0.06); }
.msg-sender { font-weight: bold; font-size: 0.72rem; color: var(--gold); margin-bottom: 0.15rem; }
.msg-sender.dm-sender { color: #c39bd3; }
.msg-time { font-size: 0.62rem; color: var(--text-muted); float: right; margin-left: 0.5rem; margin-top: 0.15rem; }

/* System messages */
.system-msg { align-self: center; color: var(--text-muted); border: 1px dashed rgba(255,255,255,0.08); padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.78rem; text-align: center; flex-shrink: 0; }

/* Scene event card */
.scene-event-card { align-self: center; width: 95%; border: 1px solid; border-radius: 8px; padding: 0.8rem 1rem; font-size: 0.88rem; text-align: center; animation: rollSlideIn 0.3s ease; flex-shrink: 0; }
.scene-event-card.narrative { border-color: rgba(212,175,55,0.4); background: rgba(212,175,55,0.05); color: var(--text-light); }
.scene-event-card.combat { border-color: rgba(192,57,43,0.6); background: rgba(192,57,43,0.08); color: #e87070; }
.scene-event-card.danger { border-color: rgba(230,126,34,0.6); background: rgba(230,126,34,0.08); color: #f39c12; }
.scene-event-card.reward { border-color: rgba(39,174,96,0.5); background: rgba(39,174,96,0.07); color: #58d68d; }
.scene-event-card.rest { border-color: rgba(52,152,219,0.5); background: rgba(52,152,219,0.07); color: #7fb3d3; }
.scene-event-icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
.scene-event-text { font-style: italic; }

/* Dice roll messages */
.roll-msg { align-self: center; background: linear-gradient(135deg, rgba(20,14,8,0.95), rgba(40,28,16,0.95)); border: 1px solid var(--gold); box-shadow: 0 4px 15px rgba(212,175,55,0.1); border-radius: 8px; padding: 0.7rem 1rem; width: 92%; max-width: 460px; margin: 0.3rem auto; animation: rollSlideIn 0.3s cubic-bezier(0.18,0.89,0.32,1.28); position: relative; overflow: hidden; flex-shrink: 0; }
.roll-msg.critical { border-color: #f1c40f; box-shadow: 0 4px 20px rgba(241,196,15,0.4); }
.roll-msg.fumble { border-color: var(--crimson-bright); box-shadow: 0 4px 20px rgba(192,57,43,0.4); }
.roll-msg.death-save-success { border-color: var(--success); }
.roll-msg.death-save-fail { border-color: var(--crimson-bright); }
.roll-msg::before { content:''; position:absolute; top:0; left:0; width:3px; height:100%; background: var(--gold); }
.roll-msg.critical::before { background: #f1c40f; }
.roll-msg.fumble::before { background: var(--crimson-bright); }
.roll-msg-header { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; border-bottom: 1px solid rgba(255,255,255,0.04); padding-bottom: 0.25rem; }
.roll-msg-header strong { color: var(--gold); }
.roll-msg-action { color: #c39bd3; font-style: italic; }
.roll-msg-body { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.roll-details { display: flex; flex-direction: column; gap: 0.15rem; }
.roll-formula { font-size: 0.8rem; color: var(--text-muted); }
.roll-breakdown { font-size: 0.72rem; color: var(--text-muted); }
.roll-special-label { font-size: 0.72rem; font-weight: bold; padding: 0.1rem 0.4rem; border-radius: 3px; display: inline-block; }
.roll-special-label.critical { background: rgba(241,196,15,0.2); color: #f1c40f; border: 1px solid #f1c40f; }
.roll-special-label.fumble { background: rgba(192,57,43,0.2); color: #e74c3c; border: 1px solid #e74c3c; }
.roll-special-label.death-success { background: rgba(39,174,96,0.2); color: #58d68d; }
.roll-special-label.death-fail { background: rgba(192,57,43,0.2); color: #e74c3c; }
.roll-total-box { background: rgba(0,0,0,0.5); border: 1px solid var(--gold); width: 52px; height: 52px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 0 8px var(--gold-glow); flex-shrink: 0; }
.roll-total-box.critical { border-color: #f1c40f; box-shadow: inset 0 0 12px rgba(241,196,15,0.4); }
.roll-total-box.fumble { border-color: var(--crimson-bright); }
.roll-total-val { font-family: var(--font-title); font-size: 1.5rem; color: var(--gold); font-weight: bold; }
.roll-total-lbl { font-size: 0.58rem; text-transform: uppercase; color: var(--text-muted); }

@keyframes rollSlideIn { from { opacity:0; transform: scale(0.88) translateY(10px); } to { opacity:1; transform: none; } }

/* Chat input */
.chat-input-area { display: flex; gap: 0.6rem; background: rgba(0,0,0,0.35); border-radius: 8px; padding: 0.5rem; border: 1px solid rgba(255,255,255,0.04); margin-top: 0.5rem; }
.chat-input-area input { flex-grow: 1; }

/* ════════════════════════════════════════
   ACTION DICE PANEL
════════════════════════════════════════ */
.action-dice-panel { border-radius: 0; border: none; border-top: 1px solid var(--card-border); padding: 0.8rem; background: rgba(12,8,4,0.98); flex-shrink: 0; }

/* Tabs */
.action-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.8rem; }
.action-tab { background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.06); color: var(--text-muted); padding: 0.35rem 0.8rem; border-radius: 6px; cursor: pointer; font-size: 0.82rem; font-family: var(--font-title); transition: all var(--tr); }
.action-tab.active { background: rgba(212,175,55,0.12); border-color: var(--gold); color: var(--gold); }
.action-tab-content { display: none; }
.action-tab-content.active { display: block; }

/* Action Buttons Grid */
.action-buttons-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 0.6rem; }
.action-btn {
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
  color: var(--text-light); padding: 0.5rem 0.3rem; cursor: pointer; transition: all var(--tr);
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem; font-size: 0.8rem; text-align: center;
}
.action-btn i { font-size: 1.1rem; }
.action-dice-label { font-size: 0.65rem; color: var(--text-muted); }
.action-btn:hover { transform: translateY(-2px); }
.btn-attack { border-color: rgba(192,57,43,0.4); }
.btn-attack:hover { border-color: var(--crimson-bright); background: rgba(192,57,43,0.1); color: #e87070; box-shadow: 0 4px 10px rgba(192,57,43,0.25); }
.btn-attack:hover .action-dice-label { color: #e87070; }
.btn-damage { border-color: rgba(230,126,34,0.3); }
.btn-damage:hover { border-color: #e67e22; background: rgba(230,126,34,0.1); color: #f39c12; }
.btn-initiative { border-color: rgba(52,152,219,0.3); }
.btn-initiative:hover { border-color: #3498db; background: rgba(52,152,219,0.1); color: #85c1e9; }
.btn-deathsave { border-color: rgba(100,100,100,0.3); }
.btn-deathsave:hover { border-color: #888; background: rgba(100,100,100,0.1); color: #ddd; }
.btn-heal { border-color: rgba(39,174,96,0.3); }
.btn-heal:hover { border-color: var(--success); background: rgba(39,174,96,0.1); color: #58d68d; }
.btn-spell { border-color: rgba(155,89,182,0.3); }
.btn-spell:hover { border-color: var(--dm-color); background: rgba(155,89,182,0.1); color: #c39bd3; }
.btn-spell-dmg:hover { border-color: #af7ac5; background: rgba(175,122,197,0.1); color: #d7bde2; }
.btn-ability:hover { border-color: var(--gold); background: rgba(212,175,55,0.08); color: var(--gold); }

/* Weapon selector */
.weapon-damage-row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; background: rgba(230,126,34,0.06); border-radius: 6px; padding: 0.4rem 0.6rem; flex-wrap: wrap; }
.weapon-damage-row span { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.weapon-damage-row select { flex: 1; min-width: 160px; }

/* Skills Grid */
.skills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.skill-btn { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.06); border-radius: 6px; padding: 0.35rem 0.6rem; cursor: pointer; transition: all var(--tr); display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--text-light); }
.skill-btn:hover { border-color: var(--gold); background: rgba(212,175,55,0.07); color: var(--gold); }
.skill-stat-label { font-size: 0.62rem; color: var(--text-muted); background: rgba(255,255,255,0.05); padding: 0.1rem 0.3rem; border-radius: 3px; }
.skill-mod-label { font-family: var(--font-title); font-size: 0.82rem; color: var(--gold); }
.skill-proficient .skill-stat-label { color: var(--gold); background: rgba(212,175,55,0.15); }

/* Saves Grid */
.saves-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.save-btn { background: rgba(0,0,0,0.3); border: 1px solid rgba(52,152,219,0.2); border-radius: 8px; padding: 0.6rem; cursor: pointer; transition: all var(--tr); display: flex; flex-direction: column; align-items: center; gap: 0.2rem; font-size: 0.78rem; text-align: center; }
.save-btn:hover { border-color: #3498db; background: rgba(52,152,219,0.08); transform: translateY(-2px); }
.save-btn-stat { font-family: var(--font-title); font-size: 0.65rem; text-transform: uppercase; color: var(--text-muted); }
.save-btn-mod { font-family: var(--font-title); font-size: 1.1rem; color: #85c1e9; }

/* Custom dice tab */
.dice-buttons { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; margin-bottom: 0.7rem; }
.btn-dice { background: linear-gradient(135deg, #1a0f07, #251811); border: 1px solid var(--card-border); color: var(--text-light); border-radius: 8px; padding: 0.6rem 0; cursor: pointer; font-family: var(--font-title); font-size: 1rem; text-align: center; transition: all var(--tr); }
.btn-dice:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 6px 12px var(--gold-glow); }
.btn-dice.selected { border-color: var(--gold); box-shadow: 0 0 10px var(--gold-glow); background: rgba(212,175,55,0.1); }
.custom-roll-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.custom-count, .modifier-input { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-muted); }
.mod-quick-btns { display: flex; gap: 0.3rem; }
.btn-mod-shortcut { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); padding: 0.25rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.78rem; }
.btn-mod-shortcut:hover { border-color: var(--gold); color: var(--gold); }

/* ════════════════════════════════════════
   CHARACTER SHEET (right sidebar)
════════════════════════════════════════ */
.char-sheet-scrollable { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.char-sheet-hero-header { text-align: center; border-bottom: 1px dashed rgba(255,255,255,0.07); padding-bottom: 0.6rem; }
.char-sheet-hero-name { font-size: 1.2rem; }
.char-sheet-hero-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Vitality HP/AC */
.char-sheet-vitality { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.vitality-card { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; padding: 0.6rem; text-align: center; }
.vitality-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.2rem; }
.vitality-val { font-family: var(--font-title); font-size: 1.2rem; font-weight: bold; }
.vitality-ctrls { display: flex; justify-content: center; gap: 0.4rem; margin-top: 0.3rem; }
.btn-vitality-adj { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); color: var(--text-light); width: 22px; height: 22px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.btn-vitality-adj:hover { background: var(--gold); color: #000; border-color: var(--gold); }

/* Stats on sheet */
.char-sheet-stats-section { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.sheet-stat-card { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.04); border-radius: 6px; padding: 0.45rem; text-align: center; cursor: pointer; transition: all var(--tr); }
.sheet-stat-card:hover { border-color: var(--gold); box-shadow: 0 0 6px var(--gold-glow); transform: scale(1.04); }
.sheet-stat-name { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; }
.sheet-stat-val { font-family: var(--font-title); font-size: 1.1rem; }
.sheet-stat-mod { font-size: 0.72rem; color: var(--gold); font-weight: bold; }

/* Ability and traits section */
.char-sheet-abilities-section h4 { font-family: var(--font-title); font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.06); padding-bottom: 0.3rem; margin-bottom: 0.4rem; }
.ability-block-text { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; background: rgba(0,0,0,0.2); border-radius: 6px; padding: 0.5rem; white-space: pre-line; }

/* Death saves tracker */
.death-saves-section h4 { font-family: var(--font-title); font-size: 0.85rem; margin-bottom: 0.4rem; }
.death-saves-row { display: flex; justify-content: space-between; align-items: center; }
.death-saves-label { font-size: 0.75rem; color: var(--text-muted); }
.death-saves-pips { display: flex; gap: 0.3rem; }
.death-pip { width: 18px; height: 18px; border-radius: 50%; border: 2px solid; cursor: pointer; transition: all var(--tr); }
.death-pip.success { border-color: var(--success); }
.death-pip.success.filled { background: var(--success); }
.death-pip.fail { border-color: var(--crimson-bright); }
.death-pip.fail.filled { background: var(--crimson-bright); }

/* Proficiency badges */
.proficiency-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.prof-badge { background: rgba(212,175,55,0.1); border: 1px solid rgba(212,175,55,0.3); color: var(--gold); font-size: 0.68rem; padding: 0.15rem 0.4rem; border-radius: 4px; }

/* ════════════════════════════════════════
   ROLL REQUEST TOAST
════════════════════════════════════════ */
.roll-request-toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: rgba(20,12,6,0.97); border: 1px solid var(--dm-color); border-radius: 10px;
  padding: 1rem 1.2rem; display: flex; align-items: center; gap: 1rem;
  z-index: 9999; box-shadow: 0 8px 30px var(--dm-glow); min-width: 320px;
  animation: toastIn 0.4s cubic-bezier(0.18,0.89,0.32,1.28);
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(20px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
.toast-icon { font-size: 1.5rem; color: #c39bd3; }
.toast-body { flex-grow: 1; }
.toast-title { font-family: var(--font-title); color: #c39bd3; font-size: 0.9rem; }
.toast-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.1rem; }
.toast-dc { font-size: 0.78rem; color: var(--gold); margin-top: 0.1rem; }
.toast-close { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; }
.toast-close:hover { color: #fff; }

/* ════════════════════════════════════════
   ANIMATIONS
════════════════════════════════════════ */
@keyframes voicePulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(0, 230, 118, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 1100px) {
  .game-container { grid-template-columns: 240px 1fr; }
  #sidebar-right { display: none; }
  .action-buttons-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .game-container { grid-template-columns: 1fr; }
  #sidebar-left { display: none; }
  .action-buttons-grid { grid-template-columns: repeat(2, 1fr); }
  .char-content { grid-template-columns: 1fr; }
  .dice-buttons { grid-template-columns: repeat(4, 1fr); }
}

/* Location Background System */
.game-location-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.24) contrast(0.95) saturate(0.85);
  transition: background-image 1.2s ease-in-out, opacity 1s ease-in-out;
  opacity: 0;
  pointer-events: none;
}
.game-location-bg.active {
  opacity: 1;
}

#screen-game {
  position: relative;
  overflow: hidden;
  background: #050403;
}

/* Glassmorphism panel overrides for immersive background */
.game-container {
  position: relative;
  z-index: 1;
  background: transparent !important;
}
.game-sidebar {
  background: rgba(20, 16, 10, 0.85) !important;
  backdrop-filter: blur(10px);
}
.chat-area {
  background: rgba(10, 7, 4, 0.8) !important;
  backdrop-filter: blur(10px);
}
.action-dice-panel {
  background: rgba(12, 8, 4, 0.86) !important;
  backdrop-filter: blur(10px);
}

/* Monster Target & HP Styles */
.initiative-entry.is-target { border: 2px solid var(--accent); box-shadow: 0 0 10px rgba(243,139,168, 0.5); }
.monster-hp-bar { display: inline-block; width: 100px; height: 10px; background: #313244; border-radius: 5px; overflow: hidden; margin-left: 10px; vertical-align: middle; }
.monster-hp-fill { height: 100%; background: #f38ba8; transition: width 0.3s ease; }
.monster-hp-text { font-size: 0.7rem; color: #a6adc8; margin-left: 5px; }
