:root {
  --hp: #4caf50; --hp-low: #e53935; --lag: #ffcc80; --en: #29b6f6;
  --panel: rgba(10, 12, 20, .55); --gold: #ffb300; --red: #c62828;
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #1b1f2a; font-family: system-ui, sans-serif; color: #fff;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
canvas { display: block; touch-action: none; }
kbd { background: #fff2; border: 1px solid #fff5; border-radius: 4px; padding: 0 5px; font: inherit; font-size: .9em; }
.gold { color: var(--gold); }
button { font: inherit; }
.touch-only { display: none; }
body.touch .desktop-only { display: none !important; }
body.touch .touch-only { display: inline; }

/* ---------- Mundo ---------- */
#hud {
  position: fixed; left: 12px; bottom: 12px; background: var(--panel);
  padding: 8px 12px; border-radius: 8px; font-size: 14px; line-height: 1.5; pointer-events: none; display: none;
}
body.in-world #hud { display: block; }
body.touch #hud {
  left: 50%; bottom: auto; top: calc(env(safe-area-inset-top) + 10px);
  transform: translateX(-50%); font-size: 12px; text-align: center; white-space: nowrap; transition: opacity .6s;
}
body.touch.played #hud { opacity: 0; }
#world-menu {
  position: fixed; right: calc(env(safe-area-inset-right) + 12px); top: calc(env(safe-area-inset-top) + 12px);
  display: none; gap: 8px;
}
body.in-world #world-menu { display: flex; }
#world-menu button { background: var(--panel); color: #fff; border: 1px solid #fff4; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
body.touch #world-menu { top: calc(env(safe-area-inset-top) + 44px); }
#zone-prompt {
  position: fixed; left: 50%; top: 30%; transform: translateX(-50%); font-size: 22px; font-weight: 700;
  color: var(--gold); text-shadow: 0 2px 8px #000; opacity: 0; transition: opacity .2s; pointer-events: none; text-align: center;
}
#zone-prompt.show { opacity: 1; }

/* ---------- HUD del ring ---------- */
#ring-hud { display: none; }
#ring-hud.show { display: block; }
#ring-hud .bars {
  position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 10px);
  display: flex; align-items: flex-start; gap: 10px; padding: 0 calc(env(safe-area-inset-right) + 12px) 0 calc(env(safe-area-inset-left) + 12px);
  pointer-events: none;
}
#ring-hud .side { flex: 1; min-width: 0; }
#ring-hud .name { font-weight: 700; font-size: 14px; text-shadow: 0 1px 3px #000; margin-bottom: 3px; }
#ring-hud .p1 .name { text-align: right; }
#ring-hud .bar { position: relative; background: rgba(0,0,0,.55); border: 2px solid #fff8; border-radius: 4px; overflow: hidden; }
#ring-hud .health { height: 16px; }
#ring-hud .energy { height: 8px; margin-top: 3px; border-width: 1px; }
#ring-hud .bar .fill, #ring-hud .bar .lag { position: absolute; inset: 0; transform-origin: left; }
#ring-hud .p1 .bar .fill, #ring-hud .p1 .bar .lag { transform-origin: right; }
#ring-hud .health .lag { background: var(--lag); }
#ring-hud .health .fill { background: var(--hp); transition: background .3s; }
#ring-hud .health.low .fill { background: var(--hp-low); }
#ring-hud .energy .fill { background: var(--en); }
#ring-hud .energy i { position: absolute; top: 0; bottom: 0; width: 2px; background: #fffc; margin-left: -1px; }
#ring-hud .timer {
  min-width: 52px; text-align: center; font-size: 30px; font-weight: 800; line-height: 1; padding-top: 6px;
  text-shadow: 0 2px 6px #000; font-variant-numeric: tabular-nums;
}
#ring-hud .timer.low { color: #ff7043; }
#ring-hud .ring-menu {
  position: fixed; right: calc(env(safe-area-inset-right) + 12px); top: calc(env(safe-area-inset-top) + 76px);
  display: flex; gap: 8px; align-items: center; font-size: 13px;
}
#ring-hud .ring-menu label { background: var(--panel); padding: 4px 8px; border-radius: 6px; display: flex; gap: 6px; align-items: center; }
#ring-hud select { font: inherit; background: #222a; color: #fff; border: 1px solid #fff5; border-radius: 4px; }
#ring-hud button { background: var(--panel); color: #fff; border: 1px solid #fff5; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
#ring-hud .skills {
  position: fixed; left: calc(env(safe-area-inset-left) + 12px); bottom: 44px; display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
