/* ==========================================================================
   SAINDOUX SIMULATOR — Main Stylesheet
   Dark Luxury Fridge aesthetic · Three.js 3D + HTML/CSS overlays
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Custom Properties
   -------------------------------------------------------------------------- */

:root {
  /* Gold / Amber palette */
  --gold: #FFD700;
  --gold-dark: #C89000;
  --amber: #E8A800;

  /* Panel surfaces */
  --panel-bg: rgba(20, 18, 12, 0.85);
  --panel-border: rgba(200, 180, 120, 0.3);
  --panel-hover: rgba(60, 50, 30, 0.95);

  /* Text */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  /* Accent colors */
  --ice-blue: #87CEEB;
  --danger: #E53935;
  --success: #4CAF50;

  /* Fridge palette (title screen) */
  --fridge-top: #d8e8f0;
  --fridge-bottom: #90b8d0;
  --fridge-wall: #6a8ea8;
  --fridge-shelf: rgba(255, 255, 255, 0.25);

  /* Spacing shortcuts */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;

  /* Layout */
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  --hud-height-top: 48px;
  --hud-height-bottom: 56px;

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

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
}

/* --------------------------------------------------------------------------
   2. Reset & Base
   -------------------------------------------------------------------------- */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0908;
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   3. Layout Base — Canvas & UI Overlay
   -------------------------------------------------------------------------- */

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

#ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   4. Screen Overlays — Common
   -------------------------------------------------------------------------- */

.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.35s ease,
    visibility 0s 0.35s;
  padding: 16px;
  pointer-events: none;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.35s ease,
    visibility 0s 0s;
  pointer-events: auto;
}

.screen-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.screen-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-lg);
  max-width: 960px;
  width: 100%;
  padding: var(--sp-lg);
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen-heading {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
   5. Screen — Title
   -------------------------------------------------------------------------- */

.screen-title {
  background: #050a10;
  background-image: radial-gradient(ellipse at 50% 30%, #1a3040 0%, #0a1520 60%, #050a10 100%);
  overflow: hidden;
}

/* Fridge interior effect — cold light from top */
.title-fridge-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(100, 180, 220, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(20, 40, 60, 0.5) 0%, transparent 50%);
}

/* Fridge shelves — horizontal glowing lines */
.title-fridge-bg::before {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 0;
  height: 100%;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0%,
      transparent 24%,
      rgba(120, 180, 220, 0.08) 24.5%,
      rgba(120, 180, 220, 0.12) 25%,
      rgba(120, 180, 220, 0.08) 25.5%,
      transparent 26%
    );
  pointer-events: none;
}

/* Frost/condensation effect */
.title-fridge-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(200, 230, 255, 0.06) 0%, transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(200, 230, 255, 0.04) 0%, transparent 25%),
    radial-gradient(circle at 50% 50%, rgba(200, 230, 255, 0.03) 0%, transparent 40%);
  pointer-events: none;
}

/* Content z-index */
.screen-title .title-text,
.screen-title .title-tagline,
.screen-title .flavor-text,
.screen-title .title-buttons,
.screen-title .title-blob {
  position: relative;
  z-index: 2;
}

/* Animated blob on title screen — real saindoux: white, creamy, glossy */
.screen-title .title-blob {
  width: clamp(90px, 18vw, 160px);
  height: clamp(90px, 18vw, 160px);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #f5f0e8 20%, #e8ddd0 50%, #d4c8b8 80%, #bfb0a0 100%);
  box-shadow:
    0 0 30px rgba(255, 255, 255, 0.3),
    0 0 60px rgba(220, 200, 170, 0.2),
    0 8px 30px rgba(0, 0, 0, 0.4),
    inset 0 -8px 16px rgba(180, 160, 130, 0.3),
    inset 0 4px 8px rgba(255, 255, 255, 0.6);
  animation: blobFloat 3s ease-in-out infinite;
  margin-bottom: var(--sp-md);
  /* Glossy sheen overlay */
  position: relative;
}

.screen-title .title-blob::after {
  content: '';
  position: absolute;
  top: 12%;
  left: 18%;
  width: 35%;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 100%);
  transform: rotate(-20deg);
}

@keyframes blobFloat {
  0%   { transform: translateY(0) scale(1) rotate(0deg); border-radius: 42% 58% 45% 55%; }
  15%  { transform: translateY(-6px) scale(1.04, 0.96); border-radius: 55% 45% 52% 48%; }
  30%  { transform: translateY(-10px) scale(0.97, 1.03); border-radius: 48% 52% 58% 42%; }
  50%  { transform: translateY(-4px) scale(1.02) rotate(2deg); border-radius: 52% 48% 42% 58%; }
  70%  { transform: translateY(-12px) scale(0.98, 1.02); border-radius: 45% 55% 50% 50%; }
  85%  { transform: translateY(-6px) scale(1.03, 0.97) rotate(-1deg); border-radius: 50% 50% 55% 45%; }
  100% { transform: translateY(0) scale(1) rotate(0deg); border-radius: 42% 58% 45% 55%; }
}

/* Title text — golden glow on dark background */
.screen-title .title-text {
  font-size: clamp(32px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(110deg, var(--gold) 0%, var(--gold) 35%, #fff5b8 45%, #ffffff 50%, #fff5b8 55%, var(--gold) 65%, var(--gold) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titleShimmer 4s linear infinite;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
  text-align: center;
  line-height: 1.1;
}

@keyframes titleShimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.screen-title .title-sub {
  display: block;
  font-size: clamp(16px, 3vw, 32px);
  font-weight: 600;
  color: rgba(200, 230, 255, 0.8);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(100, 180, 255, 0.3);
}

.screen-title .title-tagline {
  margin-top: var(--sp-sm);
  font-size: clamp(13px, 2.5vw, 20px);
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 100, 80, 0.9);
  text-shadow: 0 0 10px rgba(255, 80, 60, 0.3);
  letter-spacing: 0.05em;
}

.screen-title .flavor-text {
  margin-top: var(--sp-lg);
  font-size: clamp(11px, 2vw, 16px);
  font-style: italic;
  color: rgba(180, 210, 230, 0.6);
  min-height: 1.5em;
  transition: opacity 0.3s ease;
}

.screen-title .title-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  margin-top: var(--sp-xl);
  width: 100%;
  max-width: 300px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   6. Screen — Level Select
   -------------------------------------------------------------------------- */

.screen-select {
  background: rgba(10, 8, 5, 0.92);
  overflow-y: auto;
}

.screen-select .level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
  width: 100%;
  max-width: 800px;
}

