/* ═══════════════════════════════════════════════════════════════
   DARKQUEST — Donjon des Ombres
   Medieval Dark Fantasy UI — Complete Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* L'attribut HTML `hidden` doit TOUJOURS l'emporter. Sans ça, les nombreuses
   règles `display: flex/block/grid` de ce fichier écrasent `hidden` (les écrans,
   l'overlay de chargement et les panneaux s'affichent tous empilés). */
[hidden] {
  display: none !important;
}

/* ─── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Base colors */
  --bg-primary:       #0f0804;
  --bg-secondary:     #1a0e0a;
  --bg-tertiary:      #231510;
  --bg-panel:         rgba(26, 14, 10, 0.85);
  --bg-card:          rgba(35, 21, 13, 0.90);

  /* Accent palette */
  --gold:             #c9a84c;
  --gold-light:       #e8c96a;
  --gold-dark:        #9a7a2a;
  --gold-glow:        rgba(201, 168, 76, 0.35);
  --amber:            #e8a930;
  --amber-light:      #f5c842;

  /* Danger / Combat */
  --blood-red:        #8b1a1a;
  --red-bright:       #e05555;
  --red-glow:         rgba(224, 85, 85, 0.3);

  /* Nature / NPC */
  --green-npc:        #5fba7d;
  --green-dark:       #2E7D32;

  /* Info / Riddle */
  --blue-info:        #7eb8e0;

  /* Text */
  --text-primary:     #e8d5b0;
  --text-secondary:   #b5997a;
  --text-muted:       #7a5e45;
  --text-dim:         #5a4030;

  /* Borders */
  --border-gold:      rgba(201, 168, 76, 0.3);
  --border-gold-bright: rgba(201, 168, 76, 0.6);
  --border-dark:      rgba(255, 255, 255, 0.06);

  /* Glassmorphism */
  --glass-bg:         rgba(26, 14, 10, 0.75);
  --glass-blur:       12px;

  /* Fonts */
  --font-title:       'Cinzel Decorative', 'Cinzel', serif;
  --font-heading:     'Cinzel', serif;
  --font-body:        'Crimson Text', Georgia, serif;

  /* Sizing */
  --map-width:        280px;
  --hud-width:        280px;
  --header-height:    58px;
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        16px;
  --radius-xl:        24px;

  /* Transitions */
  --transition-fast:  0.15s ease;
  --transition-med:   0.3s ease;
  --transition-slow:  0.5s ease;

  /* Shadows */
  --shadow-gold:      0 0 20px rgba(201, 168, 76, 0.2), 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-panel:     0 8px 32px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-deep:      0 16px 48px rgba(0, 0, 0, 0.8);
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  /* Subtle noise texture overlay */
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(201,168,76,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(139,26,26,0.06) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ─── Screen System ──────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  animation: screenFadeIn 0.5s ease;
}

.screen-active {
  display: block;
}

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

/* ─── Particle Background ────────────────────────────────────── */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: particleDrift var(--dur, 8s) var(--delay, 0s) infinite ease-in-out;
}

