:root {
  /* Salesbricks palette, from stormfront/tailwind-config/colors.js */
  --bg: #121111;          /* sand 10    */
  --panel: rgba(31, 30, 30, 0.94); /* sand 20 */
  --edge: rgba(253, 251, 248, 0.12);
  --text: #fdfbf8;        /* sand 160   */
  --muted: #a8a4a1;       /* sand 110   */
  --accent: #e9364b;      /* coral 100  */
  --accent-dark: #c1172e; /* coral 80   */
  --danger: #fa485c;      /* coral 110  */
  --info: #597cda;        /* dory 100   */

  /* Open Sans and Montserrat are the product's typefaces. They are used when
     present on the machine; the game deliberately loads no external fonts so
     it stays a single self-contained binary with no network dependencies. */
  --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Montserrat", "Open Sans", system-ui, sans-serif;
  font-family: var(--font-body);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

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

.hidden { display: none !important; }

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

#hud {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.hud-row { display: flex; gap: 8px; align-items: center; }

.pill {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  backdrop-filter: blur(6px);
}

.powers { gap: 6px; }

.power {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  display: flex;
  gap: 5px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.power .ico { font-size: 14px; }

/* ---------------------------------------------------------- scoreboard */

#scoreboard {
  position: fixed;
  /* Sits below the round-over banner rather than on top of it. */
  top: 56%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 18px 22px;
  min-width: 320px;
  max-height: 46vh;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 24px 60px rgba(51, 51, 51, .45);
  backdrop-filter: blur(10px);
}

.sb-title {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: 10px;
}
.sb-title .hint { color: var(--muted); font-weight: 400; font-size: 12px; }

#scoreboard table { border-collapse: collapse; width: 100%; font-size: 13px; }
#scoreboard th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 8px;
  border-bottom: 1px solid var(--edge);
}
#scoreboard td { padding: 4px 8px; font-variant-numeric: tabular-nums; }
#scoreboard tr.me td { color: var(--accent); font-weight: 600; }
#scoreboard tr.dead td { opacity: .45; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; }

/* -------------------------------------------------------------- banner */

#banner {
  position: fixed;
  font-family: var(--font-display);
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .5px;
  text-shadow: 0 4px 24px rgba(0, 0, 0, .8);
  z-index: 15;
  pointer-events: none;
  line-height: 1.3;
}
#banner .sub { display: block; font-size: 15px; font-weight: 500; color: var(--muted); }

/* -------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  right: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  max-width: 260px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 6px 11px;
  font-size: 12.5px;
  animation: fade 4s forwards;
}
@keyframes fade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------------------------------------------------------- chat */

#chat {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 320px;
  z-index: 10;
}
#chat-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  max-height: 160px;
  overflow: hidden;
  font-size: 12.5px;
}
#chat-log div { text-shadow: 0 2px 6px rgba(0, 0, 0, .9); }
#chat-input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--edge);
  color: var(--text);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
#chat-input.hidden { display: none; }

/* --------------------------------------------------------------- lobby */

#lobby {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 28%, #2c2b2b 0%, #121111 68%);
  z-index: 40;
}

.panel {
  width: min(400px, 92vw);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 26px 28px 22px;
  box-shadow: 0 30px 80px rgba(51, 51, 51, .5);
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.4px;
}
.panel .tag { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 5px;
  text-transform: uppercase;
  letter-spacing: .8px;
}

.panel input {
  width: 100%;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--edge);
  color: var(--text);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.panel input:focus { border-color: var(--accent); }

#swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
#swatches button {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
#swatches button.sel { border-color: #fff; transform: scale(1.12); }

#rooms-live { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }
#rooms-live b { color: var(--text); cursor: pointer; text-decoration: underline dotted; }

#btn-play {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: .3px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
}
#btn-play:hover { filter: brightness(1.08); }
#btn-play:disabled { opacity: .6; cursor: default; }

.keys {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.keys b { color: var(--text); }

#lobby-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* --------------------------------------------------------------- touch */

#touch { position: fixed; inset: 0; z-index: 8; pointer-events: none; }

#dpad {
  position: absolute;
  left: 18px;
  bottom: 24px;
  width: 168px;
  height: 168px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: auto;
}
#dpad button {
  background: rgba(255, 255, 255, .10);
  border: 1px solid var(--edge);
  color: #fff;
  border-radius: 6px;
  font-size: 20px;
}
#dpad button:active { background: rgba(255, 255, 255, .3); }
#dpad [data-dir=up] { grid-area: 1 / 2; }
#dpad [data-dir=left] { grid-area: 2 / 1; }
#dpad [data-dir=right] { grid-area: 2 / 3; }
#dpad [data-dir=down] { grid-area: 3 / 2; }

#btn-bomb {
  position: absolute;
  right: 26px;
  bottom: 46px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 36px;
  background: rgba(255, 179, 71, .22);
  border: 1px solid var(--edge);
  pointer-events: auto;
}
#btn-bomb:active { background: rgba(255, 179, 71, .5); }

@media (max-width: 720px) {
  #chat { width: 56vw; }
  #banner { font-size: 24px; }
}

/* ------------------------------------------------------------ branding */

.brandmark {
  /* The supplied marks are dark-on-light; invert for the dark UI. */
  filter: brightness(0) invert(1);
}

#lobby-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  opacity: .92;
}
#lobby-brand img { height: 22px; width: auto; }
#lobby-brand .by {
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

#hud-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
}
#hud-brand img { height: 16px; width: auto; opacity: .9; }

#lobby-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--edge);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
#lobby-foot img { height: 11px; width: auto; opacity: .7; }
