:root {
  --ink: #14101f;
  --panel: #1d1633;
  --panel2: #2a1f4a;
  --pink: #ff4fd8;
  --cyan: #7df9ff;
  --gold: #ffd166;
  --red: #ff3b5c;
  --text: #f4f0ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07040f; color: var(--text); font-family: "Rubik", system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(7, 4, 15, 0.72); backdrop-filter: blur(3px); z-index: 10; }
.card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(460px, 100%); max-height: 100%; overflow: auto; padding: 24px 26px; text-align: center; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 3px solid var(--pink); border-radius: 20px; box-shadow: 0 0 0 4px var(--ink), 0 0 40px rgba(255, 79, 216, 0.35); }
.card.wide { width: min(640px, 100%); }
.card.wider { width: min(980px, 100%); }
h1, h2 { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; margin: 0; letter-spacing: 2px; }
h2 { font-size: 48px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }
.logo { font-size: clamp(64px, 14vw, 112px); line-height: 0.85; color: var(--cyan); text-shadow: 0 0 18px rgba(125, 249, 255, 0.7), 4px 4px 0 var(--ink); }
.logo span { display: block; color: var(--pink); text-shadow: 0 0 18px rgba(255, 79, 216, 0.7), 4px 4px 0 var(--ink); }
.sub { margin: 0; opacity: 0.85; }
.keys { margin: 0; font-size: 14px; opacity: 0.75; }
.status { margin: 0; min-height: 1.2em; color: var(--cyan); }
.url { word-break: break-all; }

.go { font-family: "Bebas Neue", Impact, sans-serif; font-size: 28px; letter-spacing: 2px; color: var(--ink); background: var(--gold); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 22px 4px; box-shadow: 0 5px 0 var(--ink); cursor: pointer; }
.go:hover { filter: brightness(1.1); }
.go:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.go.alt { background: var(--cyan); }
.go:disabled { opacity: 0.45; cursor: default; }
.link { font: inherit; color: var(--cyan); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 4px 8px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.modes, .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.versus { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; padding-top: 12px; border-top: 2px dashed rgba(255, 255, 255, 0.15); }
.field { font: inherit; font-size: 18px; width: 220px; padding: 8px 14px; text-align: center; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 999px; user-select: text; -webkit-user-select: text; }
.join { display: flex; gap: 8px; }
.join .field { width: 110px; letter-spacing: 4px; }
.seg { display: flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { font-family: "Bebas Neue", Impact, sans-serif; font-size: 20px; letter-spacing: 1px; padding: 6px 14px 3px; color: var(--text); background: var(--panel); border: 0; cursor: pointer; }
.seg button.on { background: var(--pink); color: var(--ink); }

.code { font-family: "Bebas Neue", Impact, sans-serif; font-size: 72px; letter-spacing: 10px; color: var(--cyan); text-shadow: 0 0 16px rgba(125, 249, 255, 0.6); }
#qr:not(:empty) { width: 200px; height: 200px; padding: 8px; background: #fff; border-radius: 14px; }
#qr svg { width: 100%; height: 100%; display: block; }

/* ---------- fighter select ---------- */
.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; width: 100%; }
.fcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 10px 12px; color: var(--text); background: rgba(0, 0, 0, 0.25); border: 3px solid rgba(255, 255, 255, 0.15); border-radius: 14px; cursor: pointer; font: inherit; text-align: center; }
.fcard:hover, .fcard:focus-visible { border-color: var(--cyan); outline: none; }
.fcard canvas { position: static; transform: none; width: 140px; height: 160px; }
.fcard .nm { font-family: "Bebas Neue", Impact, sans-serif; font-size: 34px; line-height: 1; letter-spacing: 2px; }
.fcard .st { font-size: 13px; opacity: 0.7; }
.fcard .bl { font-size: 12px; opacity: 0.85; min-height: 3.6em; }
.fcard .mv { font-size: 12px; color: var(--gold); }
.bars { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; width: 100%; font-size: 11px; align-items: center; text-align: left; }
.bar { height: 7px; background: rgba(255, 255, 255, 0.12); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--cyan); }
.tag { position: absolute; top: 8px; padding: 1px 8px; font-family: "Bebas Neue", Impact, sans-serif; font-size: 20px; border: 2px solid var(--ink); border-radius: 8px; }
.tag.p1 { left: 8px; background: var(--gold); color: var(--ink); }
.tag.p2 { right: 8px; background: var(--pink); color: var(--ink); }
.fcard.p1 { border-color: var(--gold); }
.fcard.p2 { border-color: var(--pink); }

