* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Consolas', 'Menlo', monospace;
  touch-action: none; /* sin zoom ni scroll con el dedo */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: #7dffa0;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  user-select: none;
}

.hud-tape {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid rgba(125, 255, 160, 0.6);
  background: rgba(0, 20, 8, 0.25);
  text-align: center;
}

.hud-tape.left {
  left: 18%;
}

.hud-tape.right {
  right: 18%;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.8;
}

.hud-value {
  font-size: 30px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 11px;
  opacity: 0.8;
}

.hud-bottom {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  font-size: 14px;
}

.hud-throttle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-throttle-bar {
  width: 140px;
  height: 8px;
  border: 1px solid rgba(125, 255, 160, 0.6);
}

.hud-throttle-fill {
  height: 100%;
  background: #7dffa0;
}





.hud-device {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 12px;
  opacity: 0.85;
}

.hud-help {
  position: absolute;
  top: 14px;
  left: 16px;
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.85;
  white-space: pre;
}

.hud-alert {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 34px;
  font-weight: bold;
  color: #ff5a4a;
  letter-spacing: 4px;
}

.hud-alert.warn {
  color: #ffd24a;
  font-size: 22px;
}

.hud-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hud-supersonic {
  color: #9fe3ff;
  font-weight: bold;
}

.hud-mach-flash {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  font-size: 44px;
  font-weight: bold;
  letter-spacing: 10px;
  color: #e8f7ff;
  text-shadow: 0 0 18px rgba(160, 220, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}

.hud-mach-flash.show {
  animation: mach-flash 1.6s ease-out forwards;
}

@keyframes mach-flash {
  0% { opacity: 0; transform: translateX(-50%) scale(1.6); }
  10% { opacity: 1; transform: translateX(-50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

.hud-ab {
  color: #ffb347;
  font-weight: bold;
  visibility: hidden;
}

/* ---------- Arcade ---------- */

.arcade-stats {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 22px;
  font-size: 14px;
  white-space: nowrap;
}

.arcade-stats b {
  font-size: 18px;
}

.arcade-stats .dim {
  opacity: 0.65;
}

.arcade-mult {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: #ffd24a;
  letter-spacing: 2px;
}

.arcade-ceiling {
  position: absolute;
  top: calc(50% + 62px);
  right: 18%;
  min-width: 120px;
  text-align: center;
  font-size: 12px;
  padding: 3px 0;
  border: 1px solid rgba(125, 255, 160, 0.6);
}

.arcade-ceiling.near {
  color: #ffd24a;
  border-color: #ffd24a;
}

.arcade-ceiling.over {
  color: #fff;
  background: rgba(255, 60, 50, 0.75);
  border-color: #ff5a4a;
}

.arcade-minspeed {
  position: absolute;
  top: calc(50% + 62px);
  left: 18%;
  min-width: 120px;
  text-align: center;
  font-size: 12px;
  opacity: 0.85;
}

.arcade-radar {
  display: none;
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 26px;
  font-weight: bold;
  color: #ff5a4a;
  letter-spacing: 3px;
  animation: blink 0.5s steps(2) infinite;
}

.arcade-radar b {
  font-size: 44px;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.arcade-toast {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  font-weight: bold;
  color: #ffd24a;
  letter-spacing: 3px;
  opacity: 0;
  transition: opacity 0.3s;
}

.arcade-results {
  display: none;
  position: absolute;
  bottom: 9%; /* abajo: arriba se sigue viendo la explosión */
  left: 50%;
  transform: translateX(-50%);
  min-width: 360px;
  padding: 26px 34px;
  background: rgba(0, 18, 8, 0.82);
  border: 1px solid rgba(125, 255, 160, 0.7);
  text-align: center;
}

.arcade-results-title {
  font-size: 26px;
  font-weight: bold;
  color: #ff5a4a;
  letter-spacing: 2px;
}

.arcade-results-record {
  margin-top: 6px;
  font-size: 18px;
  color: #ffd24a;
}

.arcade-results-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 28px;
  margin: 20px auto;
  width: max-content;
  text-align: left;
  font-size: 16px;
}

.arcade-results-hint {
  font-size: 13px;
  opacity: 0.85;
}

/* ---------- Menú principal de DogFights ---------- */

:root {
  --df-night: #07111f;
  --df-navy: #0d2138;
  --df-silver: #e8eef5;
  --df-steel: #8a99ab;
  --df-red: #d7262e;
  --df-glow: #7cc4ff;
}

.df-menu {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 3vw;
  padding: 4vh 4vw;
  background:
    linear-gradient(90deg, rgba(7, 17, 31, 0.92) 0%, rgba(7, 17, 31, 0.6) 42%, rgba(7, 17, 31, 0.05) 75%),
    linear-gradient(0deg, rgba(7, 17, 31, 0.7), transparent 30%);
  pointer-events: auto;
  color: var(--df-silver);
  font-family: 'Russo One', 'Arial Black', sans-serif;
  overflow: hidden;
}

.df-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2vh;
  width: min(560px, 52vw);
  min-height: 0;
}

.df-logo-wrap .df-logo {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 30px rgba(124, 196, 255, 0.18));
  animation: df-logo-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes df-logo-in {
  from { opacity: 0; transform: translateX(-40px) skewX(-8deg); }
  to { opacity: 1; transform: none; }
}

.df-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item {
  all: unset;
  cursor: pointer;
  position: relative;
  padding: 10px 18px 10px 22px;
  background: linear-gradient(90deg, rgba(13, 33, 56, 0.85), rgba(13, 33, 56, 0.35));
  border-left: 4px solid rgba(138, 153, 171, 0.5);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.menu-item.selected {
  border-left-color: var(--df-red);
  background: linear-gradient(90deg, rgba(215, 38, 46, 0.55), rgba(13, 33, 56, 0.6) 70%);
  transform: translateX(12px);
}

.menu-item-title {
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--df-silver);
}

.menu-item.selected .menu-item-title {
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

.menu-item-desc {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  opacity: 0.75;
  margin-top: 3px;
  line-height: 1.35;
}

.df-record {
  font-size: 12px;
  letter-spacing: 3px;
  color: #ffd24a;
  margin-top: 4px;
}

.df-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  opacity: 0.6;
}

.df-coming {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(300px, 30vw);
  animation: df-logo-in 0.9s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.df-coming-title {
  font-size: 13px;
  letter-spacing: 6px;
  color: var(--df-red);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.df-card {
  position: relative;
  padding: 10px 14px;
  background: rgba(7, 17, 31, 0.72);
  border: 1px solid rgba(138, 153, 171, 0.3);
  border-right: 3px solid var(--df-red);
}

.df-card-title {
  font-size: 18px;
  letter-spacing: 4px;
}

.df-card-desc {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

.df-card-tag {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--df-steel);
}

.df-ios {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 17, 31, 0.85);
  z-index: 5;
}

.df-ios-box {
  width: min(440px, 88vw);
  padding: 22px;
  background: var(--df-navy);
  border: 1px solid rgba(138, 153, 171, 0.4);
  border-top: 4px solid var(--df-red);
}

.df-ios-title {
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.df-ios-box ol {
  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding-left: 20px;
  margin: 0 0 16px;
}

/* Pantallas bajitas (teléfono acostado) */
@media (max-height: 520px) {
  .df-menu { padding: 2vh 3vw; }
  .df-left { gap: 1.2vh; width: min(460px, 58vw); }
  .df-logo-wrap .df-logo { max-height: 30vh; }
  .menu-item { padding: 6px 14px 6px 16px; }
  .menu-item-title { font-size: 16px; letter-spacing: 3px; }
  .menu-item-desc { display: none; }
  .df-hint { display: none; }
  .df-card { padding: 6px 10px; }
  .df-card-title { font-size: 14px; }
  .df-card-desc { display: none; }
}

/* Pantallas angostas (teléfono parado) */
@media (max-width: 700px) {
  .df-menu { flex-direction: column; justify-content: center; }
  .df-left { width: 100%; }
  .df-coming { display: none; }
}

#hud.in-menu > :not(.df-menu):not(.options-menu) {
  display: none;
}

.hud-screen-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55), rgba(220, 235, 255, 0.15) 70%);
  opacity: 0;
  pointer-events: none;
}

.hud-screen-flash.show {
  animation: screen-flash 0.35s ease-out forwards;
}

@keyframes screen-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.arcade-missile {
  display: none;
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  font-weight: bold;
  letter-spacing: 6px;
  color: #ff3b2f;
  text-shadow: 0 0 16px rgba(255, 40, 20, 0.8);
  animation: blink 0.25s steps(2) infinite;
}

/* ---------- Pausa ---------- */

.pause-menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  background: rgba(4, 10, 16, 0.6);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  color: #dff6e8;
  z-index: 20;
}

