:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b10;
  color: #f2f5f8;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 50% 20%, #18212c, #080b10 65%); }
button, input { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 24rem);
  display: grid;
  gap: 0.85rem;
  padding: 2rem;
  border: 1px solid #2a3542;
  border-radius: 0.75rem;
  background: #111720;
  box-shadow: 0 1.5rem 4rem #0008;
}

.login-card h1 { margin: 0 0 0.5rem; font-size: 1.55rem; }
.login-card label { color: #c2cad4; font-size: 0.9rem; }
.login-card input { width: 100%; border: 1px solid #475567; border-radius: 0.4rem; padding: 0.72rem; color: #fff; background: #080c12; }
.login-card button, .controls button { border: 1px solid #546274; border-radius: 0.4rem; padding: 0.65rem 0.9rem; color: #fff; background: #263241; }
.login-card button:hover, .controls button:hover { background: #344356; }
.error { margin: 0; color: #ff9b9b; }

.viewer { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left)); }
.stage { position: relative; width: min(calc(100vw - 1rem), calc((100vh - 1rem) * 16 / 9)); width: min(calc(100vw - 1rem), calc((100dvh - 1rem) * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden; background: #05070a; box-shadow: 0 0 0 1px #33404e, 0 1rem 4rem #000b; }
#map-canvas { display: block; width: 100%; height: 100%; }
.top-bar, .bottom-bar { position: absolute; left: 0; right: 0; display: flex; justify-content: space-between; gap: 1rem; padding: clamp(0.55rem, 1.7vw, 1.25rem); background: linear-gradient(#05080dd9, transparent); pointer-events: none; }
.top-bar { top: 0; align-items: flex-start; }
.bottom-bar { bottom: 0; align-items: flex-end; background: linear-gradient(transparent, #05080de8); }
.top-bar h1 { margin: 0; font-size: clamp(1rem, 2vw, 1.7rem); }
.top-bar p, #last-update { margin: 0.25rem 0 0; color: #c5cdd7; font-size: clamp(0.72rem, 1.25vw, 0.95rem); }
.controls { display: flex; align-items: center; gap: 0.5rem; pointer-events: auto; }
.controls button { padding: 0.45rem 0.65rem; font-size: clamp(0.7rem, 1.2vw, 0.9rem); background: #111923d9; }
.north { display: grid; grid-template-columns: auto auto; gap: 0.2rem; align-items: center; font-weight: 700; font-size: clamp(0.75rem, 1.5vw, 1.05rem); }
.north span { display: inline-block; color: #f7d167; transform-origin: center; }
.north span.turn-0 { transform: rotate(0deg); }
.north span.turn-1 { transform: rotate(90deg); }
.north span.turn-2 { transform: rotate(180deg); }
.north span.turn-3 { transform: rotate(270deg); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem 0.9rem; margin: 0; padding: 0; list-style: none; font-size: clamp(0.65rem, 1.1vw, 0.88rem); }
.legend li { display: flex; align-items: center; gap: 0.3rem; }
.marker { width: 0.65rem; height: 0.65rem; display: inline-block; border-radius: 50%; border: 1px solid #fff9; }
.marker.local { background: #e7edf3; }
.marker.teammate { background: #6f93b8; }
.marker.opponent { background: #e35e5e; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .bottom-bar { align-items: flex-start; flex-direction: column; gap: 0.35rem; }
  .controls { gap: 0.3rem; }
}
