/* Spinmoji — shared styles. The blue is the site's identity, so it stays
   the same in light and dark mode. */

:root {
  --blue: #1565FF;
  --blue-dark: #0D4FD6;
  --blue-deep: #0B3BA8;
  --pale: #E6EEFF;
  --yellow: #FFD23F;
  --navy: #0B1F4D;
  --muted: #5B6B8C;
  --white: #FFFFFF;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --emoji-font: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Segoe UI Symbol', sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--blue);
  color: var(--white);
  font-family: var(--font);
  line-height: 1.4;
  overflow-x: hidden;
}

a { color: inherit; }

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

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

/* ── Header and footer ─────────────────────────────────── */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 64px 10px;
}

.wordmark {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.wordmark a { text-decoration: none; }

.sound-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
  cursor: pointer;
}

.sound-toggle svg { display: block; width: 24px; height: 24px; }
.sound-toggle .icon-sound-on { display: none; }
.sound-toggle.is-on .icon-sound-on { display: block; }
.sound-toggle.is-on .icon-sound-off { display: none; }

.site-footer {
  margin-top: auto;
  padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

/* ── Home: wheel ───────────────────────────────────────── */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Mobile: the wheel is wider than the screen, its center at the top edge
   of the wrap, so only the lower half shows. */
.wheel-wrap {
  --D: 160vw;
  position: relative;
  width: 100%;
  height: calc(var(--D) / 2 + 20px);
  overflow: hidden;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wheel {
  position: absolute;
  left: 50%;
  top: calc(var(--D) / -2);
  width: var(--D);
  height: var(--D);
  margin-left: calc(var(--D) / -2);
  will-change: transform;
}

.wheel svg { display: block; width: 100%; height: 100%; overflow: visible; }

.wheel .seg-a { fill: var(--white); }
.wheel .seg-b { fill: var(--pale); }
.wheel .divider { stroke: var(--blue); stroke-width: 0.6; }
.wheel .rim { fill: none; stroke: var(--blue-deep); stroke-width: 3; }
.wheel .hub { fill: var(--blue); stroke: var(--blue-deep); stroke-width: 1.5; }
.wheel .hub-dot { fill: var(--white); }

.wheel .seg-emoji {
  font-family: var(--emoji-font);
  font-size: 16px;
  text-anchor: middle;
  dominant-baseline: central;
}

.pointer {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 44px;
  height: 58px;
  margin-left: -22px;
  transform-origin: 50% 75%;
  filter: drop-shadow(0 2px 3px rgba(11, 31, 77, 0.35));
  pointer-events: none;
}

@media (min-width: 600px) {
  .wheel-wrap {
    /* Also shrink on short windows so the Spin button stays in view. */
    --D: max(300px, min(520px, 86vw, calc(100vh - 290px)));
    height: calc(var(--D) + 20px);
  }
  .wheel { top: 0; }
}

/* ── Home: result and button ───────────────────────────── */

.result {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  padding: 8px 16px 4px;
}

.result-emoji {
  font-family: var(--emoji-font);
  font-size: 72px;
  line-height: 1;
}

.result-emoji.pop { animation: pop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4); }

@keyframes pop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}

.result-hint {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
}

.result-hint[hidden] { display: none; }

.spin-button {
  min-width: 220px;
  padding: 18px 48px;
  border: 0;
  border-radius: 999px;
  background: var(--white);
  color: var(--blue);
  font: 800 26px/1 var(--font);
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--blue-deep), 0 10px 24px rgba(11, 31, 77, 0.25);
  transition: transform 80ms ease, box-shadow 80ms ease, opacity 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.spin-button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--blue-deep), 0 4px 12px rgba(11, 31, 77, 0.25);
}

.spin-button:disabled { opacity: 0.6; cursor: default; }

.spin-message {
  min-height: 1.4em;
  margin: 16px 16px 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.stats-link {
  margin-top: 10px;
  padding: 8px 14px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* ── Stats page ────────────────────────────────────────── */

.stats {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 4px 16px 8px;
}

.back-link {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
}

.range {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.range button {
  flex: 1;
  padding: 10px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--white);
  font: 700 15px/1 var(--font);
  cursor: pointer;
}

.range button[aria-pressed="true"] {
  background: var(--white);
  color: var(--blue);
}

.card {
  margin: 0 0 16px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy);
  box-shadow: 0 8px 24px rgba(11, 31, 77, 0.18);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
}

.card .scope {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.card p { margin: 0; }

.big-number {
  font-size: 48px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--blue);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2 .card { margin: 0; }

@media (min-width: 600px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.emoji { font-family: var(--emoji-font); }

.emoji-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 34px;
  line-height: 1.1;
}

.emoji-row + .detail { margin-top: 6px; }

.detail { font-size: 14px; color: var(--muted); }

.verdict { font-size: 18px; font-weight: 700; }
.verdict.is-fair { color: #0E7A3E; }
.verdict.is-uneven { color: #B3261E; }

.chart { min-height: 200px; margin: 0 -6px; }

.table-wrap { overflow-x: auto; margin: 12px -4px 0; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.table th, .table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--pale);
}

.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.table td.emoji { font-size: 22px; }
.table .pos { color: #0E7A3E; }
.table .neg { color: #B3261E; }

.overdue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.overdue li {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--pale);
}

.overdue .emoji { font-size: 28px; line-height: 1.1; }
.overdue .since { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 28px;
  line-height: 1.2;
}

.empty {
  padding: 40px 18px;
  text-align: center;
}

.empty p { font-size: 20px; font-weight: 700; }
.empty a { display: inline-block; margin-top: 14px; font-weight: 700; color: var(--blue); }

.notice { font-size: 15px; color: var(--muted); }

.error-card { color: #B3261E; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .result-emoji.pop { animation-duration: 1ms; }
  .spin-button { transition: none; }
}