.pause-title {
  font-size: 48px;
  font-weight: bold;
  letter-spacing: 14px;
  color: #e8f7ff;
  text-shadow: 0 0 24px rgba(120, 200, 255, 0.5);
}

.pause-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, 80vw);
}

.pause-list .menu-item {
  text-align: center;
}

.pause-list .menu-item-title {
  font-size: 20px;
}

/* ---------- Opciones ---------- */

.options-menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4vh 0;
  gap: 12px;
  background: rgba(4, 10, 16, 0.82);
  pointer-events: auto;
  color: #dff6e8;
  z-index: 30;
}

.options-title {
  font-size: 38px;
  font-weight: bold;
  letter-spacing: 12px;
  color: #e8f7ff;
}

.options-body {
  flex: 1;
  overflow-y: auto;
  touch-action: pan-y; /* deslizar con el dedo */
  -webkit-overflow-scrolling: touch;
  width: min(760px, 92vw);
  padding-right: 6px;
}

.options-hint {
  font-size: 12px;
  opacity: 0.65;
}

.options-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 15px;
}

.options-row.header {
  cursor: default;
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: 4px;
  color: #8cffb4;
  opacity: 0.8;
  border-bottom: 1px solid rgba(140, 255, 180, 0.2);
}

.options-row.selected {
  border-color: #8cffb4;
  background: rgba(40, 110, 70, 0.45);
}

