:root {
  --ink: #0f1a2b;
  --panel: rgba(12, 20, 34, 0.82);
  --text: #f3f6fb;
  --muted: #9fb0c6;
  --accent: #D6F250;
  --us: #D6F250;
  --green: #0B6E4F;
  --them: #e2403a;
  --blue: #1f5fbf;
  --ink: #16160F;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0f1a2b; color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#game { position: fixed; inset: 0; }
#game canvas { display: block; }
[hidden] { display: none !important; }

/* HUD */
#scoreboard {
  position: fixed; top: 14px; left: 14px;
  background: var(--panel); border-radius: 10px; padding: 6px 4px;
  font-variant-numeric: tabular-nums; min-width: 230px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#scoreboard .row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; }
#scoreboard .row + .row { border-top: 1px solid rgba(255,255,255,.08); }
#scoreboard .srv { width: 9px; height: 9px; border-radius: 50%; background: transparent; flex: none; }
#scoreboard .srv.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#scoreboard .name { flex: 1; font-weight: 600; font-size: 14px; }
#row0 .name { color: var(--us); }
#row1 .name { color: #ff7a6e; }
#scoreboard .games { width: 22px; text-align: center; font-weight: 700; color: var(--muted); }
#scoreboard .pts {
  width: 40px; text-align: center; font-weight: 800; font-size: 17px;
  background: rgba(255,255,255,.08); border-radius: 5px; padding: 1px 0;
}
#golden { text-align: center; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); padding-top: 3px; }

#speed {
  position: fixed; left: 14px; bottom: 14px;
  background: var(--panel); border-radius: 10px; padding: 8px 14px;
  font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums;
}
#speedVal { font-size: 26px; font-weight: 800; color: var(--text); }
#speed small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
#stamina { margin-top: 6px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
#staminaFill { height: 100%; width: 100%; background: var(--accent); transition: width .2s, background .3s; }
#staminaFill.low { background: #ff7a6e; }
#charge { margin-top: 4px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; opacity: 0; transition: opacity .15s; }
#charge.on { opacity: 1; }
#chargeFill { height: 100%; width: 0; background: #ff9f43; }

#toast {
  position: fixed; top: 22%; left: 50%; transform: translate(-50%, -10px);
  font-size: clamp(22px, 4vw, 40px); font-weight: 900; text-align: center;
  text-shadow: 0 3px 14px rgba(0,0,0,.55); opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; padding: 0 16px; max-width: 100%;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { color: var(--accent); }
#toast.bad { color: #ff8a7e; }
#toast.neutral { color: #fff; }
#toast small { display: block; font-size: .45em; font-weight: 600; opacity: .9; margin-top: 4px; }

#hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel); padding: 8px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap;
}
#hint.show { opacity: 1; }

