:root {
  color-scheme: dark;
  --ink: #14110e;
  --paper: rgba(20, 17, 14, 0.62);
  --line: rgba(243, 236, 224, 0.16);
  --text: #f4efe6;
  --muted: #c3b6a6;
  --brass: #e2b56a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

button,
p,
h1 {
  margin: 0;
  font: inherit;
}

#stage,
#stage canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.bar {
  position: fixed;
  z-index: 5;
  left: 1.25rem;
  right: 1.25rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-0.4rem);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

body.is-ready .bar {
  opacity: 1;
  transform: none;
}

.bar.foot {
  align-items: flex-end;
}

header.bar {
  top: 1.15rem;
}

footer.bar {
  bottom: 1.15rem;
  transform: translateY(0.4rem);
}

.brand,
.foot p {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  color: var(--brass);
  letter-spacing: 0.22em;
  font-size: 0.72rem;
}

h1 {
  font-family: "Songti SC", "STSong", "Iowan Old Style", Palatino, serif;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.actions {
  display: flex;
  gap: 0.45rem;
  pointer-events: auto;
}

button {
  pointer-events: auto;
  touch-action: manipulation;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

button:hover,
button[aria-pressed="true"] {
  border-color: rgba(226, 181, 106, 0.7);
  color: var(--brass);
}

.foot p {
  color: var(--muted);
  font-size: 0.85rem;
}

.photos {
  position: fixed;
  z-index: 5;
  top: 5.6rem;
  left: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

body.is-ready .photos {
  opacity: 1;
  pointer-events: auto;
}

.photos p {
  color: var(--brass);
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

#markers {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.pin {
  position: absolute;
  pointer-events: auto;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.2rem 0;
  border: 0;
  background: transparent;
  color: var(--text);
  backdrop-filter: none;
  border-radius: 0;
  transform: translate(-50%, -100%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.pin span:last-child {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.pin i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 4px rgba(226, 181, 106, 0.28);
}

.pin:hover,
.pin[aria-pressed="true"] {
  color: var(--brass);
}

body.is-viewing #spin,
body.is-viewing #reset,
body.is-viewing #markers {
  display: none;
}

#flat-view {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 7, 0.92);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

body.is-flat #flat-view {
  display: flex;
}

#flat-image {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  pointer-events: none;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: end start;
  padding: 8vh 8vw;
  background: #14110e center / cover no-repeat;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

#overlay .veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(20, 17, 14, 0.2), rgba(20, 17, 14, 0.78)),
    rgba(20, 17, 14, 0.28);
}

.intro {
  position: relative;
  max-width: 36rem;
}

#status {
  margin-top: 0.8rem;
  color: var(--muted);
}

body.is-ready #overlay,
body.is-viewing #overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 720px) {
  header.bar {
    top: calc(0.7rem + env(safe-area-inset-top));
    left: 0.8rem;
    right: 0.8rem;
    align-items: flex-start;
  }

  footer.bar {
    left: 0.8rem;
    right: 0.8rem;
    bottom: calc(4.4rem + env(safe-area-inset-bottom));
  }

  #full,
  .hint,
  #stats {
    display: none;
  }

  h1 {
    font-size: 1.25rem;
    letter-spacing: 0.04em;
  }

  .actions button {
    min-height: 40px;
  }

  .photos {
    top: auto;
    bottom: calc(0.55rem + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow-x: auto;
    padding: 0 0.8rem;
    gap: 0.4rem;
  }

  .photos button {
    flex: 0 0 auto;
    min-height: 44px;
  }
}