/* ---------- end / taunts ---------- */
.taunts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.taunts button { font: inherit; font-size: 14px; padding: 6px 10px; color: var(--text); background: var(--panel); border: 2px solid var(--cyan); border-radius: 999px; cursor: pointer; }
#tauntLayer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.tauntMsg { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-family: "Bebas Neue", Impact, sans-serif; font-size: clamp(36px, 7vw, 72px); color: var(--gold); text-shadow: 4px 4px 0 var(--ink); white-space: nowrap; animation: pop 2.8s ease-out forwards; }
.emoji { position: absolute; bottom: -80px; font-size: 48px; animation: rise 2.6s ease-out forwards; }
@keyframes pop { 0% { transform: translateX(-50%) scale(0.3); opacity: 0; } 12% { transform: translateX(-50%) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateX(-50%) scale(1); opacity: 0; } }
@keyframes rise { to { transform: translateY(-110vh) rotate(var(--spin)); opacity: 0.2; } }

#toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 30; padding: 8px 18px; background: var(--panel); border: 2px solid var(--cyan); border-radius: 999px; }

/* ---------- in-game buttons + touch ---------- */
#hudBtns { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 8px; z-index: 5; }
.mini { width: 40px; height: 40px; font: 700 15px "Rubik", sans-serif; color: var(--text); background: rgba(29, 22, 51, 0.8); border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 50%; cursor: pointer; }
#touch { position: fixed; inset: auto 0 0 0; height: 46%; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 18px 22px; pointer-events: none; z-index: 4; }
.stick { pointer-events: auto; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); border: 3px solid rgba(255, 255, 255, 0.3); display: grid; place-items: center; touch-action: none; }
.knob { width: 62px; height: 62px; border-radius: 50%; background: rgba(125, 249, 255, 0.55); border: 3px solid var(--ink); }
.btns { pointer-events: auto; display: grid; grid-template-columns: repeat(2, 78px); gap: 10px; }
.btns button { height: 64px; font-family: "Bebas Neue", Impact, sans-serif; font-size: 20px; color: var(--ink); background: rgba(255, 209, 102, 0.75); border: 3px solid var(--ink); border-radius: 50%; touch-action: none; }
.btns button.sup { background: rgba(125, 249, 255, 0.75); }
.btns button.on { filter: brightness(1.4); transform: scale(0.94); }

/* ---------- help / records ---------- */
.keys-table { border-collapse: collapse; font-size: 14px; width: 100%; }
.keys-table th, .keys-table td { padding: 5px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.keys-table th { color: var(--gold); font-weight: 700; }
.keys-table td:first-child { text-align: left; opacity: 0.85; }
.tips { text-align: left; font-size: 14px; line-height: 1.5; margin: 0; padding-left: 20px; }
#scoresBody { width: 100%; text-align: left; font-size: 15px; }
#scoresBody h3 { font-family: "Bebas Neue", Impact, sans-serif; font-weight: 400; font-size: 26px; color: var(--cyan); margin: 10px 0 4px; letter-spacing: 1px; }
#scoresBody table { width: 100%; border-collapse: collapse; }
#scoresBody td { padding: 3px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
#scoresBody td:last-child { text-align: right; }

@media (max-width: 560px) {
  h2 { font-size: 38px; }
  .go { font-size: 24px; padding: 6px 16px 3px; }
  .roster { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .fcard canvas { width: 100px; height: 115px; }
  .fcard .bl { display: none; }
}
@media (max-height: 460px) {
  .stick { width: 120px; height: 120px; }
  .knob { width: 50px; height: 50px; }
  .btns { grid-template-columns: repeat(2, 66px); gap: 8px; }
  .btns button { height: 54px; font-size: 17px; }
  #touch { padding-bottom: 12px; }
}
