:root {
  --bg-0: #1c0e07;
  --bg-1: #2a1810;
  --bg-2: #3d2415;
  --cream: #fff5e6;
  --cream-dim: #d8c3a3;
  --red:    #e63946;
  --red-2:  #c1121f;
  --gold:   #ffd166;
  --gold-2: #f4a72b;
  --olive:  #8ab17d;
  --green:  #2a9d8f;
  --wood:   #6c3b17;
  --wood-2: #4a2710;
  --card-bg: rgba(255, 245, 230, 0.06);
  --card-border: rgba(255, 245, 230, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-0);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(244,167,43,0.18), transparent 60%),
    radial-gradient(800px 500px at 80% 110%, rgba(230,57,70,0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
}
button {
  font-family: inherit; cursor: pointer; border: 0;
  background: none; color: inherit; font-size: inherit;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  gap: 10px;
}

/* TOPBAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 1px;
  color: #2a1010;
  box-shadow: 0 4px 14px rgba(230,57,70,0.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-size: 16px; font-weight: 900; }
.brand-text small { font-size: 10px; letter-spacing: 1.5px; color: var(--cream-dim); text-transform: uppercase; }

/* CASH POD */
.cash-pod {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,209,102,0.3);
  border-radius: 12px;
  padding: 6px 12px;
  text-align: right;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 110px;
}
.cash-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gold);
  font-weight: 800;
}
.cash-value {
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease;
}
.cash-value.tick { transform: scale(1.08); }
.cash-rate {
  font-size: 10px;
  color: var(--olive);
  font-weight: 700;
  margin-top: 1px;
}
.cash-pod--inline {
  align-self: flex-start;
  text-align: left;
  margin-bottom: 12px;
}

