@font-face {
  font-family: "Cinzel";
  src: url("fonts/Cinzel.ttf") format("truetype");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #0b0908;
  --bg2: #1c1612;
  --ink: #f2e8da;
  --mut: #a39584;
  --gold: #e2b25a;
  --line: rgba(226, 178, 90, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 55%, var(--bg2) 0%, var(--bg) 70%);
}

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

#view:active { cursor: grabbing; }

.top {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.brand {
  font-family: "Cinzel", serif;
  font-weight: 600;
  letter-spacing: 0.32em;
  font-size: 15px;
  color: var(--gold);
}

.switch {
  position: absolute;
  top: max(56px, calc(env(safe-area-inset-top) + 40px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 9, 8, 0.6);
  backdrop-filter: blur(8px);
}

.switch button, .tools button {
  font: inherit;
  font-size: 13px;
  color: var(--mut);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.switch button[aria-selected="true"] {
  color: #1a1208;
  background: var(--gold);
}

.switch button:focus-visible, .tools button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.info {
  position: absolute;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(28px, env(safe-area-inset-bottom));
  max-width: 340px;
  pointer-events: none;
}

.info h1 {
  font-family: "Cinzel", serif;
  font-weight: 500;
  font-size: 26px;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
  color: var(--ink);
}

.info p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mut);
}

.tools {
  position: absolute;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
}

.tools button {
  border: 1px solid var(--line);
  background: rgba(11, 9, 8, 0.6);
}

.tools button:hover, .switch button:hover { color: var(--ink); }
.tools button[aria-pressed="true"] { color: var(--gold); }

.hint {
  position: absolute;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 6px));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  color: var(--mut);
  opacity: 0.7;
  white-space: nowrap;
  pointer-events: none;
}

#loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.4s;
}

#loader span {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

#loader.done { opacity: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .hint { display: none; }
  .info { right: 16px; left: 16px; bottom: 76px; max-width: none; text-align: center; }
  .info h1 { font-size: 20px; }
  .tools { left: 50%; right: auto; transform: translateX(-50%); bottom: max(20px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  #loader span { animation: none; }
}
