/* City sandbox page: the map fills the window; three small pieces of chrome — title, a stats pill with a
   settings popover, and one slim bottom dock. */
body.sandbox {
  --g-bg: rgba(18, 22, 21, 0.72);
  --g-line: rgba(255, 255, 255, 0.1);
  --g-ink: #eeeae0;
  --g-ink2: #a9aca4;
  --g-ink3: #757a73;
  --gold: #dcbb7c;
  --gold-ink: #231c10;
  background: #111513; color: var(--g-ink); overflow: hidden; user-select: none; -webkit-user-select: none;
}
body.sandbox #viewer { position: fixed; inset: 0; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.pill, .round, .ctrl, .dock {
  background: var(--g-bg); border: 1px solid var(--g-line);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

/* ---------- title ---------- */
.hdr { position: fixed; left: 20px; top: calc(18px + env(safe-area-inset-top, 0px)); z-index: 9; display: flex; gap: 12px; align-items: flex-start;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 1px 16px rgba(0, 0, 0, 0.5); max-width: calc(100vw - 340px); }
.hdr .back { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--g-ink2); margin-top: 4px;
  background: rgba(18, 22, 21, 0.45); border: 1px solid var(--g-line); flex: none; }
.hdr .back:hover { color: var(--g-ink); }
.hdr .back svg { width: 14px; height: 14px; }
.hdr h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05; margin: 0; color: #f6f1e4; letter-spacing: 0.02em; }
.hdr .sub { margin: 3px 0 0; font-size: 12px; color: #d4d6cf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- top right ---------- */
.topright { position: fixed; right: 20px; top: calc(18px + env(safe-area-inset-top, 0px)); z-index: 11; display: flex; gap: 8px; align-items: center; }
.pill { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 12px; color: var(--g-ink2); white-space: nowrap; }
.pill b { color: var(--g-ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.pill i { width: 1px; height: 12px; background: var(--g-line); }
.pill .warn { color: #e8a07a; }
.round { width: 36px; height: 36px; border-radius: 50%; color: var(--g-ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.round svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.round[aria-expanded="true"] { background: var(--gold); color: var(--gold-ink); border-color: transparent; }

/* ---------- settings popover ---------- */
.ctrl { position: fixed; right: 20px; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 11; width: 260px; border-radius: 16px; padding: 6px 16px 12px;
  max-height: calc(100vh - 64px - 96px); overflow-y: auto; scrollbar-width: none; transform-origin: top right; }
.grp { padding: 10px 0; border-bottom: 1px solid var(--g-line); }
.grp:last-of-type { border-bottom: 0; }
.gh { font-size: 11px; color: var(--g-ink3); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: rgba(255, 255, 255, 0.06); border-radius: 9px; padding: 2px; }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg button { border: 0; background: transparent; color: var(--g-ink2); font-size: 12px; padding: 6px 8px; border-radius: 7px; cursor: pointer; white-space: nowrap; transition: background-color .2s, color .2s; }
.seg button:hover { color: var(--g-ink); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); font-weight: 600; }
.wx { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.wx button { height: 34px; border-radius: 9px; border: 0; background: rgba(255, 255, 255, 0.06); color: var(--g-ink2); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background-color .2s; }
.wx button:hover { color: var(--g-ink); }
.wx button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.wx svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 16px; }
.toggles label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--g-ink); cursor: pointer; }
.toggles input { display: none; }
.toggles i { width: 26px; height: 15px; border-radius: 10px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background-color .25s; flex: none; }
.toggles i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: #cfd2c9; transition: transform .3s var(--ease); }
.toggles input:checked + i { background: var(--gold); }
.toggles input:checked + i::after { transform: translateX(11px); background: #fff8e8; }
.hint { font-size: 11px; color: var(--g-ink3); line-height: 1.6; margin: 10px 0 0; }

/* ---------- bottom dock ---------- */
.dock { position: fixed; left: 0; right: 0; margin: 0 auto; transform: none; flex-wrap: nowrap; justify-content: flex-start; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  width: min(880px, calc(100vw - 32px)); height: 56px; border-radius: 999px; display: flex; align-items: center; gap: 14px; padding: 0 10px 0 8px; }
.play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--gold); color: var(--gold-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.play svg { width: 15px; height: 15px; fill: currentColor; }
.play[aria-pressed="true"] .i-play, .play[aria-pressed="false"] .i-pause { display: none; }
.tclock { display: flex; align-items: baseline; gap: 7px; flex: none; }
.tclock b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: #f6f1e4; }
.tclock span { font-size: 12px; color: var(--g-ink2); min-width: 3em; }
.track { position: relative; flex: 1; height: 36px; cursor: pointer; touch-action: none; min-width: 80px; }
.track:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.rail { position: absolute; left: 0; right: 0; top: 12px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.rail .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); opacity: 0.8; }
.ticks { position: absolute; left: 0; right: 0; top: 20px; font-size: 10px; color: var(--g-ink3); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); }
.knob { position: absolute; top: 7px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%; background: #fff6e0; box-shadow: 0 0 0 4px rgba(220, 187, 124, 0.3); }
.speeds { flex: none; grid-template-columns: repeat(3, auto); }
.acts { display: flex; gap: 2px; flex: none; }
.ib { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--g-ink2); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background-color .2s, color .2s; }
.ib:hover { background: rgba(255, 255, 255, 0.08); color: var(--g-ink); }
.ib svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ib[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.ib.share { background: #f1ecdf; color: #1a1712; }
.ib.share:hover { background: #fff; color: #1a1712; }

/* ---------- landmark labels ---------- */
.lbl {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #f1ecdf; padding: 3px 8px 3px 6px; border-radius: 5px; white-space: nowrap; border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 20, 19, 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity .35s; will-change: transform;
}
.lbl::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); flex: none; }
.lbl::after { content: ""; position: absolute; left: 8px; top: 100%; width: 1px; height: 10px; background: linear-gradient(rgba(220, 187, 124, 0.6), transparent); }
.lbl:hover, .lbl.on { background: var(--gold); color: var(--gold-ink); }
.lbl.on::before, .lbl:hover::before { background: var(--gold-ink); }
.lbl.hidden { opacity: 0; pointer-events: none; }

/* ---------- building card ---------- */
body.sandbox .bcard { left: 20px; right: auto; top: auto; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); width: 280px;
  background: var(--g-bg); border-color: var(--g-line); color: var(--g-ink); padding: 16px 18px 14px; }
body.sandbox .bcard h2 { color: #f6f1e4; font-size: 24px; }
body.sandbox .bcard .kicker, body.sandbox .bcard .alt, body.sandbox .bcard dt { color: var(--g-ink3); }
body.sandbox .bcard dl > div { border-color: var(--g-line); }
body.sandbox .bcard .links a { color: var(--gold); border-color: rgba(220, 187, 124, 0.35); }
body.sandbox .bcard .bclose { color: var(--g-ink2); }

body.sandbox .attrib { right: 20px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); background: transparent; color: rgba(238, 234, 224, 0.55); font-size: 10px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
body.sandbox .loadbar { background: var(--gold); }
body.sandbox .toast { background: var(--gold); color: var(--gold-ink); }
body.sandbox::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(60% 30% at 0% 0%, rgba(8, 10, 9, 0.6), transparent 70%); }

body.touring .topright, body.touring .ctrl, body.touring #labels { opacity: 0 !important; pointer-events: none; transition: opacity .6s; }

/* ---------- narrow windows ---------- */
@media (max-width: 900px) {
  .pill > span:nth-of-type(3), .pill i:nth-of-type(2) { display: none; }
  .speeds button[data-s="600"] { display: none; }
  .ticks span:nth-child(even) { display: none; }
}
@media (max-width: 640px) {
  .hdr { max-width: calc(100vw - 80px); }
  .hdr h1 { font-size: 26px; }
  .pill { display: none; }
  .dock { gap: 8px; height: 52px; }
  .tclock span, .speeds, #poster { display: none; }
  .ctrl { left: 16px; right: 16px; width: auto; }
  body.sandbox .bcard { left: 12px; right: 12px; width: auto; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 560px) { .hdr .sub { display: none; } .hdr h1 { font-size: 26px; } }
