/* Single dark arena look: a neon-lit ring at night. */
:root {
  --bg: #07060f;
  --panel: rgba(16, 13, 30, 0.86);
  --line: rgba(190, 170, 255, 0.18);
  --fg: #f1ecff;
  --muted: #a69cc8;
  --p1: #ff2d6f;
  --p2: #2de2ff;
  --gold: #ffd166;
  --display: "Bungee", "Impact", system-ui, sans-serif;
  --body: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--fg); font-family: var(--body); }
canvas { display: block; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
/* Timer centred on top; one panel per fighter below it, coloured by --c. */
#hud { position: fixed; inset: 0; pointer-events: none; padding: 12px 24px; display: grid; align-content: start; gap: 6px; }
#bars { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 12px 22px; }
.side { display: grid; gap: 5px; min-width: 0; position: relative; }
.name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name { font-family: var(--display); font-size: 18px; letter-spacing: 0.06em; color: var(--c); }
.ptag { font-size: 11px; font-weight: 700; letter-spacing: 0.15em; padding: 1px 6px; border: 1px solid var(--c); color: var(--c); }
.ptag.you { background: var(--c); color: #0b0816; }
.pips { display: flex; gap: 5px; margin-left: auto; }
.pips i { width: 10px; height: 10px; transform: rotate(45deg); border: 2px solid var(--gold); display: block; }
.pips i.won { background: var(--gold); box-shadow: 0 0 10px var(--gold); }

.hp { position: relative; height: 18px; background: rgba(0, 0, 0, 0.55); border: 2px solid rgba(255, 255, 255, 0.85); transform: skewX(-14deg); overflow: hidden; }
.hp > div { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; }
.trail { background: #fff6d8; }
.fill { background: linear-gradient(180deg, #ffe58a, #ffb703 55%, #e98a00); }
.fill.low { background: linear-gradient(180deg, #ff8a8a, #ff2d2d 55%, #b00000); }
.side.out { opacity: 0.45; }

.meter { position: relative; height: 7px; width: 70%; background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line); }
.meter > div { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--c); }
.meter.full > div { animation: pulse 0.5s infinite alternate; }
.meter span { position: absolute; left: calc(100% + 8px); top: -4px; font-size: 10px; letter-spacing: 0.18em; color: var(--muted); }
.meter.full span { color: var(--gold); }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.8); box-shadow: 0 0 12px currentColor; } }

#timer { justify-self: center; font-family: var(--display); font-size: 38px; line-height: 1; text-align: center; text-shadow: 0 0 18px rgba(255, 255, 255, 0.35); font-variant-numeric: tabular-nums; }
#timer.low { color: var(--p1); }

.combo { font-family: var(--display); font-size: 24px; color: var(--c); opacity: 0; transition: opacity 0.3s; text-shadow: 0 0 16px currentColor; }
.combo.show { opacity: 1; transition: none; }
.combo small { font-family: var(--body); font-size: 12px; letter-spacing: 0.3em; color: var(--fg); margin-left: 6px; }

#netTag { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 12px; letter-spacing: 0.15em; color: var(--muted); }

/* ---------- Announcer ---------- */
#announce, #subtext { position: fixed; left: 0; right: 0; z-index: 2; text-align: center; pointer-events: none; padding-inline: 16px; }
#announce { top: 36%; font-family: var(--display); font-size: clamp(48px, 10vw, 120px); line-height: 1; white-space: pre-line; opacity: 0; color: var(--fg); text-shadow: 0 0 30px var(--p1), 0 6px 0 rgba(0, 0, 0, 0.6); }
#announce.go { animation: slam 1.4s ease-out forwards; }
#announce.stay { animation: slamStay 0.5s ease-out forwards; }
#announce.ko { color: var(--gold); text-shadow: 0 0 40px var(--p1), 0 8px 0 rgba(0, 0, 0, 0.6); }
#subtext { top: calc(36% + clamp(110px, 20vw, 250px)); font-size: 18px; letter-spacing: 0.25em; color: var(--muted); }
@keyframes slam {
  0% { opacity: 0; transform: scale(2.4); }
  12% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.1); }
}
#trick { position: fixed; left: 0; right: 0; top: 21%; z-index: 2; text-align: center; pointer-events: none; opacity: 0;
  font-family: var(--display); font-size: clamp(26px, 4.5vw, 52px); line-height: 1; color: var(--gold);
  text-shadow: 0 0 20px var(--c, var(--p1)), 0 4px 0 rgba(0, 0, 0, 0.6); }
