/* ============================================================================
   King of the Hill — arcade voxel look.

   Everything is set in pixel type. It is wide and it is loud, so sizes run
   small and line-height runs generous to keep prose readable. Panels are flat
   slabs with a hard offset shadow, like stickers on a cabinet. Three accents
   carry the whole thing: mint for you and for building, magenta for danger and
   destruction, gold for the crown.
   ========================================================================== */

:root {
  --night: #0c0a1c;
  --panel: #130f28;
  --edge: #322a55;
  --ink: #f4f1ff;
  --dim: #9b93c4;

  --mint: #4ef2a7;
  --magenta: #ff4d9d;
  --gold: #ffd75e;
  --sky: #7fd4ff;

  --pixel: "Press Start 2P", ui-monospace, monospace;
  --body: var(--pixel);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  font: 12px/1.95 var(--body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#view { display: block; width: 100vw; height: 100vh; }

.pixel {
  font-family: var(--pixel);
  font-weight: 400;
  line-height: 1.35;
}

/* The logo carries the identity; it floats a little so the screen breathes. */
.logo {
  width: min(420px, 82%);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
}
.logo.hero {
  width: min(500px, 92%);
  animation: float 4.5s ease-in-out infinite;
}
.panel .logo { justify-self: center; margin-bottom: -2px; }

@keyframes float {
  0%, 100% { transform: translateY(-6px); }
  50% { transform: translateY(6px); }
}

/* Chunky arcade buttons: they sit on a lip that compresses when pressed. */
button {
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 15px 18px;
  color: #08160f;
  background: var(--mint);
  box-shadow: 0 5px 0 #1f9c66, 0 8px 18px rgba(0, 0, 0, 0.45);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.12s;
}
button:hover { filter: brightness(1.07); }
button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #1f9c66, 0 3px 10px rgba(0, 0, 0, 0.4);
}
button:disabled {
  opacity: 0.5;
  cursor: progress;
  transform: none;
  box-shadow: 0 5px 0 #1f9c66;
}

/* ---------- loading / intro ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: radial-gradient(120% 100% at 50% -10%, #3b2a6b 0%, #1a1238 45%, var(--night) 100%);
  transition: opacity 0.45s ease, visibility 0.45s;
}
#loader::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 3px);
}
#loader.done { opacity: 0; visibility: hidden; }

.loader-inner {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  display: grid;
  justify-items: center;
  gap: 22px;
  text-align: center;
}

.shout {
  margin: 0;
  font-size: clamp(11px, 2.2vw, 15px);
  line-height: 1.9;
  color: var(--gold);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
}

.blurb {
  margin: -8px 0 0;
  max-width: 40ch;
  color: var(--dim);
  font-size: 11px;
  line-height: 2;
}

.loader-bar {
  width: min(320px, 90%);
  height: 14px;
  padding: 3px;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 4%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint), var(--sky));
  transition: width 0.35s ease;
}

.loader-note {
  margin: -12px 0 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--dim);
}

/* ---------- panels: menu and results ---------- */

#gate, #results {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: radial-gradient(120% 100% at 50% -10%,
    rgba(59, 42, 107, 0.92) 0%, rgba(20, 15, 48, 0.95) 45%, rgba(8, 6, 20, 0.97) 100%);
}
#gate { z-index: 40; }
#results { z-index: 45; }
#gate[hidden], #results[hidden] { display: none; }

.panel {
  width: min(580px, 100%);
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 18px;
  padding: 30px 32px 28px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35), 0 30px 70px rgba(0, 0, 0, 0.55);
  display: grid;
  gap: 16px;
}

.sub {
  margin: 0;
  color: var(--dim);
  text-align: center;
  font-size: 10px;
  line-height: 2.1;
}

#join { display: grid; gap: 10px; }