body.touch #ring-hud .skills { display: none; }
#ring-hud .skill {
  --fill: 0; position: relative; display: flex; gap: 8px; align-items: center; min-width: 210px;
  background: var(--panel); border-radius: 6px; padding: 5px 10px; overflow: hidden; opacity: .65; font-size: 14px;
}
#ring-hud .skill::before {
  content: ''; position: absolute; inset: 0; background: rgba(41,182,246,.25); transform: scaleX(var(--fill)); transform-origin: left;
}
#ring-hud .skill > * { position: relative; }
#ring-hud .skill.ready { opacity: 1; box-shadow: inset 0 0 0 2px var(--en); }
#ring-hud .skill .sname { flex: 1; }
#ring-hud .skill .cost { color: #8fd9ff; font-weight: 700; }
#ring-help {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 12px; background: var(--panel);
  padding: 4px 10px; border-radius: 6px; display: none; white-space: nowrap; pointer-events: none;
}
body.in-ring #ring-help { display: block; }
#ring-hud .banner {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(.8); opacity: 0; pointer-events: none;
  font-size: 44px; font-weight: 900; font-style: italic; letter-spacing: 1px; color: #fff;
  text-shadow: 0 0 12px #000, 0 3px 0 var(--red); transition: opacity .15s, transform .15s; white-space: nowrap;
}
#ring-hud .banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#ring-hud .banner.big { font-size: 60px; }
#ring-hud .banner.ko { color: #ffd54f; }
#ring-hud .result {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(10,12,20,.85);
  border: 1px solid #fff3; border-radius: 12px; padding: 20px 28px; text-align: center; display: none; min-width: 240px;
}
#ring-hud .result.show { display: block; }
#ring-hud .result .title { font-size: 34px; font-weight: 900; margin-bottom: 6px; }
#ring-hud .result .detail { opacity: .8; margin-bottom: 16px; }
#ring-hud .result .buttons { display: flex; gap: 10px; justify-content: center; }
#ring-hud .result button { padding: 10px 16px; font-size: 16px; }
#ring-hud .result .rematch { background: var(--red); border-color: #fff8; }
@keyframes denied { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.denied { animation: denied .25s 2; box-shadow: inset 0 0 0 2px #e53935 !important; }

/* ---------- Números y textos flotantes ---------- */
.floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; left: 0; top: 0; font-weight: 900; font-size: 22px; color: #fff; white-space: nowrap;
  text-shadow: 0 0 4px #000, 0 2px 0 #000;
}
.floater.guarded { color: #9ad4ff; font-size: 16px; }
.floater.skill { color: #ffd54f; font-size: 28px; }
.floater.counter { color: #ff7043; font-size: 18px; }
.floater.skill-name { font-size: 18px; color: #fff; font-style: italic; }
.floater.skill-name.lvl3 { font-size: 26px; color: #ff8a50; }

/* ---------- Controles táctiles ---------- */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
#stick-base {
  position: fixed; width: 120px; height: 120px; border-radius: 50%;
  left: calc(env(safe-area-inset-left) + 90px); bottom: calc(env(safe-area-inset-bottom) + 30px);
  transform: translate(-50%, 0); background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35);
  pointer-events: none; opacity: .6; transition: opacity .15s;
}
#stick-base.active { bottom: auto; transform: translate(-50%, -50%); opacity: 1; }
#stick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%;
  transform: translate(-50%, -50%); background: rgba(255,255,255,.75); box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.tbtn {
  --r: calc(env(safe-area-inset-right) + 0px); --b: calc(env(safe-area-inset-bottom) + 0px);
  position: fixed; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); color: #fff; padding: 0;
  touch-action: none; box-shadow: 0 3px 10px rgba(0,0,0,.35); line-height: 1;
}
.tbtn.down { transform: scale(.9); filter: brightness(1.3); }
#btn-jump { width: 84px; height: 84px; right: calc(var(--r) + 28px); bottom: calc(var(--b) + 40px); background: rgba(198,40,40,.7); font-size: 36px; }
.tbtn.combat { display: none; }
body.mode-ring .tbtn.combat { display: block; }
/* En el ring: golpe grande en la esquina, salto a su izquierda, guardia arriba y habilidades en abanico */
body.mode-ring #btn-attack { width: 86px; height: 86px; right: calc(var(--r) + 18px); bottom: calc(var(--b) + 24px); background: rgba(198,40,40,.8); font-size: 34px; }
body.mode-ring #btn-jump { width: 60px; height: 60px; right: calc(var(--r) + 118px); bottom: calc(var(--b) + 18px); font-size: 26px; background: rgba(60,60,70,.7); }
#btn-guard { width: 62px; height: 62px; right: calc(var(--r) + 112px); bottom: calc(var(--b) + 92px); background: rgba(40,90,160,.75); font-size: 26px; }
.tbtn.skill {
  --fill: 0; width: 56px; height: 56px; font-size: 13px; font-weight: 800; background: rgba(30,30,40,.7); opacity: .7;
  background-image: conic-gradient(rgba(41,182,246,.6) calc(var(--fill) * 360deg), transparent 0);
}
.tbtn.skill.ready { opacity: 1; border-color: #8fd9ff; box-shadow: 0 0 12px rgba(41,182,246,.8); }
#btn-skill1 { right: calc(var(--r) + 178px); bottom: calc(var(--b) + 50px); }
#btn-skill2 { right: calc(var(--r) + 168px); bottom: calc(var(--b) + 128px); }
#btn-skill3 { right: calc(var(--r) + 96px); bottom: calc(var(--b) + 164px); width: 64px; height: 64px; }
#btn-skill3.ready { border-color: #ff8a50; box-shadow: 0 0 16px rgba(255,120,60,.9); }
body.touch #ring-hud .ring-menu { top: calc(env(safe-area-inset-top) + 70px); }
@media (max-width: 500px) {
  #ring-hud .banner.big { font-size: 44px; }
  #ring-hud .timer { font-size: 24px; min-width: 40px; }
  #ring-hud .name { font-size: 12px; }
}

/* ---------- Móvil en horizontal (modo principal) ---------- */
/* La altura útil es poca (≈300–400 px): HUD compacto arriba, menú del ring a la izquierda
   y todos los botones de combate agrupados abajo a la derecha, por debajo de las barras. */
@media (orientation: landscape) and (max-height: 500px) {
  body.touch #ring-hud .bars { top: calc(env(safe-area-inset-top) + 6px); gap: 8px; }
  body.touch #ring-hud .name { font-size: 11px; margin-bottom: 2px; }
  body.touch #ring-hud .health { height: 11px; }
  body.touch #ring-hud .energy { height: 6px; margin-top: 2px; }
  body.touch #ring-hud .timer { font-size: 22px; min-width: 38px; padding-top: 2px; }
  body.touch #ring-hud .ring-menu {
    right: auto; left: calc(env(safe-area-inset-left) + 12px); top: calc(env(safe-area-inset-top) + 56px);
    font-size: 11px; gap: 6px;
  }
  body.touch #ring-hud .ring-menu button { padding: 3px 8px; }
  body.touch #ring-hud .banner { top: 38%; font-size: 34px; }
  body.touch #ring-hud .banner.big { font-size: 46px; }
  body.touch #ring-hud .result { padding: 12px 20px; }
  body.touch #ring-hud .result .title { font-size: 26px; }

  body.touch.mode-ring #btn-attack { width: 78px; height: 78px; right: calc(var(--r) + 16px); bottom: calc(var(--b) + 14px); font-size: 30px; }
  body.touch.mode-ring #btn-jump { width: 52px; height: 52px; right: calc(var(--r) + 104px); bottom: calc(var(--b) + 8px); font-size: 22px; }
  body.touch.mode-ring #btn-guard { width: 54px; height: 54px; right: calc(var(--r) + 98px); bottom: calc(var(--b) + 68px); font-size: 22px; }
  body.touch.mode-ring #btn-skill1 { width: 50px; height: 50px; right: calc(var(--r) + 166px); bottom: calc(var(--b) + 20px); }
  body.touch.mode-ring #btn-skill2 { width: 50px; height: 50px; right: calc(var(--r) + 160px); bottom: calc(var(--b) + 80px); }
  body.touch.mode-ring #btn-skill3 { width: 56px; height: 56px; right: calc(var(--r) + 100px); bottom: calc(var(--b) + 130px); }
  body.touch #btn-jump { width: 70px; height: 70px; right: calc(var(--r) + 22px); bottom: calc(var(--b) + 22px); font-size: 30px; }
  body.touch #world-menu { top: calc(env(safe-area-inset-top) + 10px); }
  body.touch #world-menu button { padding: 6px 10px; font-size: 13px; }
  body.touch #hud { top: calc(env(safe-area-inset-top) + 8px); }
  #stick-base { width: 104px; height: 104px; left: calc(env(safe-area-inset-left) + 80px); bottom: calc(env(safe-area-inset-bottom) + 18px); }
  #stick-knob { width: 46px; height: 46px; }
}
/* Pantallas muy bajas (barra del navegador visible): un poco más chico todavía */
@media (orientation: landscape) and (max-height: 330px) {
  body.touch.mode-ring #btn-attack { width: 68px; height: 68px; }
  body.touch.mode-ring #btn-skill3 { bottom: calc(var(--b) + 120px); width: 50px; height: 50px; }
  body.touch.mode-ring #btn-skill2 { bottom: calc(var(--b) + 72px); }
  body.touch.mode-ring #btn-guard { bottom: calc(var(--b) + 62px); }
}

/* ---------- Aviso de girar el teléfono ---------- */
#rotate {
  position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: #1b1f2a; text-align: center; padding: 24px; font-size: 18px;
}
#rotate .icon { font-size: 64px; animation: rotate-hint 2s ease-in-out infinite; }
#rotate small { opacity: .6; font-size: 13px; }
@keyframes rotate-hint { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) {
  body.touch #rotate { display: flex; }
}

/* ---------- Entrada y selección de personaje ---------- */
#select { display: none; --accent: #c62828; }
#select.show { display: block; }
#select .entry, #select .picker { display: none; }
#select.entry-on .entry { display: flex; }
#select.picker-on .picker { display: block; }
#select .entry {
  position: fixed; inset: 0; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(ellipse at center, rgba(20,22,35,.35), rgba(10,12,20,.9));
}
#select h1 {
  margin: 0; font-size: clamp(40px, 9vw, 84px); font-weight: 900; font-style: italic; letter-spacing: 3px;
  text-shadow: 0 4px 0 var(--red), 0 0 24px #000;
}
#select .entry p { margin: 0 0 18px; opacity: .75; letter-spacing: 4px; text-transform: uppercase; font-size: 13px; }
#select form { display: flex; gap: 8px; }
#select input {
  font: inherit; font-size: 18px; padding: 10px 14px; border-radius: 8px; border: 1px solid #fff5; background: #0008; color: #fff;
  width: min(60vw, 240px); -webkit-user-select: text; user-select: text;
}
#select button { font: inherit; cursor: pointer; }
#select form button, #select .confirm {
  font-size: 18px; font-weight: 800; padding: 10px 22px; border-radius: 8px; border: 2px solid #fff8; background: var(--red); color: #fff;
}
#select .picker .head {
  position: fixed; left: calc(env(safe-area-inset-left) + 16px); top: calc(env(safe-area-inset-top) + 12px);
  font-size: 22px; font-weight: 900; font-style: italic; text-shadow: 0 2px 6px #000;
}
#select .picker .head .who { font-size: 15px; font-weight: 600; font-style: normal; opacity: .7; }
#select .cards {
  position: fixed; left: calc(env(safe-area-inset-left) + 16px); bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex; gap: 10px;
}
#select .card {
  --c: #888; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 120px; padding: 10px 14px;
  border-radius: 10px; color: #fff; background: rgba(10,12,20,.6); border: 2px solid #fff3; border-left: 6px solid var(--c); text-align: left;
}
#select .card b { font-size: 18px; }
#select .card small { opacity: .7; font-size: 12px; }
#select .card.on { border-color: #fff; border-left-color: var(--c); background: rgba(30,34,52,.9); transform: translateY(-4px); box-shadow: 0 6px 18px #0008; }
#select .info {
  position: fixed; right: calc(env(safe-area-inset-right) + 16px); top: 50%; transform: translateY(-50%);
  width: min(340px, 42vw); background: rgba(10,12,20,.72); border: 1px solid #fff2; border-top: 4px solid var(--accent);
  border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 24px); box-sizing: border-box; overflow: auto;
}
#select .info h2 { margin: 0; font-size: 28px; font-weight: 900; font-style: italic; }
#select .info .style { color: var(--accent); filter: brightness(1.6); font-weight: 700; font-size: 14px; margin-top: -4px; }
#select .info .desc { margin: 2px 0 4px; font-size: 13px; opacity: .85; line-height: 1.35; }
#select .stat { display: grid; grid-template-columns: 88px 1fr 18px; align-items: center; gap: 8px; font-size: 13px; }
#select .stat .bar { height: 8px; background: #fff2; border-radius: 4px; overflow: hidden; }
#select .stat .bar div { height: 100%; background: var(--accent); filter: brightness(1.5); }
#select .stat b { text-align: right; }
#select .skills { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 6px; }
#select .sk { display: flex; align-items: center; gap: 8px; font-size: 13px; background: #fff1; padding: 4px 8px; border-radius: 6px; }
#select .sk .lv { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #29b6f6; color: #000; font-weight: 800; font-size: 11px; }
#select .sk.lvl3 .lv { background: #ff8a50; }
#select .sk em { margin-left: auto; font-style: normal; color: #8fd9ff; font-weight: 700; }
#select .confirm { align-self: stretch; }
#select .hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: 8px; font-size: 12px; opacity: .6; }
@media (orientation: landscape) and (max-height: 500px) {
  #select .picker .head { font-size: 16px; top: calc(env(safe-area-inset-top) + 8px); }
  #select .cards { bottom: calc(env(safe-area-inset-bottom) + 10px); gap: 6px; }
  #select .card { min-width: 0; padding: 6px 10px; }
  #select .card b { font-size: 14px; }
  #select .card small { font-size: 10px; }
  #select .info { width: min(300px, 44vw); padding: 8px 12px; gap: 3px; }
  #select .info h2 { font-size: 20px; }
  #select .info .style { font-size: 12px; }
  #select .info .desc { display: none; }
  #select .stat { font-size: 11px; grid-template-columns: 72px 1fr 14px; }
  #select .stat .bar { height: 6px; }
  #select .sk { font-size: 11px; padding: 2px 6px; }
  #select .skills { margin: 2px 0 4px; gap: 2px; }
  #select .confirm { font-size: 15px; padding: 6px 12px; }
  #select h1 { font-size: 44px; }
  #select .entry p { margin-bottom: 10px; }
}
@media (orientation: portrait) {
  #select .info { top: auto; bottom: 100px; transform: none; left: 16px; right: 16px; width: auto; max-height: 45%; }
  #select .cards { left: 16px; right: 16px; }
  #select .card { flex: 1; min-width: 0; }
}
body.in-select #touch-ui { display: none !important; }