@keyframes particleDrift {
  0%   { opacity: 0; transform: translateY(100vh) scale(0); }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.2; }
  100% { opacity: 0; transform: translateY(-20px) scale(1.5); }
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ─── Typography ─────────────────────────────────────────────── */
.title-main {
  font-family: var(--font-title);
  font-size: clamp(2.8rem, 6vw, 5.5rem);
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 30px rgba(201,168,76,0.6),
    0 0 60px rgba(201,168,76,0.3),
    0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 0.12em;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.title-sub {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--text-secondary);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.title-lore {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 0.8rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  font-family: var(--font-body);
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-style: italic;
}

/* ─── Decorative Dividers ────────────────────────────────────── */
.title-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem auto;
  width: 280px;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.divider-line.gold {
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.divider-line.red {
  background: linear-gradient(90deg, transparent, var(--blood-red), transparent);
}

.divider-gem {
  color: var(--gold);
  font-size: 0.75rem;
  text-shadow: 0 0 8px var(--gold);
}

.divider-gem.red { color: var(--red-bright); text-shadow: 0 0 8px var(--red-bright); }
.divider-gem.small { font-size: 0.55rem; }

/* ─── Glass Panel ────────────────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  position: relative;
  overflow: hidden;
}

.glass-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

/* Corner ornaments */
.glass-panel::after {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  right: 8px; bottom: 8px;
  border-radius: calc(var(--radius-lg) - 4px);
  border: 1px solid rgba(201,168,76,0.08);
  pointer-events: none;
}

/* ─── Logo Rune ──────────────────────────────────────────────── */
.logo-rune {
  font-size: 4rem;
  display: block;
  text-align: center;
  color: var(--gold);
  text-shadow:
    0 0 20px rgba(201,168,76,0.8),
    0 0 40px rgba(201,168,76,0.4);
  animation: runePulse 3s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

.logo-rune.small {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

@keyframes runePulse {
  0%, 100% { text-shadow: 0 0 20px rgba(201,168,76,0.8), 0 0 40px rgba(201,168,76,0.4); }
  50%       { text-shadow: 0 0 30px rgba(201,168,76,1),   0 0 60px rgba(201,168,76,0.6), 0 0 80px rgba(201,168,76,0.2); }
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 1 — WELCOME
   ════════════════════════════════════════════════════════════════ */
#screen-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.08) 0%, transparent 70%),
    radial-gradient(ellipse at 50% 100%, rgba(139,26,26,0.1) 0%, transparent 60%),
    var(--bg-primary);
}

.welcome-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  max-width: 520px;
}

.welcome-logo {
  text-align: center;
}

.welcome-panel {
  width: 100%;
  padding: 2.5rem;
}

.welcome-panel .panel-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--gold);
  text-align: center;
  margin-bottom: 2rem;
  letter-spacing: 0.08em;
}

.welcome-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.welcome-version {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.4rem;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.label-icon {
  margin-right: 0.3rem;
}

.label-hint {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: normal;
  letter-spacing: 0;
  margin-left: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    opacity var(--transition-fast);
  position: relative;
  overflow: hidden;
  user-select: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #9a7a2a 0%, var(--gold) 50%, #9a7a2a 100%);
  background-size: 200% 100%;
  color: #1a0e0a;
  padding: 0.7rem 1.4rem;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(201,168,76,0.3), 0 1px 0 rgba(255,255,255,0.1) inset;
  border: 1px solid rgba(201,168,76,0.5);
}

.btn-primary:hover {
  background-position: right center;
  box-shadow: 0 4px 20px rgba(201,168,76,0.5), 0 1px 0 rgba(255,255,255,0.15) inset;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(201,168,76,0.1);
  color: var(--gold);
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--border-gold);
}

.btn-secondary:hover {
  background: rgba(201,168,76,0.2);
  border-color: var(--gold);
}

.btn-danger {
  background: linear-gradient(135deg, #6b1212 0%, var(--blood-red) 50%, #6b1212 100%);
  background-size: 200% 100%;
  color: var(--text-primary);
  padding: 0.7rem 1.4rem;
  font-weight: 700;
  border: 1px solid rgba(139,26,26,0.5);
  box-shadow: 0 2px 12px rgba(139,26,26,0.3);
}

.btn-danger:hover {
  background-position: right center;
  box-shadow: 0 4px 20px rgba(224,85,85,0.4);
  transform: translateY(-1px);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
  width: 100%;
  justify-content: center;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
}

.btn-tiny {
  background: rgba(201,168,76,0.08);
  color: var(--text-secondary);
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
}

.btn-tiny:hover {
  background: rgba(201,168,76,0.2);
  color: var(--gold);
  border-color: var(--border-gold);
}

.btn-class {
  background: rgba(0,0,0,0.3);
  color: var(--class-color, var(--gold));
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.55rem 1.2rem;
  font-size: 0.82rem;
  margin-top: auto;
  width: 100%;
  justify-content: center;
  transition: all var(--transition-med);
}

.btn-class:hover {
  background: var(--class-color, var(--gold));
  color: #1a0e0a;
  border-color: var(--class-color, var(--gold));
  box-shadow: 0 0 16px rgba(201,168,76,0.4);
}

.btn-dice {
  background: linear-gradient(135deg, #3a1a0a 0%, #5a2a10 100%);
  color: var(--gold);
  border: 1px solid var(--border-gold);
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  flex: 1;
}

.btn-dice:hover {
  background: linear-gradient(135deg, #5a2a10 0%, #7a3a18 100%);
  box-shadow: 0 0 12px var(--gold-glow);
}

.btn-action {
  background: rgba(35,21,13,0.8);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-action:hover {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}

.btn-action.combat {
  border-color: rgba(139,26,26,0.5);
  color: var(--red-bright);
}

.btn-action.combat:hover {
  background: rgba(139,26,26,0.2);
  border-color: var(--red-bright);
  box-shadow: 0 0 10px var(--red-glow);
}

.btn-icon { font-size: 1.1rem; }

.btn-shimmer {
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: skewX(-20deg);
  animation: shimmerSlide 3s 1s infinite;
}

@keyframes shimmerSlide {
  0%   { left: -100%; }
  100% { left: 200%; }
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 2 — CLASS SELECTION
   ════════════════════════════════════════════════════════════════ */
#screen-class {
  min-height: 100vh;
  padding: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 50%, rgba(106,27,154,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 50%, rgba(139,69,19,0.06) 0%, transparent 60%),
    var(--bg-primary);
}

.class-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
}

.class-header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-top: 1rem;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.5rem;
}

.class-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.4rem 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition:
    transform var(--transition-med),
    box-shadow var(--transition-med),
    border-color var(--transition-med);
  position: relative;
  overflow: hidden;
}

.class-card:hover {
  transform: translateY(-6px);
  border-color: var(--class-color, var(--gold));
  box-shadow:
    0 12px 40px rgba(0,0,0,0.5),
    0 0 20px rgba(201,168,76,0.15),
    0 0 0 1px rgba(201,168,76,0.1) inset;
}

.class-card.selected {
  border-color: var(--class-color, var(--gold));
  box-shadow: 0 0 30px rgba(201,168,76,0.3), inset 0 0 20px rgba(201,168,76,0.05);
}

.class-glow {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--class-color, var(--gold)), transparent);
  opacity: 0;
  transition: opacity var(--transition-med);
}

