/* ===========================================================
   LUMEN — habillage de l'interface
   L'UI est en DOM (net à toutes les résolutions) et se met à
   l'échelle via la font-size de #ui, pilotée par le JS.
   Règle : on ne fixe la font-size que sur les éléments feuilles,
   sinon les `em` se cumulent.
   =========================================================== */

:root {
  --bg:            #08040f;
  --ink:           #ece4fb;
  --muted:         #a394c4;
  --amber:         #ffb35c;
  --amber-hi:      #ffd9a0;
  --cyan:          #9ef4ff;
  --violet:        #7a4fb8;
  --danger:        #ff6b8a;
  --panel-bg:      rgba(26, 14, 48, 0.88);
  --panel-line:    rgba(158, 244, 255, 0.16);
  --glass:         rgba(18, 9, 36, 0.55);
  --shadow:        0 24px 70px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* halo d'ambiance derrière le cadre du jeu */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(60% 50% at 50% 62%, rgba(255, 140, 70, 0.16), transparent 70%),
    radial-gradient(50% 40% at 30% 20%, rgba(110, 70, 220, 0.16), transparent 70%);
  pointer-events: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  border-radius: 14px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(158, 244, 255, 0.10);
  background: #08040f;
}

#ui {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 14px;
  overflow: hidden;
  font-size: 16px;           /* écrasé par le JS selon l'échelle */
}

/* =========================================================
   HUD
   ========================================================= */
#hud {
  position: absolute;
  inset: 0.9em 1.1em auto 1.1em;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8em;
  transition: opacity 0.25s ease;
}

.hud-left, .hud-right { display: flex; align-items: center; gap: 0.5em; }
.hud-left { flex-direction: column; align-items: flex-start; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 0.35em; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.4em 0.85em;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 1.25em;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--amber-hi);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.pill.small { font-size: 0.95em; color: var(--ink); font-weight: 600; }
.time-pill { color: var(--cyan); }