.screen-select .level-card {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.screen-select .level-card:not(.locked):hover,
.screen-select .level-card:not(.locked):active {
  transform: scale(1.05);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.2), 0 8px 32px rgba(0, 0, 0, 0.3);
  background: rgba(255, 215, 0, 0.05);
}

.screen-select .level-card .level-number {
  font-size: 1.8em;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.screen-select .level-card .level-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.screen-select .level-card .level-objective {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.screen-select .level-card .level-stars {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 2px;
}

.screen-select .level-card .level-best {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.screen-select .level-card.locked {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.8);
  position: relative;
}

.screen-select .level-card.locked::after {
  content: '\1F512';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2em;
}

/* Mobile scroll-snap carousel (activated via media query) */
.level-carousel {
  display: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: var(--sp-md);
  padding: var(--sp-md);
}

.level-carousel > .level-card {
  scroll-snap-align: center;
  flex: 0 0 70vw;
  max-width: 280px;
  aspect-ratio: auto;
}

/* --------------------------------------------------------------------------
   7. Screen — Settings
   -------------------------------------------------------------------------- */

.screen-settings {
  background: rgba(10, 8, 5, 0.92);
}

.screen-settings .settings-panel {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
}

.settings-row label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.settings-row input[type="range"] {
  width: 120px;
  accent-color: var(--gold);
}

.settings-row .toggle {
  width: 48px;
  height: 26px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.25s ease;
  border: none;
  outline: none;
}

.settings-row .toggle.on {
  background: var(--gold-dark);
}

.settings-row .toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.25s ease;
}

.settings-row .toggle.on::after {
  transform: translateX(22px);
}

/* --------------------------------------------------------------------------
   8. Screen — Upgrade Shop
   -------------------------------------------------------------------------- */

.screen-upgrade {
  background: rgba(10, 8, 5, 0.92);
  overflow-y: auto;
}

.screen-upgrade .upgrade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-md);
  width: 100%;
  max-width: 720px;
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--sp-xs);
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dark) transparent;
}

.upgrade-card {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 14px;
  cursor: pointer;
  text-align: left;
}

.upgrade-card .upgrade-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.upgrade-card .upgrade-info {
  flex: 1;
  min-width: 0;
}

.upgrade-card .upgrade-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upgrade-card .upgrade-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.upgrade-card .upgrade-dots {
  display: flex;
  gap: 4px;
  margin-top: var(--sp-xs);
}

.upgrade-card .upgrade-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.upgrade-card .upgrade-dots .dot.filled {
  background: var(--gold);
}

.upgrade-card .upgrade-cost {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 700;
  flex-shrink: 0;
}

.upgrade-card.maxed {
  opacity: 0.5;
  pointer-events: none;
}

.upgrade-card.maxed .upgrade-cost {
  color: var(--success);
}

.upgrade-card .upgrade-max {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: rgba(255, 215, 0, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   9. Screen — Perk Choice
   -------------------------------------------------------------------------- */

.screen-perk_choose {
  background: rgba(5, 3, 0, 0.88);
}

.screen-perk_choose .perk-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.screen-perk_choose .perk-cards {
  display: flex;
  gap: var(--sp-md);
  justify-content: center;
  flex-wrap: wrap;
  max-width: 800px;
  width: 100%;
}

.perk-card {
  width: 180px;
  max-width: 220px;
  padding: var(--sp-lg) var(--sp-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  text-align: center;
  cursor: pointer;
  animation: perkAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, float 3s ease-in-out infinite alternate 0.5s;
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  background: rgba(20, 18, 12, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes perkAppear {
  0% { opacity: 0; transform: scale(0.6) translateY(30px) rotate(-5deg); }
  100% { opacity: 1; transform: scale(1) translateY(0) rotate(0deg); }
}

.perk-card:nth-child(2) { animation-delay: 0.15s, 0.65s; }
.perk-card:nth-child(3) { animation-delay: 0.3s, 0.8s; }

.perk-card:hover,
.perk-card:active,
.perk-card:focus-visible {
  transform: translateY(-6px) scale(1.05);
  box-shadow: 0 8px 32px rgba(255, 215, 0, 0.25), 0 0 15px rgba(255, 215, 0, 0.1);
  border-color: var(--gold);
}

.perk-card .perk-icon {
  font-size: 2.5rem;
}

.perk-card .perk-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
}

.perk-card .perk-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* --------------------------------------------------------------------------
   10. Screen — Level Complete / Game Over / Victory (shared)
   -------------------------------------------------------------------------- */

.screen-complete,
.screen-gameover,
.screen-victory,
.screen-maillard {
  background: rgba(5, 3, 0, 0.92);
}

.screen-complete { background: radial-gradient(ellipse at center, rgba(40, 30, 0, 0.95) 0%, rgba(5, 3, 0, 0.98) 70%); }
.screen-gameover { background: radial-gradient(ellipse at center, rgba(40, 5, 0, 0.95) 0%, rgba(5, 0, 0, 0.98) 70%); }
.screen-victory { background: radial-gradient(ellipse at center, rgba(50, 40, 0, 0.95) 0%, rgba(5, 3, 0, 0.98) 70%); }

.result-modal {
  text-align: center;
  padding: 40px 32px;
  max-width: 420px;
  width: 90%;
  animation: resultAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: var(--border-radius-lg);
  background: rgba(20, 18, 12, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 0 60px rgba(255, 215, 0, 0.08), inset 0 0 30px rgba(255, 215, 0, 0.03);
}

.result-modal.result-danger {
  border-color: rgba(229, 57, 53, 0.2);
  box-shadow: 0 0 60px rgba(229, 57, 53, 0.08), inset 0 0 30px rgba(229, 57, 53, 0.03);
}

.result-modal.result-victory {
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 80px rgba(255, 215, 0, 0.15), inset 0 0 40px rgba(255, 215, 0, 0.05);
}

@keyframes resultAppear {
  0% { opacity: 0; transform: scale(0.7) translateY(30px); }
  60% { opacity: 1; transform: scale(1.05) translateY(-5px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.result-blob {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--sp-md);
}

.result-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-sm);
  text-transform: uppercase;
}

.screen-complete .result-title {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  animation: pulseGlow 2s ease-in-out infinite;
}
.screen-gameover .result-title {
  color: var(--danger);
  text-shadow: 0 0 20px rgba(229, 57, 53, 0.4);
  animation: dangerPulse 1.5s ease-in-out infinite;
}
.screen-victory .result-title {
  color: var(--gold);
  font-size: 2.2rem;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  animation: victoryTitle 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.3); }
  50% { text-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 0 80px rgba(255, 215, 0, 0.2); }
}

@keyframes dangerPulse {
  0%, 100% { text-shadow: 0 0 15px rgba(229, 57, 53, 0.3); }
  50% { text-shadow: 0 0 30px rgba(229, 57, 53, 0.5), 0 0 60px rgba(229, 57, 53, 0.2); }
}

@keyframes victoryTitle {
  0%, 100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.4); transform: scale(1); }
  50% { text-shadow: 0 0 50px rgba(255, 215, 0, 0.7), 0 0 100px rgba(255, 215, 0, 0.3); transform: scale(1.03); }
}

.grade-icon {
  font-size: 3em;
  display: block;
  margin: var(--sp-md) auto;
}

.grade-name {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--sp-md);
}