label {
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

input {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 13px 14px;
  border-radius: 10px;
  border: 2px solid var(--edge);
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
}
input:focus { outline: 3px solid var(--mint); outline-offset: 1px; }

#play { width: 100%; font-size: 13px; }

.status {
  min-height: 20px;
  margin: 0;
  color: var(--magenta);
  font-size: 10px;
  line-height: 1.9;
  text-align: center;
}

.rules {
  margin: 4px 0 0;
  padding: 18px 0 0 20px;
  border-top: 2px solid var(--edge);
  color: var(--dim);
  font-size: 10px;
  line-height: 2.1;
}
.rules li { margin: 12px 0; }
.rules b { color: var(--ink); font-weight: 700; }

/* pause mode swaps the join form for Resume */
.paused-only { display: none; }
#gate.paused .paused-only { display: block; }
#gate.paused .joining,
#gate.paused #join { display: none; }
#resume { display: none; }
#gate.paused #resume { display: block; width: 100%; font-size: 13px; }

/* sound switches */
.options { display: flex; gap: 20px; flex-wrap: wrap; }

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 10px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}
.switch input {
  appearance: none;
  width: 38px;
  height: 21px;
  flex: none;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid var(--edge);
  position: relative;
  transition: background 0.16s, border-color 0.16s;
  cursor: pointer;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform 0.16s, background 0.16s;
}
.switch input:checked { background: rgba(78, 242, 167, 0.25); border-color: var(--mint); }
.switch input:checked::after { transform: translateX(17px); background: var(--mint); }
.switch input:checked + span { color: var(--ink); }
.switch input:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }

/* ---------- results ---------- */

#results h2.pixel {
  margin: 0;
  text-align: center;
  font-size: 16px;
  color: var(--gold);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

#results-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
#results-list li {
  display: grid;
  grid-template-columns: 30px 12px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--edge);
  font-size: 11px;
}
#results-list .rank { font-family: var(--pixel); font-size: 11px; color: var(--dim); }
#results-list .dot { width: 12px; height: 12px; border-radius: 3px; }
#results-list .pts { font-family: var(--pixel); font-size: 13px; }
#results-list li.first { border-color: var(--gold); background: rgba(255, 215, 94, 0.12); }
#results-list li.first .rank,
#results-list li.first .pts { color: var(--gold); }
#results-list li.me .name { color: #fff; }

#again { width: 100%; font-size: 13px; }

.ready-note {
  margin: 0;
  text-align: center;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--dim);
}

/* ---------- hud ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud[hidden] { display: none; }

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55);
  transition: background 0.12s, transform 0.12s;
}
#crosshair.hot { transform: scale(1.4); }
#crosshair.build { background: var(--mint); transform: scale(1.8) rotate(45deg); }
#crosshair.destroy { background: var(--magenta); transform: scale(1.8) rotate(45deg); }
#crosshair.enemy { background: var(--gold); transform: scale(2) rotate(45deg); }

/* how much life the targeted block has left */
#damage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  margin: 28px 0 0 -70px;
  text-align: center;
}
#damage[hidden] { display: none; }
#damage .bar {
  height: 7px;
  padding: 1px;
  border: 2px solid rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
}
#damage .bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--magenta);
  transition: width 0.1s ease-out;
}
#damage .count {
  margin-top: 6px;
  font-size: 9px;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.8);
}

/* round banner: waiting / 3 / 2 / 1 / GO! */
#banner {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}
#banner[hidden] { display: none; }
#banner span {
  display: inline-block;
  font-family: var(--pixel);
  font-size: 26px;
  color: var(--ink);
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}
#banner.waiting span {
  font-size: 15px;
  color: var(--sky);
  animation: breathe 1.4s ease-in-out infinite;
}
#banner.count span {
  font-size: clamp(48px, 9vw, 78px);
  color: var(--gold);
  animation: slam 0.9s ease-out;
}
#banner.go span {
  font-size: clamp(40px, 7vw, 60px);
  color: var(--mint);
  animation: slam 0.6s ease-out;
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(0.97); }
  50% { opacity: 1; transform: scale(1.04); }
}
@keyframes slam {
  0% { transform: scale(2.4); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* match clock */
#timer {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: rgba(10, 8, 24, 0.82);
}
#timer[hidden] { display: none; }
#timer .num { font-family: var(--pixel); font-size: 22px; color: var(--ink); }
#timer .unit { font-family: var(--pixel); font-size: 8px; color: var(--dim); }
#timer.urgent { border-color: var(--magenta); }
#timer.urgent .num { color: var(--magenta); animation: breathe 0.6s ease-in-out infinite; }

/* toolbar */
#toolbar {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.tool {
  display: grid;
  grid-template-areas: "key icon" "label label" "time time";
  gap: 2px 10px;
  align-items: center;
  min-width: 124px;
  padding: 10px 13px 11px;
  border-radius: 12px;
  background: rgba(10, 8, 24, 0.8);
  border: 2px solid var(--edge);
  color: var(--dim);
  text-align: left;
  transition: border-color 0.12s, color 0.12s, transform 0.1s, box-shadow 0.12s;
}
.tool .key {
  grid-area: key;
  font-family: var(--pixel);
  font-size: 8px;
  padding: 3px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}