#trick small { display: block; margin-top: 6px; font-family: var(--body); font-size: 13px; letter-spacing: 0.3em; color: var(--fg); }
#trick.show { animation: trickPop 1.1s ease-out forwards; }
@keyframes trickPop { 0% { opacity: 0; transform: scale(1.8) rotate(-4deg); } 12% { opacity: 1; transform: scale(1) rotate(-4deg); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px) rotate(-4deg); } }
@keyframes slamStay { 0% { opacity: 0; transform: scale(2.4); } 100% { opacity: 1; transform: scale(1); } }

/* ---------- Menu ---------- */
.panel { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.panel h3, .controls h3, .eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lbl { min-width: 120px; color: var(--muted); font-size: 14px; }
.seg { display: flex; flex-wrap: wrap; max-width: 100%; }
.seg button { padding: 9px 14px; font-size: 13px; }
.seg button + button { border-left: none; }
.seg button.on { background: rgba(255, 209, 102, 0.18); border-color: var(--gold); color: var(--gold); }
.note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.note:empty { display: none; }
.lobby-card { width: min(480px, 100%); }
.lobby-card h2 span { color: var(--gold); letter-spacing: 0.12em; user-select: all; }
#lobbyList { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; }
#lobbyList li::marker { color: var(--muted); }
#lobbyList .c { font-family: var(--display); letter-spacing: 0.04em; }
#lobbyList .dev { color: var(--muted); font-size: 13px; margin-left: 6px; }
#lobbyList .empty { color: var(--muted); font-style: italic; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.overlay { position: fixed; inset: 0; z-index: 5; display: flex; padding: 16px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 120%, rgba(255, 45, 111, 0.25), transparent 60%), rgba(4, 3, 10, 0.45); }
.menu-card { margin: auto; width: min(760px, 100%); background: var(--panel); border: 1px solid var(--line); padding: 32px clamp(18px, 4vw, 40px); display: grid; gap: 22px; backdrop-filter: blur(6px); }
.menu-card.small { width: min(340px, 100%); text-align: center; }
.menu-card h2 { font-family: var(--display); margin: 0; font-weight: 400; letter-spacing: 0.05em; }

.logo { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 9vw, 84px); line-height: 0.9; margin: 0; color: var(--p1); text-shadow: 0 0 24px rgba(255, 45, 111, 0.6); }
.logo span { display: block; color: var(--p2); text-shadow: 0 0 24px rgba(45, 226, 255, 0.6); padding-left: 0.6em; }
.tag { margin: -8px 0 0; color: var(--muted); letter-spacing: 0.08em; }


button { font: 600 15px var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); padding: 12px 18px; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.1s; }
button:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.45); }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button.primary { background: var(--p1); border-color: var(--p1); color: #14040b; }
button.primary:hover { background: #ff5a8d; }

.join { display: flex; }
.join input { width: 130px; font: 700 16px var(--body); letter-spacing: 0.25em; text-transform: uppercase; color: var(--fg); background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line); border-right: none; padding: 11px 12px; }
.join input::placeholder { letter-spacing: 0.08em; color: var(--muted); text-transform: none; }
#netStatus { flex-basis: 100%; margin: 0; min-height: 1.3em; color: var(--muted); }
#netStatus strong { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: 26px; letter-spacing: 0.15em; user-select: all; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.controls h3 { margin-bottom: 8px; }
.controls dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 14px; }
.controls dt { color: var(--muted); }
.controls dd { margin: 0; }
kbd { font: 600 12px var(--body); display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px; margin-right: 3px; border: 1px solid rgba(255, 255, 255, 0.3); border-bottom-width: 3px; background: rgba(255, 255, 255, 0.06); }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

@media (max-width: 640px) {
  #hud { padding: 10px 12px; }
  .name { font-size: 13px; }
  #timer { font-size: 28px; }
  #bars { gap: 8px 12px; }
  .meter span { display: none; }
}