.result-stars {
  font-size: 2rem;
  letter-spacing: 8px;
  margin: var(--sp-md) 0;
  color: var(--gold);
}

/* Score breakdown table */
.score-table {
  width: 100%;
  margin: var(--sp-md) 0;
  font-size: 0.9em;
}

.score-table .row {
  display: flex;
  justify-content: space-between;
  padding: var(--sp-xs) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.score-table .row-label {
  color: var(--text-secondary);
}

.score-table .row-value {
  font-family: monospace;
  font-weight: 600;
}

.score-table .row-total {
  border-top: 1px solid var(--panel-border);
  border-bottom: none;
  font-weight: 700;
  font-size: 1.1em;
  padding-top: var(--sp-sm);
  margin-top: var(--sp-xs);
}

.result-stats {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin: var(--sp-lg) 0;
  padding: var(--sp-md);
  background: rgba(255, 215, 0, 0.03);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 215, 0, 0.08);
}

.result-stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: var(--sp-xs) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.result-stat:last-child { border-bottom: none; }

.result-stat .stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.result-stat .stat-value {
  font-family: monospace;
  font-weight: 700;
  color: var(--gold);
  font-size: 1rem;
}

.result-buttons {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
  margin-top: var(--sp-lg);
}

/* --------------------------------------------------------------------------
   11. Screen — Victory
   -------------------------------------------------------------------------- */

.screen-victory .victory-title {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #fff, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s ease-in-out infinite;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  border-radius: 2px;
  animation: confetti 3s ease-out forwards;
  pointer-events: none;
}

.confetti-piece:nth-child(odd)  { background: var(--gold); }
.confetti-piece:nth-child(even) { background: #ff6b6b; }
.confetti-piece:nth-child(3n)   { background: var(--ice-blue); width: 6px; height: 10px; }

/* --------------------------------------------------------------------------
   12. Screen — Maillard Secret Achievement
   -------------------------------------------------------------------------- */

.screen-maillard .maillard-panel {
  text-align: center;
  padding: 40px 32px;
  max-width: 440px;
  border: 1px solid var(--gold);
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.15);
}

.screen-maillard .result-title {
  color: #e8a040;
}

.screen-maillard .maillard-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: var(--sp-md);
  animation: pulse 2s ease-in-out infinite;
}

.screen-maillard .maillard-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   13. HUD — Game Management Interface
   -------------------------------------------------------------------------- */

#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

#hud.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s 0s;
}

#hud > * {
  pointer-events: auto;
}

/* --- Score Panel (top-right) --- */

.hud-score-panel {
  position: absolute;
  top: calc(var(--safe-top) + var(--sp-sm));
  right: calc(var(--safe-right) + var(--sp-sm));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-width: 100px;
}

.hud-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hud-score-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.hud-score-value {
  font-family: monospace;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  line-height: 1;
}

.hud-combo {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
  text-align: right;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.15s ease, max-height 0.15s ease;
}

.hud-combo.visible {
  opacity: 1;
  max-height: 30px;
  animation: comboPulse 500ms ease;
}

