:root {
  color-scheme: light dark;
  --background: #f7f7f7;
  --surface: #ffffff;
  --foreground: #222222;
  --muted: #6a6a6a;
  --border: #dddddd;
  --rausch: #ff385c;
  --shadow-card: 0 6px 16px rgba(0, 0, 0, 0.12);
  --shadow-button: 0 2px 8px rgba(230, 30, 77, 0.35);
  --shadow-button-hover: 0 4px 14px rgba(230, 30, 77, 0.45);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0f0f0f;
    --surface: #1c1c1c;
    --foreground: #f7f7f7;
    --muted: #a0a0a0;
    --border: #2f2f2f;
    --shadow-card: 0 6px 16px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Normal game layouts fit the viewport; very short layouts can scroll below. */
html.no-scroll,
html.no-scroll body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 2px;
}

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

/* Shared header */

.site-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  padding-left: max(env(safe-area-inset-left), clamp(16px, 5vw, 40px));
  padding-right: max(env(safe-area-inset-right), clamp(16px, 5vw, 40px));
  padding-top: env(safe-area-inset-top);
}

.site-header__inner {
  max-width: 56rem;
  margin: 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  min-width: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wordmark__mark {
  color: var(--rausch);
}

.site-nav {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}

.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}

.site-nav a[aria-current="page"] {
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

@media (max-width: 360px) {
  .site-header__inner {
    gap: 8px;
  }

  .site-nav a {
    padding: 8px;
    font-size: 0.875rem;
  }
}

/* Game page */

.game {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3dvh, 24px);
  padding-top: clamp(12px, 3dvh, 24px);
  padding-right: max(env(safe-area-inset-right), clamp(16px, 5vw, 40px));
  padding-bottom: max(env(safe-area-inset-bottom), clamp(12px, 3dvh, 24px));
  padding-left: max(env(safe-area-inset-left), clamp(16px, 5vw, 40px));
}

.game__top {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
}

.game__title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.game__subtitle {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 12px;
  margin: 0;
}

.stat {
  min-width: 5rem;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat dt {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat dd {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.board {
  position: relative;
  flex: 1;
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.board__inset {
  position: absolute;
  inset: 12px;
}

.board__message {
  margin: 0;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

.target {
  position: absolute;
  width: min(140px, 100%);
  height: min(48px, 100%);
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #e61e4d 0%, #e31c5f 50%, #d70466 100%);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow-button);
  transition: transform 150ms ease, box-shadow 150ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.target:active {
  transform: scale(0.95);
}

.game__bottom {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.reset {
  margin-left: auto;
  flex-shrink: 0;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 600;
  color: var(--foreground);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: background-color 150ms ease;
}

@media (max-height: 500px) {
  .site-header__inner {
    min-height: 44px;
  }

  .game {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
  }

  .game__top {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .game__title {
    font-size: clamp(0.875rem, 3vw, 1.25rem);
  }

  .game__subtitle,
  .game__hint {
    display: none;
  }

  .stat {
    min-width: 3.5rem;
    padding: 4px 8px;
  }

  .stat dd {
    font-size: 1.25rem;
  }
}

/* About page */

.about {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(32px, 8vh, 80px) max(env(safe-area-inset-right), 24px)
    max(env(safe-area-inset-bottom), 64px) max(env(safe-area-inset-left), 24px);
}

.about h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.about .lede {
  margin: 0 0 40px;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--muted);
}

.about h2 {
  margin: 36px 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.about p {
  margin: 0 0 16px;
  font-size: 1.0625rem;
  line-height: 1.65;
}

.about .cta {
  display: inline-block;
  margin-top: 24px;
  padding: 14px 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e61e4d 0%, #e31c5f 50%, #d70466 100%);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-button);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.about .cta:active {
  transform: scale(0.97);
}

.site-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 16px;
  padding: 4px max(env(safe-area-inset-right), 16px)
    max(env(safe-area-inset-bottom), 8px) max(env(safe-area-inset-left), 16px);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}

.site-footer a,
.site-footer button {
  padding: 6px 0;
  text-underline-offset: 3px;
}

.site-footer button {
  border: 0;
  background: transparent;
  text-decoration: underline;
}

.site-footer [data-privacy-settings][hidden] {
  display: inline-block;
  visibility: hidden;
}

/* Allocate clearance before consent/ad loading, including when an ad is blocked or dismissed. */
.ads-eligible .site-footer {
  margin-bottom: 180px;
}

.privacy-dialog {
  width: min(28rem, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--foreground);
  box-shadow: var(--shadow-card);
}

.privacy-dialog h2 {
  margin-top: 0;
}

.privacy-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* Preserve usable controls at high zoom or in unusually short viewports. */
@media (max-height: 360px), (max-width: 280px) {
  html.no-scroll,
  html.no-scroll body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .game {
    flex: none;
    min-height: 260px;
  }
}

/* Touch devices keep :hover after a tap; only apply hover effects with a real pointer. */
@media (hover: hover) {
  .site-nav a:hover {
    background: color-mix(in srgb, var(--foreground) 6%, transparent);
    color: var(--foreground);
  }

  .target:hover {
    transform: scale(1.04);
    box-shadow: var(--shadow-button-hover);
  }

  .reset:hover {
    background: color-mix(in srgb, var(--foreground) 6%, transparent);
  }

  .about .cta:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-button-hover);
  }
}

@media (prefers-reduced-motion: reduce) {
  .target,
  .about .cta,
  .site-nav a,
  .reset {
    transition: none;
  }

  .target:hover,
  .target:active,
  .about .cta:hover,
  .about .cta:active {
    transform: none;
  }
}
