:root {
  --hot: #ff5a4d;
  --fly: #2fe0c0;
  --ink: #eef0f6;
  --dim: #858da1;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: #08080c; color: var(--ink); font-family: var(--font);
  overflow: hidden; -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: none; touch-action: none; }

/* ─── Marcador ─── */
.hud {
  position: fixed; inset: 16px 18px auto 18px; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.kills b { display: block; font-family: var(--mono); font-size: 40px; line-height: 1; letter-spacing: -.04em; }
.kills span { display: block; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim); margin-top: 4px; }
.kills em { display: block; font-style: normal; font-size: 11.5px; color: #5d6478; margin-top: 7px; font-family: var(--mono); }

.she { text-align: right; }
.gen { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.gen b { color: var(--fly); font-family: var(--mono); font-size: 14px; letter-spacing: 0; }
.react { margin-top: 5px; }
.react b { font-family: var(--mono); font-size: 25px; color: var(--fly); letter-spacing: -.03em; }
.react span { font-size: 10.5px; color: var(--dim); margin-left: 5px; }
.bar { width: 132px; height: 4px; border-radius: 2px; background: #1d2028; margin: 9px 0 0 auto; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--fly); border-radius: 2px; transition: width .7s cubic-bezier(.2,.8,.3,1); }
.bar.fat { margin-top: 6px; }
.bar.fat i { background: #d9a441; transition: width .18s linear; }
.barlab { font-size: 10px; color: #5d6478; margin-top: 5px; letter-spacing: .04em; }

/* ─── Panel de aprendizaje ─── */
.stats {
  position: fixed; left: 18px; bottom: 18px; z-index: 6; width: 296px;
  background: rgba(13,14,19,.82); border: 1px solid #232733; border-radius: 12px;
  padding: 12px 13px 11px; backdrop-filter: blur(7px);
  /* Deja pasar el clic al canvas: el panel no debe robarse golpes. */
  pointer-events: none;
}
.stats button { pointer-events: auto; }
.sthead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.sthead span { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.sthead button {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 10px; letter-spacing: .08em;
  background: none; border: 1px solid #2b3040; color: #6c7488; border-radius: 6px; padding: 3px 9px;
  transition: all .18s;
}
.sthead button:hover { color: var(--hot); border-color: var(--hot); }
.sthead button.armed { color: var(--hot); border-color: var(--hot); background: rgba(255,90,77,.12); }
#chart { display: block; width: 100%; height: 116px; }
.legend { display: flex; gap: 12px; margin: 7px 0 9px; }
.legend span { display: flex; align-items: center; gap: 5px; font-size: 9.5px; color: #666d80; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.legend .lr { background: #2fe0c0; }
.legend .lx { background: #ff5a4d; }
.strow { display: flex; align-items: baseline; gap: 8px; font-size: 11px; color: var(--dim); padding: 2.5px 0; }
.strow span { min-width: 62px; }
.strow b { font-family: var(--mono); font-size: 14px; color: var(--ink); }
.strow em { font-style: normal; font-size: 10.5px; color: #5f6678; }
.strow em.good { color: var(--fly); }
.strow.big { border-top: 1px solid #1e222c; margin-top: 5px; padding-top: 7px; }
.strow.big b { font-size: 19px; }

/* ─── Mensajes ─── */
.flash {
  position: fixed; left: 50%; top: 26%; transform: translateX(-50%);
  z-index: 6; pointer-events: none; text-align: center;
  font-size: clamp(28px, 7vw, 58px); font-weight: 750; letter-spacing: -.04em;
  opacity: 0; text-shadow: 0 4px 30px rgba(0,0,0,.9);
}
.flash.on { animation: pop .95s cubic-bezier(.2,.9,.3,1) both; }
.flash.hit { color: var(--hot); }
.flash.miss { color: var(--fly); }
@keyframes pop {
  0% { opacity: 0; transform: translateX(-50%) scale(.72); }
  16% { opacity: 1; transform: translateX(-50%) scale(1.04); }
  72% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}
.hint {
  position: fixed; left: 50%; bottom: 17%; transform: translateX(-50%);
  z-index: 5; pointer-events: none; text-align: center; min-height: 20px;
  font-size: 13.5px; color: var(--dim); text-shadow: 0 2px 14px rgba(0,0,0,.9);
}
.hint b { color: var(--ink); font-family: var(--mono); }

/* ─── Fuerza del golpe, en vivo ─── */
.swatmeter {
  position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 11px; pointer-events: none;
  opacity: 0; transition: opacity .3s;
}
.playing .swatmeter { opacity: 1; }
.swatmeter .lab {
  font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--dim);
}
.swatmeter i {
  display: block; width: 116px; height: 5px; border-radius: 3px;
  background: #1d2028; overflow: hidden;
}
.swatmeter i b {
  display: block; height: 100%; width: 0; border-radius: 3px;
  background: var(--fly); transition: width .1s linear, background .2s;
}
.swatmeter .ms {
  font-family: var(--mono); font-size: 12.5px; color: var(--dim); min-width: 52px;
}

/* ─── Controles ─── */
.controls {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center;
  padding: 0 14px; pointer-events: none;
}
.controls .c { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); }
.controls kbd {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink);
  background: #171a23; border: 1px solid #2c313e; border-bottom-width: 2px;
  border-radius: 6px; padding: 4px 9px;
}
.controls .tap { display: none; }

/* ─── Portada ─── */
.veil {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 42%, rgba(8,8,12,.7) 0%, rgba(8,8,12,.96) 72%);
  backdrop-filter: blur(3px); transition: opacity .4s;
}
.veil.hide { opacity: 0; pointer-events: none; }
.panel { text-align: center; max-width: 470px; animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.panel .bug { font-size: 50px; display: block; margin-bottom: 12px; }
.panel h1 { font-size: clamp(30px, 7.5vw, 50px); line-height: 1.04; letter-spacing: -.04em; margin: 0 0 16px; }
.panel p { font-size: 15.5px; line-height: 1.55; color: #b9c0d0; margin: 0 0 10px; }
.panel .small { font-size: 13px; color: #7b8296; margin-bottom: 22px; }
.btn {
  appearance: none; border: 0; cursor: pointer; font-family: inherit; font-weight: 700;
  background: var(--hot); color: #2a0705; border-radius: 11px; font-size: 16px; padding: 14px 36px;
  margin-top: 10px; transition: transform .12s, filter .2s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.96); }

.info {
  position: fixed; right: 18px; bottom: 18px; z-index: 7;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: #15171f; color: var(--dim); border: 1px solid #262a36;
  font-family: inherit; font-size: 14px; font-weight: 600;
}
.info:hover { color: var(--ink); border-color: #3b414f; }

dialog {
  border: 1px solid #262a36; border-radius: 14px; background: #101219; color: var(--ink);
  max-width: 520px; padding: 26px 28px; font-family: var(--font);
}
dialog::backdrop { background: rgba(5,5,9,.82); }
dialog h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: .04em; }
dialog p { font-size: 13.5px; line-height: 1.62; color: #b3bac9; margin: 0 0 12px; }
dialog b { color: var(--ink); }
dialog i { color: var(--fly); font-style: normal; }
.dlgbtns { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
dialog button {
  appearance: none; border: 1px solid #262a36; background: #171a22; color: var(--ink);
  border-radius: 8px; padding: 8px 18px; cursor: pointer; font-family: inherit; font-size: 13px;
}
dialog button.ghost { background: none; color: var(--dim); }
dialog button.ghost:hover { color: var(--hot); border-color: var(--hot); }

@media (max-width: 900px) {
  .stats { width: 236px; left: 12px; bottom: 12px; padding: 10px 11px 9px; }
  #chart { height: 88px; }
  .strow { font-size: 10px; }
  .strow b { font-size: 12px; }
  .strow.big b { font-size: 16px; }
}
@media (max-width: 760px) {
  #stage { cursor: default; }
  .kills b { font-size: 30px; }
  .react b { font-size: 20px; }
  .bar { width: 92px; }
  .controls .c:not(.tap) { display: none; }
  .controls .tap { display: block; font-size: 11.5px; }
  .hint { bottom: 13%; font-size: 12.5px; }
}
