:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1c1b22;
  --muted: #6b6878;
  --border: #e3dfd6;
  --accent: #5b4bdb;
  --accent-text: #ffffff;
  --accent-soft: #ebe8ff;
  --good: #1f9d63;
  --warn: #c2410c;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(20 16 40 / 6%), 0 8px 24px rgb(20 16 40 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121118;
    --surface: #1c1b24;
    --text: #efedf6;
    --muted: #9c98ab;
    --border: #2e2c3a;
    --accent: #8f82ff;
    --accent-text: #120f2b;
    --accent-soft: #2a2550;
    --good: #45c98b;
    --warn: #fb923c;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

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

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

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

h1 {
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

h1:focus {
  outline: none;
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0;
}

.muted {
  color: var(--muted);
}

/* Layout */

.site-header,
.site-main,
.site-footer {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding-inline: 16px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 750;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand-globe {
  font-size: 1.5rem;
}

.language-switcher {
  display: flex;
  gap: 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.language-switcher a,
.language-switcher .current {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  text-decoration: none;
}

.language-switcher a {
  color: var(--muted);
}

.language-switcher a:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.language-switcher .current {
  background: var(--text);
  color: var(--bg);
}

.site-main {
  padding-block: 1rem 3rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0.25rem 0;
}

/* Home */

.hero {
  text-align: center;
  padding-block: 2rem 2.5rem;
}

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

.challenge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.challenge-card:hover,
.challenge-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.challenge-card.featured {
  border: 2px solid var(--accent);
}

.challenge-card .challenge-emoji {
  font-size: 2.2rem;
}

.challenge-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.challenge-tagline {
  color: var(--muted);
}

.badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Challenge pages */

.back {
  margin-bottom: 1rem;
}

.back a {
  color: var(--muted);
  text-decoration: none;
}

.back a:hover {
  color: var(--text);
}

.challenge-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.challenge-header .challenge-emoji {
  display: block;
  font-size: 3rem;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.instructions {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  min-height: 1.6em;
}

.instructions.hint {
  color: var(--warn);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

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

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button.facebook {
  gap: 0.5rem;
  background: #1877f2;
  border-color: #1877f2;
  color: #fff;
}

.button.facebook svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Ten seconds */

.big-button {
  width: min(260px, 70vw);
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 1.8rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.08s ease;
}

.big-button:active {
  transform: scale(0.97);
}

.big-button.running {
  background: var(--warn);
  animation: pulse 1.6s ease-in-out infinite;
}

.big-button:disabled {
  opacity: 0.5;
  cursor: default;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 18px color-mix(in srgb, var(--warn) 18%, transparent);
  }
}

/* Perfect circle */

.draw-pad {
  --guide: var(--muted);
  --fit: var(--good);
  --ink: var(--accent);
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--bg);
  touch-action: none;
  cursor: crosshair;
}

/* Dot flash */

.dot-field {
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--bg);
}

.dot-field circle {
  fill: var(--text);
}

.dot-field text {
  fill: var(--border);
  font-size: 24px;
  font-weight: 800;
  dominant-baseline: middle;
}

.guess-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.guess-form label {
  width: 100%;
  text-align: center;
  font-weight: 600;
}

.guess-form input {
  width: 8rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.25rem;
  text-align: center;
}

.round-list {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
  color: var(--muted);
}

/* Color memory */

.swatch {
  width: min(260px, 60vw);
  aspect-ratio: 1;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%);
}

.swatch.empty {
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--border);
  font-size: 4rem;
  font-weight: 800;
}

.countdown {
  width: min(260px, 60vw);
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
  transform-origin: left;
  animation: countdown linear forwards;
}

@keyframes countdown {
  to {
    transform: scaleX(0);
  }
}

.sliders {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
}

.sliders label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.sliders input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
}

.sliders input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 35%), 0 2px 6px rgb(0 0 0 / 30%);
  cursor: grab;
}

.sliders input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 35%), 0 2px 6px rgb(0 0 0 / 30%);
  cursor: grab;
}

.swatch-pair {
  display: flex;
  gap: 1rem;
}

.swatch-pair figure {
  margin: 0;
  text-align: center;
}

.swatch-pair .swatch {
  width: min(150px, 38vw);
}

.swatch-pair figcaption {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Dead center */

.line-field {
  width: 100%;
  aspect-ratio: 2;
  border-radius: var(--radius);
  background: var(--bg);
  touch-action: manipulation;
  cursor: crosshair;
}

.target-line {
  stroke: var(--text);
  stroke-width: 6;
  stroke-linecap: round;
}

.true-middle {
  fill: none;
  stroke: var(--good);
  stroke-width: 4;
}

.your-mark {
  fill: var(--accent);
}

/* Result */

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.result-headline {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.result-detail {
  margin: -0.5rem 0 0;
  color: var(--muted);
}

.ranking {
  margin: 0;
  font-size: 1.15rem;
}

.meter {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: var(--accent-soft);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  transition: width 0.8s ease-out;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.share-status {
  margin: 0;
  color: var(--good);
  font-weight: 600;
}

/* Text pages */

.prose {
  max-width: 640px;
  margin: 2rem auto;
}

/* Blazor */

#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  background: #fde68a;
  color: #1c1b22;
  box-shadow: 0 -1px 4px rgb(0 0 0 / 20%);
}

#blazor-error-ui .dismiss {
  position: absolute;
  right: 0.75rem;
  top: 0.6rem;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }

  .big-button.running {
    animation: none;
  }
}

/* Account */

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.account-link {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.account-link:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.account .actions {
  margin-top: 1.5rem;
}

.account form {
  display: contents;
}

.notice {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--warn);
  border-radius: 12px;
  color: var(--warn);
  font-weight: 600;
}

.records {
  list-style: none;
  margin: 0;
  padding: 0;
}

.records li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.records a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.record-best {
  font-weight: 650;
  text-align: right;
}

.record-plays {
  grid-column: 2;
  font-size: 0.85rem;
  text-align: right;
}

.new-record {
  margin: 0.25rem 0;
  color: var(--accent);
  font-weight: 750;
}

.account-link {
  max-width: 14rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.account-link.sign-in {
  background: var(--accent);
  color: var(--accent-text);
}

.account-link.sign-in:hover {
  background: var(--accent);
  color: var(--accent-text);
  opacity: 0.9;
}

.sign-in-hint {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  text-align: center;
}

.record-play {
  justify-self: end;
  min-height: 36px;
  padding: 0.35rem 1rem;
}

/* Shared result */

.shared-result {
  max-width: 560px;
  margin: 0 auto;
  padding-block: 2rem 3rem;
  text-align: center;
}

.shared-challenge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.shared-result h1 {
  margin-block: 0.5rem 1rem;
}

.shared-result .meter {
  margin-block: 0.5rem 1.5rem;
}

.shared-result .actions {
  justify-content: center;
}