@keyframes comboPulse {
  0% { transform: scale(0.5); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.hud-grade {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

/* --- Info Panel (top-left) — level name + objective + timer --- */

.hud-info-panel {
  position: absolute;
  top: calc(var(--safe-top) + var(--sp-sm));
  left: calc(var(--safe-left) + var(--sp-sm));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-width: 180px;
}

.hud-level-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-objective {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.hud-timer {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ice-blue);
  display: none;
}

.hud-timer.visible {
  display: block;
}

.hud-timer.warning {
  color: var(--danger);
  animation: pulse 0.8s ease-in-out infinite;
}

/* --- Gauges (bottom-left) — mass + temp + state --- */

.hud-gauges {
  position: absolute;
  bottom: calc(var(--safe-bottom) + var(--sp-sm));
  left: calc(var(--safe-left) + var(--sp-sm));
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-width: 140px;
}

.hud-gauge {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-gauge-icon {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.hud-gauge-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.hud-gauge-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.15s ease;
}

.mass-fill {
  background: linear-gradient(90deg, #e8ddd0, #f5f0e8);
  box-shadow: 0 0 4px rgba(245, 240, 232, 0.3);
}

.temp-fill {
  background: linear-gradient(90deg, var(--ice-blue), #4CAF50, var(--amber), var(--danger));
  background-size: 200% 100%;
  box-shadow: 0 0 4px rgba(135, 206, 235, 0.3);
}

.hud-gauge-val {
  font-family: monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 28px;
  text-align: right;
}

.hud-state-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
}

.hud-state-badge.state-solid   { border-color: var(--ice-blue); color: var(--ice-blue); background: rgba(135, 206, 235, 0.08); }
.hud-state-badge.state-soft    { border-color: var(--gold-dark); color: var(--gold); background: rgba(255, 215, 0, 0.06); }
.hud-state-badge.state-melted  { border-color: var(--danger);   color: var(--danger); background: rgba(229, 57, 53, 0.08); }

/* --- Perks (bottom-right, above solidify button) --- */

.hud-perks {
  position: absolute;
  bottom: calc(var(--safe-bottom) + var(--sp-sm));
  right: calc(var(--safe-right) + var(--sp-sm));
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.hud-perk {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* --- Enemies counter (top-center) --- */

.hud-enemies {
  position: absolute;
  top: calc(var(--safe-top) + var(--sp-sm));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
}

.hud-enemies #hud-enemies-count {
  color: var(--danger);
  font-size: 0.9rem;
}

.hud-enemies-label {
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Mobile adjustments for HUD --- */

@media (max-width: 768px), (pointer: coarse) {
  .hud-score-panel {
    padding: 6px 10px;
    min-width: 80px;
  }
  .hud-score-value {
    font-size: 1.1rem;
  }
  .hud-info-panel {
    max-width: 140px;
    padding: 4px 8px;
  }
  .hud-level-name {
    font-size: 0.6rem;
  }
  .hud-gauges {
    min-width: 100px;
    padding: 5px 7px;
    bottom: calc(var(--safe-bottom) + 90px); /* above joystick area */
  }
  .hud-perks {
    bottom: calc(var(--safe-bottom) + 140px); /* above gauges */
    right: calc(var(--safe-right) + 12px);
  }
  .hud-enemies {
    font-size: 0.65rem;
    padding: 3px 10px;
  }
}

/* --- Boss Health Bar --- */

.hud-boss {
  position: absolute;
  top: calc(var(--sp-xl) + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(60%, 400px);
  text-align: center;
  display: none;
}

.hud-boss.active {
  display: block;
  animation: slideUp 300ms ease;
}

.hud-boss .boss-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ff6b6b;
  margin-bottom: var(--sp-xs);
  letter-spacing: 0.05em;
}

.hud-boss .bar {
  height: 8px;
}

/* --------------------------------------------------------------------------
   14. Mobile Controls
   -------------------------------------------------------------------------- */

#mobile-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
  display: none !important;
}

#mobile-controls.visible {
  display: block !important;
}

.joystick-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 60%;
  height: 100%;
  pointer-events: auto;
}

.joystick-base {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 204, 0, 0.25);
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.1);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.joystick-base.visible {
  opacity: 1;
}

.joystick-thumb {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 204, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.3);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: none;
  opacity: 0;
}

.joystick-thumb.visible {
  opacity: 1;
}

#btn-solidify {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 32px);
  right: calc(var(--safe-right) + 24px);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(135, 206, 235, 0.2);
  border: 2px solid var(--ice-blue);
  color: var(--ice-blue);
  font-size: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 0 8px rgba(135, 206, 235, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 6;
}

#btn-solidify:active,
#btn-solidify.pressed {
  background: rgba(135, 206, 235, 0.45);
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(135, 206, 235, 0.5), 0 0 40px rgba(135, 206, 235, 0.2);
}

#btn-solidify.cooldown {
  opacity: 0.4;
  pointer-events: none;
}

#btn-gyro-toggle {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 116px);
  right: calc(var(--safe-right) + 36px);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.15);
  border: 2px solid var(--gold-dark);
  color: var(--gold);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 6;
}
#btn-gyro-toggle.gyro-active {
  background: rgba(135, 206, 235, 0.2);
  border-color: var(--ice-blue);
  box-shadow: 0 0 12px rgba(135, 206, 235, 0.3);
}
#btn-gyro-toggle.gyro-inactive {
  background: rgba(255, 215, 0, 0.15);
  border-color: var(--gold-dark);
}
#btn-gyro-toggle:active {
  transform: scale(1.1);
}

#btn-pause {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: calc(var(--safe-right) + 12px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
  z-index: 7;
}

#btn-pause:hover,
#btn-pause:active {
  background: var(--panel-hover);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   15. Common — Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-lg);
  min-height: 48px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--transition-normal),
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-fast);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  outline: none;
}

.btn:hover {
  background: var(--panel-hover);
  border-color: var(--gold-dark);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.1);
}

.btn:active {
  transform: scale(0.95);
  transition: transform 0.05s ease;
}

.btn:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.3);
}

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1400;
  font-weight: 700;
  text-shadow: none;
  animation: shimmer 3s linear infinite;
  background-size: 200% 100%;
  background-image: linear-gradient(
    110deg,
    var(--gold) 0%,
    var(--gold) 40%,
    #fff5b8 50%,
    var(--gold) 60%,
    var(--gold) 100%
  );
}

.btn-primary:hover {
  background-image: linear-gradient(
    110deg,
    var(--amber) 0%,
    var(--amber) 40%,
    #fff5b8 50%,
    var(--amber) 60%,
    var(--amber) 100%
  );
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.35), 0 0 60px rgba(255, 215, 0, 0.1);
  transform: scale(1.02);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--text-primary);
  background: rgba(255, 215, 0, 0.08);
}

.btn-danger {
  border-color: rgba(229, 57, 53, 0.5);
  color: var(--danger);
}

.btn-danger:hover {
  border-color: var(--danger);
  box-shadow: 0 0 16px rgba(229, 57, 53, 0.15);
}

.btn-sm {
  padding: var(--sp-xs) var(--sp-md);
  min-height: 36px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: var(--sp-md) 48px;
  min-height: 56px;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  border-radius: var(--border-radius);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* --------------------------------------------------------------------------
   16. Common — Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: var(--sp-md);
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal),
    transform var(--transition-normal);
  overflow: hidden;
}

