:root {
  --bg: #0d1017;
  --panel: rgba(18, 22, 31, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef1f6;
  --muted: #9aa4b5;
  --accent: #ff5d4a;
  --accent-2: #ffb02e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

/* thin native scrollbars with a transparent track, same look everywhere */
:root { --scroll-thumb: rgba(238, 241, 246, 0.2); --scroll-thumb-active: rgba(238, 241, 246, 0.34); }
:where(*) { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
:where(*:hover, *:focus-within) { scrollbar-color: var(--scroll-thumb-active) transparent; }
:where(*)::-webkit-scrollbar { width: 8px; height: 8px; }
:where(*)::-webkit-scrollbar-track { background: transparent; }
:where(*)::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: var(--scroll-thumb); background-clip: padding-box; }
:where(*:hover, *:focus-within)::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb-active); }
@media (forced-colors: active) {
  :where(*) { scrollbar-width: auto; scrollbar-color: auto; }
}

canvas {
  position: fixed;
  inset: 0;
  /* a canvas is a replaced element: without this it keeps its pixel size, so on a 2x screen it is drawn twice as large as the window */
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#labels {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.plabel {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  will-change: transform;
  white-space: nowrap;
}
.plabel .nm {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.72);
  color: #eef1f6;
  text-shadow: 0 1px 2px #000;
}
.plabel.me .nm { color: #ffd34d; }
.plabel .rl { font-size: 10.5px; font-weight: 600; color: #c9d1de; text-shadow: 0 1px 2px #000; line-height: 1.1; }
.plabel .rl:empty { display: none; }
.plabel .emo { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.plabel .emo:empty { display: none; }
/* mana bar under our own name */
.plabel .mana {
  display: block;
  width: 46px;
  height: 6px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.plabel .mana i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(180deg, #7cc4ff, #2f86e6);
}
.plabel .mana.low i { background: linear-gradient(180deg, #a3b4d0, #5d6f91); }
.plabel .mana.flash { box-shadow: 0 0 0 1px #ff5d4a, 0 0 8px rgba(255, 93, 74, 0.8); }
/* health bar over a damaged object */
.hpbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 6px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  overflow: hidden;
  will-change: transform;
}
.hpbar i { display: block; height: 100%; width: 100%; transform-origin: left center; background: #3ddc84; }
.hpbar.warm i { background: #ffb02e; }
.hpbar.hot i { background: #ff5d4a; }
.ftext {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 0 4px #000, 0 2px 3px #000;
  will-change: transform;
}

.pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  backdrop-filter: blur(6px);
}

.btn {
  font: inherit;
  cursor: pointer;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 14px;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.35); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
/* text-like fields: a 1px ring plus a soft halo instead of an offset outline */
.card select:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--accent-2), 0 0 0 4px rgba(255, 176, 46, 0.28);
}
.btn.pill { padding: 6px 12px; border-radius: 999px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.smash {
  background: linear-gradient(180deg, #ff6a55, #e63b2a);
  border-color: #ff8a78;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.btn.it {
  font-size: 13px;
  padding: 8px 12px;
}

/* The top bar is one full-width strip. The game view starts below it (see
   S.top in game.js), so it never covers the plants or the clock. */
#topbar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
}
#topLeft {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#board {
  display: flex;
  align-items: center;
  gap: 4px 14px;
  flex-wrap: wrap;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 12px;
  backdrop-filter: blur(6px);
  font-size: 13px;
}
.board-head { display: flex; align-items: baseline; gap: 8px; }
.board-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.board-total { font-size: 18px; font-weight: 800; color: var(--accent-2); }
#boardList {
  display: flex;
  gap: 4px 12px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}
#boardList li {
  counter-increment: rank;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#boardList li::before { content: counter(rank) ". "; color: var(--muted); }
#boardList li span { color: var(--muted); }

#bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 10px;
  pointer-events: none;
}
#bottombar > * { pointer-events: auto; }

#emotes {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}
#emotes button {
  font-size: 20px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 4px 6px;
  cursor: pointer;
}
#emotes button:hover { background: rgba(255, 255, 255, 0.1); }

#smashBtn { font-size: 18px; padding: 12px 22px; touch-action: none; }
/* mini map: the whole office, you in yellow, other players in white, smashed things in red */
#minimap {
  position: fixed;
  left: 12px;
  top: 60px;
  width: 200px;
  height: 125px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 20, 0.7);
  z-index: 4;
  pointer-events: auto;
  cursor: pointer;
}
#minimap.off { display: none; }
@media (max-width: 640px) { #minimap { width: 128px; height: 80px; top: 104px; left: 8px; } }
/* side buttons: help and map everywhere, zoom only on touch screens (no mouse wheel there; pinching works too) */
#sideBtns {
  position: fixed;
  right: 12px;
  top: 64px; /* game.js moves it just under the damage board, whatever height that has */
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
#sideBtns .btn { width: 44px; height: 44px; padding: 0; font-size: 20px; line-height: 1; border-radius: 12px; touch-action: manipulation; }
#sideBtns .btn[aria-pressed="false"] { opacity: 0.55; }
#sideBtns .btn.dim { opacity: 0.3; cursor: default; }
#zoomBtns { display: none; flex-direction: column; gap: 8px; }
@media (pointer: coarse) { #zoomBtns { display: flex; } }
#help {
  position: fixed;
  inset: 0;
  display: flex;
  background: rgba(6, 8, 12, 0.72);
  z-index: 30;
  overflow-y: auto;
  padding: 16px;
}
#help[hidden] { display: none; }
#help .card { margin: auto; width: min(460px, 100%); }
#help h2 { margin: 0; font-size: 20px; }
#help ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.45; color: var(--text); }
#help li b { color: var(--accent-2); }

#hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 66px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.75;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  transition: opacity 1s;
}
#hint.fade { opacity: 0; }

#toasts {
  position: fixed;
  left: 10px;
  bottom: 110px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 20px));
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  animation: pop 0.2s ease-out;
}
@keyframes pop { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(40, 50, 75, 0.92), rgba(8, 10, 15, 0.97));
  z-index: 10;
  overflow-y: auto; /* the card is taller than a phone in landscape */
}
#overlay .card { margin: auto; }
#overlay.gone { display: none; }

