:root {
  color-scheme: light;
  --ink: #282b2d;
  --muted: #73756f;
  --paper: #e8e5dd;
  --paper-deep: #d8d3c8;
  --console: #bdb7a9;
  --console-dark: #77766d;
  --metal-light: #e9e9e3;
  --metal-mid: #b8b9b2;
  --metal-dark: #6b6d69;
  --line: rgba(44, 46, 44, 0.28);
  --accent: #a35f3f;
  --accent-dark: #70402d;
  --shadow: rgba(35, 36, 33, 0.24);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 300px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.74), transparent 42rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 42%), var(--paper);
  overscroll-behavior-y: none;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.page-shell {
  display: flex;
  width: calc(100% - 40px);
  max-width: 1080px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  flex-direction: column;
}

.topbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand span {
  color: var(--muted);
  font-weight: 600;
}

.version-label {
  font-variant-numeric: tabular-nums;
}

.main-content {
  display: grid;
  flex: 1;
  align-items: center;
  min-width: 0;
  gap: clamp(28px, 7vw, 84px);
  grid-template-columns: minmax(210px, 0.72fr) minmax(360px, 1fr);
  padding: clamp(44px, 7vw, 88px) 0 clamp(48px, 7vw, 84px);
}

.intro-copy {
  max-width: 360px;
  min-width: 0;
  align-self: center;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.4;
}

h1 {
  max-width: 320px;
  margin: 0 0 24px;
  font-size: clamp(42px, 5vw, 68px);
  font-weight: 760;
  letter-spacing: -0.07em;
  line-height: 0.98;
}

.intro-text {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.wheel-console {
  width: 100%;
  max-width: 540px;
  min-width: 0;
  justify-self: center;
}

.console-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.spin-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.05em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--console-dark);
  box-shadow: 0 0 0 3px rgba(119, 118, 109, 0.13);
}

.wheel-console.is-spinning .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(163, 95, 63, 0.18);
}

.wheel-stage {
  position: relative;
  display: grid;
  width: clamp(320px, calc(100vh - 380px), 540px);
  width: clamp(320px, calc(100dvh - 380px), 540px);
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  place-items: center;
  border: 1px solid rgba(46, 48, 46, 0.35);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.17), transparent 55%), #8f8e84;
  box-shadow:
    0 18px 32px rgba(49, 49, 44, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -8px 18px rgba(33, 34, 31, 0.24);
  isolation: isolate;
  touch-action: none;
}

.wheel-stage::before,
.wheel-stage::after {
  position: absolute;
  z-index: -1;
  border-radius: inherit;
  content: '';
}

.wheel-stage::before {
  inset: 7%;
  border: 1px solid rgba(238, 237, 227, 0.24);
  box-shadow: inset 0 0 0 1px rgba(39, 40, 38, 0.22);
}

.wheel-stage::after {
  inset: 3.4%;
  border: 1px solid rgba(25, 26, 24, 0.28);
}

.reading-head {
  position: absolute;
  z-index: 7;
  top: 2.6%;
  left: 50%;
  width: 50px;
  height: 50px;
  transform: translateX(-50%);
  pointer-events: none;
}

.reading-head-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 24px;
  transform: translateX(-50%);
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(82, 45, 32, 0.2);
}

.reading-head-tip {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 7px solid transparent;
  border-bottom: 11px solid var(--accent);
  border-left: 7px solid transparent;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 1px rgba(44, 30, 24, 0.3));
}

.reading-head.is-flashing .reading-head-line,
.reading-head.is-flashing .reading-head-tip {
  filter: brightness(1.25) drop-shadow(0 2px 2px rgba(44, 30, 24, 0.34));
}

.ball-orbit {
  position: absolute;
  z-index: 6;
  inset: 10%;
  border-radius: 50%;
  transform: rotate(0rad);
  pointer-events: none;
  will-change: transform;
}

.ball-orbit::before {
  position: absolute;
  inset: -1px;
  border: 1px solid rgba(31, 33, 31, 0.24);
  border-radius: inherit;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    0 1px 1px rgba(32, 33, 31, 0.22);
  content: '';
}

.orbit-ball {
  position: absolute;
  top: 0;
  left: 50%;
  width: clamp(9px, 3.4%, 15px);
  aspect-ratio: 1;
  border: 1px solid rgba(48, 49, 46, 0.52);
  border-radius: 50%;
  background: radial-gradient(
    circle at 32% 28%,
    #fffef6 0 12%,
    #deddd3 30%,
    #888a84 72%,
    #555853 100%
  );
  box-shadow:
    0 3px 5px rgba(26, 27, 25, 0.46),
    inset 1px 1px 1px rgba(255, 255, 255, 0.78);
  transform: translate(-50%, -50%);
}

.wheel-console.is-spinning .orbit-ball {
  box-shadow:
    0 3px 7px rgba(26, 27, 25, 0.56),
    0 0 8px rgba(248, 245, 229, 0.38),
    inset 1px 1px 1px rgba(255, 255, 255, 0.78);
}

.wheel {
  position: relative;
  z-index: 3;
  width: 86%;
  aspect-ratio: 1;
  border-radius: 50%;
  outline: none;
  transform: rotate(0rad);
  transform-origin: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}

.wheel:focus-visible {
  box-shadow: 0 0 0 4px rgba(163, 95, 63, 0.38);
}

.wheel-shadow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #555752;
  box-shadow:
    12px 16px 16px rgba(36, 37, 34, 0.32),
    -2px -3px 5px rgba(245, 244, 235, 0.16);
}

