:root {
  --bg: #0b0820;
  --panel: rgba(18, 12, 48, 0.82);
  --line: rgba(160, 130, 255, 0.35);
  --text: #f2eeff;
  --muted: #a79fd0;
  --pink: #ff3d9a;
  --cyan: #4dd8ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

[hidden] { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 8, 32, 0.2), rgba(11, 8, 32, 0.8));
}

.panel {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

h1 {
  margin: 0;
  font-family: 'Russo One', sans-serif;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ff3d9a, #ffb84d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h1 span {
  display: block;
  font-size: 30px;
  letter-spacing: 9px;
  background: linear-gradient(90deg, #4dd8ff, #b388ff);
  -webkit-background-clip: text;
  background-clip: text;
}
h2 { font-family: 'Russo One', sans-serif; margin: 0 0 8px; }

.tag { color: var(--muted); margin: 14px 0 20px; line-height: 1.4; }

.field { display: block; text-align: left; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 1px; text-transform: uppercase; }

input {
  width: 100%;
  padding: 12px 14px;
  font: 600 16px 'Inter', sans-serif;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(77, 216, 255, 0.2); }

.colors { display: flex; gap: 8px; justify-content: center; margin: 4px 0 18px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
}
.swatch.on { border-color: #fff; transform: scale(1.15); box-shadow: 0 0 14px rgba(255, 255, 255, 0.5); }

.btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font: 800 16px 'Inter', sans-serif;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: linear-gradient(90deg, #ff3d9a, #ff7a59); border-color: transparent; box-shadow: 0 6px 20px rgba(255, 61, 154, 0.35); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

.join { display: flex; gap: 8px; margin: 10px 0; }
.join input { text-transform: uppercase; letter-spacing: 4px; text-align: center; }
.join .btn { width: auto; flex: none; padding: 12px 22px; }

.msg { min-height: 1.2em; color: #ffb84d; margin: 12px 0 0; font-size: 14px; }
.help { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
/* Always visible (menu and in game) so players can compare versions at a glance. */
#version {
  position: fixed;
  left: 10px; bottom: 8px;
  z-index: 20;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  opacity: 0.75;
  pointer-events: none;
}
kbd { background: rgba(255, 255, 255, 0.12); border-radius: 4px; padding: 1px 6px; font-family: inherit; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#hud .box, #hud button, #touch { pointer-events: auto; }

.box {
  position: absolute;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}
.tl { top: 12px; left: 12px; width: 170px; }
.tr { top: 12px; right: 12px; min-width: 180px; }
.lbl { font-size: 10px; letter-spacing: 2px; color: var(--muted); font-weight: 800; }
#roomCode { font-family: 'Russo One', sans-serif; font-size: 26px; letter-spacing: 4px; margin: 2px 0 8px; }
.row { display: flex; gap: 6px; margin-top: 6px; }
.row .btn { flex: 1; }
#netStatus { margin-top: 8px; font-size: 11px; color: var(--muted); line-height: 1.35; }
.map-name { margin-bottom: 4px; color: var(--cyan); }
.btn.full { margin-top: 6px; }
.map-picks {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}
.pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.pick:hover { background: rgba(255, 255, 255, 0.07); }
.pick input {
  width: 14px; height: 14px;
  margin: 0; padding: 0;
  accent-color: var(--pink);
  cursor: pointer;
}
.tag small { color: var(--cyan); font-weight: 600; }

#tip {
  position: absolute;
  bottom: 66px; left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid;
  border-radius: 10px;
}
#chips {
  position: absolute;
  bottom: 38px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.chip {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid;
  border-radius: 999px;
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.75; } to { opacity: 1; } }

#banner {
  position: absolute;
  top: 16%;
  left: 0; right: 0;
  text-align: center;
  font-family: 'Russo One', sans-serif;
  font-size: clamp(40px, 9vw, 92px);
  text-shadow: 0 0 28px rgba(255, 61, 154, 0.85), 0 4px 0 rgba(0, 0, 0, 0.4);
}
#sub {
  position: absolute;
  top: calc(16% + clamp(56px, 11vw, 112px));
  left: 16px; right: 16px;
  text-align: center;
  font-weight: 600;
  color: #e7e1ff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.score-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.score-row.out { opacity: 0.4; }
.score-row.me .nm { font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts { font-family: 'Russo One', sans-serif; }

#feed { position: absolute; left: 12px; bottom: 40px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.feed-item {
  align-self: flex-start;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  animation: feed 5s forwards;
}
.feed-item b { font-weight: 800; }
@keyframes feed { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#dashMeter {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  width: 160px; height: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 7px;
}
#dashFill { height: 100%; width: 100%; background: linear-gradient(90deg, #4dd8ff, #ff3d9a); }
#dashMeter span { position: absolute; inset: 0; font-size: 10px; font-weight: 800; letter-spacing: 2px; line-height: 14px; text-align: center; }

#touch { position: absolute; inset: auto 0 0 0; height: 0; }
#stick {
  position: absolute;
  left: 24px; bottom: 44px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--line);
  touch-action: none;
}
#knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
#touchDash {
  position: absolute;
  right: 24px; bottom: 60px;
  width: 96px; height: 96px;
  border-radius: 50%;
  font: 800 16px 'Inter', sans-serif;
  color: #fff;
  background: rgba(255, 61, 154, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.4);
  touch-action: none;
}

@media (max-width: 600px) {
  .tl { width: 140px; padding: 8px; }
  #roomCode { font-size: 20px; }
  .tr { min-width: 0; width: 150px; padding: 8px; }
  .score-row { font-size: 12px; }
  #feed { bottom: 190px; font-size: 12px; }
  #dashMeter { bottom: 8px; }
  #chips { bottom: 30px; }
  #tip { bottom: 180px; font-size: 12px; }
}
