:root {
  --ink: #1a1530;
  --panel: #fff8ea;
  --grass: #2f9e44;
  --gold: #ffd166;
  --pink: #ff5c8a;
  --sky: #3aa0ff;
  --text: #1a1530;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f2a17; color: var(--text); font-family: "Nunito", 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(15, 42, 23, 0.55); z-index: 10; }
.card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(460px, 100%); max-height: 100%; overflow: auto; padding: 22px 26px; text-align: center; background: var(--panel); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink); }
.card.wide { width: min(640px, 100%); }
.card.wider { width: min(980px, 100%); }
h1, h2 { font-family: "Luckiest Guy", Impact, sans-serif; font-weight: 400; margin: 0; letter-spacing: 1px; }
h2 { font-size: 46px; color: var(--gold); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }
.logo { font-size: clamp(60px, 13vw, 104px); line-height: 0.85; color: #ffffff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; transform: rotate(-3deg); }
.logo span { display: block; color: var(--gold); }
.sub { margin: 0; font-size: 17px; }
.keys { margin: 0; font-size: 14px; opacity: 0.75; }
.status { margin: 0; min-height: 1.2em; color: #1f7a35; font-weight: 800; }
.url { word-break: break-all; }
.final { margin: 0; font-family: "Luckiest Guy", Impact, sans-serif; font-size: 44px; }

.go { font-family: "Luckiest Guy", Impact, sans-serif; font-size: 26px; letter-spacing: 1px; color: #fff; background: var(--pink); border: 4px solid var(--ink); border-radius: 16px; padding: 8px 22px 4px; box-shadow: 0 5px 0 var(--ink); cursor: pointer; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.go:hover { filter: brightness(1.08); }
.go:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.go.alt { background: var(--sky); }
.go:disabled { opacity: 0.5; cursor: default; }
.link { font: inherit; color: #1f5fbf; 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, .opts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.versus { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; padding-top: 12px; border-top: 3px dashed rgba(26, 21, 48, 0.2); }
.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: "Luckiest Guy", Impact, sans-serif; font-size: 17px; padding: 6px 12px 3px; color: var(--ink); background: #fff; border: 0; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--gold); }
.check { display: flex; align-items: center; gap: 6px; font-weight: 800; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--pink); }

.code { font-family: "Luckiest Guy", Impact, sans-serif; font-size: 72px; letter-spacing: 10px; color: var(--sky); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }
#qr:not(:empty) { width: 200px; height: 200px; padding: 8px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; }
#qr svg { width: 100%; height: 100%; display: block; }

/* ---------- player select ---------- */
.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; width: 100%; }
.pcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 8px 10px; color: var(--ink); background: #fff; border: 4px solid var(--ink); border-radius: 16px; cursor: pointer; font: inherit; box-shadow: 0 4px 0 var(--ink); }
.pcard:hover, .pcard:focus-visible { background: #fff2c9; outline: none; }
.pcard canvas { position: static; transform: none; width: 120px; height: 130px; }
.pcard .nm { font-family: "Luckiest Guy", Impact, sans-serif; font-size: 28px; line-height: 1; }
.pcard .mv { font-size: 13px; font-weight: 800; color: #c2410c; }
.pcard .bl { font-size: 12px; opacity: 0.8; min-height: 3em; }
.bars { display: grid; grid-template-columns: auto 1fr; gap: 2px 6px; width: 100%; font-size: 11px; align-items: center; text-align: left; }
.bar { height: 7px; background: rgba(26, 21, 48, 0.12); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--grass); }
.tag { position: absolute; top: 6px; padding: 1px 8px; font-family: "Luckiest Guy", Impact, sans-serif; font-size: 17px; border: 2px solid var(--ink); border-radius: 8px; }
.tag.p1 { left: 6px; background: var(--gold); }
.tag.p2 { right: 6px; background: var(--pink); color: #fff; }
.pcard.p1 { background: #fff2c9; }
.pcard.p2 { background: #ffe0ea; }

/* ---------- 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(--ink); background: #fff; border: 3px solid var(--ink); 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: "Luckiest Guy", Impact, sans-serif; font-size: clamp(34px, 7vw, 68px); color: var(--gold); -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; 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; } }

/* ---------- 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: 800 15px "Nunito", sans-serif; color: var(--ink); background: rgba(255, 248, 234, 0.85); border: 3px solid var(--ink); border-radius: 50%; cursor: pointer; }
#touch { position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 16px 18px; pointer-events: none; z-index: 4; }
.pad { pointer-events: auto; display: flex; gap: 10px; align-items: flex-end; }
.pad button { width: 76px; height: 76px; font-family: "Luckiest Guy", Impact, sans-serif; font-size: 18px; color: var(--ink); background: rgba(255, 248, 234, 0.7); border: 4px solid var(--ink); border-radius: 50%; touch-action: none; }
.pad.left button { font-size: 30px; }
.pad .kick { background: rgba(255, 92, 138, 0.8); color: #fff; }
.pad .jump { background: rgba(58, 160, 255, 0.8); color: #fff; margin-bottom: 40px; }
.pad .pw { background: rgba(255, 209, 102, 0.85); width: 64px; height: 64px; font-size: 14px; }
.pad button.on { filter: brightness(1.3); transform: scale(0.93); }

/* ---------- help / records ---------- */
.keys-table { border-collapse: collapse; font-size: 14px; width: 100%; }
.keys-table th, .keys-table td { padding: 5px 8px; border-bottom: 2px solid rgba(26, 21, 48, 0.1); }
.keys-table td:first-child { text-align: left; font-weight: 800; }
.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: "Luckiest Guy", Impact, sans-serif; font-weight: 400; font-size: 24px; margin: 10px 0 4px; color: #1f5fbf; }
#scoresBody table { width: 100%; border-collapse: collapse; }
#scoresBody td { padding: 3px 6px; border-bottom: 2px solid rgba(26, 21, 48, 0.08); }
#scoresBody td:last-child { text-align: right; }

@media (max-width: 560px) {
  h2 { font-size: 36px; }
  .go { font-size: 22px; padding: 6px 16px 3px; }
  .roster { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .pcard canvas { width: 80px; height: 90px; }
  .pcard .bl, .pcard .bars { display: none; }
}
@media (max-height: 460px) {
  .pad button { width: 62px; height: 62px; font-size: 15px; }
  .pad .pw { width: 54px; height: 54px; font-size: 12px; }
  .pad .jump { margin-bottom: 26px; }
  #touch { padding-bottom: 10px; }
}