.card {
  width: min(420px, 100%);
  background: #151a25;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.card .logo { display: block; width: 64px; height: 64px; margin: 0 auto -6px; }
.card h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; text-align: center; }
.card .sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.roompick { display: flex; flex-direction: column; gap: 6px; }
.roompick .lbl { font-size: 13px; color: var(--muted); }
.gender { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gender label { position: relative; display: block; }
.gender input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.gender span {
  display: block;
  text-align: center;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 15px;
  background: #0f131c;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.gender input:checked + span { border-color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent-2); }
.gender input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.roomlist { display: grid; grid-template-columns: 1fr; gap: 8px; }
.roomcard {
  font: inherit;
  color: var(--text);
  text-align: left;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 12px 14px;
  background: #0f131c;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.roomcard:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.35); }
.roomcard.on { border-color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent-2); }
.roomcard:disabled { opacity: 0.5; cursor: not-allowed; }
.roomcard .rn { font-weight: 700; font-size: 15px; }
.roomcard .rc { font-size: 12px; color: var(--muted); min-height: 1.2em; font-weight: 600; }
.roomcard .rc.cool { color: #3ddc84; }
.roomcard .rc.warm { color: #ffb02e; }
.roomcard .rc.hot { color: #ff5d4a; }
/* Loading skeleton for the server list: same row size as the real cards, so nothing jumps. */
.roomskel {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(100deg, #0f131c 30%, #1a2030 50%, #0f131c 70%) 0 0 / 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
}
.roomskel:nth-child(2) { animation-delay: 0.15s; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .roomskel { animation: none; } }
@media (forced-colors: active) { .roomskel { border-color: CanvasText; background: Canvas; } }
.roomcard:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.card input {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: #0f131c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  -webkit-user-select: text;
  user-select: text;
}
/* native select, one custom chevron (colour baked into the image) */
.card select {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background-color: #0f131c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a4adbd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 2.25rem 10px 12px;
  text-overflow: ellipsis;
  cursor: pointer;
  width: 100%;
}
.card select option { background: #151a25; color: var(--text); }
@media (forced-colors: active) {
  .card select { appearance: auto; background-image: none; }
}
.err { min-height: 1.2em; margin: 0; color: #ff8a78; font-size: 13px; }

#conn {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 12px 12px;
  font-size: 13px;
  z-index: 20;
}

@media (max-width: 640px) {
  #hint { display: none; }
  #board { width: 100%; font-size: 12px; }
  .board-total { font-size: 15px; }
  #boardList li:nth-child(n + 4) { display: none; }
  #toasts { bottom: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
