:root {
  --cyan: #33f6ff;
  --magenta: #ff3cf0;
  --red: #ff3355;
  --gold: #ffd24a;
  --panel: rgba(4, 12, 28, 0.82);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05060f;
  color: #e8fbff;
  font-family: 'Orbitron', 'Segoe UI', sans-serif;
  user-select: none;
}

#game canvas { display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

#visor {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 50, 70, 0.3) 80%, rgba(0, 8, 18, 0.9) 100%);
}
#visor::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
}
.corner { position: absolute; width: 60px; height: 60px; border: 2px solid var(--cyan); opacity: 0.55; }
.tl { top: 18px; left: 18px; border-right: none; border-bottom: none; }
.tr { top: 18px; right: 18px; border-left: none; border-bottom: none; }
.bl { bottom: 18px; left: 18px; border-right: none; border-top: none; }
.br { bottom: 18px; right: 18px; border-left: none; border-top: none; }

#crosshair, #hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  stroke: var(--cyan);
  stroke-width: 2.5;
  fill: var(--cyan);
  filter: drop-shadow(0 0 3px var(--cyan));
}
#hitmarker { stroke: #fff; stroke-width: 3.5; opacity: 0; transition: opacity 0.15s; }
#hitmarker.show { opacity: 1; transition: none; }

.label { font-size: 11px; letter-spacing: 3px; color: var(--cyan); opacity: 0.85; }

#objective { position: absolute; top: 30px; left: 96px; max-width: 46vw; }
#objective-text { margin-top: 4px; font-size: 16px; text-shadow: 0 0 8px rgba(51, 246, 255, 0.6); }
#objective-text.new { animation: pulse 1.2s ease-out; }
@keyframes pulse { 0% { color: var(--gold); transform: scale(1.08); } 100% { color: inherit; transform: none; } }

#health { position: absolute; left: 44px; bottom: 44px; width: min(300px, 40vw); }
.bar {
  height: 14px;
  margin-top: 6px;
  border: 1px solid var(--cyan);
  background: rgba(0, 30, 40, 0.6);
  transform: skewX(-20deg);
}
#health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #0090ff, var(--cyan));
  box-shadow: 0 0 12px var(--cyan);
  transition: width 0.2s;
}
#health-fill.low { background: linear-gradient(90deg, #900, var(--red)); box-shadow: 0 0 12px var(--red); }

#weapon { position: absolute; right: 44px; bottom: 44px; text-align: right; }
#weapon-slots { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; }
.slot {
  min-width: 26px;
  padding: 3px 6px;
  border: 1px solid rgba(51, 246, 255, 0.4);
  font-size: 11px;
  opacity: 0.6;
}
.slot.active { border-color: var(--gold); color: var(--gold); opacity: 1; box-shadow: 0 0 8px rgba(255, 210, 74, 0.5); }

.coin-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -3px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c8, #ffc83a 45%, #c47f00);
  box-shadow: 0 0 10px rgba(255, 200, 58, 0.7);
}
#money { position: absolute; top: 30px; right: 96px; font-size: 22px; font-weight: 700; color: var(--gold); text-shadow: 0 0 10px rgba(255, 200, 58, 0.6); }
#money.bump { animation: bump 0.3s ease-out; }
@keyframes bump { 50% { transform: scale(1.25); } }

#radar { position: absolute; top: 76px; right: 44px; width: 150px; text-align: center; }
.radar-screen {
  position: relative;
  width: 150px;
  height: 150px;
  margin-bottom: 6px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle, transparent 32%, rgba(51, 246, 255, 0.25) 33%, transparent 34%, transparent 65%, rgba(51, 246, 255, 0.25) 66%, transparent 67%),
    radial-gradient(circle, rgba(0, 60, 80, 0.55), rgba(0, 15, 30, 0.85));
  box-shadow: 0 0 16px rgba(51, 246, 255, 0.4);
}
.radar-sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(rgba(51, 246, 255, 0.35), transparent 25%);
  animation: sweep 2.5s linear infinite;
}
@keyframes sweep { to { transform: rotate(1turn); } }
.radar-ship {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -60%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #fff;
}
#radar-arrow {
  position: absolute;
  left: calc(50% - 10px);
  top: calc(50% - 10px);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 20px solid var(--gold);
  filter: drop-shadow(0 0 6px var(--gold));
}
#radar-arrow.ahead { border-bottom-color: #44ff88; filter: drop-shadow(0 0 8px #44ff88); }
#radar-blips span {
  position: absolute;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}