.opt-label {
  flex: 1;
}

.opt-value {
  color: #ffd24a;
}

.opt-cell {
  width: 170px;
  text-align: center;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.opt-cell.fixed {
  opacity: 0.5;
}

.options-row.selected .opt-cell.col {
  border-color: #ffd24a;
  color: #ffd24a;
}

.options-row.button {
  justify-content: center;
  letter-spacing: 3px;
}

/* ---------- Controles táctiles ---------- */

.touch-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.touch-zone {
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 0;
  width: 48%;
  pointer-events: auto;
  touch-action: none;
}

.touch-ui.tilt .touch-zone {
  width: 70%;
}

.touch-base {
  display: none;
  position: fixed;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  border: 2px solid rgba(232, 238, 245, 0.45);
  background: radial-gradient(circle, rgba(13, 33, 56, 0.25), rgba(13, 33, 56, 0.55));
}

.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f4f7fb, #8a99ab);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
}

.touch-btn {
  all: unset;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #e8eef5;
  font-family: 'Russo One', sans-serif;
  background: rgba(7, 17, 31, 0.55);
  border: 2px solid rgba(232, 238, 245, 0.35);
  border-radius: 14px;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn.pressed,
.touch-btn:active {
  background: rgba(215, 38, 46, 0.6);
  border-color: #d7262e;
}

.touch-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
}

.touch-btn.small {
  width: 48px;
  height: 42px;
  font-size: 18px;
}

.touch-btn.center {
  display: none;
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  font-size: 14px;
  letter-spacing: 3px;
}

.touch-ui.tilt .touch-btn.center {
  display: flex;
}

.touch-right {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.touch-btn.thr {
  width: 82px;
  height: 72px;
  font-size: 24px;
}

.touch-btn.thr span {
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.8;
}

.touch-rotate {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #07111f;
  color: #e8eef5;
  font-family: 'Russo One', sans-serif;
  font-size: 20px;
  letter-spacing: 2px;
  pointer-events: auto;
}

.touch-rotate div {
  font-size: 64px;
  color: #d7262e;
}

@media (orientation: portrait) {
  .touch-rotate {
    display: flex;
  }
}

/* En el teléfono escondemos lo que estorba y achicamos el HUD */
body.touch-game .hud-help,
body.touch-game .hud-device {
  display: none !important;
}

@media (max-height: 520px) {
  .hud-tape {
    min-width: 84px;
    padding: 4px 8px;
    font-size: 12px;
  }
}