.class-card:hover .class-glow { opacity: 1; }

.class-emoji {
  font-size: 2.8rem;
  display: block;
  filter: drop-shadow(0 0 8px var(--class-color, var(--gold)));
  transition: transform var(--transition-med);
}

.class-card:hover .class-emoji { transform: scale(1.15); }

.class-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--class-color, var(--gold));
  text-shadow: 0 0 10px rgba(201,168,76,0.4);
  letter-spacing: 0.06em;
}

.class-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}

.class-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
}

.class-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
}

.stat-mini-label {
  font-family: var(--font-heading);
  color: var(--text-muted);
  width: 30px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.stat-mini-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.stat-mini-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--class-color, var(--gold-dark)), var(--class-color, var(--gold)));
  border-radius: 2px;
  opacity: 0.8;
}

.class-skills-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.skill-tag {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 3 — GAME
   ════════════════════════════════════════════════════════════════ */
#screen-game {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Game Header ────────────────────────────────────────────── */
.game-header {
  height: var(--header-height);
  background: rgba(10, 6, 3, 0.95);
  border-bottom: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.6);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.header-rune {
  color: var(--gold);
  font-size: 1.4rem;
  text-shadow: 0 0 10px var(--gold);
}

.header-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-shadow: 0 0 15px var(--gold-glow);
}