/* ---------- Phone edition: touch controls ---------- */
.phone-help { display: none; }
html.phone .phone-help { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
html.phone .phone-help h3 { margin: 0; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
html.phone .phone-help p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
html.phone .phone-help b { color: var(--fg); }
html.phone .controls, html.phone .hint, html.phone #humansRow { display: none; }
.rotate { display: none; }
@media (orientation: portrait) { html.phone .rotate { display: block; color: var(--gold) !important; } }
html.phone, html.phone body { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.phone .menu-card { padding: 22px 18px; gap: 18px; }
html.phone .overlay { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
html.phone #hud { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
/* Room for the pause button in the top-right corner. */
html.phone #bars { margin-top: 10px; }
html.phone #netTag { display: none; }

#touch { position: fixed; inset: 0; z-index: 3; touch-action: none; -webkit-user-select: none; user-select: none; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.05); pointer-events: none; opacity: 0.55; transition: opacity 0.15s; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.3); border: 2px solid rgba(255, 255, 255, 0.6); }
#tbtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 64px); gap: 10px; }
#tbtns button { width: 64px; height: 64px; padding: 0; border-radius: 50%; font-size: 12px; letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.35); touch-action: none; }
#tbtns button.atk { font: 400 24px var(--display); color: var(--gold); border-color: rgba(255, 209, 102, 0.7); }
#tbtns button.on { background: rgba(255, 255, 255, 0.35); transform: scale(0.93); }
#tbtns [data-b="punch"] { grid-column: 3; grid-row: 2; }
#tbtns [data-b="kick"] { grid-column: 2; grid-row: 2; }
#tbtns [data-b="jump"] { grid-column: 3; grid-row: 1; }
#tbtns [data-b="block"] { grid-column: 1; grid-row: 2; }
#tbtns [data-b="super"] { grid-column: 2; grid-row: 1; opacity: 0.45; }
#tbtns [data-b="super"].ready { opacity: 1; background: var(--gold); color: #1a1000; border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 209, 102, 0.8); }
#tPause { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top));
  height: 34px; padding: 0 12px; border-radius: 17px; font-size: 12px; letter-spacing: 0.1em;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.5); }
#tOver { position: absolute; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; gap: 12px; justify-content: center; }
#tOver button { min-width: 130px; }
#touch.over #tbtns, #touch.over #stick { display: none; }
@media (max-height: 420px) {
  #tbtns { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 58px); gap: 8px; }
  #tbtns button { width: 58px; height: 58px; }
  html.phone #announce { font-size: 56px; }
}
@media (max-width: 480px) {
  .seg button { padding: 9px 9px; font-size: 12px; letter-spacing: 0.03em; }
}

/* ---------- Sports and custom level ---------- */
#customRow input { flex: 1; min-width: 140px; max-width: 320px; accent-color: var(--gold); }
.level-val { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: 22px; min-width: 2.2em; }
#tbtns button.word { font: 700 13px var(--body); letter-spacing: 0.04em; }
/* Throw / pin / submission: what's happening, the count or tap meter, and the escape meter. */
#hold { position: fixed; left: 50%; top: 58%; transform: translateX(-50%); z-index: 2; width: min(340px, 80vw); pointer-events: none;
  display: grid; gap: 6px; text-align: center; padding: 10px 14px; background: rgba(6, 4, 14, 0.62); border: 1px solid var(--line); }
.hold-name { font-family: var(--display); font-size: 22px; letter-spacing: 0.06em; color: var(--gold); }
/* Tug of war: the marker swings left (escape) or right (pin / tap). */
.tug { position: relative; height: 16px; display: flex; justify-content: space-between; align-items: center; padding: 0 6px;
  font-size: 9px; letter-spacing: 0.2em; font-weight: 700;
  background: linear-gradient(90deg, rgba(45, 226, 255, 0.45), rgba(45, 226, 255, 0.12) 50%, rgba(255, 45, 111, 0.12) 50%, rgba(255, 45, 111, 0.5)); }
.tug-l { color: #bff6ff; } .tug-r { color: #ffc2d4; }
.tug-mark { position: absolute; top: -3px; bottom: -3px; width: 5px; margin-left: -2px; left: 50%; background: #fff; box-shadow: 0 0 10px #fff; }
#hold.rev { border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 209, 102, 0.75); }
.hold-tip { font-size: 12px; letter-spacing: 0.2em; color: var(--fg); text-transform: uppercase; }
.hold-tip.mash { color: var(--gold); animation: mash 0.25s infinite alternate; }
@keyframes mash { to { transform: scale(1.08); } }
html.phone #hold { top: 44%; }
.pts { font-family: var(--display); font-size: 13px; color: var(--gold); letter-spacing: 0.05em; }
