/* ===== ¡PELEA! — estilos móvil-first ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b0e1a;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#gameCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ===== HUD ===== */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
  z-index: 5;
}
.hud-name {
  font-weight: 800; font-size: 13px; letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
  width: 42px;
}
.hud-name.right { text-align: right; }
.bar-wrap {
  position: relative; flex: 1; height: 18px;
  background: rgba(0,0,0,.55);
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%; width: 100%;
  transition: width .12s linear;
}
.bar-fill.player { background: linear-gradient(90deg,#2563eb,#38bdf8); }
.bar-fill.enemy { background: linear-gradient(270deg,#dc2626,#f87171); }
.bar-fill.low { background: linear-gradient(90deg,#991b1b,#ef4444); animation: blink .5s infinite; }
@keyframes blink { 50% { opacity: .6; } }
.hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(0,0,0,.7);
}
#timer {
  font-size: 20px; font-weight: 900; min-width: 38px; text-align: center;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
}
#roundInfo {
  position: absolute; top: 44px; left: 0; right: 0;
  text-align: center; font-size: 14px; font-weight: 800;
  letter-spacing: 3px; color: #fcd34d;
  text-shadow: 0 2px 4px rgba(0,0,0,.8);
}

/* ===== Controles táctiles ===== */
#touchControls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 10px calc(12px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: flex-end;
  z-index: 10;
}
#dpad { display: flex; gap: 8px; }
#actions {
  display: grid;
  grid-template-columns: repeat(2, auto);
  grid-template-rows: repeat(2, auto);
  gap: 8px;
  justify-items: center;
}
.ctrl-btn {
  width: 62px; height: 62px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(15,23,42,.55);
  color: #fff; font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
  pointer-events: auto;
}
.ctrl-btn:active, .ctrl-btn.pressed { background: rgba(56,189,248,.45); transform: scale(.94); }
.ctrl-btn.attack { background: rgba(127,29,29,.55); border-color: rgba(252,165,165,.4); }
.ctrl-btn.attack:active, .ctrl-btn.attack.pressed { background: rgba(239,68,68,.6); }
.ctrl-btn.small { width: 54px; height: 54px; font-size: 20px; }

/* ===== Pantallas ===== */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(6,8,16,.88);
  padding: 24px;
  text-align: center;
  overflow-y: auto;
}
.logo {
  font-size: clamp(48px, 14vw, 84px);
  font-weight: 900; letter-spacing: 4px;
  background: linear-gradient(180deg,#fcd34d,#f97316);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(249,115,22,.35);
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { transform: scale(1.03); } }
.subtitle { color: #94a3b8; letter-spacing: 2px; margin-bottom: 8px; }

.btn {
  min-width: 220px; padding: 14px 26px;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  cursor: pointer; color: #fff;
}
.btn.primary { background: linear-gradient(180deg,#f97316,#dc2626); box-shadow: 0 6px 18px rgba(220,38,38,.4); }
.btn.primary:active { transform: scale(.97); }
.btn.secondary { background: linear-gradient(180deg,#2563eb,#1e40af); }
.btn.ghost { background: transparent; border: 2px solid rgba(255,255,255,.3); min-width: 220px; }
.btn:hover { filter: brightness(1.1); }

.howto {
  margin-top: 12px; font-size: 13px; color: #cbd5e1; line-height: 1.6;
  max-width: 420px;
}

.result-detail { color: #cbd5e1; font-size: 15px; line-height: 1.7; }
.score-big {
  font-size: 56px; font-weight: 900; color: #fcd34d;
  text-shadow: 0 4px 0 rgba(0,0,0,.5);
}
.name-row { display: flex; gap: 10px; }
#playerName {
  width: 180px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08); color: #fff;
  font-size: 16px; text-align: center;
}

table { width: 100%; max-width: 420px; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.12); }
th { color: #fcd34d; letter-spacing: 1px; }
td:nth-child(2) { text-align: left; }
tbody tr:first-child td { color: #fcd34d; font-weight: 800; }

@media (min-width: 768px) {
  .ctrl-btn { width: 78px; height: 78px; font-size: 32px; }
  .ctrl-btn.small { width: 66px; height: 66px; font-size: 26px; }
}
