:root {
  --red: #ef3e4a;
  --red-dark: #9e1b2a;
  --blue: #2f80ff;
  --blue-dark: #1748a8;
  --ink: #eef2fa;
  --muted: #9aa6bd;
  --panel: rgba(12, 17, 32, 0.72);
  --line: rgba(255, 255, 255, 0.09);
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #060912; color: var(--ink); font-family: var(--body); }
canvas#game { position: fixed; inset: 0; display: block; cursor: crosshair; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 14px;
}

/* ------------------------------------------------ scoreboard */
#scoreboard {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; pointer-events: none;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .45));
  font-family: var(--display);
}
.sb-team { display: flex; align-items: center; gap: 14px; padding: 6px 18px; min-width: 150px; }
.sb-team.red { background: linear-gradient(90deg, var(--red-dark), var(--red)); border-radius: 12px 0 0 12px; justify-content: flex-end; }
.sb-team.blue { background: linear-gradient(90deg, var(--blue), var(--blue-dark)); border-radius: 0 12px 12px 0; }
.sb-name { font-weight: 700; font-size: 18px; letter-spacing: .12em; opacity: .9; }
.sb-score { font-weight: 800; font-size: 40px; line-height: 1; min-width: 28px; text-align: center; }
.sb-mid { background: #0c1120; padding: 4px 20px; text-align: center; min-width: 120px; display: flex; flex-direction: column; justify-content: center; }
#clock { font-weight: 800; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
#phase { font-family: var(--body); font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; white-space: nowrap; }

/* ------------------------------------------------ goal banner */
#banner {
  position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%) scale(.8);
  text-align: center; pointer-events: none; opacity: 0;
  transition: opacity .25s, transform .35s cubic-bezier(.2, 1.6, .4, 1);
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.b-title { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 11vw, 140px); letter-spacing: .04em; line-height: .9; text-shadow: 0 6px 40px rgba(0, 0, 0, .55); }
.b-sub { font-weight: 600; font-size: 18px; margin-top: 8px; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }

/* ------------------------------------------------ side panel */
#side { position: fixed; top: 14px; right: 14px; width: 220px; padding: 12px; font-size: 13px; }
.side-head { display: flex; align-items: center; gap: 10px; width: 100%; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 10px; background: none; border: 0; padding: 0; text-align: left; }
.side-head .chev { transition: transform .15s; }
#side.collapsed { width: auto; padding: 8px 12px; }
#side.collapsed .side-head { margin-bottom: 0; }
#side.collapsed .side-head .chev { transform: rotate(-90deg); }
#side.collapsed .side-body { display: none; }
.side-head b { color: var(--ink); }
.team-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.tbtn { border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink); padding: 7px 0; border-radius: 9px; font-weight: 600; font-size: 12px; transition: background .15s; }
.tbtn.red:hover, .tbtn.red.on { background: var(--red); border-color: var(--red); }
.tbtn.blue:hover, .tbtn.blue.on { background: var(--blue); border-color: var(--blue); }
.tbtn.spec:hover, .tbtn.spec.on { background: rgba(255, 255, 255, .2); }
.tbtn.gk:hover, .tbtn.gk.on { background: #e3a92b; border-color: #e3a92b; color: #16120a; }
.tbtn:disabled { opacity: .35; cursor: default; background: rgba(255, 255, 255, .05); color: var(--ink); border-color: var(--line); }
#roster .grp { margin-bottom: 8px; }
#roster .grp-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
#roster .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
#roster .row { display: flex; justify-content: space-between; padding: 3px 6px; border-radius: 6px; }
#roster .row.me { background: rgba(255, 255, 255, .08); }
#roster .stat { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.ghost { width: 100%; background: none; border: 1px dashed rgba(255, 255, 255, .2); color: var(--muted); padding: 7px; border-radius: 9px; font-size: 12px; }
.ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, .4); }