#topRight { position: fixed; top: 14px; right: 14px; z-index: 10; display: flex; align-items: center; gap: 10px; }
.hud-signet { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
#pauseBtn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; border: 0; background: var(--panel); color: var(--text); cursor: pointer;
}
.team-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: none; border: 1.5px solid var(--accent); }
.set-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; font-size: 15px; }
.toggle { min-width: 110px; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: var(--text); font-weight: 700; cursor: pointer; }
.toggle.on { background: var(--green); border-color: var(--green); }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(15,26,43,.55), rgba(15,26,43,.88));
  overflow-y: auto;
}
.card {
  width: min(520px, 100%); background: var(--panel); border-radius: 18px; padding: 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); backdrop-filter: blur(8px);
}
.card.small { width: min(380px, 100%); text-align: center; }
h1 { margin: 0; font-size: 46px; letter-spacing: -.035em; font-weight: 900; line-height: 1; display: flex; align-items: center; gap: 12px; }
h1 .logo { width: 52px; height: 52px; }
h1 .game-logo { width: min(100%, 420px); height: auto; display: block; }
h1 .word { color: #fff; }
h1 .game { color: var(--accent); font-size: .5em; letter-spacing: 0; margin-left: 2px; align-self: flex-end; margin-bottom: 4px; }
h2 { margin: 0 0 10px; font-size: 30px; }
.tag { color: var(--muted); margin: 10px 0 20px; line-height: 1.45; }
.muted { color: var(--muted); font-size: 14px; }

.opt { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.opt label { width: 60px; color: var(--muted); font-size: 14px; flex: none; }
.seg { display: flex; flex: 1; background: rgba(255,255,255,.06); border-radius: 10px; padding: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--text); padding: 9px 4px;
  border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.seg button.on { background: var(--green); }

button.big {
  display: block; width: 100%; margin: 18px 0 6px; padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--ink); font-size: 20px; font-weight: 900; cursor: pointer;
  letter-spacing: .03em;
}
button.big:hover { filter: brightness(1.05); }
button.ghost {
  display: block; width: 100%; padding: 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px;
  background: transparent; color: var(--text); font-size: 15px; cursor: pointer; margin-top: 8px;
}

.controls { margin-top: 16px; font-size: 13px; color: var(--muted); display: grid; gap: 5px; }
kbd {
  display: inline-block; background: rgba(255,255,255,.1); border-radius: 4px; padding: 0 5px;
  font-family: inherit; font-size: 12px; color: var(--text);
}
.rules { margin-top: 14px; font-size: 13px; color: var(--muted); }
.rules summary { cursor: pointer; color: var(--text); }
.rules ul { padding-left: 18px; line-height: 1.5; }

/* Dotyk */
#gestureLayer { position: fixed; inset: 0; z-index: 5; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: flex; } .controls .touch-only { display: block; } }
#joystick {
  position: fixed; left: 24px; bottom: 90px; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.25);
}
#joystick .knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(255,255,255,.5);
}
#sprintBtn {
  position: fixed; left: 170px; bottom: 100px; width: 70px; height: 70px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.18); color: #fff; font-weight: 800; font-size: 13px;
}
#sprintBtn.on { background: var(--accent); color: var(--ink); }
#shotBtns { position: fixed; right: 16px; bottom: 90px; display: grid; gap: 10px; justify-items: end; }
#shotBtns button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; font-weight: 800; font-size: 14px;
  background: rgba(255,255,255,.18); color: #fff;
}
#shotBtns button.main { width: 96px; height: 96px; background: var(--accent); color: var(--ink); font-size: 16px; }

@media (max-width: 600px) {
  #scoreboard { min-width: 190px; top: 10px; left: 10px; }
  #scoreboard .name { font-size: 12px; }
  h1 { font-size: 42px; }
  .card { padding: 20px; }
  #hint { bottom: 240px; }
}

