:root {
  --bg: #14161c;
  --panel: #1e2129;
  --panel-border: #2c303b;
  --text: #f1f2f6;
  --muted: #9aa0ae;
  --accent: #4dd2ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.screen { position: fixed; inset: 0; }

/* ---- character select ---- */

#setup {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 28px 28px 20px;
  width: min(440px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card h1 { margin: 0 0 6px; font-size: 32px; letter-spacing: 0.5px; }
.card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }

input#name {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
input#name:focus { border-color: var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.swatch {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--bg);
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

.preview-row { display: flex; align-items: center; gap: 20px; margin: 4px 0 12px; }
#preview { width: 96px; height: 96px; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  padding: 8px 14px;
}
button.primary {
  flex: 1;
  background: var(--accent);
  color: #08202b;
  font-weight: 700;
  font-size: 18px;
  padding: 14px;
  border: none;
}
button.primary:hover { filter: brightness(1.1); }

.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---- game ---- */

#game { background: #0e1014; }
#canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

#hud { position: absolute; inset: 0; pointer-events: none; }

#scoreboard {
  position: absolute; top: 12px; right: 12px;
  background: rgba(20, 22, 28, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 160px;
  font-size: 14px;
}
#scoreboard .row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
#scoreboard .row.me { font-weight: 700; }
#scoreboard .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#scoreboard .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scoreboard .score { font-variant-numeric: tabular-nums; }

#feed {
  position: absolute; top: 12px; left: 12px;
  font-size: 13px; color: var(--muted);
  display: flex; flex-direction: column; gap: 4px;
}
#feed div { background: rgba(20, 22, 28, 0.7); padding: 4px 8px; border-radius: 6px; animation: fade 4s forwards; }
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

#change {
  position: absolute; bottom: 12px; right: 12px;
  pointer-events: auto;
  font-size: 12px;
  opacity: 0.7;
}
#change:hover { opacity: 1; }

#status {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 22, 28, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 18px 28px;
  font-size: 20px;
  text-align: center;
  pointer-events: none;
}
#status small { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