.header-subtitle {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.session-label {
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.session-id-display {
  color: var(--gold);
  font-family: monospace;
  font-size: 0.8rem;
  background: rgba(201,168,76,0.08);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--border-gold);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-room-display {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.room-label { font-size: 0.75rem; }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.players-online {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  background: rgba(0,0,0,0.3);
}

.connection-status.connected { color: var(--green-npc); border: 1px solid rgba(95,186,125,0.3); }
.connection-status.disconnected { color: var(--red-bright); border: 1px solid rgba(224,85,85,0.3); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ─── Game Grid ──────────────────────────────────────────────── */
.game-grid {
  display: grid;
  /* Par défaut : carte masquée → journal prend toute la place, statut à droite */
  grid-template-columns: 1fr var(--hud-width);
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* Quand la carte est visible, on lui réserve sa colonne à gauche */
.game-grid:has(#panel-map:not([hidden])) {
  grid-template-columns: var(--map-width) 1fr var(--hud-width);
}

/* ─── Panels (shared) ────────────────────────────────────────── */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-panel);
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent);
  opacity: 0.6;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-gold);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

.panel-title-small {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-badge {
  background: rgba(201,168,76,0.15);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  border: 1px solid var(--border-gold);
}

/* ════════════════════════════════════════════════════════════════
   MAP PANEL
   ════════════════════════════════════════════════════════════════ */
.panel-map {
  overflow: hidden;
}

.map-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#dungeon-map {
  width: 100%;
  height: auto;
}

/* SVG Room Styles */
.room-rect {
  fill: rgba(20, 12, 8, 0.9);
  stroke: var(--text-dim);
  stroke-width: 1.5;
  transition: fill 0.4s ease, stroke 0.4s ease, filter 0.4s ease;
}

.map-room {
  cursor: pointer;
}

.map-room.locked .room-rect {
  fill: rgba(15, 8, 5, 0.95);
  stroke: var(--text-dim);
  opacity: 0.5;
}

.map-room.visited .room-rect {
  fill: rgba(35, 22, 8, 0.9);
  stroke: var(--gold-dark);
  stroke-width: 1.5;
}

.map-room.current .room-rect {
  fill: rgba(50, 32, 8, 0.95);
  stroke: var(--gold);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(201,168,76,0.7));
  animation: roomGlow 2s ease-in-out infinite;
}

.map-room.cleared .room-rect {
  fill: rgba(20, 45, 20, 0.8);
  stroke: var(--green-npc);
  stroke-width: 1.5;
}

.map-room.cleared.room-boss .room-rect {
  fill: rgba(40, 80, 40, 0.85);
}

.room-boss .room-rect {
  stroke: var(--blood-red);
}

@keyframes roomGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(201,168,76,0.6)); }
  50%       { filter: drop-shadow(0 0 12px rgba(201,168,76,0.9)) drop-shadow(0 0 20px rgba(201,168,76,0.4)); }
}

.room-emoji {
  font-size: 12px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.room-name {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  fill: var(--text-secondary);
  text-anchor: middle;
  dominant-baseline: middle;
  transition: fill 0.3s ease;
}

.map-room.current .room-name { fill: var(--gold); }
.map-room.locked  .room-name { fill: var(--text-dim); }
.map-room.cleared .room-name { fill: var(--green-npc); }

.room-name-sub {
  font-family: 'Cinzel', serif;
  font-size: 6px;
  fill: var(--blood-red);
  text-anchor: middle;
  dominant-baseline: middle;
}

.boss-label { fill: var(--amber); }

.map-connector {
  stroke: var(--text-dim);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  opacity: 0.5;
  transition: stroke 0.4s ease, opacity 0.4s ease;
}

.map-connector.active {
  stroke: var(--gold-dark);
  stroke-dasharray: none;
  opacity: 0.8;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-gold);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid;
  flex-shrink: 0;
}

