:root {
  --ink: #f8f4ff;
  --muted: #b9aed3;
  --panel: rgba(22, 17, 40, 0.88);
  --pink: #ff4f9a;
  --cyan: #41d9ff;
  --lime: #b6ff3b;
  --violet: #a97bff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #120f1f;
  color: var(--ink);
  font-family: ui-rounded, "Trebuchet MS", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

#app,
#app canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#app canvas {
  cursor: crosshair;
  outline: none;
}

.hud {
  position: fixed;
  inset: 18px 20px auto 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 4;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.65));
}

.brand-name {
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 950;
  letter-spacing: 0.045em;
  transform: rotate(-1.5deg);
}

.phase {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  padding: 3px 8px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(255, 79, 154, 0.24);
  color: #ffd3e5;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hud-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(65, 217, 255, 0.36);
  border-radius: 999px;
  background: rgba(9, 29, 38, 0.72);
  color: #d8f9ff;
  font-size: 12px;
  font-weight: 800;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  transition: border-color 120ms ease, background 120ms ease;
}

.room-pill:hover {
  border-color: var(--cyan);
  background: rgba(16, 48, 61, 0.9);
}

.room-label {
  color: #7bcfe0;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.room-pill strong {
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.room-copy {
  color: var(--cyan);
  font-size: 15px;
}

.status-pill,
.player-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(10, 8, 20, 0.58);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.player-count {
  color: var(--ink);
  letter-spacing: 0.04em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6e6684;
  box-shadow: 0 0 0 3px rgba(110, 102, 132, 0.16);
}

.status-pill.connecting .status-dot {
  background: #ffb020;
  box-shadow: 0 0 10px #ffb020;
}

.status-pill.online .status-dot {
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
}

.status-pill.offline .status-dot {
  background: #ff5d5d;
  box-shadow: 0 0 10px #ff5d5d;
}

.controls-tip {
  position: fixed;
  left: 20px;
  bottom: 18px;
  z-index: 4;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(10, 8, 20, 0.58);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.controls-tip strong {
  color: var(--ink);
}

.lock-hint {
  position: fixed;
  left: 50%;
  bottom: 72px;
  z-index: 5;
  transform: translateX(-50%);
  padding: 11px 20px;
  border: 2px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  background: rgba(20, 15, 38, 0.9);
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.lock-hint span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lock-hint:hover {
  background: rgba(40, 29, 73, 0.96);
  border-color: var(--pink);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(169, 123, 255, 0.16), transparent 42%),
    rgba(8, 6, 16, 0.55);
  backdrop-filter: blur(3px);
  transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card {
  width: min(580px, 100%);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 28px 18px 32px 14px;
  background: var(--panel);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transform: rotate(-0.5deg);
}

.kicker {
  margin: 0 0 13px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(54px, 11vw, 94px);
  font-weight: 950;
  letter-spacing: -0.065em;
  line-height: 0.82;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.42);
}

h1 span {
  color: var(--pink);
  text-shadow:
    4px 4px 0 #531d50,
    0 0 34px rgba(255, 79, 154, 0.3);
}

.lead {
  max-width: 430px;
  margin: 22px 0 28px;
  color: #ddd3f3;
  font-size: 16px;
  line-height: 1.45;
}

.lan-hint {
  max-width: 430px;
  margin: -14px 0 26px;
  padding: 10px 14px;
  border: 1px solid rgba(65, 217, 255, 0.35);
  border-radius: 12px;
  background: rgba(65, 217, 255, 0.08);
  color: #bfefff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.lan-hint code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #eaffff;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.code-row {
  margin-top: 0;
}

#roomCode {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 20px;
  font-weight: 900;
}

#name {
  margin-bottom: 10px;
}

input {
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  outline: none;
  background: rgba(7, 5, 15, 0.66);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(65, 217, 255, 0.12);
}

button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.primary-btn,
.secondary-btn {
  font-weight: 950;
  letter-spacing: 0.06em;
  transition: transform 100ms ease, box-shadow 100ms ease, filter 100ms ease;
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  background: linear-gradient(135deg, var(--pink), #ff7b45);
  color: #2a0718;
  box-shadow: 0 6px 0 #9f2058, 0 12px 28px rgba(255, 79, 154, 0.2);
}

.primary-btn:hover,
.secondary-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.primary-btn:active,
.secondary-btn:active {
  transform: translateY(3px);
}

.primary-btn:active {
  box-shadow: 0 1px 0 #9f2058;
}

.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: wait;
  filter: grayscale(0.45);
  opacity: 0.72;
}

.secondary-btn {
  min-height: 52px;
  padding: 0 22px;
  border: 2px solid rgba(65, 217, 255, 0.45);
  background: rgba(65, 217, 255, 0.12);
  color: #d7f9ff;
  box-shadow: 0 4px 0 rgba(18, 123, 147, 0.45);
}

