:root {
  --glass: rgba(18, 20, 24, 0.72);
  --glass-strong: rgba(18, 20, 24, 0.88);
  --ink: #f2f3f5;
  --ink-dim: #a9afb8;
  --accent: #4fb3ff;
  --warn: #ff5a5a;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0e10; color: var(--ink); }
button {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--glass);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 7px 12px; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
button:hover { background: var(--glass-strong); border-color: rgba(255,255,255,0.25); }
button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

#stage { position: fixed; inset: 0; touch-action: none; cursor: grab; }
#stage.dragging { cursor: grabbing; }
#gl { width: 100%; height: 100%; display: block; }
#hotspots { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.hotspot {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; padding: 0; background: none;
  transform-origin: 50% 50%;
}
.hotspot .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9); background: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25), 0 2px 10px rgba(0,0,0,0.35);
  transition: background .15s, transform .15s;
}
.hotspot:hover .ring, .hotspot.aim .ring { background: rgba(79,179,255,0.55); transform: scale(1.1); }
.hotspot .tag {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -6px);
  white-space: nowrap; font-size: 12px; padding: 3px 8px; border-radius: 6px;
  background: var(--glass-strong); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.hotspot:hover .tag { opacity: 1; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 12px; padding: 14px 16px; pointer-events: none;
  background: linear-gradient(rgba(0,0,0,0.45), transparent);
}
#topbar > * { pointer-events: auto; }
.title { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
#tour-name { font-size: 12px; color: var(--ink-dim); letter-spacing: .04em; text-transform: uppercase; }
.room { font-size: 20px; font-weight: 600; }
#floor-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

#minimap {
  position: fixed; left: 16px; bottom: 16px; width: min(320px, calc(100vw - 32px)); aspect-ratio: 1;
  background: var(--glass); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: hidden;
}
#minimap.collapsed { width: 44px; height: 44px; aspect-ratio: auto; }
#minimap.collapsed #map { display: none; }
#map { width: 100%; height: 100%; display: block; cursor: pointer; }
#map-toggle { position: absolute; top: 6px; right: 6px; padding: 2px 9px; }

#toolbar { position: fixed; right: 16px; bottom: 16px; display: flex; gap: 6px; }

.panel {
  position: fixed; right: 16px; bottom: 64px; width: min(300px, calc(100vw - 32px));
  background: var(--glass-strong); border: 1px solid rgba(255,255,255,0.12); border-radius: var(--radius);
  padding: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 8px;
}
.panel[hidden] { display: none; }
.panel input[type=text] {
  font: inherit; color: var(--ink); background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 6px; padding: 7px 9px;
}
.panel input[type=range] { width: 100%; }
.panel label { display: flex; flex-direction: column; gap: 4px; }
.panel .row { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { margin: 0; color: var(--ink-dim); font-size: 12px; line-height: 1.4; }
.dbg-head { font-weight: 600; }
#dbg-info { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-dim); }
#dbg-info .bad { color: var(--warn); }

#loading { position: fixed; left: 0; right: 0; top: 0; height: 2px; pointer-events: none; }
#loading .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s, opacity .4s; opacity: 0; }
#loading.on .bar { opacity: 1; }

@media (max-width: 640px) {
  #minimap { width: 46vw; left: 12px; bottom: 12px; }
  #toolbar { right: 12px; bottom: 12px; flex-direction: column; }
  .panel { right: 12px; left: 12px; width: auto; bottom: auto; top: 70px; }
  .room { font-size: 17px; }
}

#hotspots.hidden .hotspot { opacity: 0; pointer-events: none; }
.hotspot { transition: opacity .25s; }

#walkpad {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; touch-action: none; user-select: none; -webkit-user-select: none;
}
#walkpad[hidden] { display: none; }
#walkpad button { width: 64px; height: 52px; font-size: 20px; border-radius: 14px; -webkit-touch-callout: none; }
#walkpad button.held { background: rgba(79,179,255,0.55); border-color: var(--accent); }

#help {
  position: fixed; left: 50%; top: 72px; transform: translate(-50%, -8px); max-width: calc(100vw - 32px);
  padding: 8px 14px; border-radius: 999px; background: var(--glass-strong); font-size: 13px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s;
}
#help.show { opacity: 1; transform: translate(-50%, 0); }
#toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%); max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: 10px; background: var(--glass-strong); font-size: 13px; line-height: 1.4; text-align: center;
}
#toast[hidden] { display: none; }
#fader { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .18s; }
#fader.on { opacity: 1; }
.seg button { flex: 1; }
@media (max-width: 640px) {
  #walkpad { bottom: 12px; }
}
#loading.on .bar { width: 70%; }