.level-tag {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

/* pastilles icônes, dessinées en CSS pur */
.ico { width: 1em; height: 1em; display: inline-block; flex: none; }
.ico-gem {
  background: linear-gradient(160deg, #fff3d0, #ffb347 55%, #ef7a2a);
  clip-path: polygon(50% 0%, 100% 35%, 50% 100%, 0% 35%);
}
.ico-shard {
  background: linear-gradient(160deg, #e8fbff, #9ef4ff 55%, #4aa9ff);
  clip-path: polygon(50% 0%, 100% 35%, 50% 100%, 0% 35%);
  width: 0.8em; height: 0.8em;
}
.ico-clock {
  border: 0.14em solid currentColor;
  border-radius: 50%;
  width: 0.85em; height: 0.85em;
  position: relative;
}
.ico-clock::after {
  content: "";
  position: absolute;
  left: 50%; top: 20%;
  width: 0.09em; height: 0.34em;
  background: currentColor;
}
.ico-ticket {
  width: 1.5em; height: 1em;
  background: linear-gradient(135deg, var(--amber-hi), var(--amber));
  border-radius: 0.18em;
  position: relative;
  box-shadow: 0 0 1.4em rgba(255, 179, 92, 0.5);
}
.ico-ticket::before, .ico-ticket::after {
  content: "";
  position: absolute;
  width: 0.34em; height: 0.34em;
  background: var(--panel-bg);
  border-radius: 50%;
  top: 50%; transform: translateY(-50%);
}
.ico-ticket::before { left: -0.17em; }
.ico-ticket::after  { right: -0.17em; }
.ico-ticket.big { width: 3.4em; height: 2.3em; border-radius: 0.3em; }
.ico-ticket.big::before, .ico-ticket.big::after { width: 0.8em; height: 0.8em; }
.ico-ticket.big::before { left: -0.4em; }
.ico-ticket.big::after  { right: -0.4em; }

/* multiplicateur de combo */
.combo {
  margin-left: 0.2em;
  padding: 0.05em 0.45em;
  border-radius: 999px;
  font-size: 0.8em;
  background: linear-gradient(135deg, var(--amber), #ff7a4d);
  color: #2a1200;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
}
.combo.show {
  opacity: 1;
  transform: scale(1);
  animation: comboPulse 0.4s ease;
}
@keyframes comboPulse {
  0%   { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.lives { display: flex; gap: 0.28em; align-items: center; }
.heart {
  width: 1.1em; height: 1.1em;
  background: linear-gradient(160deg, #ff9db4, #ff4d6d);
  clip-path: path("M12 21s-7.5-4.7-9.6-9.2C.9 8.4 2.6 4.8 6 4.1c2.1-.5 4.2.6 6 2.6 1.8-2 3.9-3.1 6-2.6 3.4.7 5.1 4.3 3.6 7.7C19.5 16.3 12 21 12 21z");
  /* repli si clip-path path() n'est pas supporté */
  border-radius: 50% 50% 12% 12%;
  filter: drop-shadow(0 0 0.35em rgba(255, 77, 109, 0.55));
  transition: opacity 0.3s, transform 0.3s;
}
.heart.off { opacity: 0.22; transform: scale(0.82); filter: grayscale(1); }

.icon-btn {
  pointer-events: auto;
  width: 2.1em; height: 2.1em;
  display: grid;
  place-items: center;
  border-radius: 0.6em;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover { background: rgba(158, 244, 255, 0.16); }
.icon-btn:active { transform: scale(0.93); }

/* =========================================================
   BANNIÈRE DE NIVEAU
   ========================================================= */
#banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
#banner.show { animation: bannerIn 3.2s ease forwards; }
@keyframes bannerIn {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.9); letter-spacing: 0.4em; }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
.banner-title {
  font-size: 2.6em;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff, var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0.1em 0.5em rgba(0, 0, 0, 0.8));
}
.banner-sub {
  font-size: 0.95em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0.85;
}

/* =========================================================
   COMMANDES TACTILES
   ========================================================= */
#touch { display: none; }
body.touch #touch {
  display: flex;
  position: absolute;
  inset: auto 0 0 0;
  justify-content: space-between;
  padding: 1.2em 1.4em;
  align-items: flex-end;
}
.touch-cluster { display: flex; gap: 0.8em; }
.touch-btn {
  pointer-events: auto;
  width: 4.2em; height: 4.2em;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(20, 10, 40, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.5em;
  line-height: 1;
  display: grid;
  place-items: center;
  touch-action: none;
  transition: background 0.1s, transform 0.1s;
}
.touch-btn.jump {
  width: 5.2em; height: 5.2em;
  background: rgba(158, 244, 255, 0.14);
  border-color: rgba(158, 244, 255, 0.35);
  color: var(--cyan);
}
.touch-btn.power {
  width: 4.4em; height: 4.4em;
  align-self: center;
  background: rgba(255, 179, 92, 0.16);
  border-color: rgba(255, 179, 92, 0.42);
  color: var(--amber-hi);
}
.touch-btn.active { background: rgba(255, 179, 92, 0.35); transform: scale(0.93); }

/* =========================================================
   ÉCRANS MODAUX
   ========================================================= */
#ui.modal #hud { opacity: 0; }
#ui.modal #touch { display: none; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  background: radial-gradient(70% 70% at 50% 50%, rgba(10, 4, 24, 0.72), rgba(6, 2, 14, 0.92));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  pointer-events: auto;
  overflow-y: auto;
}
.screen.show { display: flex; animation: screenIn 0.28s ease; }
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(30em, 100%);
  max-height: 100%;
  padding: 1.8em 1.8em 1.6em;
  border-radius: 1.1em;
  background: var(--panel-bg);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  text-align: center;
  animation: panelIn 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes panelIn {
  from { transform: translateY(1.2em) scale(0.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.title-panel { width: min(34em, 100%); }

.logo h1 {
  margin: 0;
  font-size: 4.6em;
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 0.95;
  background: linear-gradient(180deg, #fff 10%, var(--amber-hi) 45%, #ff8b4d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 0.3em rgba(255, 160, 90, 0.35));
}
.tagline {
  margin: 0.2em 0 0;
  font-size: 0.95em;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: 0.9;
}

h2 {
  margin: 0.15em 0 0.5em;
  font-size: 1.9em;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.eyebrow {
  font-size: 0.75em;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.4em;
}
.eyebrow.danger { color: var(--danger); }
.eyebrow.gold { color: var(--amber); }

.pitch {
  margin: 0.6em 0 1.2em;
  font-size: 1em;
  line-height: 1.55;
  color: var(--muted);
}
.pitch strong { color: var(--amber-hi); font-weight: 700; }

.fine {
  margin: 0.5em 0 1em;
  font-size: 0.82em;
  color: var(--muted);
}

/* --- boutons --- */
.btn {
  pointer-events: auto;
  display: block;
  width: 100%;
  padding: 0.72em 1.2em;
  margin: 0.4em 0 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.7em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 700;
  letter-spacing: 0.09em;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn.primary {
  background: linear-gradient(135deg, var(--amber-hi), var(--amber) 45%, #f97b3d);
  color: #2b1000;
  border-color: rgba(255, 220, 180, 0.5);
  box-shadow: 0 0.5em 1.6em rgba(255, 140, 70, 0.32);
}
.btn.primary:hover {
  box-shadow: 0 0.6em 2em rgba(255, 160, 90, 0.5);
  background: linear-gradient(135deg, #fff0d5, var(--amber-hi) 45%, #ff9455);
}
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.btn.big { font-size: 1.15em; padding: 0.85em 1.2em; margin-top: 0.9em; }

.btn-col { margin-top: 0.6em; }

/* --- tableau de score --- */
.score-table {
  margin: 1.1em 0;
  text-align: left;
  font-size: 0.95em;
}
.score-table .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1em;
  padding: 0.34em 0;
  color: var(--muted);
}
.score-table .row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.score-table .row.dim { opacity: 0.4; }
.score-table .row.total { color: var(--amber-hi); font-weight: 800; letter-spacing: 0.08em; }
.score-table .row.total b { color: var(--amber-hi); font-size: 1.35em; }
.score-table .sep {
  height: 1px;
  margin: 0.5em 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
}

.ticket-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.7em 1em;
  margin: 0.4em 0 0.2em;
  border-radius: 0.7em;
  background: rgba(255, 179, 92, 0.10);
  border: 1px solid rgba(255, 179, 92, 0.28);
  font-size: 0.95em;
  color: var(--amber-hi);
}
.ticket-strip b { font-size: 1.2em; }

.ticket-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1em;
  margin: 1em 0 0.4em;
}
.ticket-count {
  font-size: 3.4em;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #fff, var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ticket-label {
  font-size: 0.8em;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.big-number {
  margin: 0.6em 0 1em;
  font-size: 3em;
  font-weight: 900;
  line-height: 1;
  color: var(--amber-hi);
}
.big-number small {
  display: block;
  font-size: 0.26em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-top: 0.5em;
}

/* --- statistiques du menu --- */
.stats-row {
  display: flex;
  gap: 0.8em;
  margin-top: 1.2em;
}
.stat {
  flex: 1;
  padding: 0.7em;
  border-radius: 0.6em;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.stat-label {
  display: block;
  font-size: 0.7em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 0.25em;
  font-size: 1.4em;
  font-weight: 800;
  color: var(--amber-hi);
}

/* --- rappel des commandes --- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em 1em;
  margin-top: 1.3em;
  padding-top: 1.1em;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.ctrl {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.78em;
  color: var(--muted);
}
kbd {
  padding: 0.2em 0.5em;
  border-radius: 0.35em;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-width: 2px;
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 700;
  color: var(--ink);
}

/* =========================================================
   BADGE DE POUVOIR (HUD)
   ========================================================= */
.power-badge {
  display: none;
  align-items: center;
  gap: 0.4em;
  margin-top: 0.15em;
  padding: 0.28em 0.8em;
  border-radius: 999px;
  background: rgba(158, 244, 255, 0.10);
  border: 1px solid rgba(158, 244, 255, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.8em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  animation: powerIn 0.4s ease;
}
.power-badge.show { display: inline-flex; }
.power-badge b { font-size: 1.3em; line-height: 1; }
.power-badge.cooling {
  opacity: 0.42;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--muted);
}
@keyframes powerIn {
  from { transform: translateY(-0.4em); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* =========================================================
   CARTE DES MONDES
   ========================================================= */
.map-panel { width: min(46em, 100%); }

.map-stats {
  display: flex;
  justify-content: center;
  gap: 1.6em;
  margin: 0.2em 0 1em;
  font-size: 0.85em;
  color: var(--muted);
}
.map-stats b { color: var(--amber-hi); font-size: 1.15em; }

.world-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7em;
  margin-bottom: 1.1em;
}

.world-card {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18em;
  padding: 0.9em 0.85em 0.8em;
  border-radius: 0.75em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  /* les deux teintes viennent du ciel du thème : chaque carte
     ressemble au monde qu'elle ouvre */
  background: linear-gradient(155deg, var(--w1, #33306e), var(--w2, #b76a80));
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.14s, box-shadow 0.18s, filter 0.18s;
}
.world-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(6, 2, 14, 0.65));
  pointer-events: none;
}
.world-card > * { position: relative; z-index: 1; }
.world-card:hover:not(.locked) {
  transform: translateY(-3px);
  box-shadow: 0 0.7em 1.8em rgba(0, 0, 0, 0.5);
  filter: saturate(1.15) brightness(1.08);
}
.world-card:active:not(.locked) { transform: translateY(-1px) scale(0.99); }

.world-card.locked {
  filter: grayscale(0.85) brightness(0.5);
  cursor: default;
}

.world-num {
  font-size: 0.7em;
  font-weight: 800;
  letter-spacing: 0.2em;
  opacity: 0.75;
}
.world-name {
  font-size: 1em;
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.world-tag {
  font-size: 0.72em;
  opacity: 0.8;
  margin-bottom: 0.35em;
}
.world-power {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.18em 0.55em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.68em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.world-power b { font-size: 1.2em; line-height: 1; }
.world-power.base { opacity: 0.7; }
.world-lock {
  margin-top: 0.4em;
  font-size: 0.62em;
  letter-spacing: 0.06em;
  opacity: 0.9;
}

/* =========================================================
   INVITATION À PIVOTER (mobile portrait)
   ========================================================= */
#rotate { display: none; }

@media (orientation: portrait) and (max-width: 860px) {
  body.touch #rotate {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 2rem;
    text-align: center;
    background: radial-gradient(70% 60% at 50% 45%, #1d1038, #0a0518 75%);
  }
}

.rotate-icon {
  width: 3.4rem;
  height: 5.6rem;
  margin-bottom: 1.4rem;
  border: 3px solid var(--amber);
  border-radius: 0.7rem;
  box-shadow: 0 0 2.4rem rgba(255, 179, 92, 0.35);
  animation: rotateHint 2.4s ease-in-out infinite;
}
@keyframes rotateHint {
  0%, 32%   { transform: rotate(0deg); }
  62%, 100% { transform: rotate(-90deg); }
}

.rotate-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.rotate-sub {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* =========================================================
   Adaptations
   ========================================================= */
@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  .panel { padding: 1.4em 1.2em; }
}

/* la grille des mondes passe à 2 colonnes quand le panneau rétrécit */
@media (max-width: 900px) {
  .world-grid { grid-template-columns: repeat(2, 1fr); }
}

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