.card:hover {
  border-color: var(--gold-dark);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.card.focused,
.card:focus-visible {
  border-color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(255, 215, 0, 0.2),
    0 4px 32px rgba(255, 215, 0, 0.1);
  outline: none;
}

.card.selected {
  border-color: var(--gold);
  background: var(--panel-hover);
}

/* --------------------------------------------------------------------------
   17. Common — Progress Bars
   -------------------------------------------------------------------------- */

.bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
  position: relative;
}

.bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 5px 5px 0 0;
}

.bar-mass .bar-fill {
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
}

.bar-temp .bar-fill {
  background: linear-gradient(90deg, var(--ice-blue), var(--amber), var(--danger));
}

.bar-fill.health {
  background: linear-gradient(90deg, #e04040, #ff6b6b);
}

.bar-lg {
  height: 12px;
  border-radius: 6px;
}

.bar-lg .bar-fill {
  border-radius: 6px;
}

/* --------------------------------------------------------------------------
   18. Common — Modal
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: var(--sp-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s 0s;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 100%;
  animation: slideUp 0.3s ease;
}

/* --------------------------------------------------------------------------
   19. Common — Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: monospace;
  line-height: 1;
}

.badge-gold {
  background: var(--gold-dark);
  color: #1a1500;
}

.badge-ice {
  background: rgba(135, 206, 235, 0.2);
  color: var(--ice-blue);
  border: 1px solid rgba(135, 206, 235, 0.3);
}

.badge-danger {
  background: rgba(229, 57, 53, 0.2);
  color: var(--danger);
  border: 1px solid rgba(229, 57, 53, 0.3);
}

.badge-success {
  background: rgba(76, 175, 80, 0.2);
  color: var(--success);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

/* --------------------------------------------------------------------------
   20. Common — Score Popups
   -------------------------------------------------------------------------- */

.popups-container {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  overflow: hidden;
}

.popup {
  position: absolute;
  pointer-events: none;
  font-family: monospace;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--gold);
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.6),
    0 0 20px rgba(255, 215, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.8);
  animation: scorePopup 1.2s ease-out forwards;
  white-space: nowrap;
  letter-spacing: 0.05em;
}

.popup-combo  { font-size: 1.6rem; color: #FF6600; text-shadow: 0 0 12px rgba(255, 100, 0, 0.7), 0 0 25px rgba(255, 100, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.8); }
.popup-bonus  { color: var(--success); text-shadow: 0 0 10px rgba(76, 175, 80, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7); }
.popup-damage { color: var(--danger); font-size: 1rem; text-shadow: 0 0 10px rgba(229, 57, 53, 0.5), 0 2px 8px rgba(0, 0, 0, 0.7); }

/* --------------------------------------------------------------------------
   20b. Flash Overlay & Confetti
   -------------------------------------------------------------------------- */

.flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.05s ease;
}
.flash-overlay.flash-damage {
  background: radial-gradient(ellipse at center, rgba(255, 30, 30, 0.4) 0%, rgba(255, 0, 0, 0.1) 60%, transparent 100%);
  animation: flashFade 0.3s ease-out forwards;
}
.flash-overlay.flash-combo {
  background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.35) 0%, rgba(255, 180, 0, 0.1) 60%, transparent 100%);
  animation: flashFade 0.25s ease-out forwards;
}
.flash-overlay.flash-mega {
  background: radial-gradient(ellipse at center, rgba(255, 255, 200, 0.5) 0%, rgba(255, 215, 0, 0.15) 50%, transparent 100%);
  animation: flashFade 0.4s ease-out forwards;
}

@keyframes flashFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.confetti-container {
  position: fixed;
  inset: 0;
  z-index: 16;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(110vh) rotate(720deg) scale(0.3); }
}

/* --------------------------------------------------------------------------
   21. Typography Helpers
   -------------------------------------------------------------------------- */

.heading {
  font-weight: 800;
  letter-spacing: 0.05em;
}

.text-gold   { color: var(--gold); }
.text-ice    { color: var(--ice-blue); }
.text-danger { color: var(--danger); }
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }

.mono {
  font-family: monospace;
}

.text-shadow {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
   22. Keyframe Animations
   -------------------------------------------------------------------------- */

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

@keyframes scorePopup {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translateY(-8px) scale(1.4);
  }
  30% {
    opacity: 1;
    transform: translateY(-15px) scale(1.1);
  }
  60% {
    opacity: 0.8;
    transform: translateY(-40px) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.8);
  }
}

@keyframes confetti {
  0% {
    opacity: 1;
    transform: translateY(-10vh) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(110vh) rotate(720deg);
  }
}

@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

@keyframes comboFlash {
  0%   { color: var(--gold); }
  50%  { color: #ff8c00; }
  100% { color: var(--gold); }
}

@keyframes float {
  from { transform: translateY(-5px); }
  to   { transform: translateY(5px); }
}

@keyframes barPulse {
  0%, 100% { box-shadow: none; }
  50%      { box-shadow: 0 0 12px rgba(229, 57, 53, 0.4); }
}

/* --------------------------------------------------------------------------
   22b. Loading Screen
   -------------------------------------------------------------------------- */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1200 100%);
  transition: opacity 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-blob {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #FFD700, #C89000, #8B6914);
  animation: loadingJiggle 1.5s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

@keyframes loadingJiggle {
  0%, 100% { border-radius: 50% 50% 50% 50%; transform: scale(1); }
  25% { border-radius: 45% 55% 60% 40%; transform: scale(1.05, 0.95); }
  50% { border-radius: 55% 45% 40% 60%; transform: scale(0.95, 1.05); }
  75% { border-radius: 40% 60% 55% 45%; transform: scale(1.03, 0.97); }
}

.loading-text {
  color: var(--gold);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  animation: loadingProgress 2s ease-in-out forwards;
}

@keyframes loadingProgress {
  0% { width: 0%; }
  30% { width: 40%; }
  60% { width: 70%; }
  90% { width: 90%; }
  100% { width: 100%; }
}

.loading-flavor {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   22c. Level Intro
   -------------------------------------------------------------------------- */

.level-intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s 0.4s;
  pointer-events: none;
}

.level-intro.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s 0s;
}

