:root {
  --plaster: #E9EBEE;
  --plaster-hi: #F6F7F9;
  --concrete: #C2C6CB;
  --graphite: #1E2125;
  --graphite-soft: #5C6168;
  --gold: #C9A04E;

  --display: "Syne", "Helvetica Neue", Arial, sans-serif;
  --text: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --arabic: "Readex Pro", "Geeza Pro", sans-serif;

  --pad: clamp(16px, 2.6vw, 32px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--plaster);
  color: var(--graphite);
  font-family: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--graphite);
  outline-offset: 4px;
  border-radius: 6px;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene.dragging { cursor: grabbing; }
@media (hover: hover) and (pointer: fine) {
  #scene, #scene.dragging { cursor: none; }
}

/* ---------- top bar ---------- */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: var(--pad);
  pointer-events: none;
  z-index: 5;
}

.top > * { pointer-events: auto; }

.mark {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.mark-a {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.mark-b {
  font-size: 14px;
  color: var(--graphite-soft);
}

.rooms {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(246, 247, 249, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px rgba(30, 33, 37, 0.07);
}

.rooms button {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--graphite-soft);
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}

.rooms button:hover { color: var(--graphite); }

.rooms button[aria-current="true"] {
  background: var(--graphite);
  color: var(--plaster-hi);
}

/* ---------- where you are ---------- */

.now {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad) + 14px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 4;
}

.now-k {
  display: block;
  font-size: 12px;
  color: var(--graphite-soft);
  margin-bottom: 2px;
}

.now-v {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(22px, 2.4vw, 30px);
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.now-v.swap { animation: swap 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }

@keyframes swap {
  from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

.controls {
  position: fixed;
  right: var(--pad);
  bottom: var(--pad);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 5;
}

.hint {
  margin: 0;
  max-width: 200px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--graphite-soft);
  text-align: right;
}

.steps { display: flex; gap: 6px; }

.step {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(246, 247, 249, 0.8);
  box-shadow: inset 0 0 0 1px rgba(30, 33, 37, 0.1);
  transition: background-color 0.2s, transform 0.2s;
}

.step:hover { background: var(--plaster-hi); transform: scale(1.06); }
.step:active { transform: scale(0.94); }

.step svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--graphite);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.track {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(30, 33, 37, 0.06);
  z-index: 5;
}

.track i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--graphite);
  transform-origin: left;
  transform: scaleX(0);
}

.again {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 120px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--graphite);
  color: var(--plaster-hi);
  font-weight: 500;
  font-size: 14px;
  z-index: 6;
  animation: swap 0.5s ease-out;
}

.again[hidden] { display: none; }

/* ---------- cursor ---------- */

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--graphite);
  pointer-events: none;
  z-index: 10;
  display: grid;
  place-items: center;
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    margin 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.3s, opacity 0.2s;
  opacity: 0;
}

.cursor span {
  font-size: 13px;
  font-weight: 600;
  color: var(--plaster-hi);
  opacity: 0;
  transition: opacity 0.2s;
}

.cursor.on { opacity: 1; }

.cursor.open {
  width: 76px;
  height: 76px;
  margin: -38px 0 0 -38px;
}

.cursor.open span { opacity: 1; }

.cursor.drag {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  background: rgba(30, 33, 37, 0.35);
}

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
}

/* ---------- loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  background: var(--plaster);
  z-index: 20;
  transition: opacity 0.8s ease, visibility 0.8s;
}

.loader.done { opacity: 0; visibility: hidden; }

.loader-name {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.loader-name span:first-child {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 7vw, 76px);
  letter-spacing: -0.03em;
}

.loader-name span:last-child {
  font-size: clamp(16px, 2vw, 20px);
  color: var(--graphite-soft);
}

.loader-bar {
  width: 160px;
  height: 2px;
  background: rgba(30, 33, 37, 0.1);
  overflow: hidden;
}

.loader-bar i {
  display: block;
  height: 100%;
  background: var(--graphite);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.25s ease-out;
}

/* ---------- fallback list ---------- */

.fallback {
  position: fixed;
  inset: 0;
  overflow: auto;
  padding: 96px var(--pad) 64px;
  background: var(--plaster);
  z-index: 8;
}

.fallback h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  margin: 40px 0 16px;
}

.fallback ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.fallback a { color: inherit; text-decoration: none; font-size: 14px; }
.fallback img { width: 100%; display: block; border-radius: 4px; margin-bottom: 6px; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .rooms { display: none; }
  .hint { display: none; }
}

@media (max-width: 600px) {
  .now { bottom: calc(var(--pad) + 64px); }
  .controls { left: 50%; right: auto; transform: translateX(-50%); }
  .steps { gap: 12px; }
  .step { width: 46px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .now-v.swap, .again { animation: none; }
}
