:root {
  --bg: #10140e;
  --bg-2: #181e14;
  --ink: #ebe6d8;
  --muted: #a39b88;
  --line: #3a4134;
  --brass: #d7b57a;
  --brass-deep: #8d6b3a;
  --sea: #8fbfb0;
  --rose: #c17b6b;
  --card: #141a11;
  --shadow: rgba(0, 0, 0, 0.45);
  --rhumb: rgba(215, 181, 122, 0.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3ead7;
  --bg-2: #fff8ec;
  --ink: #1c2218;
  --muted: #5c564a;
  --line: #d2c4a6;
  --brass: #8a6230;
  --brass-deep: #5c3e18;
  --sea: #1e5c4e;
  --rose: #8d3f34;
  --card: #fffaf1;
  --shadow: rgba(62, 44, 18, 0.14);
  --rhumb: rgba(92, 62, 24, 0.055);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background-color: var(--bg);
  background-image:
    linear-gradient(30deg, transparent 0 49.4%, var(--rhumb) 49.4% 50.6%, transparent 50.6%),
    linear-gradient(150deg, transparent 0 49.4%, var(--rhumb) 49.4% 50.6%, transparent 50.6%);
  background-size: 84px 84px;
}

a { color: var(--sea); }

a:hover { color: var(--ink); }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--brass);
  color: #14180f;
  padding: 0.4rem 0.7rem;
  z-index: 20;
}

.skip:focus { top: 1rem; }

.frame {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--bg);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.mark {
  width: 42px;
  height: 42px;
  flex: none;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.theme {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  cursor: pointer;
}

.theme:hover { border-color: var(--brass); }

.theme:focus-visible,
.marks a:focus-visible,
.phone:focus-visible,
.bowl:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(260px, 1fr);
  gap: 2.5rem 3rem;
  align-items: center;
  padding-top: 2rem;
}

.instrument { min-width: 0; }

.bowl {
  position: relative;
  width: min(100%, 440px);
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, var(--bg-2), var(--card) 62%, #0c100b 100%);
  box-shadow:
    inset 0 0 0 10px var(--brass-deep),
    inset 0 0 0 12px var(--brass),
    inset 0 0 0 14px var(--brass-deep),
    0 18px 40px var(--shadow);
  touch-action: none;
  cursor: grab;
  user-select: none;
}

[data-theme="light"] .bowl {
  background: radial-gradient(circle at 50% 42%, #fffdf8, #f6edd9 70%, #e7dcc4 100%);
}

.bowl:active { cursor: grabbing; }

.card,
.fixed {
  position: absolute;
  inset: 7%;
  width: 86%;
  height: 86%;
}

.card {
  transition: transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

.fixed { pointer-events: none; }

.tick { stroke: var(--line); stroke-width: 1; }
.tick-major { stroke: var(--muted); stroke-width: 1.5; }
.tick-card { stroke: var(--brass); stroke-width: 2.4; }

.rose-label {
  fill: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.rose-card {
  fill: var(--brass);
  font-size: 18px;
  font-weight: 650;
}

.rose-num {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.ring { fill: none; stroke: var(--line); stroke-width: 1; }
.ring-brass { stroke: var(--brass); stroke-width: 1.25; opacity: 0.7; }

.lubber { fill: var(--rose); }
.needle-n { stroke: var(--brass); stroke-width: 3; stroke-linecap: round; }
.needle-s { stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.pivot { fill: var(--ink); stroke: var(--brass); stroke-width: 2; }

.medal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--brass);
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 8px 20px var(--shadow);
}

.medal b {
  display: block;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.45rem;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.medal span {
  display: block;
  margin-top: 0.15rem;
  color: var(--brass);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hint,
.status {
  margin: 0.85rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.phone {
  display: none;
  margin: 0.8rem auto 0;
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

.phone.is-available { display: block; }
.phone:hover { border-color: var(--brass); }
.phone[aria-pressed="true"] {
  border-color: var(--sea);
  color: var(--sea);
}

.reading { min-width: 0; }

.kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
}

.reading h2 {
  margin: 0.35rem 0 0.8rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2rem, 4vw, 3.1rem);
  letter-spacing: -0.03em;
  line-height: 1;
}

.reading p {
  margin: 0;
  max-width: 38rem;
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.55;
}

.lede {
  margin: 1.4rem 0 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.marks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.4rem;
}

.marks a {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--card) 80%, transparent);
}

.marks a:hover { color: var(--ink); border-color: var(--brass); }

.marks a[aria-current="true"] {
  color: var(--ink);
  border-color: var(--brass);
  background: color-mix(in srgb, var(--brass) 18%, var(--card));
}

.bearing { display: none; }

html:not(.js) .bearing:target,
html:not(.js):not(:has(.bearing:target)) #b0 { display: block; }

.js .bearing.is-on { display: block; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.foot p { margin: 0; }

.lost {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem 1rem;
}

.lost h1 {
  letter-spacing: 0.08em;
  font-size: clamp(2rem, 6vw, 3.4rem);
}

.lost p {
  font-family: var(--serif);
  font-size: 1.2rem;
  max-width: 28rem;
  margin: 0.8rem auto 1.4rem;
}

.lost a.home {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--brass);
  padding-bottom: 0.1rem;
}

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; gap: 1.6rem; }
  .reading { text-align: left; }
  .top { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}