.level-intro-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.level-intro-number {
  font-size: 5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
  animation: levelIntroZoom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
}

.level-intro-name {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  animation: levelIntroSlide 0.5s ease 0.2s forwards;
  opacity: 0;
  transform: translateY(15px);
}

.level-intro-objective {
  font-size: 1rem;
  color: var(--text-secondary);
  animation: levelIntroSlide 0.5s ease 0.4s forwards;
  opacity: 0;
  transform: translateY(15px);
}

@keyframes levelIntroZoom {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

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

/* --------------------------------------------------------------------------
   22d. Pause Screen
   -------------------------------------------------------------------------- */

.pause-screen {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.pause-screen.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s 0s;
}

.pause-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-lg);
  animation: slideUp 0.3s ease;
}

.pause-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.pause-flavor {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  min-width: 220px;
}

/* --------------------------------------------------------------------------
   22e. Screen Transitions (enhanced)
   -------------------------------------------------------------------------- */

.screen {
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s 0.4s;
  transform: translateY(10px);
}

.screen.active {
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s 0s;
}

/* Stagger children animation in screens */
.screen.active .screen-content > * {
  animation: staggerIn 0.35s ease forwards;
  opacity: 0;
}

.screen.active .screen-content > *:nth-child(1) { animation-delay: 0s; }
.screen.active .screen-content > *:nth-child(2) { animation-delay: 0.05s; }
.screen.active .screen-content > *:nth-child(3) { animation-delay: 0.1s; }
.screen.active .screen-content > *:nth-child(4) { animation-delay: 0.15s; }
.screen.active .screen-content > *:nth-child(5) { animation-delay: 0.2s; }

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

/* Grade reveal animation on result screens */
.result-modal .stat-value {
  animation: gradeReveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
  opacity: 0;
  transform: scale(0.5);
}

@keyframes gradeReveal {
  from { opacity: 0; transform: scale(0.5) rotate(-5deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* Victory confetti-like glow */
.result-victory .result-title {
  animation: victoryGlow 2s ease-in-out infinite alternate;
}

@keyframes victoryGlow {
  from { text-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
  to { text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.2); }
}

/* Combo HUD scale overshoot */
.hud-combo.visible {
  animation: comboAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes comboAppear {
  from { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  to { transform: scale(1); opacity: 1; }
}

/* --------------------------------------------------------------------------
   23. Utility Classes
   -------------------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.35s ease forwards;
}

.slide-up {
  animation: slideUp 0.35s ease forwards;
}

.no-select {
  user-select: none;
  -webkit-user-select: none;
}

/* --------------------------------------------------------------------------
   24. Scrollbar Styling
   -------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* --------------------------------------------------------------------------
   25. Responsive — Mobile Portrait (max-width: 480px)
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .screen-title .title-text {
    font-size: clamp(22px, 8vw, 40px);
  }

  .screen-title .title-sub {
    font-size: 0.85rem;
  }

  .screen-content {
    padding: var(--sp-md);
    gap: var(--sp-md);
  }

  /* Level select — horizontal scroll-snap carousel */
  .screen-select .level-grid {
    display: none;
  }

  .level-carousel {
    display: flex;
  }

  /* Upgrade shop — single column */
  .screen-upgrade .upgrade-grid {
    grid-template-columns: 1fr;
  }

  /* Perk cards — vertical stack */
  .screen-perk_choose .perk-cards {
    flex-direction: column;
    align-items: center;
  }

  .perk-card {
    width: 100%;
    max-width: 260px;
    flex-direction: row;
    text-align: left;
    padding: var(--sp-md);
    animation: none;
  }

  .perk-card .perk-icon {
    font-size: 2rem;
  }

  /* HUD adjustments */
  .hud-score { font-size: 1.1rem; }
  .hud-combo { font-size: 0.85rem; }
  .hud-timer { font-size: 0.85rem; }

  /* Larger touch targets */
  .btn {
    min-height: 48px;
    padding: 14px 20px;
  }

  .btn-lg {
    min-height: 56px;
  }

  #mobile-controls {
    display: block;
  }

  /* Result panels */
  .result-modal {
    padding: 28px 20px;
  }

  .result-buttons {
    flex-direction: column;
  }

  .result-buttons .btn {
    width: 100%;
  }
}

/* --------------------------------------------------------------------------
   26. Responsive — Mobile Landscape / Z Fold Closed (481px–768px)
   -------------------------------------------------------------------------- */

@media (min-width: 481px) and (max-width: 768px) {
  .screen-select .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .screen-upgrade .upgrade-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .perk-card {
    width: 160px;
    padding: 20px 14px;
  }

  #mobile-controls {
    display: block;
  }

  /* Perk cards vertical on narrow landscape */
  .screen-perk_choose .perk-cards {
    flex-direction: column;
    align-items: center;
    gap: var(--sp-sm);
  }

  .perk-card {
    max-width: 85%;
    width: 100%;
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   27. Responsive — Tablet (769px–1024px)
   -------------------------------------------------------------------------- */

@media (min-width: 769px) and (max-width: 1024px) {
  .screen-select .level-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px;
  }

  .screen-upgrade .upgrade-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 720px;
  }

  .perk-card {
    max-width: 240px;
  }

  .result-modal {
    max-width: 460px;
  }

  .hud-score {
    font-size: 1.4rem;
  }

  #hud {
    padding:
      calc(var(--sp-md) + var(--safe-top))
      calc(var(--sp-md) + var(--safe-right))
      calc(var(--sp-md) + var(--safe-bottom))
      calc(var(--sp-md) + var(--safe-left));
  }

  #mobile-controls {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   28. Responsive — Desktop (min-width: 1025px)
   -------------------------------------------------------------------------- */

@media (min-width: 1025px) {
  .screen-select .level-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 900px;
  }

  .screen-upgrade .upgrade-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 900px;
  }

  .perk-card {
    max-width: 260px;
  }

  .screen-perk_choose .perk-cards {
    gap: var(--sp-lg);
  }

  /* Smaller HUD on desktop */
  :root {
    --hud-height-top: 40px;
    --hud-height-bottom: 48px;
  }

  .hud-score { font-size: 1.1rem; }
  .hud-combo { font-size: 0.9rem; }
  .hud-timer { font-size: 0.9rem; }

  .bar     { height: 8px; border-radius: 4px; }
  .bar-lg  { height: 10px; border-radius: 5px; }

  /* No mobile controls on desktop */
  #mobile-controls {
    display: none;
  }

  .joystick-zone {
    display: none;
  }

  #btn-solidify {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   29. Responsive — Z Fold Unfolded
   -------------------------------------------------------------------------- */