.legend-dot.current { background: rgba(50,32,8,0.95); border-color: var(--gold); box-shadow: 0 0 4px var(--gold); }
.legend-dot.visited { background: rgba(35,22,8,0.9); border-color: var(--gold-dark); }
.legend-dot.locked  { background: rgba(15,8,5,0.95); border-color: var(--text-dim); opacity: 0.5; }
.legend-dot.cleared { background: rgba(20,45,20,0.8); border-color: var(--green-npc); }

/* ════════════════════════════════════════════════════════════════
   NARRATION PANEL
   ════════════════════════════════════════════════════════════════ */
.panel-narration {
  display: flex;
  flex-direction: column;
}

/* ─── Image de salle ────────────────────────────────────────── */
.room-image-container {
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-gold);
  max-height: 240px;
}

.room-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  filter: brightness(0.85) saturate(1.1);
  transition: opacity 0.5s ease;
}

.room-image-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0.4rem 1rem;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  color: var(--gold-light);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

/* ─── Narration Log ──────────────────────────────────────────── */
.narration-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
}

.narration-log > * + * { margin-top: 0.1rem; }

/* Message types */
.narration-log p,
.log-entry {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.55;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  animation: logEntryIn 0.3s ease;
}

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

.msg-room    { color: var(--gold); }
.msg-combat  { color: var(--red-bright); }
.msg-system  { color: #888; font-style: italic; }
.msg-npc     { color: var(--green-npc); }
.msg-riddle  { color: var(--blue-info); }
.msg-victory { color: #ffd700; font-weight: 600; }
.msg-death   { color: var(--red-bright); font-style: italic; }
.msg-event   { color: #c87941; }
.msg-dice    { color: var(--amber); font-family: var(--font-heading); font-size: 0.88rem; }

.log-timestamp {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: monospace;
  margin-right: 0.5rem;
}

.log-welcome { padding: 1rem; }
.log-separator {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: var(--font-heading);
  letter-spacing: 0.15em;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* ─── NPC Dialogue ───────────────────────────────────────────── */
.npc-dialogue-box {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 1rem 1.2rem;
  background: rgba(20, 40, 20, 0.5);
  border-top: 1px solid rgba(95, 186, 125, 0.3);
  border-bottom: 1px solid rgba(95, 186, 125, 0.3);
  position: relative;
  flex-shrink: 0;
  animation: slideUp 0.3s ease;
}

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

.npc-portrait {
  font-size: 2.2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(95,186,125,0.4));
}

.npc-speech { flex: 1; min-width: 0; }

.npc-name {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--green-npc);
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.npc-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.55;
  font-style: italic;
}

.npc-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
}

/* ─── Riddle Area ────────────────────────────────────────────── */
.riddle-area {
  padding: 1rem 1.2rem;
  background: rgba(10, 20, 35, 0.5);
  border-top: 1px solid rgba(126, 184, 224, 0.25);
  flex-shrink: 0;
  animation: slideUp 0.3s ease;
}

.riddle-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.riddle-icon { font-size: 1.2rem; }

.riddle-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--blue-info);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.riddle-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.55;
  margin-bottom: 0.8rem;
  padding: 0.6rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--blue-info);
}

.riddle-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.riddle-answer {
  flex: 1;
  min-width: 0;
}

/* ─── Action Area ────────────────────────────────────────────── */
.action-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-gold);
  flex-shrink: 0;
  background: rgba(0,0,0,0.15);
}

