:root {
  --ink: #fff;
  --panel: rgba(12, 14, 40, 0.78);
  --accent: #ffcf33;
  --accent2: #ff4f7b;
  --focus: #4fd1ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d24;
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  cursor: default;
  user-select: none;
}
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#hud { pointer-events: none; }

.screen {
  position: fixed;
  inset: 0;
  padding: 3vh 4vw;
  display: flex;
  flex-direction: column;
  gap: 2.5vh;
  background: linear-gradient(180deg, rgba(5, 8, 30, 0.55), rgba(5, 8, 30, 0.2) 40%, rgba(5, 8, 30, 0.65));
}
.hidden { display: none !important; }

.brand h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 110px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.03em;
  text-shadow: 0 6px 0 #000, 0 0 30px rgba(255, 80, 120, 0.6);
}
.brand h1 span { color: var(--accent); }
.brand p { margin: 0.2em 0 0; font-size: clamp(14px, 1.6vw, 26px); opacity: 0.9; }

.lobby-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2vw;
}
.panel {
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 2.4vh 1.6vw;
  backdrop-filter: blur(6px);
  min-height: 0;
  overflow: hidden;
}
.panel h2 { margin: 0 0 1.5vh; font-size: clamp(18px, 2vw, 34px); }
.panel h2 small { opacity: 0.6; font-weight: 600; }

.join { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5vh; }
#qr { width: min(100%, 34vh); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 10px; }
.join-url { font-size: clamp(14px, 1.7vw, 30px); font-weight: 800; color: var(--accent); word-break: break-all; text-align: center; }
.join-code { font-size: clamp(14px, 1.5vw, 26px); opacity: 0.9; }
.join-code b { font-size: 1.6em; letter-spacing: 0.15em; color: #fff; margin-left: 0.3em; }

#playerList { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vh 1vw; }
#playerList li {
  display: flex;
  align-items: center;
  gap: 0.8vw;
  padding: 1vh 0.8vw;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-size: clamp(14px, 1.5vw, 26px);
  font-weight: 700;
  min-width: 0;
}
#playerList li.empty { opacity: 0.35; font-weight: 500; }
#playerList .dot { width: 1.8em; height: 1.8em; border-radius: 50%; flex: none; border: 3px solid #fff; }
#playerList .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#playerList .tag { margin-left: auto; font-size: 0.7em; padding: 0.2em 0.5em; border-radius: 8px; background: var(--accent); color: #000; }

.settings .row {
  display: grid;
  grid-template-columns: 1fr auto minmax(6em, auto) auto;
  align-items: center;
  gap: 0.6vw;
  padding: 1vh 0.8vw;
  margin-bottom: 1vh;
  border-radius: 14px;
  border: 3px solid transparent;
  font-size: clamp(14px, 1.5vw, 26px);
}
.settings .row b { text-align: center; }
.settings .row.focus { border-color: var(--focus); background: rgba(79, 209, 255, 0.12); }
.settings button {
  font: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  border-radius: 10px;
  padding: 0.3em 0.7em;
  cursor: pointer;
}
.settings .row.start { display: block; padding: 0; }
#startBtn {
  width: 100%;
  font-size: 1.3em;
  font-weight: 900;
  padding: 0.7em;
  background: linear-gradient(90deg, var(--accent2), #ff8a3d);
  border-radius: 16px;
  box-shadow: 0 6px 0 #8a1f3a;
}
#startBtn:disabled { filter: grayscale(1); opacity: 0.5; }
.hint { opacity: 0.7; font-size: clamp(12px, 1.1vw, 20px); line-height: 1.5; }
kbd { background: #fff; color: #000; border-radius: 5px; padding: 0 0.35em; font-weight: 700; }

#results { align-items: center; justify-content: center; background: rgba(5, 8, 30, 0.72); }
#results h1 { margin: 0; font-size: clamp(36px, 5vw, 80px); font-style: italic; font-weight: 900; color: var(--accent); text-shadow: 0 5px 0 #000; }
#results table { border-collapse: separate; border-spacing: 0 0.8vh; font-size: clamp(16px, 1.8vw, 32px); min-width: 55vw; }
#results th { text-align: left; opacity: 0.6; font-weight: 600; padding: 0 1.2vw; }
#results td { background: var(--panel); padding: 1vh 1.2vw; font-weight: 700; }
#results td:first-child { border-radius: 14px 0 0 14px; font-weight: 900; }
#results td:last-child { border-radius: 0 14px 14px 0; color: var(--accent); }
#results tr.cpu td { opacity: 0.65; }
#results .sw { display: inline-block; width: 1em; height: 1em; border-radius: 50%; vertical-align: -0.12em; margin-right: 0.5em; border: 2px solid #fff; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 4vh;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 0.6em 1.2em;
  border-radius: 999px;
  font-size: clamp(14px, 1.6vw, 28px);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#soundHint {
  position: fixed;
  right: 2vw;
  top: 2vh;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.5em 1em;
  border-radius: 12px;
  font-size: clamp(12px, 1.2vw, 20px);
}
#conn {
  position: fixed;
  top: 0; left: 0; right: 0;
  text-align: center;
  background: #c62828;
  padding: 0.5em;
  font-weight: 700;
}