#radar-blips span.big { width: 16px; height: 16px; margin: -8px 0 0 -8px; background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
#radar-dist { font-size: 16px; font-weight: 700; color: var(--gold); }

#boss { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); width: min(560px, 70vw); text-align: center; }
#boss .label { color: var(--red); font-size: 14px; }
.boss-bar { border-color: var(--red); height: 16px; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #900, var(--red), #ff8a1e); box-shadow: 0 0 14px var(--red); transition: width 0.15s; }
#weapon-name { font-size: 22px; font-weight: 700; text-shadow: 0 0 10px rgba(51, 246, 255, 0.6); }
#weapon-name.future { color: var(--magenta); text-shadow: 0 0 14px var(--magenta); }
#keycard { margin-top: 8px; font-size: 13px; color: var(--gold); }

#prompt {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--cyan);
  font-size: 15px;
  white-space: nowrap;
}

#dialog {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  width: min(720px, 90vw);
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--cyan);
  border-left: 5px solid var(--cyan);
}
#dialog-name { color: var(--cyan); font-weight: 700; letter-spacing: 2px; margin-bottom: 6px; }
#dialog-text { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 19px; line-height: 1.4; }
#dialog-hint { margin-top: 8px; font-size: 11px; opacity: 0.6; text-align: right; }

#toast {
  position: absolute;
  top: 17%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  color: var(--magenta);
  text-shadow: 0 0 14px var(--magenta);
  opacity: 0;
  transition: opacity 0.3s;
}
#toast.show { opacity: 1; }

#damage {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(255, 0, 40, 0.65));
  opacity: 0;
}
#damage.flash { animation: dmg 0.45s ease-out; }
@keyframes dmg { from { opacity: 1; } to { opacity: 0; } }

