:root {
  color-scheme: light;
  --paper: #f1ebdf;
  --paper-deep: #dfd5c5;
  --card: #fffaf0;
  --ink: #172a2a;
  --ink-soft: #687572;
  --line: rgba(29, 41, 43, 0.13);
  --accent: #e96442;
  --accent-dark: #b8422b;
  --teal: #345f5c;
  --gold: #d8b36b;
  --shadow: 0 26px 70px rgba(48, 42, 32, 0.13), 0 5px 16px rgba(48, 42, 32, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 2% 3%, rgba(233, 100, 66, 0.15), transparent 24rem),
    radial-gradient(circle at 102% 34%, rgba(52, 95, 92, 0.13), transparent 27rem),
    var(--paper);
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  background-image:
    repeating-linear-gradient(112deg, rgba(23, 42, 42, 0.014) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(22deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 7px);
  content: "";
  pointer-events: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 0;
  width: min(100%, 500px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.wordmark-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  color: #fffaf0;
  background: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 5px 13px rgba(29, 41, 43, 0.20);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(251, 249, 243, 0.66);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(12px);
}

.source-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #82a17d;
  box-shadow: 0 0 0 3px rgba(130, 161, 125, 0.14);
}

.source-badge[data-mode="loading"] .source-dot {
  background: #d1a047;
  animation: pulse 0.9s ease-in-out infinite alternate;
}

.source-badge[data-mode="remote"] .source-dot {
  background: var(--teal);
}

.source-badge[data-mode="local"] .source-dot {
  background: #d88b56;
}

.intro {
  padding: 26px 4px 24px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  line-height: 1.2;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 430px;
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(39px, 11.2vw, 55px);
  font-weight: 600;
  letter-spacing: -0.052em;
  line-height: 0.91;
}

.intro h1 em {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(233, 100, 66, 0.22);
  text-decoration-thickness: 0.18em;
  text-underline-offset: -0.05em;
}

.intro-copy {
  max-width: 350px;
  margin: 15px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.wheel-card,
.ledger-card,
.fairness-card {
  border: 1px solid rgba(29, 41, 43, 0.10);
  background: rgba(251, 249, 243, 0.92);
  box-shadow: var(--shadow);
}

.wheel-card {
  position: relative;
  padding: 19px;
  overflow: hidden;
  border-color: rgba(255, 250, 240, 0.12);
  border-radius: 34px;
  background:
    radial-gradient(circle at 52% 31%, rgba(125, 174, 160, 0.23), transparent 38%),
    linear-gradient(155deg, #254945 0%, #183633 47%, #102725 100%);
  box-shadow: 0 29px 70px rgba(26, 48, 45, 0.23), 0 6px 18px rgba(26, 48, 45, 0.12);
}

.wheel-card::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 38%),
    repeating-radial-gradient(circle at 50% 46%, transparent 0 26px, rgba(255, 255, 255, 0.018) 27px 28px);
  content: "";
  pointer-events: none;
}

.round-meta {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1px 4px 13px;
}

.round-meta div {
  display: grid;
  gap: 3px;
}

.round-meta span {
  color: rgba(235, 240, 231, 0.64);
  font-size: 11px;
  font-weight: 650;
}

.round-meta strong {
  color: #fff7e8;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.round-meta small {
  color: rgba(235, 240, 231, 0.50);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.round-label {
  text-align: right;
}

.round-label strong {
  color: #e8c880;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.wheel-stage {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 354px);
  aspect-ratio: 1;
  margin: 0 auto 15px;
  place-items: center;
}

.wheel-stage::before {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  background: rgba(224, 199, 139, 0.23);
  box-shadow: 0 0 55px rgba(229, 200, 135, 0.20);
  content: "";
}

.wheel-wrap {
  position: absolute;
  inset: 4.5%;
  overflow: hidden;
  border: 5px solid #d9b96f;
  border-radius: 50%;
  background: #132a29;
  box-shadow:
    0 22px 38px rgba(3, 17, 16, 0.42),
    0 3px 0 rgba(255, 249, 228, 0.76) inset,
    0 0 0 4px #193331,
    0 0 0 7px rgba(231, 205, 145, 0.24);
}

.wheel-wrap::after {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 250, 230, 0.58);
  border-radius: inherit;
  content: "";
  pointer-events: none;
}

.wheel {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
  will-change: transform;
}

.wheel.is-spinning {
  transition: transform 3.75s cubic-bezier(0.12, 0.72, 0.08, 1);
}

.wheel-segment {
  stroke: rgba(255, 248, 226, 0.72);
  stroke-width: 1.25;
  transition: opacity 220ms ease, filter 220ms ease;
}

.wheel-letter {
  fill: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 850;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.wheel-segment.is-used,
.wheel-letter.is-used {
  opacity: 0.14;
}

.wheel-segment.is-current {
  filter: saturate(1.45) brightness(1.02);
  opacity: 1;
}

.wheel-letter.is-current {
  opacity: 1;
  fill: #fffaf1;
}

.pointer {
  position: absolute;
  z-index: 5;
  top: -1px;
  left: 50%;
  width: 38px;
  height: 48px;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 6px rgba(60, 36, 29, 0.24));
}

.pointer::before {
  position: absolute;
  top: 0;
  left: 5px;
  width: 28px;
  height: 37px;
  border: 4px solid #f8dfaa;
  border-radius: 50% 50% 47% 47%;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  content: "";
}

.pointer span {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff7e9;
}

.wheel-hub {
  position: relative;
  z-index: 4;
  display: grid;
  width: 108px;
  height: 108px;
  place-items: center;
  align-content: center;
  border: 5px solid #daba73;
  border-radius: 50%;
  background: #fff8e9;
  box-shadow: 0 9px 23px rgba(22, 33, 34, 0.3);
  color: var(--ink);
  text-align: center;
}

.wheel-hub span {
  margin-bottom: 1px;
  color: var(--teal);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wheel-hub strong {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
}

.wheel-hub.has-result {
  background: var(--accent);
  border-color: #f2d29a;
  color: #fffaf0;
  animation: result-pop 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.wheel-hub.has-result span {
  color: #ffe2d8;
}

.wheel-hub.has-result strong {
  font-size: 52px;
}

.wheel-hub.is-loading strong {
  animation: pulse 0.65s ease-in-out infinite alternate;
}

.spin-button {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px 0 23px;
  border: 0;
  border-radius: 21px;
  color: var(--ink);
  background: #fff7e7;
  box-shadow: 0 12px 27px rgba(3, 17, 16, 0.28), 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  cursor: pointer;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.02em;
  touch-action: manipulation;
  transition: transform 140ms ease, background 140ms ease, opacity 140ms ease;
}

.spin-button:active {
  transform: scale(0.985);
}

.spin-button:focus-visible,
.reset-button:focus-visible,
.dialog-actions button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(230, 95, 63, 0.42);
  outline-offset: 3px;
}

.spin-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-arrow {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: #fffaf0;
  background: var(--accent);
  font-size: 23px;
  transition: transform 180ms ease;
}

.spin-button:not(:disabled):active .button-arrow {
  transform: rotate(14deg);
}

.progress-block {
  position: relative;
  z-index: 2;
  padding: 16px 4px 2px;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: rgba(239, 241, 229, 0.68);
  font-size: 11px;
  font-weight: 700;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 250, 232, 0.14);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #e8c880);
  transition: width 500ms ease;
}

.ledger-card {
  margin-top: 16px;
  padding: 22px 18px 18px;
  border-radius: 28px;
  background: rgba(255, 250, 240, 0.88);
}

.ledger-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.ledger-heading .eyebrow {
  margin-bottom: 5px;
}

.ledger-heading h2,
.fairness-card h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.saved-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  padding: 5px 8px 5px 5px;
  border-radius: 999px;
  background: rgba(52, 95, 92, 0.08);
}