@media (min-width: 600px) and (max-width: 900px) and (min-height: 700px) {
  .screen-select .level-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-sm);
  }

  .screen-upgrade .upgrade-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .screen-title .title-text {
    font-size: clamp(28px, 6vw, 48px);
  }

  .perk-card {
    width: 170px;
  }

  #mobile-controls {
    display: block;
  }

  #btn-solidify {
    width: 72px;
    height: 72px;
    font-size: 1.7rem;
  }
}

/* --------------------------------------------------------------------------
   30. Responsive — Very Small (Z Fold closed, < 360px)
   -------------------------------------------------------------------------- */

@media (max-width: 359px) {
  .screen-select .level-grid {
    grid-template-columns: 1fr;
  }

  .level-carousel {
    display: flex;
  }

  .screen-select .level-grid {
    display: none;
  }

  .screen-perk_choose .perk-cards {
    flex-direction: column;
    align-items: center;
  }

  .perk-card {
    max-width: 90%;
    animation: none;
  }

  .screen-title .title-text {
    font-size: clamp(20px, 8vw, 36px);
  }

  .hud-score {
    font-size: 1rem;
  }

  #btn-solidify {
    width: 54px;
    height: 54px;
    font-size: 1.3rem;
  }
}

/* --------------------------------------------------------------------------
   31. Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .screen {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   32. Landscape Blocker (mobile only)
   -------------------------------------------------------------------------- */

#landscape-blocker {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #050a10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
  color: var(--text-primary);
  text-align: center;
  padding: var(--sp-xl);
}

#landscape-blocker .rotate-icon {
  font-size: 4rem;
  animation: rotateHint 2s ease-in-out infinite;
}

#landscape-blocker .rotate-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-20deg); }
  75% { transform: rotate(20deg); }
}

@media (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  #landscape-blocker {
    display: flex !important;
  }
}

/* --------------------------------------------------------------------------
   27. Username Input (title screen)
   -------------------------------------------------------------------------- */

.title-username {
  display: flex;
  justify-content: center;
}

.username-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--gold-dark);
  border-radius: var(--border-radius-sm);
  color: var(--gold);
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  padding: 8px 16px;
  max-width: 200px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.username-input::placeholder {
  color: var(--text-muted);
}

.username-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

/* --------------------------------------------------------------------------
   28. Leaderboard
   -------------------------------------------------------------------------- */

.leaderboard-list {
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  backdrop-filter: blur(4px);
}

.leaderboard-row.current-user {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}

.lb-rank {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--gold);
  min-width: 36px;
}

.lb-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.lb-score {
  font-weight: 700;
  font-size: 1rem;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.lb-delete {
  background: rgba(229, 57, 53, 0.3);
  border: 1px solid rgba(229, 57, 53, 0.5);
  color: #ff6666;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.lb-delete:hover {
  background: rgba(229, 57, 53, 0.6);
}

.leaderboard-empty {
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-lg);
}

/* --------------------------------------------------------------------------
   29. Cheat Flash animation
   -------------------------------------------------------------------------- */

.cheat-flash {
  animation: cheatGoldFlash 0.3s ease 6;
}

@keyframes cheatGoldFlash {
  0%, 100% { color: #ff0; text-shadow: none; }
  50% { color: #FFD700; text-shadow: 0 0 10px #FFD700, 0 0 20px #C89000; }
}

/* --------------------------------------------------------------------------
   30. Compact layout for short portrait viewports
   -------------------------------------------------------------------------- */

@media (max-height: 700px) {
  .screen-content {
    padding: var(--sp-sm);
    gap: var(--sp-sm);
  }
  .screen-title .title-blob {
    width: 60px;
    height: 60px;
  }
  .title-text {
    font-size: clamp(20px, 6vw, 36px) !important;
  }
  .title-tagline {
    font-size: 0.7rem;
  }
  .btn-lg {
    min-height: 44px;
    padding: 10px 24px;
  }
}

/* ==========================================================================
   33. CONSCIENCE BUBBLE — Saindoux monologue interieur
   Bulle semi-transparente, typo manuscrite, apparait au-dessus du blob.
   CSS fait l'animation de fade-in/out. JS change juste le texte.
   ========================================================================== */

.conscience-bubble {
  position: fixed;
  bottom: 35%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  max-width: min(320px, 80vw);
  padding: 10px 18px;
  background: rgba(255, 255, 240, 0.12);
  border: 1px solid rgba(255, 255, 200, 0.15);
  border-radius: 16px 16px 16px 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 230, 0.9);
  font-family: 'Segoe Script', 'Comic Sans MS', 'Bradley Hand', cursive;
  font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  font-style: italic;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s 0.6s, transform 0.6s ease;
}

.conscience-bubble.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0s 0s, transform 0.6s ease;
  animation: conscienceFloat 3s ease-in-out infinite;
}

/* Petit triangle vers le bas-gauche */
.conscience-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 18px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 0 solid transparent;
  border-top: 8px solid rgba(255, 255, 240, 0.12);
}

@keyframes conscienceFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ==========================================================================
   34. TRIBUNAL DU GRAS — 3 juges au game over
   Chaque juge apparait en stagger, CSS anime tout.
   ========================================================================== */

.tribunal-gras {
  margin: var(--sp-md) 0;
  text-align: center;
}

.tribunal-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: var(--sp-sm);
}

.tribunal-judges {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tribunal-judge {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius-sm);
  opacity: 0;
  transform: translateX(-15px);
  animation: tribunalSlideIn 0.4s ease forwards;
}

