html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #e9e9e7;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#title {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 9vh;
  box-sizing: border-box;
  pointer-events: none;
  transition: opacity 3.5s ease;
  color: #151515;
  text-align: center;
  /* Lift the lettering off the busy ink of the map, like snow drifting behind it. */
  text-shadow: 0 0 14px rgba(244, 244, 242, 0.95), 0 0 34px rgba(244, 244, 242, 0.8);
}

#title h1 {
  font-family: 'Playfair Display SC', 'Didot', 'Bodoni 72', Georgia, serif;
  font-weight: 400;
  font-size: clamp(30px, 9.5vw, 104px);
  letter-spacing: 0.08em;
  margin: 0 4vw;
  line-height: 1.05;
}

#begin {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: clamp(13px, 1.6vw, 18px);
  letter-spacing: 0.2em;
  opacity: 0.55;
  margin-top: 1.4em;
  animation: breathe 3.2s ease-in-out infinite;
}

/* The prompt waits until every system has loaded, so the first tap can unlock audio. */
#begin { visibility: hidden; }
#title.ready #begin { visibility: visible; }

#title.gone { opacity: 0; }
#title.gone #begin { animation: none; opacity: 0; }

@keyframes breathe {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.65; }
}

/* The gear: barely there until you look for it. */
#gear {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 30px;
  height: 30px;
  padding: 4px;
  border: 0;
  background: none;
  color: #1a1a1a;
  opacity: 0.16;
  cursor: pointer;
  transition: opacity 0.3s;
  z-index: 10;
}
#gear:hover, #gear:focus-visible { opacity: 0.6; }
#gear svg { width: 100%; height: 100%; display: block; }

#menu {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 36px);
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
  padding: 10px;
  background: rgba(244, 244, 242, 0.92);
  border: 1px solid rgba(40, 40, 40, 0.15);
  font: 14px Georgia, serif;
  color: #1a1a1a;
  z-index: 10;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
#menu[hidden] { display: none; }
#menu button, #menu select, #menu a {
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 1px solid rgba(40, 40, 40, 0.18);
  padding: 7px 9px;
  cursor: pointer;
  text-decoration: none;
}
#menu button:hover, #menu a:hover { background: rgba(40, 40, 40, 0.06); }
#menu label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 2px; }
#menu select { padding: 4px 6px; }

#perf {
  position: fixed;
  top: 8px;
  left: 8px;
  margin: 0;
  padding: 6px 8px;
  font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color: #111;
  background: rgba(255, 255, 255, 0.78);
  pointer-events: none;
  z-index: 9;
}