.saved-note span {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-size: 10px;
}

.letter-ledger {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.letter-chip {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #a4aaa7;
  background: rgba(242, 238, 228, 0.6);
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 17px;
  font-weight: 650;
}

.letter-chip.is-used {
  border-color: transparent;
  color: #fffaf0;
  background: var(--ink);
  box-shadow: 0 5px 10px rgba(61, 105, 102, 0.16);
}

.letter-chip.is-current {
  background: var(--accent);
  box-shadow: 0 6px 13px rgba(230, 95, 63, 0.24);
  transform: translateY(-1px);
}

.draw-order {
  position: absolute;
  top: 3px;
  right: 5px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 7px;
  font-weight: 800;
  opacity: 0.72;
}

.privacy-note {
  margin: 15px 3px 13px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}

.reset-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 740;
  touch-action: manipulation;
}

.fairness-card {
  display: flex;
  gap: 14px;
  margin-top: 16px;
  padding: 20px 19px;
  border-radius: 24px;
  border-color: rgba(52, 95, 92, 0.13);
  background: rgba(52, 95, 92, 0.075);
  box-shadow: none;
}

.fairness-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: #fffaf0;
  background: var(--teal);
  font-family: Georgia, serif;
  font-size: 27px;
}

.fairness-card h2 {
  font-size: 19px;
}

.fairness-card p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 25px 0 2px;
  color: #7d8582;
  font-size: 10px;
  font-weight: 650;
}

footer a {
  color: inherit;
  text-underline-offset: 3px;
}

.reset-dialog {
  width: min(calc(100% - 32px), 410px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 30px 90px rgba(20, 28, 28, 0.30);
}

.reset-dialog::backdrop {
  background: rgba(26, 34, 34, 0.55);
  backdrop-filter: blur(5px);
}

.reset-dialog form {
  padding: 26px 22px 21px;
  text-align: center;
}

.dialog-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 16px;
  color: var(--accent);
  background: rgba(230, 95, 63, 0.11);
  font-size: 25px;
}

.reset-dialog h2 {
  margin: 0;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 26px;
  letter-spacing: -0.04em;
}

.reset-dialog p {
  margin: 9px auto 20px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dialog-actions button {
  min-height: 50px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
}

.dialog-cancel {
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
}

.dialog-confirm {
  border: 0;
  color: #fff;
  background: var(--accent);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes pulse {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

@keyframes result-pop {
  0% { transform: scale(0.82); }
  58% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@media (min-width: 620px) {
  .app-shell {
    padding-right: 20px;
    padding-left: 20px;
  }

  .intro {
    padding-top: 42px;
  }
}

@media (max-width: 350px) {
  .source-badge {
    padding: 0 9px;
    font-size: 10px;
  }

  .wheel-card {
    padding: 15px;
    border-radius: 28px;
  }

  .letter-ledger {
    gap: 5px;
  }

  .letter-chip {
    border-radius: 10px;
  }
}

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