.secondary-btn:active {
  box-shadow: 0 1px 0 rgba(18, 123, 147, 0.45);
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 14px;
  color: #8f84a9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.or-divider::before,
.or-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
}

.menu-status {
  min-height: 20px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.menu-status.error {
  color: #ff8b8b;
}

.toast {
  position: fixed;
  top: 82px;
  left: 50%;
  z-index: 30;
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 18px;
  border: 1px solid rgba(182, 255, 59, 0.35);
  border-radius: 12px;
  background: rgba(16, 30, 12, 0.92);
  color: #e9ffd1;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(8px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.menu-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #9e93b9;
  font-size: 12px;
  font-weight: 700;
}

.menu-controls span {
  margin: 0 3px;
  color: #5f5678;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font: 800 11px/1 ui-monospace, monospace;
}

/* Empujón activo (M0.5) */
.shove-hud {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 6;
  width: min(310px, calc(100vw - 40px));
  padding: 10px 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(12, 9, 22, 0.74);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translateX(-50%);
  transition: border-color 150ms ease, box-shadow 150ms ease;
  backdrop-filter: blur(10px);
}

.shove-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.shove-head kbd {
  min-width: 58px;
  height: 20px;
  font-size: 9px;
}

.shove-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.shove-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #41d9ff, #b6ff3b);
  transform: scaleX(0);
  transform-origin: left center;
  transition: background 120ms linear;
}

.shove-hud.ready {
  border-color: rgba(182, 255, 59, 0.42);
}

.shove-hud.ready .shove-fill {
  background: linear-gradient(90deg, #b6ff3b, #eaff9b);
}

.shove-hud.charging {
  border-color: rgba(65, 217, 255, 0.6);
}

.shove-hud.charging .shove-fill {
  background: linear-gradient(90deg, #41d9ff, #ff4f9a);
}

.shove-hud.full {
  border-color: var(--pink);
  box-shadow: 0 0 26px rgba(255, 79, 154, 0.45);
  animation: shovePulse 280ms infinite alternate;
}

.shove-hud.full .shove-head span {
  color: #ffd1e8;
}

.shove-hud.cooling {
  border-color: rgba(255, 176, 32, 0.42);
}

.shove-hud.cooling .shove-fill {
  background: linear-gradient(90deg, #ff6b3d, #ffb020);
}

@keyframes shovePulse {
  from {
    transform: translateX(-50%) scale(1);
  }
  to {
    transform: translateX(-50%) scale(1.025);
  }
}

.hit-flash {
  position: fixed;
  inset: 0;
  z-index: 12;
  background: radial-gradient(circle at center, rgba(255, 79, 154, 0) 34%, rgba(255, 79, 154, 0.6) 100%);
  opacity: 0;
  pointer-events: none;
}

.hit-flash.show {
  animation: hitFlash 420ms ease-out;
}

@keyframes hitFlash {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 620px) {
  .card {
    padding: 26px 22px;
  }

  .code-row {
    grid-template-columns: 1fr;
  }

  .secondary-btn {
    min-height: 48px;
  }

  .controls-tip {
    right: 20px;
    bottom: 94px;
    text-align: center;
  }

  .hud {
    inset: 12px 12px auto 12px;
  }

  .hud-right {
    gap: 6px;
  }

  .status-pill {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Vidas y muerte (M2) */
.power-hud {
  position: fixed;
  left: 50%;
  bottom: 104px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px 7px 10px;
  border: 1px solid var(--power-color, #b6ff3b);
  border-radius: 999px;
  background: rgba(12, 9, 22, 0.84);
  box-shadow: 0 0 18px color-mix(in srgb, var(--power-color, #b6ff3b) 32%, transparent);
  transform: translateX(-50%);
  pointer-events: none;
  backdrop-filter: blur(10px);
  animation: power-pop 220ms ease-out;
}

.power-hud[hidden] {
  display: none;
}

.power-icon {
  font-size: 19px;
  line-height: 1;
}

.power-name {
  color: #f8f4ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@keyframes power-pop {
  from {
    transform: translateX(-50%) scale(0.82);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

.lives-hud {
  position: fixed;
  top: 68px;
  left: 24px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.lives-pips {
  display: flex;
  gap: 6px;
}

.life-pip {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 12px rgba(255, 79, 154, 0.75);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.life-pip.lost {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  transform: scale(0.82);
}

.lives-state {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lives-state.invulnerable {
  color: #8ee7ff;
}

.death-banner {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  background: radial-gradient(circle at 50% 42%, rgba(18, 15, 31, 0.25), rgba(18, 15, 31, 0.86));
  text-align: center;
  pointer-events: none;
}

.death-banner strong {
  color: #ffffff;
  font-size: clamp(40px, 9vw, 88px);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 0 28px rgba(255, 79, 154, 0.85), 0 6px 0 rgba(0, 0, 0, 0.35);
}

.death-banner span {
  max-width: 520px;
  color: #ffd7ea;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}
