@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@500;600;700&display=swap');

:root {
  --bg: #060817;
  --accent: #ff4f7b;
  --accent-soft: rgba(255, 79, 123, 0.32);
  --cyan: #63dcff;
  --gold: #ffc05a;
  --mint: #7cffc7;
  --glass: rgba(15, 20, 42, 0.72);
  --border: rgba(255, 255, 255, 0.14);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font-display: 'Orbitron', sans-serif;
  --font-ui: 'Rajdhani', sans-serif;
}

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

body {
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
  font-family: var(--font-ui);
  color: #fff;
}

body.playing {
  cursor: crosshair;
}

canvas {
  display: block;
}

#c {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.65) 100%);
}

#scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.35;
  background: linear-gradient(rgba(255, 255, 255, 0.02) 50%, rgba(0, 0, 0, 0.05) 50%);
  background-size: 100% 3px;
}

body.menu-open #hud,
body.menu-open #biome-tag,
body.menu-open #powerup-tag,
body.menu-open #desktop-controls {
  opacity: 0;
  pointer-events: none;
}

#hud {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 34px;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.35s;
}

#hud.hud-hidden {
  opacity: 0;
}

.hud-item {
  text-align: center;
}

.hud-label {
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 3px #000;
}

.hud-val {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 6px #000;
}

#dist-val {
  color: #ff5577;
}

#biome-tag,
#powerup-tag {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 1px 4px #000;
  transition: opacity 0.35s;
}

#biome-tag {
  top: 62px;
  font-size: 9px;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.35);
}

#powerup-tag {
  top: 84px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
}

#danger-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 50, 68, 0);
  z-index: 4;
  pointer-events: none;
}

#desktop-controls {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 6;
  display: flex;
  gap: 8px;
  pointer-events: none;
  opacity: 0.72;
  transition: opacity 0.35s;
}

#desktop-controls span {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 9px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(10, 14, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

/* ── Overlay menu ── */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: all;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#overlay.hidden {
  display: none;
  pointer-events: none;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 12%, rgba(99, 220, 255, 0.22), transparent 28%),
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(132, 92, 255, 0.4), transparent 58%),
    radial-gradient(ellipse 60% 40% at 92% 82%, rgba(255, 79, 123, 0.24), transparent 54%),
    radial-gradient(ellipse 52% 42% at 8% 74%, rgba(124, 255, 199, 0.13), transparent 52%),
    linear-gradient(180deg, #121837 0%, #07091a 55%, #03040b 100%);
}

.menu-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  opacity: 0.4;
  pointer-events: none;
}

.menu-shell {
  width: min(980px, 100%);
  animation: menuIn 0.5s ease-out;
}

.menu-shell.hidden {
  display: none !important;
}

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

.menu-hero {
  text-align: center;
  margin-bottom: 24px;
}

.menu-eyebrow {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 5px;
  color: var(--cyan);
  opacity: 0.8;
  margin-bottom: 10px;
}

.menu-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 10vw, 72px);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 20%, #ffd8e0 48%, #ff6e94 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(255, 80, 120, 0.45));
  animation: titlePulse 3s ease-in-out infinite;
}

.mode-dead .menu-title {
  background: linear-gradient(180deg, #ff8899 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes titlePulse {
  0%,
  100% {
    filter: drop-shadow(0 0 22px rgba(255, 80, 120, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 36px rgba(255, 80, 120, 0.65));
  }
}

.menu-tagline {
  margin-top: 12px;
  font-size: clamp(15px, 3.5vw, 18px);
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.menu-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 700px) {
  .menu-grid {
    grid-template-columns: 1fr;
  }
}

.menu-card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 20px 60px rgba(0, 0, 0, 0.45),
    0 0 42px rgba(99, 220, 255, 0.06);
}

.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 8px;
}

.field-label + .hs-opts,
.field-label + input {
  margin-bottom: 18px;
}

input[type='text'] {
  width: 100%;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 15px 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type='text']:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 20px var(--accent-soft);
}

.mode-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-label + .mode-opts {
  margin-bottom: 18px;
}

.mode-btn,
.map-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 66px;
  padding: 12px 10px;
  font-family: var(--font-display);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.2s;
}

.mode-name {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
}

.mode-desc {
  font-size: 7.5px;
  letter-spacing: 1px;
  opacity: 0.7;
  text-align: center;
}

.mode-btn:hover,
.map-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
}

