:root{
  --dpadScale: 1.05;
  --dpadOffsetX: 0px;
  --glow: rgba(56,189,248,0.35);

  --dpadSize: 1.0; /* 1..5 mapped */

  --bg:#0b1220;
  --card:#0f172a;
  --muted:#94a3b8;
  --text:#e5e7eb;
  --border:#1f2a44;
  --btn:#111827;
  --btn2:#1f2937;
  --primary:#2563eb;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:
    radial-gradient(900px 700px at 15% 20%, rgba(56,189,248,0.20) 0%, rgba(2,6,23,0.0) 60%),
    radial-gradient(900px 700px at 85% 30%, rgba(167,139,250,0.14) 0%, rgba(2,6,23,0.0) 60%),
    radial-gradient(1200px 800px at 20% 20%, #0b2a4a 0%, var(--bg) 55%, #050913 100%);
  color: var(--text);
}
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 18px;
  border-bottom:1px solid rgba(148,163,184,0.12);
  backdrop-filter: blur(8px);
}
.title{font-size:18px;font-weight:700;letter-spacing:.3px}
.meta{font-size:12px;color:var(--muted);text-align:right}
.wrap{
  display:flex;
  gap:14px;
  padding:14px;
  max-width: 1200px;
  margin:0 auto;
}
.left{flex: 1.2; min-width: 320px}
.right{flex: 0.8; min-width: 280px; display:flex; flex-direction:column; gap:12px}
canvas{
  width:100%;
  background: rgba(2,6,23,0.65);
  border:1px solid rgba(148,163,184,0.14);
  border-radius:16px;
  display:block;
}
.hud{margin-top:10px; display:flex; justify-content:center; align-items:flex-start; gap:12px; flex-wrap:wrap; width:100%}
.row{display:flex; gap:8px}
.btn{
  background: linear-gradient(180deg, var(--btn2), var(--btn));
  border:1px solid rgba(148,163,184,0.18);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
}
.btn:hover{filter:brightness(1.08)}
.btn.primary{
  background: linear-gradient(180deg, #3b82f6, var(--primary));
  border:1px solid rgba(59,130,246,0.6);
}
.card{
  background: rgba(15,23,42,0.75);
  border:1px solid rgba(148,163,184,0.14);
  border-radius:16px;
  padding:12px;
}
.cardTitle{
  font-weight:700;
  margin-bottom:10px;
}
.joinRow{
  display:flex;
  gap:8px;
}
input{
  flex:1;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(148,163,184,0.18);
  background: rgba(2,6,23,0.55);
  color:var(--text);
}
.small{font-size:12px;color:var(--muted);margin-top:8px}
.event{color:var(--text); font-size:13px; line-height:1.35}
.rowScore{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 8px;
  border-radius:12px;
}
.rowScore.me{outline:1px solid rgba(59,130,246,0.65)}
.rowScore.dead{opacity:0.55}
.dot{width:10px;height:10px;border-radius:999px;display:inline-block;margin-right:8px}
.nm{flex:1}
.sc{font-weight:800}
.hint{font-size:12px;color:var(--muted);line-height:1.3}

/* === Futurisztikus mobil control panel === */
.controlPanel{
  width: min(720px, 100%);
  background: rgba(15,23,42,0.62);
  border:1px solid rgba(148,163,184,0.16);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
}

.controlHead{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.controlTitle{font-weight:800; letter-spacing:.3px}
.controlSub{font-size:12px; color: var(--muted)}

.dpadOuter{
  width:100%;
  display:flex;
  justify-content:center;
  padding: 10px 0 12px 0;
  transform: translateX(var(--dpadOffsetX));
  transition: transform 120ms ease;
}

.dpadNeo{
  --btn: clamp(64px, 14vw, 92px);
  --btnW: calc(var(--btn) * var(--dpadScale));
  --gap:  calc(10px * var(--dpadScale));
  display:grid;
  grid-template-columns: var(--btnW) var(--btnW) var(--btnW);
  grid-template-rows: var(--btnW) var(--btnW) var(--btnW);
  gap: var(--gap);
  align-items:center;
  justify-items:center;
  user-select:none;
  touch-action: manipulation;
}

.neoCenter{
  grid-column:2;
  grid-row:2;
  width: calc(var(--btnW) * 0.78);
  height: calc(var(--btnW) * 0.78);
  border-radius: 20px;
  background: rgba(2,6,23,0.35);
  border: 1px solid rgba(148,163,184,0.14);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

.dpadNeo .neo{
  width: var(--btnW);
  height: var(--btnW);
  border-radius: 22px;
  border: 1px solid rgba(148,163,184,0.18);
  background:
    radial-gradient(120px 120px at 30% 30%, rgba(56,189,248,0.25) 0%, rgba(2,6,23,0.0) 55%),
    linear-gradient(180deg, rgba(30,41,59,0.95), rgba(2,6,23,0.85));
  color: var(--text);
  font-size: calc(22px * var(--dpadScale));
  font-weight: 900;
  letter-spacing: .2px;
  box-shadow:
    0 10px 20px rgba(0,0,0,0.40),
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 22px var(--glow);
  display:flex;
  align-items:center;
  justify-content:center;
}

.dpadNeo .neo span{ filter: drop-shadow(0 8px 10px rgba(0,0,0,0.55)); }

.dpadNeo .neo:active{
  transform: translateY(1px) scale(0.99);
  filter: brightness(1.08);
}

.dpadNeo .up{ grid-column:2; grid-row:1; }
.dpadNeo .left{ grid-column:1; grid-row:2; }
.dpadNeo .right{ grid-column:3; grid-row:2; }
.dpadNeo .down{ grid-column:2; grid-row:3; }

.ctrlGrid{ display:flex; flex-direction:column; gap:10px; padding-top:6px; }
.ctrlRow{ display:grid; grid-template-columns: 90px 1fr 70px; gap:10px; align-items:center; }

.ctrlLbl{ font-size:12px; color: var(--muted); font-weight:700 }
.ctrlVal{ font-size:12px; color: var(--muted); text-align:right }
.smallHint{ opacity:0.7 }

.seg{ display:flex; gap:8px; align-items:center; }
.seg button{
  flex:1;
  padding:10px 0;
  border-radius:14px;
  border:1px solid rgba(148,163,184,0.16);
  background: rgba(2,6,23,0.35);
  color: var(--text);
  font-weight:800;
}
.seg button.active{
  border-color: rgba(56,189,248,0.55);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.25), 0 0 18px rgba(56,189,248,0.22);
}

.quick{ display:flex; gap:8px; }
.quick button{
  flex:1;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,0.16);
  background: rgba(2,6,23,0.35);
  color: var(--text);
  font-weight:800;
}

input[type="range"]{ width:100%; accent-color:#38bdf8; }

@media (max-width: 980px){
  .controlPanel{ position:sticky; bottom:10px; }
  .ctrlRow{ grid-template-columns: 80px 1fr 60px; }
}


@media (max-width: 980px){
  /* dpadWrapCenter */
  .hud{justify-content:center;}
  .wrap{flex-direction:column}
  .right{min-width:auto}
}


/* ---- Mobile D-pad improvements ---- */
.dpadWrap {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
}

.dpadSize {
  font-size:12px;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
}

.dpadSize input {
  width:160px;
}

.dpad {
  --btn: 64px;
  display:grid;
  grid-template-columns: var(--btn) var(--btn) var(--btn);
  grid-template-rows: var(--btn) var(--btn) var(--btn);
  gap:10px;
  justify-items:center;
  align-items:center;
}

.dpad button {
  width:var(--btn);
  height:var(--btn);
  font-size:22px;
}

.dpad button[data-dir="U"] { grid-column:2; grid-row:1; }
.dpad button[data-dir="L"] { grid-column:1; grid-row:2; }
.dpad button[data-dir="D"] { grid-column:2; grid-row:3; }
.dpad button[data-dir="R"] { grid-column:3; grid-row:2; }

/* size steps */
.dpad.size-1 { --btn:48px; }
.dpad.size-2 { --btn:56px; }
.dpad.size-3 { --btn:64px; }
.dpad.size-4 { --btn:72px; }
.dpad.size-5 { --btn:84px; }

/* highscores + effects */
.list .rowScore{ display:grid; grid-template-columns: 18px 1fr auto; gap:10px; align-items:center; padding:6px 4px; border-radius:12px; }
.list .rowScore:nth-child(odd){ background: rgba(148,163,184,0.06); }

.effects .effRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:8px 8px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,0.12);
  background: rgba(2,6,23,0.28);
  margin-bottom:8px;
}
.effects .effLeft{ display:flex; flex-direction:column; gap:2px; }
.effects .effName{ font-weight:800; font-size:12px; }
.effects .effDesc{ font-size:12px; color: var(--muted); }
.effects .effTime{ font-weight:900; font-size:12px; }
.effects .badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.effects .swatch{
  width:10px; height:10px; border-radius:50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06), 0 0 14px rgba(56,189,248,0.20);
}

.lv{ font-size:11px; opacity:.85; margin-left:6px; }


/* Mobile scroll fix: prevent page scroll while swiping on the game area */
#game { touch-action: none; }
#gameWrap, .gameWrap { overscroll-behavior: contain; touch-action: none; }

.qtag{ font-size:10px; padding:2px 6px; border:1px solid rgba(148,163,184,0.4); border-radius:999px; margin-left:6px; opacity:.85; }
.rowScore.queued{ opacity:.75; }

/* End-of-match modal */
.modal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  z-index: 1000;
}
.modal.hidden{ display:none; }
.modalCard{
  width: min(560px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(148,163,184,0.18);
  background: linear-gradient(180deg, rgba(15,23,42,0.92), rgba(2,6,23,0.92));
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  padding: 16px;
}
.modalTitle{ font-weight: 900; font-size: 16px; margin-bottom: 8px; }
.modalText{ color: var(--text); opacity: .95; font-size: 13px; line-height: 1.35; }
.modalActions{ display:flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modalHint{ margin-top: 10px; font-size: 12px; color: var(--muted); }
