/* Self-hosted fonts (SIL Open Font License, see fonts/OFL-*.txt). Latin subset. */
@font-face { font-family: "Bungee"; font-weight: 400; font-display: swap; src: url(fonts/bungee-400.woff2) format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-display: swap; src: url(fonts/chakrapetch-600.woff2) format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 700; font-display: swap; src: url(fonts/chakrapetch-700.woff2) format("woff2"); }

:root {
  --ink: #0b0b0b;
  --panel: #141414;
  --yellow: #ffd400;
  --orange: #ff5a1f;
  --white: #f4f1ea;
  --dim: #8a857c;
  --green: #3ddc5a;
  --display: "Bungee", Impact, "Arial Black", sans-serif;
  --ui: "Chakra Petch", "Arial Narrow", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1a0805; color: var(--white);
  font-family: var(--ui); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  user-select: none;
}
canvas { display: block; width: 100vw; height: 100vh; cursor: crosshair; }

/* ---- Blocks ---------------------------------------------------------- */
.box {
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}
.box-head { background: var(--yellow); color: var(--ink); padding: 14px 20px; border-bottom: 3px solid var(--ink); }
.box-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 14px; }

.btn {
  font: inherit; text-transform: uppercase; letter-spacing: .06em; cursor: pointer;
  color: var(--ink); background: var(--yellow);
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 14px; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: #ffe24d; }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn-big { font-family: var(--display); font-size: 22px; padding: 14px 18px; }

.key {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  background: var(--white); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink); font-size: 13px; letter-spacing: 0;
}
.key.wide { min-width: 64px; }

/* ---- Join ------------------------------------------------------------ */
#join {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 32px));
}
h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 46px; line-height: .95; letter-spacing: .02em; }
.tag { margin: 0; color: var(--dim); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--yellow); }
input {
  font: inherit; font-size: 18px; text-transform: none; letter-spacing: .02em;
  padding: 10px 12px; border: 3px solid var(--ink); background: #000; color: var(--white); outline: none;
}
input:focus { border-color: var(--yellow); }

/* ---- HUD ------------------------------------------------------------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

#scores { position: absolute; left: 14px; top: 14px; min-width: 230px; font-size: 15px; }
#scores .head { background: var(--yellow); color: var(--ink); padding: 6px 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--ink); }
#scores .rows { padding: 6px 10px 8px; }
#scores .row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
#scores .sw { width: 14px; height: 14px; flex: none; border: 2px solid var(--ink); }
#scores .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }
#scores .me .nm { color: var(--yellow); }
#scores .team { margin-top: 6px; }
#scores .team .nm { text-transform: uppercase; }
#scores .sub { padding-left: 22px; }
#scores .out .nm { color: var(--dim); text-decoration: line-through; }
.pips { display: flex; gap: 3px; }
.pips i { width: 10px; height: 10px; border: 2px solid var(--dim); }
.pips i.on { background: var(--yellow); border-color: var(--yellow); }
.tagv { font-size: 11px; padding: 1px 5px; border: 2px solid var(--dim); color: var(--dim); }
.tagv.ok { background: var(--green); border-color: var(--green); color: var(--ink); }

#feed { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 14px; }
#feed div { background: var(--panel); border: 3px solid var(--ink); border-left: 6px solid var(--orange); padding: 5px 10px; box-shadow: 4px 4px 0 var(--ink); transition: opacity .4s; }
#feed b { text-transform: none; }

#banner {
  position: absolute; left: 0; right: 0; top: 20%; text-align: center;
  font-family: var(--display); font-size: clamp(32px, 7vw, 84px); line-height: 1; color: var(--yellow);
  text-shadow: 4px 0 0 var(--ink), -4px 0 0 var(--ink), 0 4px 0 var(--ink), 0 -4px 0 var(--ink), 4px 4px 0 var(--ink), 8px 8px 0 var(--ink);
  padding: 0 16px;
}
#toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: var(--orange); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 14px; font-size: 15px; white-space: nowrap;
}

/* ---- Lobby panel ----------------------------------------------------- */
#lobby { position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); width: min(980px, calc(100vw - 28px)); pointer-events: auto; }
#lobbyStatus {
  display: inline-block; margin-bottom: 10px; background: var(--ink); color: var(--yellow);
  padding: 6px 12px; font-size: 15px;
}
#lobbyStatus.go { background: var(--green); color: var(--ink); }
.lobby-row { display: flex; gap: 14px; align-items: stretch; }
.lobby-cell { padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.lobby-cell.controls { flex: 1; font-size: 13px; }
.cell-title { font-size: 12px; color: var(--yellow); }
.ctl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctl em { font-style: normal; color: var(--dim); }
.votes { display: flex; gap: 10px; }
.vote { background: #2a2a2a; color: var(--white); box-shadow: 4px 4px 0 var(--ink); }
.vote:hover { background: #3a3a3a; }
.vote b { background: var(--ink); color: var(--white); min-width: 24px; padding: 1px 6px; }
.vote.on { background: var(--yellow); color: var(--ink); }
.vote.on b { background: var(--ink); color: var(--yellow); }
.ready { min-width: 200px; background: #2a2a2a; color: var(--white); }
.ready:hover { background: #3a3a3a; }
.ready.on { background: var(--green); color: var(--ink); }

#spectate {
  position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%);
  background: var(--ink); color: var(--yellow); padding: 6px 12px; font-size: 14px; white-space: nowrap;
}
#net {
  position: absolute; left: 14px; bottom: 16px;
  background: var(--ink); color: var(--dim); padding: 4px 8px; font-size: 11px; letter-spacing: .08em;
}
#net b { color: var(--white); font-weight: 700; }
#net b.warn { color: var(--yellow); }
#net b.bad { color: var(--orange); }
#dashbar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: 200px; height: 24px; background: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  font-size: 12px; letter-spacing: .3em;
}
#dashfill { height: 100%; width: 100%; background: var(--yellow); }
#dashfill.cool { background: #5a5345; }
#dashbar span { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); }

@media (max-width: 900px) {
  #net { left: 50%; transform: translateX(-50%); bottom: 2px; padding: 1px 6px; font-size: 10px; white-space: nowrap; background: none; }
  #dashbar { bottom: 22px; }
  #lobby { bottom: 62px; }
}
@media (max-width: 640px) {
  .lobby-cell.controls { display: none; } /* keyboard help is no use on a phone */
  .vote { font-size: 12px; white-space: nowrap; padding: 6px 8px; }
}
@media (max-width: 900px) {
  #scores { min-width: 170px; font-size: 13px; }
  #feed { font-size: 12px; top: auto; bottom: 230px; }
  .lobby-row { flex-direction: column; gap: 10px; }
  .lobby-cell { padding: 8px 10px; gap: 6px; }
  .lobby-cell.controls { flex-direction: row; flex-wrap: wrap; column-gap: 14px; font-size: 12px; }
  .lobby-cell.controls .cell-title { width: 100%; }
  .key { min-width: 22px; height: 22px; font-size: 11px; }
  .btn-big { font-size: 18px; padding: 10px; }
  .votes .btn { flex: 1; }
  .ready { min-width: 0; }
}