/* ---------- Red: estado y nombres sobre las cabezas ---------- */
#net-status {
  position: fixed; left: calc(env(safe-area-inset-left) + 12px); top: calc(env(safe-area-inset-top) + 12px);
  font-size: 12px; background: var(--panel); padding: 4px 10px; border-radius: 6px; display: none; pointer-events: none;
}
body.in-world #net-status { display: block; }
#net-status.online { color: #9be7a1; }
#net-status.connecting { color: #ffd54f; }
#net-status.offline { color: #ff8a80; }
body.touch #hud { top: calc(env(safe-area-inset-top) + 36px); }
.nametags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#world-menu, #net-status, #hud, #zone-prompt { z-index: 2; }
.nametag {
  position: absolute; left: 0; top: 0; font-size: 13px; font-weight: 700; white-space: nowrap; color: #fff;
  background: rgba(10,12,20,.55); padding: 1px 7px; border-radius: 4px; text-shadow: 0 1px 2px #000;
}
#ring-hud.online .ring-menu label { display: none; }
.zonetag {
  position: absolute; left: 0; top: 0; font-size: 13px; font-weight: 800; white-space: nowrap; color: #fff;
  padding: 2px 9px; border-radius: 6px; background: rgba(10,12,20,.6); border: 1px solid #4fc3f7; text-shadow: 0 1px 2px #000;
}
.zonetag[data-state="esperando"] { border-color: #ffd54f; color: #ffe082; }
.zonetag[data-state="cuenta"] { border-color: #ff7043; color: #ffab91; font-size: 15px; }
.zonetag[data-state="ocupada"] { border-color: #e53935; color: #ef9a9a; }
.zonetag[data-state="offline"] { border-color: #9e9e9e; color: #bdbdbd; font-weight: 600; }

/* ---------- Ajustes ---------- */
#btn-settings {
  position: fixed; z-index: 5; right: calc(env(safe-area-inset-right) + 12px); bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #fff4; background: var(--panel); color: #fff; font-size: 20px; cursor: pointer;
}
body.in-ring #btn-settings, body.touch.in-world #btn-settings { bottom: auto; top: calc(env(safe-area-inset-top) + 112px); }
body.in-select #btn-settings { top: calc(env(safe-area-inset-top) + 10px); bottom: auto; }
#settings { position: fixed; inset: 0; z-index: 20; display: none; background: rgba(0,0,0,.45); align-items: center; justify-content: center; }
#settings.show { display: flex; }
#settings .panel {
  background: #151a28; border: 1px solid #fff3; border-radius: 12px; padding: 16px 18px; width: min(340px, 88vw);
  display: flex; flex-direction: column; gap: 10px; max-height: 92vh; overflow: auto; box-sizing: border-box;
}
#settings h3 { margin: 0 0 4px; }
#settings label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
#settings label.row { flex-direction: row; justify-content: space-between; align-items: center; }
#settings input[type=range] { width: 100%; }
#settings select { font: inherit; background: #222a; color: #fff; border: 1px solid #fff5; border-radius: 4px; }
#settings .fps { font-size: 11px; opacity: .55; }
#settings .close { align-self: flex-end; background: var(--red); color: #fff; border: 0; border-radius: 6px; padding: 6px 14px; font: inherit; cursor: pointer; }
@media (orientation: landscape) and (max-height: 500px) {
  #settings .panel { gap: 6px; padding: 10px 14px; }
  #settings label { font-size: 12px; }
  body.touch.in-ring #btn-settings, body.touch.in-world #btn-settings { top: calc(env(safe-area-inset-top) + 86px); width: 34px; height: 34px; font-size: 17px; }
}
/* Destello de pantalla (K.O., definitivas) */
.screen-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 1; mix-blend-mode: screen; }

/* ---------- Definitiva ---------- */
#ring-hud .meter { height: 5px; margin-top: 2px; border-width: 1px; }
#ring-hud .meter .fill { background: linear-gradient(90deg, #ff9800, #ffd54f); }
#ring-hud .meter.full { box-shadow: 0 0 8px #ffd54f; border-color: #ffd54f; animation: meter-glow 0.8s ease-in-out infinite alternate; }
@keyframes meter-glow { from { filter: brightness(1); } to { filter: brightness(1.5); } }
#ring-hud .skill.ult::before { background: rgba(255, 193, 7, .3); }
#ring-hud .skill.ult.ready { box-shadow: inset 0 0 0 2px #ffd54f, 0 0 10px #ffd54f88; }
#ring-hud .skill.ult .cost { color: #ffd54f; }
#btn-ult {
  --fill: 0; width: 60px; height: 60px; font-size: 24px; color: #fff; opacity: .65;
  background: rgba(40,30,10,.75); background-image: conic-gradient(rgba(255,193,7,.75) calc(var(--fill) * 360deg), transparent 0);
  right: calc(var(--r) + 240px); bottom: calc(var(--b) + 30px);
}
#btn-ult.ready { opacity: 1; border-color: #ffd54f; box-shadow: 0 0 18px rgba(255,200,60,.95); animation: meter-glow .6s ease-in-out infinite alternate; }
@media (orientation: landscape) and (max-height: 500px) {
  body.touch.mode-ring #btn-ult { width: 50px; height: 50px; right: calc(var(--r) + 228px); bottom: calc(var(--b) + 14px); font-size: 20px; }
}
/* Durante la cinemática no hay controles ni HUD de habilidades */
body.cinematic #touch-ui, body.cinematic #ring-hud .skills, body.cinematic #ring-help, body.cinematic #ring-hud .ring-menu,
body.cinematic #btn-settings, body.cinematic .floater.skill-name { display: none !important; }
#cine { --ult: #ffc23d; position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#cine .bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .25s ease-out; }
#cine .bar.top { top: 0; } #cine .bar.bottom { bottom: 0; }
#cine.on .bar { height: 11vh; }
#cine .lines {
  position: absolute; inset: -20%; opacity: 0; transition: opacity .2s;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,.16) 0deg 1.2deg, transparent 1.2deg 7deg);
  -webkit-mask: radial-gradient(circle at center, transparent 32%, #000 70%); mask: radial-gradient(circle at center, transparent 32%, #000 70%);
  animation: cine-spin 6s linear infinite;
}
#cine.titled .lines { opacity: 1; }
@keyframes cine-spin { to { transform: rotate(360deg); } }
#cine .title {
  position: absolute; left: 6vw; bottom: calc(11vh + 4vh); opacity: 0; transform: translateX(-30px); transition: all .3s ease-out;
  display: flex; flex-direction: column; text-shadow: 0 3px 0 #000, 0 0 18px #000;
}
#cine.titled .title { opacity: 1; transform: none; }
#cine .title b { font-size: clamp(14px, 2.4vw, 22px); letter-spacing: 4px; text-transform: uppercase; color: #fff; }
#cine .title span { font-size: clamp(26px, 5.5vw, 56px); font-weight: 900; font-style: italic; color: var(--ult); line-height: 1.05; }
#cine.on ~ .screen-flash { z-index: 4; }
