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

:root {
  --terra: #e2725b;
  --mint: #7ef9d2;
  --gold: #ffd166;
  --bad: #ff5470;
  --dim: #8a8272;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0c10;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #fbf6ea;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 26px;
  pointer-events: none;
  z-index: 3;
}

.hud-left, .hud-right { display: flex; flex-direction: column; gap: 3px; }
.hud-right { text-align: right; }

.hud-label { font-size: 10px; letter-spacing: 3px; color: var(--dim); }

.hud-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--terra);
  text-shadow: 0 0 12px rgba(226,114,91,.45);
  font-variant-numeric: tabular-nums;
}

.small-v { font-size: 16px; }
.dim2 { color: #b3a68e; }

.hud-sub { font-size: 12px; letter-spacing: 1px; color: #e8dcc4; font-variant-numeric: tabular-nums; }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.lvl-name {
  font-size: clamp(13px, 2vw, 17px);
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #efe3cd;
}

.bar {
  width: 170px;
  height: 11px;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

#fuel-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffc312, #ffe08a);
  box-shadow: 0 0 10px rgba(255,195,18,.7);
  transition: width .12s linear;
}

.bar.cargo { height: 9px; }
#cargo-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7ef9d2, #d8fff0);
  box-shadow: 0 0 10px rgba(126,249,210,.7);
  transition: width .12s linear;
}

#hintbar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  max-width: 94vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- D-pad táctil ---------- */
#dpad {
  position: fixed;
  left: 26px;
  bottom: 26px;
  width: 150px;
  height: 150px;
  z-index: 4;
}

.dp {
  position: absolute;
  width: 46px;
  height: 46px;
  font-size: 17px;
  font-weight: 700;
  color: #ffe9b3;
  background: rgba(255,195,18,.09);
  border: 1.5px solid rgba(255,195,18,.5);
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
}

.dp.u { left: 52px; top: 0; }
.dp.d { left: 52px; bottom: 0; }
.dp.l { left: 0; top: 52px; }
.dp.r { right: 0; top: 52px; }

.dp:active { background: rgba(255,195,18,.3); }

@media (min-width: 900px) and (pointer: fine) {
  #dpad { opacity: .35; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(13,11,14,.88) 0%, rgba(8,7,10,.97) 100%);
  z-index: 10;
  padding: 24px;
}

.hidden { display: none !important; }

.game-title {
  font-size: clamp(56px, 11vw, 104px);
  font-weight: 800;
  letter-spacing: 18px;
  line-height: 1;
  color: #fdf8f0;
  margin-left: 18px;
}

.game-title span {
  color: var(--terra);
  text-shadow: 0 0 28px var(--terra), 0 0 70px rgba(226,114,91,.35);
}

.tagline {
  font-size: clamp(12px, 2vw, 17px);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
}

.rules p { margin: 3px 0; color: #d5c8b2; font-size: clamp(12px, 1.65vw, 14.5px); }
.rules strong { color: var(--terra); }
.rules p:nth-child(3) strong { color: var(--mint); }
.rules p:nth-child(4) strong { color: var(--gold); }
.rules p:nth-child(5) strong { color: var(--bad); }

.btn {
  margin-top: 6px;
  padding: 14px 38px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  font-family: inherit;
  color: var(--terra);
  background: transparent;
  border: 2px solid var(--terra);
  border-radius: 40px;
  cursor: pointer;
  transition: all .18s;
  box-shadow: 0 0 18px rgba(226,114,91,.22), inset 0 0 14px rgba(226,114,91,.06);
}

.btn:hover {
  background: rgba(226,114,91,.13);
  box-shadow: 0 0 30px rgba(226,114,91,.44), inset 0 0 18px rgba(226,114,91,.1);
}

.btn.secondary {
  color: #b5a894;
  border-color: rgba(180,165,140,.5);
  box-shadow: none;
}

.btn.secondary:hover { background: rgba(180,165,140,.1); box-shadow: none; }

.btn-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.win-title {
  font-size: clamp(24px, 5vw, 42px);
  letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(255,209,102,.45);
}

.final-wrap { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.final-label { font-size: 11px; letter-spacing: 4px; color: var(--dim); }

.final-score {
  font-size: clamp(38px, 7.5vw, 62px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 24px rgba(255,255,255,.35);
  font-variant-numeric: tabular-nums;
}

.dim { color: #b3a68e; font-size: 13px; letter-spacing: 1.5px; }

.best {
  min-height: 20px;
  font-size: 12.5px;
  letter-spacing: 2px;
  color: #ffd97a;
}

/* ---------- Tienda ---------- */
.shop-credits {
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--mint);
  font-variant-numeric: tabular-nums;
}

#shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 320px;
}

.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  padding: 10px 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,209,102,.25);
  border-radius: 12px;
}

.shop-name { font-size: 14px; font-weight: 700; letter-spacing: 2px; color: #e8dcc4; }

.shop-buy {
  padding: 7px 16px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--mint);
  background: rgba(126,249,210,.08);
  border: 1.5px solid rgba(126,249,210,.55);
  border-radius: 20px;
  cursor: pointer;
}

.shop-buy:hover:not(:disabled) { background: rgba(126,249,210,.2); }

.shop-buy:disabled { color: #6b6455; border-color: rgba(255,255,255,.12); cursor: not-allowed; }
