:root {
  --bg: #1d2230;
  --panel: rgba(18, 22, 34, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --muted: #9aa3b8;
  --accent: #3ddc84;
  --danger: #ff5a6e;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

#app {
  position: fixed;
  inset: 0;
}

#app > canvas {
  display: block;
}

.labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1; /* own stacking context for the per-label z-index */
}

.slime-label {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(10, 12, 20, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.slime-label.own {
  background: rgba(61, 220, 132, 0.7);
  color: #08140d;
  text-shadow: none;
}

/* ---------------------------------------------------------------- screens */

.screen-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
  padding: 16px;
  text-align: center;
}

.login {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login[hidden] {
  display: none;
}

.login h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.login h1 span {
  color: var(--accent);
}

.login .tagline {
  margin: 0 0 8px;
  color: var(--muted);
}

.login label {
  font-size: 12px;
  color: var(--muted);
}

.login input {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.login input:focus {
  border-color: var(--accent);
}

.login button {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #08140d;
  cursor: pointer;
}

.login button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.error {
  color: var(--danger);
}

/* ---------------------------------------------------------------- HUD */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.panel {
  position: absolute;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}

.panel .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.mass {
  left: 16px;
  bottom: 16px;
  width: 240px;
}

.mass-bar {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.mass-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2fbf6f, var(--accent));
  transition: width 0.12s linear;
}

.mass-fill.low {
  background: linear-gradient(90deg, #d0384a, var(--danger));
}

.mass-text {
  position: absolute;
  right: 12px;
  top: 8px;
  font-weight: 700;
}

.round {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 170px;
}

.round .phase {
  font-size: 12px;
  color: var(--muted);
}

.round .timer {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.board {
  top: 16px;
  right: 16px;
  width: 220px;
}

.board-list,
.player-list,
.places {
  list-style: none;
  margin: 0;
  padding: 0;
}

.board-list li,
.player-list li,
.places li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.board-list li.me .name,
.places li.me .name,
.player-list li.me .name {
  color: var(--accent);
  font-weight: 700;
}

.swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pct {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.players {
  top: 16px;
  left: 16px;
  width: 220px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  pointer-events: auto;
}

.player-list li.offline {
  opacity: 0.45;
}

.player-list .actions {
  display: flex;
  gap: 4px;
}

.ping {
  position: absolute;
  right: 16px;
  bottom: 44px;
  font-size: 12px;
  color: var(--muted);
}

.help {
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}

.help,
.ping {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel);
}

.notice,
.status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  text-align: center;
  max-width: calc(100vw - 32px);
}

.notice {
  top: 92px;
  font-weight: 600;
}

.status {
  bottom: 80px;
  color: #ffd27a;
}

.notice[hidden],
.status[hidden],
.results[hidden],
.debug[hidden] {
  display: none;
}

.results {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 32px));
  padding: 20px 24px;
  border-radius: 18px;
  background: rgba(18, 22, 34, 0.9);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.results h2 {
  margin: 0 0 4px;
}

.results .winner {
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 12px;
}

.places {
  counter-reset: place;
}

.places li::before {
  counter-increment: place;
  content: counter(place) ".";
  width: 22px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.results .next {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.debug {
  position: absolute;
  left: 16px;
  bottom: 96px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #b8f5c9;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------- reports */

.report-btn {
  font: inherit;
  font-size: 11px;
  padding: 1px 7px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
}

.player-list li:hover .report-btn,
.report-btn:focus-visible {
  opacity: 1;
}

.report-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.report-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: min(380px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px;
  border-radius: 18px;
  background: rgba(18, 22, 34, 0.92);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.report-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.report-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report-cats label {
  cursor: pointer;
}

.report-cats input {
  position: absolute;
  opacity: 0;
}

.report-cats span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
}

.report-cats input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #08140d;
  font-weight: 700;
}

.report-cats input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.report-dialog textarea,
.report-dialog button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.report-dialog textarea {
  padding: 8px 10px;
  resize: vertical;
  outline: none;
}

.report-dialog textarea:focus {
  border-color: var(--accent);
}

.report-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.report-dialog button {
  padding: 8px 14px;
  cursor: pointer;
}

.report-dialog button.primary {
  border: 0;
  background: var(--accent);
  color: #08140d;
  font-weight: 700;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 130px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-weight: 600;
  pointer-events: none;
}

@media (max-width: 720px) {
  .players {
    display: none;
  }
  .board {
    width: 160px;
  }
  .help {
    display: none;
  }
}
