:root {
  --bg: #0b0d12;
  --panel: #151922;
  --line: #262c38;
  --text: #e9edf5;
  --muted: #8a93a6;
  --accent: #ffd23f;
  --self: #3fd27a;
  --others: #ff4b4b;
  --all: #3fa9ff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
  display: flex;
  padding: 16px;
}

/* margin: auto centres the screen but lets a tall lobby scroll instead of being clipped. */
.screen {
  margin: auto;
}

.hidden {
  display: none !important;
}

.card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 30px;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
button {
  font: inherit;
  color: inherit;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f1219;
  padding: 10px 14px;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  cursor: pointer;
  background: #1f2532;
  font-weight: 600;
}

button:hover:not(:disabled) {
  background: #283043;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: #111;
  border-color: transparent;
}

button.primary:hover:not(:disabled) {
  background: #ffe066;
}

button.on {
  background: var(--self);
  color: #111;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  word-break: break-all;
  text-align: left;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-weight: 700;
}

.error {
  color: var(--others);
  margin: 0;
  min-height: 1.2em;
  font-size: 14px;
}

.colors {
  display: flex;
  gap: 10px;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  padding: 0;
}

.swatch.selected {
  border-color: var(--text);
}

.swatch.taken {
  opacity: 0.2;
  cursor: not-allowed;
}

.code {
  color: var(--accent);
  letter-spacing: 0.15em;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.players li,
.scores li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #0f1219;
  border-radius: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}

.players .name,
.scores .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tag.ready {
  color: var(--self);
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button {
  flex: 1;
}

.result {
  margin: 0;
  font-weight: 700;
  color: var(--accent);
}

.result:empty {
  display: none;
}

.help {
  font-size: 14px;
  color: var(--muted);
}

.help summary {
  cursor: pointer;
}

.help ul {
  padding-left: 18px;
  margin: 8px 0 0;
}

kbd {
  background: #0f1219;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 12px;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 13px;
  color: var(--muted);
}

.segmented {
  display: flex;
  background: #0f1219;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.segmented button {
  flex: 1;
  padding: 7px 4px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--muted);
}

.segmented button.selected {
  background: var(--accent);
  color: #111;
}

/* Non-hosts see the choice but can't change it. */
.segmented button:disabled {
  cursor: default;
  opacity: 1;
}

.segmented button:disabled:not(.selected) {
  opacity: 0.5;
}

.pu-img {
  display: inline-block;
  vertical-align: middle;
}

/* Power-up badge: dark disc with a glowing ring in green (good), red (bad) or blue (all). */
.badge {
  --ring: var(--self);
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: radial-gradient(circle at 35% 30%, #222a38, #0b0e15 70%);
  border: 2px solid var(--ring);
  box-shadow: 0 0 10px color-mix(in srgb, var(--ring) 55%, transparent);
}

.badge.bad,
.boosts li.bad .badge {
  --ring: var(--others);
}

.badge.all {
  --ring: var(--all);
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin-top: 12px;
}

.legend-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend h3 {
  margin: 0;
  font-size: 14px;
}

.legend h3.good {
  color: var(--self);
}

.legend h3.bad {
  color: var(--others);
}

.legend h3.all {
  color: var(--all);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

@media (max-width: 480px) {
  .legend {
    grid-template-columns: 1fr;
  }
}

/* Game */
#game {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
  justify-content: center;
}

.board-wrap {
  position: relative;
  touch-action: none;
}

#board {
  display: block;
  background: #000;
  border: 2px solid #3a4152;
  border-radius: 4px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 34px;
  font-weight: 800;
  pointer-events: none;
  text-shadow: 0 2px 12px #000;
}

.scores {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scores ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scores li.dead .name {
  opacity: 0.4;
  text-decoration: line-through;
}

.scores .score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scores .fx {
  font-size: 13px;
}

.target {
  color: var(--muted);
}

.target b {
  color: var(--text);
}

.boosts {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.boosts-title {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.boosts ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.boosts li {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #0f1219;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--boost) 55%, transparent);
}

.boosts li.good {
  --boost: var(--self);
  background: color-mix(in srgb, var(--self) 12%, #0f1219);
}

.boosts li.bad {
  --boost: var(--others);
  background: color-mix(in srgb, var(--others) 12%, #0f1219);
}

.boosts li.good .label {
  color: var(--self);
}

.boosts li.bad .label {
  color: var(--others);
}


.boosts .label {
  flex: 1;
  font-weight: 600;
}

.boosts .left {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13px;
}

/* Remaining time, shrinking from full width to nothing. */
.boosts .bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  background: var(--boost);
}

@media (max-width: 760px) {
  body {
    padding: 8px;
  }

  #game {
    margin-top: 0;
  }

  #game {
    flex-direction: column;
    align-items: center;
  }

  .scores {
    width: 100%;
  }

  .scores ol {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .scores li {
    flex: 1 1 140px;
  }
}