/* ------------------------------------------------ chat */
#chat { position: fixed; left: 14px; bottom: 14px; width: min(380px, calc(100vw - 28px)); }
#chatlog { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; font-size: 13px; }
#chatlog .line { background: rgba(8, 12, 24, .6); padding: 4px 9px; border-radius: 8px; width: fit-content; max-width: 100%; overflow-wrap: anywhere; transition: opacity 1s; }
#chatlog .line.sys { color: var(--muted); font-style: italic; }
#chatlog .line.old { opacity: 0; }
#chat.active #chatlog .line.old { opacity: .85; }
#chatin { width: 100%; background: rgba(8, 12, 24, .55); border: 1px solid var(--line); color: var(--ink); padding: 8px 10px; border-radius: 9px; font: inherit; font-size: 13px; outline: none; opacity: .5; }
#chatin:focus { opacity: 1; border-color: rgba(255, 255, 255, .3); }

/* ------------------------------------------------ help */
#help { position: fixed; right: 14px; bottom: 14px; padding: 8px 12px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); max-width: calc(100vw - 420px); }
kbd { font-family: var(--body); font-size: 11px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; margin-right: 3px; color: var(--ink); }

/* ------------------------------------------------ join screen */
#join {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 50, 100, .55), rgba(4, 6, 14, .92) 70%);
  backdrop-filter: blur(4px);
}
.join-card { width: min(420px, 100%); background: rgba(12, 17, 32, .9); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo svg { width: 52px; height: 52px; }
.logo h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 52px; letter-spacing: .04em; line-height: 1; }
.logo h1 span { color: var(--blue); }
.tag { margin: 6px 0 22px; color: var(--muted); }
.join-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.join-card input { display: block; width: 100%; margin-top: 6px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); color: var(--ink); border-radius: 10px; padding: 12px 14px; font: inherit; font-size: 16px; outline: none; text-transform: none; letter-spacing: 0; }
.join-card input:focus { border-color: var(--blue); }
.primary { width: 100%; border: 0; border-radius: 12px; padding: 14px; font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: .12em; color: #fff; background: linear-gradient(90deg, var(--red), #c13bd6 50%, var(--blue)); box-shadow: 0 10px 30px rgba(47, 128, 255, .3); transition: transform .1s, filter .15s; }
.primary:hover { filter: brightness(1.12); }
.primary:active { transform: scale(.98); }
#joinErr { color: #ff8a93; font-size: 13px; min-height: 18px; margin-top: 10px; }
.howto { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.howto b { color: var(--ink); }

@media (max-width: 900px) {
  #side { top: 84px; }
}
@media (max-width: 760px) {
  #help { display: none; }
  #side { width: 180px; }
  .sb-team { min-width: 0; padding: 6px 10px; }
  .sb-name { display: none; }
}

.ghost.practice { margin-top: 10px; padding: 11px; font-size: 14px; font-weight: 600; }

/* ------------------------------------------------ pause menu / options */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(4, 6, 14, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.menu-card {
  width: min(360px, 100%); background: rgba(12, 17, 32, .94); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; gap: 10px;
}
.menu-card h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 800; font-size: 34px; letter-spacing: .06em; }
.menu-card .team-btns { margin: 0; }
.menu-card .ghost { padding: 10px; font-size: 14px; font-weight: 600; }
.ghost.leave:hover { color: #ff8a93; border-color: rgba(239, 62, 74, .6); }
.opt { display: grid; grid-template-columns: 1fr 44px; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.opt label { grid-column: 1 / -1; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.opt label small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.opt input[type=range] { width: 100%; accent-color: var(--blue); }
.opt output { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.join-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.join-row .ghost.practice { margin-top: 10px; }

#lockHint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  background: rgba(8, 12, 24, .82); border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; pointer-events: none;
}
/* while the mouse is captured the real cursor is hidden; the game draws its own */
body.locked, body.locked canvas#game { cursor: none; }

/* ------------------------------------------------ roster tags */
#roster .tag { font-style: normal; font-size: 9px; font-weight: 700; letter-spacing: .06em; margin-left: 6px; padding: 1px 4px; border-radius: 4px; background: rgba(255, 255, 255, .12); color: var(--muted); vertical-align: 1px; }
#roster .row.bot > span:first-child { color: var(--muted); }

/* ------------------------------------------------ connection */
#netBadge { position: fixed; top: 14px; left: 14px; display: flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; background: rgba(8, 12, 24, .6); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
#netBadge .dot { width: 8px; height: 8px; border-radius: 50%; background: #46d483; box-shadow: 0 0 8px currentColor; }
#netBadge.good .dot { background: #46d483; color: #46d483; }
#netBadge.ok .dot { background: #f2c14e; color: #f2c14e; }
#netBadge.bad .dot { background: #ff5a64; color: #ff5a64; }
#netWarn { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); background: rgba(120, 22, 32, .85); border: 1px solid rgba(255, 120, 130, .4); color: #ffe3e5; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; pointer-events: none; z-index: 4; white-space: nowrap; }

/* ------------------------------------------------ join screen rows */
.room-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.room-row input { background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); color: var(--ink); border-radius: 10px; padding: 11px 14px; font: inherit; font-size: 15px; outline: none; min-width: 0; }
.room-row input:focus { border-color: var(--blue); }
.room-row .ghost { width: auto; padding: 0 16px; font-size: 14px; font-weight: 600; }
.room-row .ghost.invited { border-style: solid; border-color: var(--blue); color: var(--ink); background: rgba(47, 128, 255, .18); }

/* ------------------------------------------------ options extras */
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; }
.opt-row select { background: rgba(255, 255, 255, .06); color: var(--ink); border: 1px solid rgba(255, 255, 255, .15); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; }
.opt-row select option { background: #11172a; }
.opt-check { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.opt-check input { width: 16px; height: 16px; accent-color: var(--blue); }

/* ------------------------------------------------ controls card */
.menu-card.wide { width: min(560px, 100%); }
.ctl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.ctl { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ctl .keys { min-width: 92px; }
.ctl-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.ctl-col { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ctl-col h3 { margin: 0 0 6px; font-family: var(--display); font-size: 18px; letter-spacing: .06em; }
.ctl-col p { margin: 6px 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.ctl-col b { color: var(--ink); }
.ctl-foot { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
@media (max-width: 560px) { .ctl-grid, .ctl-cols { grid-template-columns: 1fr; } }

/* ------------------------------------------------ end screen */
#endTitle { font-size: 44px; text-align: center; margin: 0; }
#endScore { text-align: center; font-family: var(--display); font-weight: 800; font-size: 34px; margin-top: -6px; font-variant-numeric: tabular-nums; }
#endTeams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.end-team { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.end-h { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: .06em; margin-bottom: 6px; }
.end-team table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.end-team th { color: var(--muted); font-weight: 600; text-align: right; padding: 2px 4px; }
.end-team td { text-align: right; padding: 3px 4px; }
.end-team th:first-child, .end-team td:first-child { text-align: left; }
.end-team tr.me td { color: #fff; font-weight: 700; }
#endNext { text-align: center; color: var(--muted); font-size: 13px; }
#endScreen .join-row .primary { font-size: 20px; padding: 11px; }
#endScreen .join-row .ghost { padding: 11px; font-size: 14px; font-weight: 600; }
@media (max-width: 560px) { #endTeams { grid-template-columns: 1fr; } }

/* ------------------------------------------------ reconnect */
.spinner { width: 28px; height: 28px; margin: 4px auto; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--blue); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ practice setup (pause menu) */
#practiceBox { display: flex; flex-direction: column; gap: 8px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pbox-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; }
.seg { display: flex; gap: 4px; }
.seg button, .stepper button { border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--ink); border-radius: 8px; padding: 5px 9px; font-size: 12px; font-weight: 600; }
.seg button:hover, .stepper button:hover { background: rgba(255, 255, 255, .12); }
.seg button.on { background: var(--blue); border-color: var(--blue); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 30px; padding: 4px 0; font-size: 15px; line-height: 1; }
.stepper b { min-width: 14px; text-align: center; font-variant-numeric: tabular-nums; }