.tribunal-judge:nth-child(1) { animation-delay: 0.5s; }
.tribunal-judge:nth-child(2) { animation-delay: 1.0s; }
.tribunal-judge:nth-child(3) { animation-delay: 1.5s; }

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

.judge-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.judge-verdict {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  text-align: left;
  line-height: 1.3;
}

/* ==========================================================================
   35. HUD QUI FOND — quand Saindoux depasse 70°C, le HUD degouline
   Classe .hud-melting ajoutee par JS sur #hud. CSS fait le reste.
   ========================================================================== */

#hud.hud-melting .hud-score-panel,
#hud.hud-melting .hud-info-panel,
#hud.hud-melting .hud-gauges {
  animation: hudMelt 2s ease-in-out infinite;
}

#hud.hud-melting .hud-score-value {
  animation: hudDrip 1.5s ease-in-out infinite;
  filter: blur(0.5px);
}

#hud.hud-melting .hud-info-panel {
  animation-delay: 0.3s;
}

#hud.hud-melting .hud-gauges {
  animation-delay: 0.6s;
}

@keyframes hudMelt {
  0%, 100% { transform: translateY(0) skewX(0deg); }
  25% { transform: translateY(2px) skewX(-0.5deg); }
  50% { transform: translateY(4px) skewX(0.3deg); }
  75% { transform: translateY(1px) skewX(-0.3deg); }
}

@keyframes hudDrip {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.08) translateY(2px); }
}

/* Barre de masse degouline */
#hud.hud-melting .mass-fill {
  border-radius: 3px 3px 6px 6px;
  box-shadow: 0 3px 8px rgba(245, 200, 100, 0.4);
}

/* Texte du score se deforme legerement */
#hud.hud-melting .hud-score-panel {
  border-color: rgba(229, 57, 53, 0.3);
  box-shadow: 0 4px 12px rgba(229, 57, 53, 0.15);
}

/* ==========================================================================
   36. ENEMY LIFE BUBBLES — micro-vies au-dessus des ennemis
   Petites bulles de dialogue ephemeres, positionnees par JS.
   ========================================================================== */

.enemy-bubbles-container {
  position: fixed;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  overflow: hidden;
}

.enemy-bubble,
.enemy-speech-bubble {
  position: absolute;
  padding: 4px 10px;
  background: rgba(30, 30, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px 10px 10px 2px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.65rem;
  line-height: 1.3;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0) scale(0.8);
  animation: enemyBubbleIn 0.3s ease forwards, enemyBubbleOut 0.4s ease 2.6s forwards;
}

@keyframes enemyBubbleIn {
  from { opacity: 0; transform: translateY(5px) scale(0.8); }
  to { opacity: 1; transform: translateY(-8px) scale(1); }
}

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

/* ==========================================================================
   37. SCORE MENTEUR — classe pour le texte de score delire
   ========================================================================== */

.hud-score-value.score-liar {
  animation: scoreLiarShake 0.15s ease infinite;
  color: var(--danger);
  text-shadow: 0 0 8px rgba(229, 57, 53, 0.5);
}

@keyframes scoreLiarShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

/* ==========================================================================
   38. Mobile adjustments for new features
   ========================================================================== */

@media (max-width: 480px) {
  .conscience-bubble {
    bottom: 40%;
    max-width: 85vw;
    font-size: 0.72rem;
    padding: 8px 14px;
  }

  .tribunal-judges {
    gap: 4px;
  }

  .tribunal-judge {
    padding: 4px 8px;
  }

  .judge-emoji {
    font-size: 1.1rem;
  }

  .judge-verdict {
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   39. ACHIEVEMENTS ABSURDES — banniere slide-in/out depuis le haut
   ========================================================================== */

.achievement-container {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  pointer-events: none;
  display: flex;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.achievement-container.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s 0s;
}

.achievement-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 24px 10px;
  background: linear-gradient(180deg, rgba(40, 35, 15, 0.95) 0%, rgba(25, 20, 8, 0.92) 100%);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(255, 215, 0, 0.08),
    inset 0 1px 0 rgba(255, 215, 0, 0.1);
  animation: achievementSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  max-width: min(340px, 85vw);
}

.achievement-container:not(.visible) .achievement-banner {
  animation: achievementSlideOut 0.3s ease forwards;
}

@keyframes achievementSlideIn {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes achievementSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-100%);
  }
}

.achievement-label {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.achievement-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Petit shimmer sur le bord */
.achievement-banner::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
  opacity: 0.4;
}

/* ==========================================================================
   40. Mobile + Reduced motion for achievements
   ========================================================================== */

@media (max-width: 480px) {
  .achievement-banner {
    padding: 6px 16px 8px;
    max-width: 90vw;
  }

  .achievement-text {
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .conscience-bubble.visible {
    animation: none;
  }
  #hud.hud-melting .hud-score-panel,
  #hud.hud-melting .hud-info-panel,
  #hud.hud-melting .hud-gauges,
  #hud.hud-melting .hud-score-value {
    animation: none;
    filter: none;
  }
  .tribunal-judge {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .achievement-banner {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .narrator-bandeau.visible {
    animation: none;
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   35. Narrator Bandeau — Documentary voice
   -------------------------------------------------------------------------- */

.narrator-bandeau {
  position: fixed;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  max-width: min(90%, 600px);
  padding: 12px 28px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.0) 0%, rgba(0, 0, 0, 0.75) 15%, rgba(0, 0, 0, 0.85) 50%, rgba(0, 0, 0, 0.75) 85%, rgba(0, 0, 0, 0.0) 100%);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s ease, visibility 0s 1.2s;
}

.narrator-bandeau.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.2s ease, visibility 0s 0s;
  animation: narratorGlow 4s ease-in-out infinite;
}

.narrator-text {
  display: block;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(0.8rem, 2.2vw, 1.05rem);
  color: rgba(220, 210, 190, 0.9);
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

@keyframes narratorGlow {
  0%, 100% { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
  50% { text-shadow: 0 1px 12px rgba(255, 215, 0, 0.15), 0 1px 6px rgba(0, 0, 0, 0.8); }
}