.tool .icon { grid-area: icon; font-size: 18px; justify-self: end; }
.tool .label { grid-area: label; font-size: 10px; }
.tool .time { grid-area: time; font-size: 8px; opacity: 0.7; margin-top: 3px; }

.tool.ready { color: var(--ink); border-color: #4a3f7d; }
.tool.active {
  color: var(--ink);
  border-color: var(--mint);
  transform: translateY(-4px);
  box-shadow: 0 4px 0 rgba(78, 242, 167, 0.3);
}
[data-tool="destroy"].active {
  border-color: var(--magenta);
  box-shadow: 0 4px 0 rgba(255, 77, 157, 0.3);
}
.tool.cooling { opacity: 0.4; }

/* directional flash when someone shoves you */
#shoved {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 32%, rgba(255, 77, 157, 0.6) 100%);
}
#shoved.hit { animation: shoved 0.45s ease-out; }
@keyframes shoved {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#notice {
  position: absolute;
  left: 50%;
  bottom: 122px;
  transform: translateX(-50%);
  padding: 8px 15px;
  border-radius: 9px;
  border: 2px solid var(--edge);
  background: rgba(10, 8, 24, 0.88);
  font-size: 10px;
  line-height: 1.8;
  opacity: 0;
  transition: opacity 0.22s;
  white-space: nowrap;
}
#notice.show { opacity: 1; }

/* scoreboard, centred at the top so it never covers the crosshair */
#scoreboard {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 270px;
  padding: 11px 14px 10px;
  background: rgba(10, 8, 24, 0.82);
  border: 2px solid var(--edge);
  border-radius: 14px;
}
#scoreboard h2 {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 8px;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 400;
}
#scoreboard h2 #board-title { color: var(--gold); }
#scoreboard h2 #count { color: var(--dim); }

/* between rounds: the all-time table */
.row.high { grid-template-columns: 18px 1fr 34px; }
.row.high .rank { font-size: 9px; color: var(--dim); }
.row.high.best .rank,
.row.high.best .name,
.row.high.best .points { color: var(--gold); }
.row.empty { display: block; padding: 6px 0; color: var(--dim); font-size: 9px; }
#scoreboard ol { margin: 0; padding: 0; list-style: none; font-size: 10px; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 10px 1fr auto 34px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.row .dot { width: 10px; height: 10px; border-radius: 3px; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .lvl { font-size: 8px; color: var(--dim); }
.row .points { text-align: right; font-size: 11px; }
.row.me .name { color: #fff; }

/* whoever holds the top level alone: a bar fills over the second they need */
.row.leader .name { color: var(--gold); }
.row.leader .lvl { color: var(--mint); }
.row .tick {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0;
  border-radius: 2px;
  background: var(--mint);
  opacity: 0;
}
.row.leader .tick { opacity: 1; }

.row.soon .name,
.row.soon .points { animation: soon 0.4s ease-in-out infinite alternate; }
@keyframes soon {
  from { transform: scale(1); }
  to { transform: scale(1.12); color: var(--gold); }
}

.row.pop .points { animation: pop 0.5s ease-out; }
@keyframes pop {
  0% { transform: scale(1.9); color: var(--gold); text-shadow: 0 0 16px var(--gold); }
  100% { transform: scale(1); }
}

#stats {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 9px 12px;
  background: rgba(10, 8, 24, 0.72);
  border: 2px solid var(--edge);
  border-radius: 10px;
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.9;
  color: var(--dim);
  white-space: pre;
}

/* what the radio is playing, credited to the station it comes from */
#nowplaying {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: 40ch;
  padding: 8px 12px;
  background: rgba(10, 8, 24, 0.72);
  border: 2px solid var(--edge);
  border-radius: 10px;
  font-size: 9px;
  line-height: 1.9;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#nowplaying[hidden] { display: none; }
#nowplaying b { color: var(--sky); }
#nowplaying .src { opacity: 0.6; }

#help {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 8px;
  color: rgba(255, 255, 255, 0.42);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
#help b { color: rgba(255, 255, 255, 0.72); }
#hud.locked #help { opacity: 0.3; }

@media (max-width: 640px) {
  #help { display: none; }
  #toolbar { gap: 6px; }
  .tool { min-width: 92px; padding: 7px 10px 8px; }
  #stats { display: none; }
}