/* SCENE */
.scene {
  position: relative;
  /* 96px tassaient les tables contre les bords : +34px donnent de l'air au décor */
  height: 130px;
  background: linear-gradient(180deg, #3a1d10 0%, #2a1004 100%);
  border-radius: 14px;
  border: 1px solid rgba(255,209,102,0.2);
  overflow: hidden;
  flex-shrink: 0;
  transition: background 0.6s ease;
}
.scene[data-room="2"] { background: linear-gradient(180deg, #4a1a18 0%, #2a0808 100%); }
.scene[data-room="3"] { background: linear-gradient(180deg, #1c2d4a 0%, #0a1430 100%); }
.scene[data-room="4"] { background: linear-gradient(180deg, #1c4a2d 0%, #0a2010 100%); }
.scene[data-room="5"] { background: linear-gradient(180deg, #4a1a4d 0%, #1a0830 100%); }
.scene-wallpaper {
  position: absolute;
  /* plein cadre : le décor porte le mur ET le parquet, plus besoin de bande basse libre */
  inset: 0;
  pointer-events: none;
  opacity: 1;
  background-image: url("assets/decor.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transition: opacity 0.4s ease, filter 0.6s ease;
}
/* Les 5 salles gardent leur ambiance : le décor est TEINTÉ par un filtre, pas redessiné.
   Sans ça, acheter une salle ne changerait plus rien à l'écran. */
.scene[data-room="2"] .scene-wallpaper { filter: sepia(.5) hue-rotate(-25deg) saturate(1.5) brightness(.92); }
.scene[data-room="3"] .scene-wallpaper { filter: hue-rotate(175deg) saturate(1.1) brightness(.9); }
.scene[data-room="4"] .scene-wallpaper { filter: hue-rotate(85deg) saturate(1.15) brightness(.9); }
.scene[data-room="5"] .scene-wallpaper { filter: hue-rotate(230deg) saturate(1.25) brightness(.88); }
/* Les motifs de mur des salles 3/4/5 sont retirés : leur background-image ÉCRASERAIT le décor
   en image (le dernier background-image gagne). L'ambiance de salle passe désormais par le
   filtre du .scene-wallpaper, déclaré plus haut. */
.scene-floor {
  /* masqué : le parquet est maintenant DANS le décor en image */
  display: none;
}
.scene-counter {
  position: absolute;
  bottom: 18px;
  left: 0; right: 0;
  height: 12px;
  background: linear-gradient(180deg, var(--wood), var(--wood-2));
  border-top: 2px solid var(--gold);
}
.counter-stripe {
  position: absolute;
  inset: 2px 0 auto 0;
  height: 2px;
  background: rgba(255,209,102,0.35);
}
.scene-tables, .scene-staff, .scene-scooters {
  position: absolute;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 14px;
  z-index: 2;
}
.scene-tables {
  /* le parquet est passé DANS le décor en image : les tables descendents sur le sol */
  bottom: 6px;
  left: 0; right: 0;
}
.scene-staff {
  top: 14px;
  left: 0;
  z-index: 3;
}
.scene-scooters {
  bottom: 4px;
  right: 0;
  gap: 6px;
}
.scene-table {
  width: 28px;
  height: 26px;
  /* sprite généré : la table est dessinée, plus construite en dégradés */
  background: url("assets/table.png") center / contain no-repeat;
  position: relative;
  animation: pop 0.35s cubic-bezier(.2,.9,.4,1.4);
  flex-shrink: 0;
}
/* le liseré décoratif du plateau est dans le sprite : on masque le pseudo-élément de base.
   Les nappes VIP / Deluxe ci-dessous le réactivent avec leur propre couleur. */
.scene-table::before {
  content: "";
  position: absolute;
  top: 2px; left: 3px; right: 3px;
  height: 2px;
  background: rgba(255,209,102,0.18);
  border-radius: 2px;
  display: none;
}
.scene-table.vip {
  /* plus de dégradé (il masquerait le sprite) : on TEINTE la même image en doré */
  filter: sepia(.75) saturate(2.2) brightness(1.12);
  box-shadow: 0 0 10px rgba(255,209,102,0.4);
  border-radius: 6px;
}
/* VIP red tablecloth — réactivé, il est masqué par la règle de base */
.scene-table.vip::before {
  display: block;
  top: 0px; left: -2px; right: -2px;
  height: 7px;
  background: var(--red);
  border-radius: 3px;
  box-shadow: 0 1px 0 #6c1010;
}
.scene-table.deluxe {
  /* idem : teinte claire plutôt qu'un fond opaque */
  filter: grayscale(.55) brightness(1.55) contrast(1.05);
  box-shadow: 0 0 12px rgba(255,255,255,0.5);
  border-radius: 6px;
}
/* Deluxe white tablecloth + candle — réactivé */
.scene-table.deluxe::before {
  display: block;
  top: 0px; left: -2px; right: -2px;
  height: 7px;
  background: var(--cream);
  border-radius: 3px;
}
.scene-table.deluxe::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 6px;
  background: var(--gold);
  border-radius: 1px;
  box-shadow: 0 -3px 4px var(--gold);
}

/* STAFF: chefs and drivers — sprites générés, plus de silhouettes en rectangles CSS */
.scene-staff-icon {
  width: 26px;
  height: 34px;
  position: relative;
  animation: pop 0.35s cubic-bezier(.2,.9,.4,1.4);
  flex-shrink: 0;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
}
.scene-staff-icon.chef {
  background-image: url("assets/chef.png");
}
/* tête, toque et casquette sont DANS le sprite : on neutralise les pseudo-éléments */
.scene-staff-icon.chef::before,
.scene-staff-icon.chef::after {
  display: none;
}
.scene-staff-icon.driver {
  background-image: url("assets/livreur.png");
}
.scene-staff-icon.driver::before,
.scene-staff-icon.driver::after {
  display: none;
}

/* SCOOTERS — sprite généré ; le SVG injecté par game.js reste en repli mais est masqué */
.scene-scooter {
  width: 44px;
  height: 26px;
  position: relative;
  animation: pop 0.35s cubic-bezier(.2,.9,.4,1.4);
  flex-shrink: 0;
  background: url("assets/scooter.png") center bottom / contain no-repeat;
}
.scene-scooter svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* le sprite remplace le dessin vectoriel : on le masque sans supprimer le code */
.scene-scooter.has-sprite svg {
  display: none;
}

/* MARKETING BANNER */
.scene-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--red), var(--red-2));
  color: var(--cream);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 4;
  animation: pop 0.35s cubic-bezier(.2,.9,.4,1.4);
}
.scene-banner::before, .scene-banner::after {
  content: "";
  width: 1px; height: 8px;
  background: rgba(0,0,0,0.4);
  position: absolute;
  top: -8px;
}
.scene-banner::before { left: 6px; }
.scene-banner::after  { right: 6px; }
.scene-banner svg { width: 8px; height: 8px; }
.scene-banner .stars {
  display: inline-flex;
  gap: 1px;
}
@keyframes pop {
  from { transform: translateY(8px) scale(0.6); opacity: 0; }
  to   { transform: translateY(0) scale(1);    opacity: 1; }
}
.scene-stats {
  position: absolute;
  top: 6px; right: 8px;
  display: flex;
  gap: 4px;
}
.stat-pill {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,209,102,0.25);
  color: var(--gold);
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* BOARD */
.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  width: 100%;
  max-height: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  border-radius: 16px;
  background:
    radial-gradient(500px 280px at 50% 0%, rgba(244,167,43,0.18), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,0.4), rgba(0,0,0,0.65));
  border: 1px solid rgba(255,209,102,0.18);
  display: block;
  touch-action: none;
}
.cash-pop-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cash-pop {
  position: absolute;
  font-weight: 900;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6), 0 0 12px rgba(255,209,102,0.4);
  animation: cashFloat 1s ease-out forwards;
  font-variant-numeric: tabular-nums;
}
.cash-pop.jackpot {
  font-size: 24px;
  color: var(--red);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6), 0 0 16px rgba(230,57,70,0.6);
}
@keyframes cashFloat {
  0%   { transform: translateY(0) scale(0.6);  opacity: 0; }
  20%  { transform: translateY(-8px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-60px) scale(1);  opacity: 0; }
}

.auto-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--olive);
  color: var(--olive);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}