/* ---------- Écrans ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(20, 10, 50, 0.75), rgba(2, 3, 10, 0.95));
  cursor: pointer;
}
.screen h1 {
  margin: 0;
  font-size: clamp(48px, 11vw, 120px);
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 60, 240, 0.45));
}
.screen h2 { margin: 0 0 12px; font-size: clamp(14px, 2.2vw, 20px); font-weight: 500; opacity: 0.9; }
.screen h2.big { font-size: clamp(36px, 7vw, 72px); font-weight: 900; color: var(--cyan); }
.screen h2.red { color: var(--red); text-shadow: 0 0 20px var(--red); }
.screen p { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 18px; opacity: 0.85; }

.tape {
  padding: 4px 14px;
  border: 2px solid var(--gold);
  color: var(--gold);
  letter-spacing: 6px;
  font-size: 14px;
}

.controls {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 18px;
  align-items: center;
  margin: 10px 0 18px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  text-align: left;
}
.controls > div:nth-child(odd) { text-align: right; }
kbd {
  display: inline-block;
  min-width: 28px;
  margin: 0 2px;
  padding: 3px 7px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  background: rgba(51, 246, 255, 0.08);
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  text-align: center;
}

.cta { margin-top: 10px; font-size: 20px; font-weight: 700; color: var(--gold); letter-spacing: 3px; }
.blink { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

#win-stats { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 20px; line-height: 1.7; }
.soon { color: var(--gold); }
.buttons { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; }
button {
  padding: 12px 22px;
  border: 2px solid var(--cyan);
  background: rgba(51, 246, 255, 0.1);
  color: #e8fbff;
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  cursor: pointer;
}
button:hover { background: rgba(51, 246, 255, 0.3); }

/* ---------- Menus ---------- */
.screen { cursor: default; }
.menu-money { font-size: 20px; font-weight: 700; color: var(--gold); margin: 6px 0 14px; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: stretch; width: min(380px, 90vw); margin: 8px 0; }
.big-btn {
  position: relative;
  padding: 14px 22px;
  border: 2px solid var(--cyan);
  background: rgba(51, 246, 255, 0.08);
  color: #e8fbff;
  font-family: 'Orbitron', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.big-btn:hover:not(:disabled) { background: rgba(51, 246, 255, 0.25); transform: translateX(4px); }
.big-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.big-btn.shop-btn { border-color: var(--gold); color: var(--gold); background: rgba(255, 210, 74, 0.08); }
.big-btn.shop-btn:hover { background: rgba(255, 210, 74, 0.22); }
.tape-label { display: block; font-size: 11px; letter-spacing: 4px; color: var(--gold); margin-bottom: 4px; }
#screen-menu { justify-content: safe center; overflow-y: auto; padding-bottom: 64px; }
.credits {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(51, 246, 255, 0.12), rgba(255, 60, 240, 0.18), rgba(51, 246, 255, 0.12));
  border-top: 1px solid rgba(255, 60, 240, 0.5);
  backdrop-filter: blur(6px);
  font-size: 14px;
  letter-spacing: 3px;
  text-align: center;
}
.credits strong { color: var(--gold); text-shadow: 0 0 10px rgba(255, 210, 74, 0.6); }
#screen-menu h1 { font-size: clamp(44px, 9vw, 96px); }
#screen-menu .controls { margin-top: 14px; font-size: 13px; opacity: 0.8; gap: 5px 16px; }

/* ---------- Boutique ---------- */
#screen-shop { overflow-y: auto; justify-content: flex-start; padding-top: 30px; }
.shop { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.shop-header { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; flex-wrap: wrap; width: 100%; }
.shop-header h2 { margin: 0; }
.shop-tabs { display: flex; gap: 8px; width: 100%; }
.shop-tabs button { flex: 1; font-size: 15px; }
.shop-tabs button.active { background: var(--cyan); color: #04101c; }
.shop-body { display: flex; gap: 18px; width: 100%; align-items: flex-start; }
#shop-preview { flex: 0 0 300px; height: 380px; border: 1px solid rgba(51, 246, 255, 0.4); background: radial-gradient(circle at 50% 40%, rgba(80, 40, 160, 0.5), rgba(5, 5, 20, 0.9)); }
#shop-preview.hidden-preview { display: none; }
#shop-items { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(51, 246, 255, 0.35);
  background: rgba(4, 12, 28, 0.85);
  text-align: left;
  cursor: pointer;
}
.item:hover, .item.selected { border-color: var(--cyan); box-shadow: 0 0 12px rgba(51, 246, 255, 0.35); }
.item .swatch { height: 8px; border-radius: 4px; }
.item .name { font-weight: 700; font-size: 15px; }
.item .desc { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 13px; opacity: 0.8; flex: 1; }
.item .action { padding: 8px; font-size: 13px; }
.item .action.owned { border-color: #33ff88; color: #33ff88; }
.item .action.equipped { border-color: var(--gold); color: var(--gold); background: rgba(255, 210, 74, 0.12); cursor: default; }
.item .action.buy { border-color: var(--gold); color: #04101c; background: var(--gold); }
.item .action.buy:disabled { background: transparent; color: var(--gold); opacity: 0.5; cursor: not-allowed; }

@media (max-width: 760px) {
  .shop-body { flex-direction: column; }
  #shop-preview { flex: none; width: 100%; height: 260px; }
}

@media (max-width: 700px) {
  #objective { left: 24px; top: 24px; max-width: 80vw; }
  #health { left: 24px; bottom: 24px; }
  #weapon { right: 24px; bottom: 24px; }
}
