:root {
  --ink: #111827;
  --muted: #5b6472;
  --paper: #ffffff;
  --maroon: #880000;
  --teal: #008b84;
  --lime: #91d300;
  --shadow: 0 18px 50px rgba(3, 12, 24, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body,
.tour-shell,
#panorama {
  width: 100%;
  height: 100%;
  min-height: 520px;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: #0d121a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.tour-shell {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

#panorama {
  position: absolute;
  inset: 0;
  background: #0d121a;
}

.brand-card {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  display: grid;
  gap: 2px;
  max-width: min(370px, calc(100vw - 230px));
  padding: 14px 18px 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  color: #fff;
  background: rgba(13, 18, 26, 0.82);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.brand-card__eyebrow,
.panel__eyebrow,
.welcome__eyebrow {
  color: var(--lime);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-card strong {
  overflow: hidden;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scene-title {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.83rem;
}

.tour-actions {
  position: absolute;
  z-index: 6;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  min-width: 52px;
  min-height: 52px;
  place-items: center;
  gap: 2px;
  padding: 7px 9px 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  color: #fff;
  background: rgba(13, 18, 26, 0.82);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: background 150ms ease, transform 150ms ease;
}

.icon-button[hidden] {
  display: none;
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button[aria-expanded="true"],
.icon-button[aria-pressed="true"] {
  background: rgba(136, 0, 0, 0.94);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button span {
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.drag-hint {
  position: absolute;
  z-index: 4;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 160px);
  margin: 0;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  background: rgba(13, 18, 26, 0.78);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  font-size: 0.78rem;
  transform: translateX(-50%);
  transition: opacity 350ms ease, visibility 350ms ease;
  backdrop-filter: blur(12px);
}

.drag-hint.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.drag-hint svg {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--lime);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.motion-status {
  position: absolute;
  z-index: 10;
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 70px));
  left: 50%;
  width: max-content;
  max-width: min(440px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(13, 18, 26, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  font-size: 0.78rem;
  line-height: 1.3;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.motion-status:empty {
  display: none;
}

.panel {
  position: absolute;
  z-index: 12;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(420px, 92vw);
  height: 100%;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  overflow-y: auto;
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 260ms ease, visibility 260ms ease;
}

.panel.is-open {
  transform: translateX(0);
  visibility: visible;
}

.panel--map {
  width: min(980px, 96vw);
  overflow: hidden;
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.panel__eyebrow {
  color: var(--teal);
}

.panel h2 {
  margin: 2px 0 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.1;
}

.close-button {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  padding: 0 0 3px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.close-button:hover,
.close-button:focus-visible {
  background: var(--maroon);
}

.room-groups {
  display: grid;
  gap: 24px;
}

.room-group h3 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.room-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.room-button {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #dde2e8;
  border-radius: 10px;
  color: var(--ink);
  background: #f7f8fa;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.room-button:hover,
.room-button:focus-visible {
  border-color: var(--teal);
  background: #eefafa;
}

.room-button.is-active {
  border-color: var(--maroon);
  color: #fff;
  background: var(--maroon);
}

.map-help {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.floor-plan {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  place-items: center;
  border: 1px solid #e0e5eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
  overflow: hidden;
}

.floor-plan object {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--maroon);
}

.panel-backdrop {
  position: absolute;
  z-index: 11;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  visibility: hidden;
  cursor: default;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.panel-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.welcome {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(120deg, rgba(5, 13, 24, 0.88), rgba(5, 13, 24, 0.58));
  transition: opacity 320ms ease, visibility 320ms ease;
}

.welcome.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.welcome__card {
  width: min(520px, 100%);
  max-height: calc(100% - 24px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  color: #fff;
  background: rgba(13, 18, 26, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.welcome h1 {
  margin: 5px 0 10px;
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.welcome p {
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.94rem;
  line-height: 1.5;
}

.start-button {
  min-height: 52px;
  padding: 13px 24px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--maroon);
  box-shadow: 0 8px 22px rgba(136, 0, 0, 0.32);
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.start-button:hover,
.start-button:focus-visible {
  background: #a50000;
  transform: translateY(-1px);
}

.no-script {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: #fff;
  background: var(--ink);
  text-align: center;
}

.pnlm-controls-container {
  top: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
}

/* The custom header already displays the room name, and the custom Motion
   button provides a clearer phone-orientation control. */
.pnlm-panorama-info,
.pnlm-orientation-button {
  display: none !important;
}

.pnlm-control {
  border: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.tour-shell:fullscreen,
.tour-shell:-webkit-full-screen {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #0d121a;
}

@media (max-width: 780px) {
  html,
  body,
  .tour-shell,
  #panorama {
    min-height: 460px;
  }

  .brand-card {
    max-width: calc(100vw - 136px);
    padding: 11px 13px;
  }

  .motion-supported .brand-card {
    max-width: calc(100vw - 190px);
  }

  .brand-card__eyebrow {
    font-size: 0.6rem;
  }

  .brand-card strong {
    font-size: 0.85rem;
  }

  #scene-title {
    font-size: 0.72rem;
  }

  .tour-actions {
    gap: 6px;
  }

  .icon-button {
    min-width: 46px;
    min-height: 46px;
    padding: 7px;
  }

  .icon-button span {
    display: none;
  }

  #rotate-button,
  #fullscreen-button {
    display: none;
  }

  .drag-hint {
    bottom: max(14px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 120px);
    padding: 8px 12px;
    font-size: 0.7rem;
  }

  .drag-hint svg {
    display: none;
  }

  .room-list {
    grid-template-columns: 1fr;
  }

  .panel--map {
    width: 100vw;
  }
}

@media (max-width: 420px) {
  .brand-card {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }

  .tour-actions {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .welcome {
    padding: 14px;
  }

  .welcome__card {
    padding: 22px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