.auto-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--olive);
  box-shadow: 0 0 8px var(--olive);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* CONTROLS */
.controls {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}
.cta {
  border-radius: 14px;
  padding: 14px 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s, filter 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.cta:active { transform: scale(0.97); }
.cta:disabled { opacity: 0.5; pointer-events: none; filter: saturate(0.5); }

.cta--drop {
  background: linear-gradient(135deg, var(--red), var(--red-2));
  color: var(--cream);
  box-shadow: 0 6px 22px rgba(230,57,70,0.5);
  position: relative;
  overflow: hidden;
}
.cta--drop::after {
  content: "";
  position: absolute;
  inset: -50% -10%;
  background: linear-gradient(60deg, transparent 30%, rgba(255,255,255,0.18) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: shine 3s ease-in-out infinite;
}
@keyframes shine {
  0%, 65%, 100% { transform: translateX(-120%); }
  80% { transform: translateX(120%); }
}
.cta-eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,245,230,0.78);
}
.cta-main { font-size: 16px; }

.cta--shop {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #2a1010;
  box-shadow: 0 6px 22px rgba(244,167,43,0.45);
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.cta--shop .shop-icon {
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 1px;
}
.shop-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--red);
  color: var(--cream);
  font-size: 10px;
  font-weight: 900;
  border-radius: 999px;
  padding: 2px 6px;
  border: 2px solid var(--bg-1);
  animation: pulse 1.4s ease-in-out infinite;
}

.cta--ghost {
  background: transparent;
  color: var(--cream-dim);
  border: 1px solid var(--card-border);
  font-weight: 700;
  padding: 10px;
  font-size: 13px;
}

/* TICKER */
.ticker {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--cream-dim);
  text-align: center;
  min-height: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.ticker strong { color: var(--gold); }

/* MODAL */
.modal-screen {
  position: absolute;
  inset: 0;
  background: rgba(20, 8, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-screen[hidden] { display: none; }
.modal {
  background: linear-gradient(180deg, #3d2415 0%, #1c0e07 100%);
  border: 1px solid rgba(255,209,102,0.25);
  border-radius: 18px;
  padding: 18px;
  max-width: 420px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--cream);
}
.modal-close {
  background: rgba(255,245,230,0.08);
  border: 1px solid var(--card-border);
  color: var(--cream-dim);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 14px;
}

/* TUTORIAL */
.tuto-lead {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 14px;
  color: var(--cream);
}
.tuto-lead strong { color: var(--gold); }
.tuto-list {
  padding-left: 20px;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.tuto-list strong { color: var(--gold); }

/* SHOP */
.shop-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  background: rgba(255,245,230,0.05);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  align-items: center;
  position: relative;
}
.shop-item.locked { opacity: 0.55; }
.shop-item.affordable { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,209,102,0.25) inset; }
.shop-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shop-icon-tag {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #2a1010;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.shop-info strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
}
.shop-info .shop-effect {
  display: block;
  font-size: 11px;
  color: var(--cream-dim);
  margin-top: 2px;
}
.shop-info .shop-next {
  display: block;
  font-size: 10px;
  color: var(--olive);
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.shop-buy {
  background: linear-gradient(135deg, var(--green), #1f7a6e);
  color: var(--cream);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  min-width: 90px;
  transition: transform 0.1s;
}
.shop-buy:active { transform: scale(0.96); }
.shop-buy:disabled {
  background: rgba(255,245,230,0.08);
  color: var(--cream-dim);
  pointer-events: none;
}
.shop-buy small {
  font-size: 9px;
  letter-spacing: 1px;
  opacity: 0.85;
  text-transform: uppercase;
}
.shop-level {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  background: rgba(255,209,102,0.18);
  color: var(--gold);
  padding: 2px 6px;
  border-radius: 999px;
}

/* small screens */
@media (max-height: 720px) {
  .scene { height: 92px; }
  .scene-tables { bottom: 6px; }
  .brand-logo { width: 32px; height: 32px; font-size: 12px; }
  .brand-text strong { font-size: 14px; }
  .cash-value { font-size: 18px; }
}