/* Boutons de sortie narratifs — style discret pour les retours, doré pour avancer */
.btn-exit {
  font-size: 0.85rem;
  font-style: italic;
}
.btn-exit.btn-secondary {
  opacity: 0.75;
  border-color: rgba(201,168,76,0.3);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.action-placeholder {
  font-size: 0.85rem;
}

.skill-select {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  outline: none;
}

.skill-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

/* ─── Dice Area — déplacée dans le panneau statut ────────────── */
.dice-area {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

.dice-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
}

.die-wrapper {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.die {
  font-size: 2rem;
  transition: all 0.3s ease;
  display: block;
  line-height: 1;
}

.die-wrapper.rolling .die {
  animation: diceRollAnim 0.8s ease-in-out;
}

@keyframes diceRollAnim {
  0%   { transform: rotate(0deg)   scale(1);    filter: blur(0px); }
  20%  { transform: rotate(120deg) scale(1.2);  filter: blur(1px); }
  40%  { transform: rotate(250deg) scale(0.9);  filter: blur(2px); }
  60%  { transform: rotate(330deg) scale(1.15); filter: blur(1px); }
  80%  { transform: rotate(360deg) scale(1.05); filter: blur(0.5px); }
  100% { transform: rotate(360deg) scale(1);    filter: blur(0px); }
}

.dice-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.result-number {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 15px var(--gold-glow);
  line-height: 1;
  animation: resultPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes resultPop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1);   opacity: 1; }
}

.result-detail {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.dice-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
}

.die-type-select {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  outline: none;
}

.die-type-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

/* ════════════════════════════════════════════════════════════════
   HUD PANEL
   ════════════════════════════════════════════════════════════════ */
.panel-hud {
  overflow-y: auto;
}