/* Konto padelmiks */
.account { margin: -6px 0 16px; padding: 10px 12px; border-radius: 12px; background: rgba(214,242,80,.08); border: 1px solid rgba(214,242,80,.25); }
.account > div { display: flex; align-items: center; gap: 10px; }
.acc-txt { flex: 1; font-size: 13px; line-height: 1.35; color: var(--muted); }
.acc-txt b { color: var(--text); }
.acc-txt small { display: block; color: var(--accent); }
#accAvatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #222; flex: none; }
.acc-btn { flex: none; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--accent); color: var(--ink); font-weight: 800; cursor: pointer; }
.acc-link { flex: none; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; }
.seg button.locked { opacity: .45; position: relative; }
.seg button.locked::after { content: '🔒'; font-size: 10px; margin-left: 4px; }
.login { text-align: center; }
.login .oauth, #loginForm { max-width: 100%; }
.login-logo { height: 34px; margin: 4px auto 6px; display: block; }
.oauth { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); background: #fff; color: #16160F; font-weight: 700; font-size: 15px; cursor: pointer; }
.oauth[data-provider="apple"] { background: #000; color: #fff; }
.oauth .g { font-weight: 900; color: #4285F4; }
.oauth .a::before { content: ''; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.12); }
#loginForm input { display: block; width: 100%; margin-top: 8px; padding: 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: var(--text); font-size: 15px; }
#loginForm .big { margin-top: 12px; }
.err { color: #ff8a7e; font-size: 13px; margin: 8px 0 0; }
.small-link { display: inline-block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.reg { margin: 12px 0 0; }
.reg a { color: var(--accent); font-weight: 700; }
.cta-app { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; padding: 12px; border-radius: 12px; background: var(--green); color: #fff; text-decoration: none; text-align: left; }
.cta-app img { width: 38px; height: 38px; flex: none; }
.cta-app small { display: block; opacity: .85; font-size: 12px; }

/* Ekran startowy */
button.big small { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0; opacity: .7; margin-top: 2px; }
button.big.secondary { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid rgba(214,242,80,.35); display: flex; flex-direction: column; align-items: center; }
button.big.secondary img { width: 26px; height: 26px; margin-bottom: 4px; }
button.big:disabled { opacity: .45; cursor: default; }
#guestMenu .reg { text-align: center; }
#scoreboard .sets { width: 22px; text-align: center; font-weight: 800; color: var(--accent); }
.rules .controls { margin-top: 8px; }

/* Instrukcja sterowania */
.card.help { width: min(620px, 100%); }
.help h2 { text-align: center; }
.help-grid { display: grid; gap: 10px; margin: 6px 0 4px; }
.hk { display: grid; grid-template-columns: 200px 1fr; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); }
.hk p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.hk p b { display: block; color: var(--text); font-size: 15px; }
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.key { min-width: 30px; height: 30px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 7px;
  background: linear-gradient(#f4f5f0, #d9dbd2); color: var(--ink); font-weight: 800; font-size: 13px;
  box-shadow: 0 3px 0 #9a9c93, 0 4px 8px rgba(0,0,0,.35); }
.key.wide { min-width: 74px; }
.or-sm { font-size: 11px; color: var(--muted); margin: 0 2px; }
.mouse { width: 24px; height: 34px; border-radius: 12px; border: 2px solid #e8e9e2; position: relative; margin-left: 6px; }
.mouse::before { content: ''; position: absolute; top: 0; width: 50%; height: 13px; background: var(--accent); }
.mouse.l::before { left: 0; border-radius: 10px 0 0 0; }
.mouse.r::before { right: 0; border-radius: 0 10px 0 0; }
.mouse::after { content: ''; position: absolute; left: 50%; top: 0; height: 13px; width: 2px; background: #e8e9e2; transform: translateX(-50%); }
.gest { width: 54px; height: 54px; border-radius: 14px; background: rgba(214,242,80,.12); border: 2px solid rgba(214,242,80,.5); position: relative; }
.gest::before { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; border-radius: 50%; background: var(--accent); }
.gest.hold::before { box-shadow: 0 0 0 6px rgba(214,242,80,.35); }
.gest.up::after, .gest.down::after, .gest.side::after { content: ''; position: absolute; left: 50%; width: 3px; height: 18px; background: var(--accent); margin-left: -1.5px; }
.gest.up::after { top: 5px; } .gest.down::after { bottom: 5px; }
.gest.side::after { top: 50%; left: auto; right: 5px; width: 18px; height: 3px; margin-top: -1.5px; }
.gest.two::before { margin-left: -16px; } .gest.two::after { content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 2px; border-radius: 50%; background: var(--accent); opacity: .6; }
@media (max-width: 600px) { .hk { grid-template-columns: 1fr; } }
#helpTouch .hk { grid-template-columns: 58px 1fr; }
/* szeroki i niski: dwie kolumny, zwięzłe kafelki */
.card.help { width: min(860px, 100%); padding: 18px 22px; }
.help h2 { font-size: 24px; margin-bottom: 8px; }
.help-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
.hk { padding: 8px 10px; gap: 10px; grid-template-columns: 150px 1fr; }
.hk p { font-size: 12.5px; }
.hk p b { font-size: 14px; }
.key { min-width: 26px; height: 26px; font-size: 12px; padding: 0 6px; }
.key.wide { min-width: 62px; }
.mouse { width: 20px; height: 28px; }
.gest { width: 44px; height: 44px; }
.help .big { margin-top: 10px; padding: 11px; font-size: 18px; }
@media (max-width: 640px) { .help-grid { grid-template-columns: 1fr; } .hk { grid-template-columns: 1fr; } }