/* ================================================================ customer polish (Meybohm) */
:root {
  --navy: #122c3b; --navy2: #0e2330; --wine: #6e1726; --red: #c72a2f; --orange: #e0612d; --bronze: #a86f34; --cream: #f7f3ee;
  --glass: rgba(14, 35, 48, 0.62); --glass-strong: rgba(14, 35, 48, 0.86); --line: rgba(255,255,255,0.14);
  --accent: var(--orange); --ink-dim: #b9c6cf;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --serif: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
  --sans: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}
html, body { background: var(--navy2); overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { user-select: none; -webkit-user-select: none; }
button {
  font-family: var(--sans); font-weight: 500; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 4px 18px rgba(0,0,0,0.22); transition: background .15s, border-color .15s, transform .1s;
}
button:active { transform: scale(0.96); }
button svg { display: block; }
button[aria-pressed="true"] { border-color: var(--orange); color: #fff; background: rgba(224,97,45,0.55); }

/* top bar: brand + where you are, floor switch */
#topbar {
  padding: calc(14px + var(--sat)) calc(16px + var(--sar)) 28px calc(16px + var(--sal));
  background: linear-gradient(rgba(8,22,31,0.62), rgba(8,22,31,0.25) 60%, transparent);
  align-items: center;
}
.title { gap: 3px; text-shadow: 0 1px 8px rgba(0,0,0,0.45); }
.title .brand { font: 600 10.5px var(--sans); letter-spacing: .42em; color: #fff; opacity: .92; }
.title .brand::after { content: ''; display: block; width: 26px; height: 2px; margin-top: 6px;
  background: linear-gradient(90deg, var(--wine) 0 20%, var(--red) 20% 40%, var(--orange) 40% 60%, #9a2b40 60% 80%, var(--bronze) 80%); }
.room { font: 400 22px/1.15 var(--serif); letter-spacing: .005em; }
#floor-tabs { flex-wrap: nowrap; gap: 0; padding: 3px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 4px 18px rgba(0,0,0,0.22); }
#floor-tabs button { background: transparent; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600; letter-spacing: .03em; color: var(--ink-dim); white-space: nowrap; }
#floor-tabs button[aria-pressed="true"] { background: #fff; color: var(--navy); }

/* floor plan card */
#minimap { left: calc(16px + var(--sal)); bottom: calc(16px + var(--sab)); width: min(300px, calc(100vw - 32px));
  background: rgba(14,35,48,0.72); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 34px rgba(0,0,0,0.3);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: width .25s, height .25s, border-radius .25s; }
#map-toggle { top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  background: rgba(255,255,255,0.1); box-shadow: none; z-index: 1; }
#minimap.collapsed { width: 52px; height: 52px; border-radius: 50%; }
#minimap.collapsed #map-toggle { inset: 0; width: 100%; height: 100%; background: transparent; border: 0; }

/* controls */
#toolbar { right: calc(16px + var(--sar)); bottom: calc(16px + var(--sab)); gap: 10px; }
#toolbar button { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
#toolbar button[hidden] { display: none; }
html.dev #toolbar button#btn-label, html.dev #toolbar button#btn-debug { width: auto; border-radius: 999px; padding: 0 14px; }
#walkpad { gap: 10px; }
#walkpad button { width: 62px; height: 54px; border-radius: 18px; display: grid; place-items: center; color: #fff; }
#walkpad button.held { background: rgba(224,97,45,0.7); border-color: var(--orange); }

/* messages */
#help, #toast { top: calc(var(--sat) + 132px); background: rgba(255,255,255,0.95); color: var(--navy); font: 500 13px/1.4 var(--sans);
  box-shadow: 0 8px 26px rgba(0,0,0,0.25); border-radius: 999px; padding: 10px 16px; }
#toast { border-radius: 14px; }
#fader { background: var(--navy2); }
#loading { top: var(--sat); height: 3px; }
#loading .bar { background: linear-gradient(90deg, var(--wine), var(--red), var(--orange)); }

/* motion panel reads as a customer sheet */
.panel { background: rgba(255,255,255,0.97); color: var(--navy); border: 0; border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,0.35); padding: 16px; }
.panel button { background: #fff; color: var(--navy); border: 1px solid #d5dbe0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.panel button[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.panel .hint { color: #5d6c76; }
.dbg-head { font: 400 18px var(--serif); }
#debug-panel, #label-panel { color: var(--ink); background: var(--glass-strong); }

/* incentive hunt bar sits under the top bar */
html body #hunt { top: calc(var(--sat) + 74px); }
html body #huntHint { top: calc(var(--sat) + 128px); }

@media (max-width: 640px) {
  #topbar { padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 26px calc(14px + var(--sal)); }
  .room { font-size: 19px; }
  #floor-tabs button { padding: 7px 11px; font-size: 11.5px; }
  #minimap { aspect-ratio: 4 / 3.2; width: min(64vw, 260px); left: calc(12px + var(--sal)); bottom: calc(14px + var(--sab)); }
  #toolbar { right: calc(12px + var(--sar)); bottom: calc(14px + var(--sab) + 136px); flex-direction: column; }
  #walkpad { left: auto; right: calc(12px + var(--sar)); transform: none; bottom: calc(14px + var(--sab)); }
  .panel { left: 12px; right: 12px; top: auto; bottom: calc(14px + var(--sab)); width: auto; }
  html body #hunt { top: calc(var(--sat) + 72px); left: 12px; right: 12px; transform: none; max-width: none; justify-content: space-between;
    padding: 8px 8px 7px 12px; gap: 8px; border-radius: 14px; }
  html body #hunt .t { white-space: nowrap; font-size: 14px; }
  html body #hunt .s { font-size: 12px; white-space: nowrap; flex: 1; }
  html body #hunt .meter { width: 44px; }
  html body #huntHint { top: calc(var(--sat) + 126px); left: 12px; right: 12px; transform: none; max-width: none; }
  #help, #toast { top: auto; bottom: calc(var(--sab) + 84px); max-width: calc(100vw - 32px); }
}
html body .card button { box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
html body .card button.ghost { background: none; border: 0; }
html body .card button.go { box-shadow: 0 6px 16px rgba(18,44,59,0.25); }

/* panel header with a close button (motion menu) */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px -4px 0 0; }
.panel .panel-close { flex: none; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  background: #eef1f3; border: 0; color: var(--navy); }
.panel .panel-close:hover { background: #e2e7ea; }

/* ================================================================ intro: picture -> Enter tour -> video -> tour
   Built for a phone held upright. The landscape photo is cropped to the beams, fan and kitchen. */
#intro { position: fixed; inset: 0; z-index: 10000; background: var(--navy2); overflow: hidden;
  transition: opacity .4s ease, visibility 0s linear .4s; }
#intro.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
#intro-poster, #intro-video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#intro-poster { object-fit: cover; object-position: 60% 50%; transform: scale(1.05); transition: opacity .25s ease, transform 9s ease-out; }
#intro.ready #intro-poster { transform: scale(1); }
/* the loading video is shot vertical (1080x1920): fill a phone; letterbox on a wide screen */
#intro-video { object-fit: cover; background: var(--navy2); opacity: 0; transition: opacity .25s ease; }
@media (min-aspect-ratio: 4/5) { #intro-video { object-fit: contain; } }
.intro-shade { position: absolute; inset: 0; pointer-events: none; transition: opacity .25s ease;
  background: linear-gradient(to top, rgba(8,22,31,0.45), rgba(8,22,31,0) 38%); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the small branded popup */
.intro-card { position: absolute; left: 50%; bottom: calc(44px + var(--sab)); width: min(268px, calc(100vw - 48px));
  transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 20px 20px 18px; border-radius: 20px; background: rgba(255,255,255,0.96); color: var(--navy);
  box-shadow: 0 18px 48px rgba(8,22,31,0.35); transition: opacity .35s ease, transform .35s ease; }
.intro-card .brand { font: 600 11px var(--sans); letter-spacing: .42em; margin-right: -.42em; color: var(--navy); }
.intro-card .brand::after { content: ''; display: block; width: 30px; height: 2px; margin: 8px auto 0;
  background: linear-gradient(90deg, var(--wine) 0 20%, var(--red) 20% 40%, var(--orange) 40% 60%, #9a2b40 60% 80%, var(--bronze) 80%); }
#intro-enter { align-self: stretch; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 14px 20px;
  border: 0; border-radius: 999px; background: var(--navy); color: #fff; font: 600 15px var(--sans); letter-spacing: .02em;
  box-shadow: 0 6px 16px rgba(18,44,59,0.28); backdrop-filter: none; -webkit-backdrop-filter: none; }
#intro-enter:hover { background: var(--navy2); }
#intro-enter svg { color: var(--orange); }
@keyframes intro-card-in { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.intro-card { animation: intro-card-in .6s cubic-bezier(.2,.7,.2,1) .3s both; }

.intro-controls { position: absolute; right: calc(14px + var(--sar)); bottom: calc(18px + var(--sab)); display: flex; gap: 10px;
  opacity: 0; pointer-events: none; transition: opacity .4s ease .3s; }
.intro-controls button { height: 44px; min-width: 44px; padding: 0 18px; border-radius: 999px; display: grid; place-items: center;
  color: #fff; font: 600 13px var(--sans); letter-spacing: .03em; }
#intro button:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

/* video playing */
#intro.playing #intro-video { opacity: 1; }
#intro.playing #intro-poster, #intro.playing .intro-shade { opacity: 0; }
#intro.playing .intro-card { animation: none; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
#intro.playing .intro-controls { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  #intro, #intro-poster, #intro-video, .intro-shade, .intro-card, .intro-controls { transition: none; }
  #intro-poster { transform: none; }
  .intro-card { animation: none; }
}