.hud-my-char {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.char-identity {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.char-class-emoji {
  font-size: 2.2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

.char-info { min-width: 0; }

.char-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-class-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
}

/* ─── HP Bar ─────────────────────────────────────────────────── */
.hp-section { width: 100%; }

.hp-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.hp-label {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hp-values {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.hp-bar-track {
  height: 10px;
  background: rgba(0,0,0,0.5);
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  position: relative;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #1e7a1e, #4caf50, #80e080);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s ease;
  position: relative;
  overflow: hidden;
}

.hp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: hpShimmer 2s 0.5s infinite;
}

@keyframes hpShimmer {
  0%   { left: -60%; }
  100% { left: 160%; }
}

/* HP color states via JS class */
.hp-bar-fill.hp-medium {
  background: linear-gradient(90deg, #7a4a00, #c87800, #ffa000);
}

.hp-bar-fill.hp-low {
  background: linear-gradient(90deg, #6b0000, #b71c1c, #e53935);
  animation: hpDanger 1s ease-in-out infinite alternate, hpShimmer 2s 0.5s infinite;
}

@keyframes hpDanger {
  from { filter: brightness(1); }
  to   { filter: brightness(1.3); }
}

/* ─── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.stat-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.2rem;
  text-align: center;
  transition: border-color var(--transition-fast);
}

.stat-box:hover { border-color: var(--border-gold); }

.stat-value {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--gold);
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-family: var(--font-heading);
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── HUD Sections ───────────────────────────────────────────── */
.hud-section {
  width: 100%;
}

.hud-section-title {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--gold-dark);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-gold);
}

.hud-section-title.red { color: var(--red-bright); border-color: rgba(224,85,85,0.3); }

.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.skill-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.skill-item:hover {
  background: rgba(201,168,76,0.1);
  border-color: var(--border-gold);
  color: var(--gold);
}

.skill-icon { font-size: 0.9rem; }

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.inventory-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.inventory-item:hover {
  background: rgba(201,168,76,0.1);
  border-color: var(--border-gold);
  color: var(--gold);
}

/* ─── HUD Divider ────────────────────────────────────────────── */
.hud-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
}

.hud-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.hud-divider-line.red {
  background: linear-gradient(90deg, transparent, var(--blood-red), transparent);
}

/* ─── Other Players ──────────────────────────────────────────── */
.hud-other-players {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hud-enemies {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hud-empty {
  font-size: 0.82rem;
  padding: 0.5rem 0;
}

.player-card-mini {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.player-card-mini-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.player-mini-identity {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.player-mini-emoji { font-size: 1rem; }

.player-mini-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-mini-class {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
}

.hp-mini-track {
  height: 5px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
}

.hp-mini-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #1e7a1e, #4caf50);
  transition: width 0.5s ease, background 0.5s ease;
}

.hp-mini-fill.hp-medium { background: linear-gradient(90deg, #7a4a00, #ffa000); }
.hp-mini-fill.hp-low    { background: linear-gradient(90deg, #6b0000, #e53935); }

.enemy-card {
  background: rgba(35, 5, 5, 0.4);
  border: 1px solid rgba(139,26,26,0.4);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.enemy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.enemy-name {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--red-bright);
}

.enemy-hp-text {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.hp-enemy-fill {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #6b0000, var(--red-bright));
  transition: width 0.5s ease;
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 4 — VICTORY / SCREEN 5 — DEATH
   ════════════════════════════════════════════════════════════════ */
#screen-victory,
#screen-death {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

#screen-victory {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(201,168,76,0.12) 0%, transparent 60%),
    var(--bg-primary);
}

#screen-death {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(139,26,26,0.15) 0%, transparent 60%),
    var(--bg-primary);
}

.endgame-container {
  position: relative;
  z-index: 1;
  max-width: 600px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.victory-crown {
  font-size: 5rem;
  animation: crownFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(201,168,76,0.6));
}

@keyframes crownFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-10px) rotate(5deg); }
}

.death-skull {
  font-size: 5rem;
  animation: skullShake 4s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(139,26,26,0.6));
}

@keyframes skullShake {
  0%, 90%, 100% { transform: rotate(0deg); }
  92%  { transform: rotate(-8deg); }
  94%  { transform: rotate(8deg); }
  96%  { transform: rotate(-4deg); }
  98%  { transform: rotate(4deg); }
}

.endgame-title {
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  letter-spacing: 0.1em;
}

.victory-title {
  color: var(--gold);
  text-shadow: 0 0 40px rgba(201,168,76,0.7), 0 0 80px rgba(201,168,76,0.3);
  animation: victoryGlow 2s ease-in-out infinite alternate;
}

@keyframes victoryGlow {
  from { text-shadow: 0 0 30px rgba(201,168,76,0.7), 0 0 60px rgba(201,168,76,0.3); }
  to   { text-shadow: 0 0 50px rgba(201,168,76,1),   0 0 100px rgba(201,168,76,0.5), 0 0 0px rgba(232,169,48,0.3); }
}

.death-title {
  color: var(--red-bright);
  text-shadow: 0 0 40px rgba(224,85,85,0.6), 0 0 80px rgba(139,26,26,0.4);
}

.endgame-subtitle {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  font-style: italic;
}

.victory-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 300px;
}

.victory-rewards {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.reward-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}

.reward-icon { font-size: 1.5rem; }

.reward-text {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
}

.endgame-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.death-message {
  background: rgba(50, 0, 0, 0.3);
  border: 1px solid rgba(139,26,26,0.4);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.5rem;
  width: 100%;
}

.death-epitaph {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-dim);
  font-size: 1rem;
}

/* ════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
  pointer-events: none;
}

.toast {
  background: rgba(26, 14, 10, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  max-width: 340px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.toast.toast-success { border-color: rgba(95,186,125,0.5); }
.toast.toast-error   { border-color: rgba(224,85,85,0.5); }
.toast.toast-info    { border-color: var(--border-gold); }

.toast.removing { animation: toastOut 0.3s ease forwards; }

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

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

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-msg  { flex: 1; }

/* ════════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ════════════════════════════════════════════════════════════════ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 3, 0.92);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* L'attribut `hidden` doit réellement masquer l'overlay : sans cette règle,
   `display: flex` ci-dessus l'emporte sur `hidden` (display:none du navigateur),
   l'overlay reste affiché en permanence et bloque TOUS les clics. */
.loading-overlay[hidden] {
  display: none;
}

.loading-spinner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.spinner-rune {
  font-size: 3rem;
  color: var(--gold);
  animation: spinnerRotate 1.5s linear infinite;
  display: inline-block;
}

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

.loading-text {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  animation: loadingBlink 1.5s ease-in-out infinite;
}

@keyframes loadingBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ════════════════════════════════════════════════════════════════
   COMBAT FLASH EFFECTS
   ════════════════════════════════════════════════════════════════ */
.damage-flash {
  animation: damageFlash 0.4s ease;
}

@keyframes damageFlash {
  0%   { filter: brightness(1); }
  25%  { filter: brightness(0.3) sepia(1) saturate(5) hue-rotate(-20deg); }
  100% { filter: brightness(1); }
}

.heal-flash {
  animation: healFlash 0.4s ease;
}

@keyframes healFlash {
  0%   { filter: brightness(1); }
  25%  { filter: brightness(1.5) sepia(0.5) saturate(2) hue-rotate(100deg); }
  100% { filter: brightness(1); }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root {
    --map-width: 240px;
    --hud-width: 240px;
  }
}

@media (max-width: 900px) {
  .game-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
    overflow: visible;
  }

  .panel-map {
    max-height: 350px;
  }

  .panel-narration {
    min-height: 500px;
  }

  .panel-hud {
    max-height: 500px;
  }

  .game-header {
    flex-wrap: wrap;
    height: auto;
    padding: 0.6rem 1rem;
    gap: 0.5rem;
  }

  .header-center {
    order: 3;
    width: 100%;
  }

  #screen-game {
    height: auto;
  }
}

@media (max-width: 768px) {
  .game-grid {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .class-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

  .class-card { padding: 1.2rem 1rem 1rem; }

  .header-subtitle { display: none; }

  .dice-area {
    flex-wrap: wrap;
  }

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

  .map-container {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .title-main { font-size: 2.5rem; }

  .welcome-panel { padding: 1.5rem; }

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

  .toast { max-width: calc(100vw - 2rem); right: 1rem; }
}

/* ─── Utility classes ────────────────────────────────────────── */
.hidden   { display: none !important; }
.visible  { display: flex !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.red  { color: var(--red-bright) !important; }
.gold { color: var(--gold) !important; }
.green { color: var(--green-npc) !important; }

/* Pulse animation for highlighted elements */
.pulse-gold {
  animation: pulseGold 2s ease-in-out infinite;
}

@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
  50%       { box-shadow: 0 0 0 6px rgba(201,168,76,0.2); }
}

/* Victory particle burst effect */
.victory-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 500;
  animation: victoryBurst var(--dur, 1s) ease-out forwards;
}

@keyframes victoryBurst {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx,0), var(--ty,-150px)) scale(0); }
}

/* ─── Free Action Area ───────────────────────────────────────── */
.free-action-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-gold);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(var(--glass-blur));
}

.free-action-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.free-action-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.8rem;
  outline: none;
  transition: all var(--transition-fast);
}

.free-action-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-glow);
  background: rgba(0, 0, 0, 0.6);
}

.btn-voice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  flex-shrink: 0;
}

.btn-voice:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-voice.recording {
  background: rgba(139, 26, 26, 0.3) !important;
  border-color: var(--red-bright) !important;
  color: var(--red-bright) !important;
  box-shadow: 0 0 10px var(--red-glow);
  animation: pulseRecording 1.5s infinite alternate;
}

@keyframes pulseRecording {
  from { box-shadow: 0 0 2px var(--red-glow); filter: brightness(0.9); }
  to   { box-shadow: 0 0 12px var(--red-glow); filter: brightness(1.3); }
}

.btn-send-action {
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}

.voice-status {
  display: block;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--amber);
  margin-top: 0.25rem;
  min-height: 1rem;
  text-shadow: 0 0 4px rgba(232, 169, 48, 0.2);
}