.mode-btn.active {
  border-color: var(--cyan);
  color: #fff;
  background: linear-gradient(180deg, rgba(99, 220, 255, 0.22), rgba(99, 220, 255, 0.06));
  box-shadow: 0 12px 34px rgba(99, 220, 255, 0.18), 0 0 24px rgba(99, 220, 255, 0.3);
}

.map-btn.active {
  border-color: var(--mint);
  color: #fff;
  background: linear-gradient(180deg, rgba(124, 255, 199, 0.2), rgba(124, 255, 199, 0.05));
  box-shadow: 0 12px 34px rgba(124, 255, 199, 0.16), 0 0 24px rgba(124, 255, 199, 0.28);
}

.hs-opts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.hs-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px;
  font-family: var(--font-display);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.2s;
}

.hs-num {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.hs-cap {
  font-size: 7px;
  letter-spacing: 1px;
  opacity: 0.7;
}

.hs-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
}

.hs-btn.active {
  border-color: var(--accent);
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 79, 123, 0.28), rgba(255, 79, 123, 0.08));
  box-shadow: 0 12px 34px rgba(255, 79, 123, 0.2), 0 0 24px var(--accent-soft);
}

.btn-play {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 26px;
  margin-top: 4px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-display);
  background: linear-gradient(135deg, #ff5f8b 0%, #ff2f63 45%, #ff8c4a 100%);
  color: #fff;
  box-shadow:
    0 8px 0 #8f1e39,
    0 18px 42px rgba(255, 79, 123, 0.3),
    0 0 32px var(--accent-soft);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 2;
}

.btn-play:hover {
  transform: translateY(-2px);
  box-shadow:
    0 10px 0 #8f1e39,
    0 24px 52px rgba(255, 79, 123, 0.36),
    0 0 44px rgba(255, 79, 123, 0.5);
}

.btn-play:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #8a1530,
    0 0 20px var(--accent-soft);
}

.btn-play-text {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 4px;
}

.btn-play-sub {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.75;
}

.pc-controls-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.key {
  min-width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 900;
  color: #101527;
  background: linear-gradient(180deg, #ffffff, #c8eaff);
  box-shadow: 0 4px 0 rgba(99, 220, 255, 0.24);
}

.pc-controls-text {
  margin-left: 4px;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.58);
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  border: 1px solid rgba(255, 170, 90, 0.45);
  border-radius: 999px;
  background: rgba(255, 170, 90, 0.08);
  color: var(--gold);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 170, 90, 0.18);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn-home {
  width: 100%;
  margin-top: 12px;
}

.menu-card-lb {
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.lb-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.lb-title {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.5);
}

.lb-hint {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: rgba(90, 214, 255, 0.55);
}

.lb-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  max-height: 220px;
  padding-right: 4px;
}

.lb-list li {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.65);
  padding: 11px 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
  display: flex;
  gap: 8px;
}

.lb-list li::before {
  content: '▸';
  color: var(--accent);
  flex-shrink: 0;
}

.lb-list li.lb-empty {
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

.lb-list li.lb-empty::before {
  content: none;
}

.menu-tips {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  backdrop-filter: blur(14px);
}

.menu-tips summary {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 3px;
  color: rgba(90, 214, 255, 0.8);
  cursor: pointer;
  list-style: none;
}

.menu-tips summary::-webkit-details-marker {
  display: none;
}

.menu-tips ul {
  margin-top: 12px;
  padding-left: 0;
  list-style: none;
}

.menu-tips li {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 0;
}

.menu-tips strong {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}

/* ── Écran défaite ── */
.dead-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.dead-stat {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}

.dead-stat-label {
  display: block;
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 8px;
}

.dead-stat-val {
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 36px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 170, 90, 0.35);
}

.score-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.btn-play-retry {
  margin-top: 8px;
}

/* ── Joystick ── */
.joy-zone {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 150px;
  pointer-events: all;
  z-index: 10;
}

.joy-base {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5), 0 0 28px rgba(99, 220, 255, 0.12);
}

.joy-knob {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(99, 220, 255, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(99, 220, 255, 0.2);
}

@media (max-width: 560px) {
  #overlay {
    align-items: flex-start;
    padding: 18px 14px 28px;
  }

  .menu-hero {
    margin-top: 14px;
    margin-bottom: 18px;
  }

  .menu-card {
    padding: 18px;
    border-radius: 24px;
  }

  .menu-title {
    letter-spacing: 0.04em;
  }
}

.joy-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 8px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  body.playing .joy-zone {
    display: none !important;
  }
}

@media (hover: none), (pointer: coarse) {
  #desktop-controls {
    display: none;
  }
}

@media (max-width: 560px) {
  .pc-controls-card {
    display: none;
  }
}