.wheel-face {
  position: absolute;
  inset: 4%;
  overflow: hidden;
  border: 2px solid #686a65;
  border-radius: 50%;
  background: var(--metal-mid);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.64),
    inset 0 -8px 15px rgba(65, 66, 62, 0.3),
    0 2px 0 rgba(255, 255, 255, 0.18);
}

.wheel-brushed-metal {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background:
    repeating-radial-gradient(
      circle at 50% 50%,
      transparent 0 7px,
      rgba(255, 255, 255, 0.1) 7.5px 8px,
      transparent 8.5px 15px
    ),
    radial-gradient(circle at 36% 25%, rgba(255, 255, 255, 0.85), transparent 34%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.18), transparent 55%);
  pointer-events: none;
}

.tick-layer,
.number-layer {
  position: absolute;
  inset: 0;
}

.tick,
.number {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  transform-origin: center;
}

.tick {
  width: 3px;
  height: 16px;
  margin: -8px 0 0 -1.5px;
  border-radius: 99px;
  background: #585b57;
  box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.35);
}

.tick.is-major {
  width: 4px;
  height: 24px;
  margin-top: -12px;
  background: #3f4441;
}

.tick.is-hot {
  background: var(--accent);
  box-shadow: 0 0 7px rgba(163, 95, 63, 0.82);
}

.number {
  width: 32px;
  height: 25px;
  margin: -12.5px 0 0 -16px;
  color: #353a38;
  font-size: clamp(13px, 2.5vw, 18px);
  font-weight: 800;
  letter-spacing: -0.06em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.number:nth-child(5n + 1) {
  color: #292d2b;
}

.inner-ring {
  position: absolute;
  inset: 29%;
  border: 1px solid rgba(52, 55, 52, 0.48);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.72), transparent 24%),
    linear-gradient(145deg, #8c8e88, #c9c9c1 45%, #777a74);
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.48),
    inset 0 -7px 11px rgba(43, 45, 42, 0.31),
    0 1px 2px rgba(35, 35, 33, 0.36);
}

.center-rotor {
  position: absolute;
  inset: 36%;
  border: 2px solid #575b57;
  border-radius: 50%;
  background: linear-gradient(145deg, #d2d2ca, #777a74 68%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.75),
    inset 0 -4px 5px rgba(38, 39, 36, 0.3),
    0 2px 2px rgba(35, 36, 33, 0.3);
}

.rotor-slot {
  position: absolute;
  top: 27%;
  left: 50%;
  width: 35%;
  height: 8%;
  border-radius: 99px;
  background: #4c514e;
  transform: translateX(-50%) rotate(-16deg);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.32);
}

.rotor-bolt {
  position: absolute;
  inset: 39%;
  border-radius: 50%;
  background: #565a56;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.5),
    0 1px 1px rgba(30, 31, 29, 0.4);
}

.readout {
  margin: 16px 0 12px;
  text-align: center;
}

.readout-label,
.mechanical-note,
.result-text {
  margin: 0;
}

.readout-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.result-text {
  margin-top: 5px;
  color: var(--ink);
  font-size: clamp(23px, 4vw, 31px);
  font-weight: 750;
  letter-spacing: -0.05em;
}

.mechanical-note {
  min-height: 1.5em;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.controls button {
  min-height: 44px;
  border-radius: 3px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.controls button:hover {
  transform: translateY(-1px);
}

.controls button:focus-visible {
  outline: 3px solid rgba(163, 95, 63, 0.32);
  outline-offset: 2px;
}

.primary-button {
  min-width: 150px;
  padding: 0 18px;
  color: #f8f5eb;
  background: var(--accent-dark);
  border-color: var(--accent-dark) !important;
}

.primary-button:hover {
  background: #5e3525;
}

.secondary-button {
  min-width: 92px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.24);
}

.secondary-button:hover {
  border-color: var(--accent);
}

.interaction-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.hint-mark {
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1;
}

.page-footer {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.page-footer a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.page-footer a:hover {
  color: var(--accent-dark);
}

@media (min-width: 821px) and (max-height: 820px) {
  .main-content {
    padding: 24px 0 28px;
  }

  .wheel-console {
    max-width: 480px;
  }
}

@media (max-width: 820px) {
  .main-content {
    grid-template-columns: 1fr;
    align-content: start;
    justify-items: center;
    padding-top: 48px;
  }

  .intro-copy {
    width: 100%;
    max-width: 540px;
    justify-self: center;
    text-align: center;
  }

  h1,
  .intro-text {
    margin-right: auto;
    margin-left: auto;
  }

  .wheel-console {
    width: 100%;
    max-width: 540px;
  }

  .wheel-stage {
    width: clamp(260px, calc(100vh - 190px), 420px);
    width: clamp(260px, calc(100dvh - 190px), 420px);
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: calc(100% - 28px);
    max-width: 540px;
  }

  .topbar {
    min-height: 58px;
    font-size: 10px;
  }

  .main-content {
    gap: 20px;
    padding: 24px 0 30px;
  }

  .eyebrow {
    margin-bottom: 8px;
    font-size: 9px;
  }

  h1 {
    margin-bottom: 10px;
    font-size: clamp(34px, 10vw, 46px);
  }

  .intro-text {
    max-width: 280px;
    font-size: 14px;
    line-height: 1.7;
  }

  .console-topline {
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 10px;
    font-size: 8px;
  }

  .readout {
    margin-top: 12px;
  }

  .controls {
    width: 100%;
  }

  .controls button {
    flex: 1;
  }

  .page-footer {
    min-height: 68px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
  }
}

@media (max-width: 560px) and (max-height: 680px) {
  .main-content {
    gap: 18px;
    padding-top: 20px;
    padding-bottom: 24px;
  }

  .wheel-stage {
    max-width: 380px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .controls button:hover {
    transform: none;
  }
}
