:root {
  color-scheme: dark;
  --panel: rgba(12, 15, 19, 0.88);
  --panel-solid: #11151a;
  --line: rgba(255, 255, 255, 0.12);
  --muted: #a8b1bd;
  --text: #f6f8fa;
  --green: #56e08f;
  --amber: #ffc857;
  --red: #ff6b6b;
  --blue: #62a8ff;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b0e;
  color: var(--text);
}

button,
select,
input { font: inherit; }

.hidden { display: none !important; }

#game-wrap,
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game-canvas { display: block; }

#hud {
  position: absolute;
  top: 18px;
  left: 18px;
  width: min(430px, calc(100vw - 36px));
  z-index: 40;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(22px) saturate(125%);
}

.brand-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  text-decoration: none;
  font-size: 28px;
  line-height: 1;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

#hud h1 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.live-pill,
.signal-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #dce2e9;
  font-size: 11px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(86, 224, 143, 0.12);
}

.guide-card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid rgba(98, 168, 255, 0.28);
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(34, 76, 128, 0.52), rgba(17, 25, 35, 0.68));
}

.guide-card.arrived {
  border-color: rgba(86, 224, 143, 0.5);
  background: linear-gradient(135deg, rgba(31, 104, 65, 0.54), rgba(17, 35, 27, 0.72));
}

.direction-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 15px;
  background: #f7f9fb;
  color: #10151b;
  font-size: 31px;
  font-weight: 800;
}

.guide-copy { min-width: 0; }
.guide-copy span,
.guide-copy strong { display: block; }
#guide-kicker,
#guide-detail { color: #b8c4d1; font-size: 11px; }
#guide-instruction {
  margin: 3px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.guide-distance {
  min-width: 48px;
  text-align: right;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.readiness,
.banner,
.offline {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.readiness {
  border: 1px solid rgba(255, 200, 87, 0.34);
  background: rgba(109, 70, 13, 0.34);
  color: #ffe3a6;
}
.readiness.ready {
  border-color: rgba(86, 224, 143, 0.3);
  background: rgba(20, 86, 50, 0.3);
  color: #bdf7d3;
}
.banner { border: 1px solid rgba(98, 168, 255, 0.3); background: rgba(25, 62, 106, 0.54); }
.offline { border: 1px solid rgba(255, 107, 107, 0.34); background: rgba(96, 33, 33, 0.5); }

.primary-actions {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 9px;
  margin-top: 12px;
}

.primary-btn,
.secondary-btn,
.hud-btn,
.hud-select,
.hud-coordinate,
.tool-btn,
.map-style-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
}

.primary-btn,
.secondary-btn,
.hud-btn,
.tool-btn,
.map-style-btn { cursor: pointer; }
.primary-btn { border-color: transparent; background: #f6f8fa; color: #11151a; font-weight: 760; }
.secondary-btn { background: rgba(255, 255, 255, 0.08); font-weight: 700; }
.secondary-btn.active { border-color: rgba(86, 224, 143, 0.5); background: rgba(35, 118, 72, 0.56); }

.signal-row {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  overflow: hidden;
}
.signal-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status { flex: 1; }
#gps-state[data-quality="good"] { color: var(--green); }
#gps-state[data-quality="weak"] { color: var(--amber); }
#gps-state[data-quality="poor"],
#gps-state[data-quality="stale"] { color: var(--red); }

.setup-drawer {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.setup-drawer summary,
#editor-panel > summary { padding: 10px 2px 0; cursor: pointer; user-select: none; }
.meta { margin: 9px 0 0; color: var(--muted); }
.hud-row,
#editor-panel .row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 9px; }
.hud-btn,
.hud-select,
.hud-coordinate,
.tool-btn { min-height: 34px; padding: 6px 9px; background: #20262d; }
.hud-btn.active,
.tool-btn.active { border-color: var(--blue); background: #245a92; }
.coordinate-controls label,
#editor-panel label { display: inline-flex; align-items: center; gap: 5px; }
.hud-coordinate { width: 112px; }

#mini-map-wrap {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 25;
  width: min(360px, calc(100vw - 36px));
  height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.42);
}
#mini-map-wrap.large { width: min(760px, calc(100vw - 36px)); height: min(70vh, 580px); }
#mini-map { position: absolute; inset: 0 0 32px; }
#coords { position: absolute; inset: auto 0 0; height: 32px; padding: 8px 11px; background: #10151a; color: #c3cbd4; font-size: 11px; }
#map-style-controls { position: absolute; top: 8px; left: 8px; z-index: 5000; display: flex; gap: 5px; }
.map-style-btn { min-height: 30px; padding: 4px 8px; background: rgba(17, 21, 26, 0.9); font-size: 10px; }
.map-style-btn.active { background: #f4f7fa; color: #11151a; }

#editor-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(470px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  backdrop-filter: blur(18px);
}
#editor-panel > summary { padding: 11px 13px; }
.editor-content { padding: 0 13px 13px; }
#editor-panel input { width: 60px; min-height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #20262d; color: white; padding: 4px 6px; }
.tool-btn { font-size: 11px; }
.tool-btn.danger { border-color: rgba(255, 107, 107, 0.4); color: #ffb5b5; }
#editor-hint { margin-top: 8px; font-size: 11px; }

@media (max-width: 760px) {
  #hud { top: 10px; left: 10px; width: calc(100vw - 20px); padding: 13px; border-radius: 18px; }
  #hud h1 { font-size: 17px; }
  .live-pill { font-size: 10px; }
  .guide-card { margin-top: 12px; min-height: 74px; grid-template-columns: 46px 1fr auto; }
  .direction-icon { width: 44px; height: 44px; font-size: 27px; border-radius: 13px; }
  #guide-instruction { font-size: 14px; }
  .guide-distance { font-size: 18px; }
  .primary-actions { grid-template-columns: 1fr 1fr; }
  .primary-btn, .secondary-btn { min-height: 46px; font-size: 13px; }
  #mini-map-wrap { right: 10px; bottom: 10px; width: 150px; height: 150px; border-radius: 14px; }
  #mini-map-wrap.large { right: 10px; bottom: 10px; width: calc(100vw - 20px); height: 48vh; }
  #map-style-controls { gap: 3px; }
  .map-style-btn { padding: 3px 5px; }
  #editor-panel { left: 10px; bottom: 10px; width: calc(100vw - 180px); min-width: 150px; }
  #editor-panel[open] { width: calc(100vw - 20px); max-height: 45vh; overflow: auto; }
}

@media (max-height: 720px) {
  .setup-drawer { display: none; }
  #hud { max-height: calc(100vh - 20px); overflow: auto; }
}
