* { box-sizing: border-box; }

:root {
  --bg: #0e1320;
  --panel: #182033;
  --line: #2e3a55;
  --text: #f2f5fb;
  --muted: #aab4c8;
  --prey: #5cc8ff;
  --hunter: #ff3b3b;
}

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;
}

.hidden { display: none !important; }

.screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}
.wide-card { max-width: 560px; }

h1 { margin: 0 0 4px; font-size: 2.2rem; letter-spacing: -0.02em; }
.accent { color: var(--hunter); }
.sub { margin: 0 0 16px; color: var(--muted); }
.code { font-size: 3.4rem; letter-spacing: 0.25em; margin-right: -0.25em; color: var(--prey); }
.error { color: var(--hunter); min-height: 1.2em; margin: 12px 0 0; }

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--prey); }
#codeInput { text-transform: uppercase; letter-spacing: 0.2em; text-align: center; width: 110px; flex: none; }

.btn {
  display: inline-block;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #0e1320;
  background: var(--prey);
  border: 1px solid var(--prey);
  border-radius: 10px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.wide { width: 100%; }

.avatar-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; }
#avatarPreview { border-radius: 50%; border: 3px solid var(--prey); }
.join-row { display: flex; gap: 8px; margin-top: 10px; }
.join-row .btn { flex: 1; }
.divider { color: var(--muted); margin: 14px 0; font-size: 0.9rem; }

#playerList {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
}
#playerList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 0.9rem;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#playerList img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
#playerList .me { outline: 1px solid var(--prey); }

/* ---- Game ---- */
#game { position: fixed; inset: 0; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: rgba(14, 19, 32, 0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  font-size: 0.95rem;
}
#timer { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#roleChip { font-weight: 700; }
#roleChip.prey { color: var(--prey); }
#roleChip.hunter { color: var(--hunter); }
#roleChip.caught { color: var(--muted); }

#feed {
  position: absolute;
  top: 62px;
  left: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}
#feed div { margin-bottom: 4px; text-shadow: 0 1px 2px #000; }

#banner {
  position: absolute;
  top: 28%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(1.6rem, 6vw, 3.2rem);
  font-weight: 800;
  text-shadow: 0 2px 12px #000;
  pointer-events: none;
}
#banner.prey { color: var(--prey); }
#banner.hunter { color: var(--hunter); }
#banner small { display: block; font-size: 0.45em; color: var(--text); font-weight: 500; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.65);
}

#stats { text-align: left; margin: 0 0 20px; }
#stats dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 12px; }
#stats dd { margin: 2px 0 0; }

.sub.small { font-size: 0.85rem; margin-top: -6px; }

/* Host's hunter-count stepper */
.hunter-ctl { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.ctl-label { color: var(--hunter); font-weight: 700; margin-right: 4px; }
.ctl-val { min-width: 2ch; font-size: 1.5rem; font-weight: 800; color: var(--hunter); font-variant-numeric: tabular-nums; }
.btn.step { width: 40px; height: 40px; padding: 0; font-size: 1.3rem; line-height: 1; }
.btn.auto { padding: 8px 12px; font-size: 0.85rem; }
.btn.auto.on { border-color: var(--prey); color: var(--prey); }
.hunter-ctl.readonly .btn { display: none; }

/* Hunter reveal during the pre-game countdown */
#reveal {
  position: absolute;
  top: calc(28% + clamp(5rem, 14vw, 8rem));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 520px);
  padding: 14px 18px;
  background: rgba(14, 19, 32, 0.9);
  border: 2px solid var(--hunter);
  border-radius: 14px;
  box-shadow: 0 0 24px rgba(255, 59, 59, 0.35);
  text-align: center;
  pointer-events: none;
}
#reveal h2 { margin: 0 0 10px; color: var(--hunter); font-size: 1rem; letter-spacing: 0.15em; text-transform: uppercase; }
#hunterList { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; }
#hunterList li { display: flex; align-items: center; gap: 8px; font-weight: 600; }
#hunterList img { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--hunter); }
#hunterList .me { color: var(--hunter); }

/* Map + time settings */
.settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; margin-bottom: 12px; }
.setting { display: flex; align-items: center; gap: 8px; }
.ctl-label.plain, .ctl-val.plain { color: var(--text); }
.ctl-val.plain { min-width: 3.2ch; font-size: 1.2rem; }
.ctl-text { font-weight: 700; }
#mapSelect {
  padding: 9px 10px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.readonly #mapSelect, .readonly .step { display: none; }
#mapPreview {
  display: block;
  width: 240px;
  max-width: 100%;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.settings:not(.readonly) #mapName { display: none; }
