/* thumbpower.org — screen-print arcade.
 *
 * The look: riso inks on cool bone paper. Hard 2px ink outlines, hard offset
 * shadows with no blur (a print misregistration, not a drop shadow), halftone
 * dot fields. No webfonts anywhere — a games site cannot afford a font
 * round-trip, and a silent fallback would wreck the type.
 */

:root {
  /* inks */
  --paper: #f3f1ea;
  --paper-2: #fffefa;
  --paper-sunk: #e6e3d9;
  --ink: #16181c;
  --ink-soft: #5a5f68;
  --blue: #2c46e8;
  --coral: #ff4b33;
  --mustard: #ffc02e;
  --mint: #17c29a;

  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-press: 1px 1px 0 var(--ink);
  --border: 2px solid var(--ink);
  --radius: 14px;

  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;

  --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.85rem);
  --step-0: clamp(0.98rem, 0.95rem + 0.15vw, 1.05rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
  --step-2: clamp(1.6rem, 1.35rem + 1.2vw, 2.4rem);
  --step-3: clamp(2.3rem, 1.7rem + 3vw, 4.2rem);

  --gutter: clamp(1rem, 4vw, 2rem);
  --page: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101218;
    --paper-2: #191c24;
    --paper-sunk: #0a0c11;
    --ink: #f3f1ea;
    --ink-soft: #a7adb8;
    --blue: #6d80ff;
    --coral: #ff6d58;
    --mustard: #ffcb4d;
    --mint: #29d9ae;
  }
}

/* The viewer's toggle must win over the media query in both directions. */
:root[data-theme='dark'] {
  --paper: #101218;
  --paper-2: #191c24;
  --paper-sunk: #0a0c11;
  --ink: #f3f1ea;
  --ink-soft: #a7adb8;
  --blue: #6d80ff;
  --coral: #ff6d58;
  --mustard: #ffcb4d;
  --mint: #29d9ae;
}

:root[data-theme='light'] {
  --paper: #f3f1ea;
  --paper-2: #fffefa;
  --paper-sunk: #e6e3d9;
  --ink: #16181c;
  --ink-soft: #5a5f68;
  --blue: #2c46e8;
  --coral: #ff4b33;
  --mustard: #ffc02e;
  --mint: #17c29a;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* Vertical scroll only: kills pinch-zoom and double-tap-zoom sitewide without
   * touching normal scrolling. This has to live here, not only on .stage —
   * fast, imprecise tapping during play routinely lands a touch a few pixels
   * outside the stage's own box, and the browser's own gesture recognizer
   * decides on zoom before any JS on the page ever sees the event. iOS Safari
   * has ignored user-scalable=no in the viewport meta since iOS 10 specifically
   * so pages can't lock out zoom for accessibility reasons — touch-action is
   * the one mechanism it still honours, so it carries the whole fix. */
  touch-action: pan-y;
}

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* halftone, used sparingly: hero and thumbnails */
.halftone {
  background-image: radial-gradient(var(--ink) 1px, transparent 1.6px);
  background-size: 8px 8px;
  opacity: 0.14;
}

.wrap {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* --- header ---------------------------------------------------------------- */

.masthead {
  border-bottom: var(--border);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
}

.wordmark svg {
  display: block;
  flex: none;
}

.wordmark-text {
  font-size: var(--step-1);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1;
  text-transform: uppercase;
}

.wordmark-text i {
  font-style: normal;
  color: var(--coral);
}

.wordmark-tld {
  font-size: 0.62em;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- buttons and chips ----------------------------------------------------- */

.btn {
  appearance: none;
  font: inherit;
  font-weight: 800;
  letter-spacing: -0.01em;
  border: var(--border);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  padding: 0.6rem 1.1rem;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 90ms ease, box-shadow 90ms ease;
  text-decoration: none;
}

.btn:hover {
  transform: translate(1px, 1px);
  box-shadow: var(--shadow-press);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-primary {
  background: var(--blue);
  color: var(--paper-2);
}

.btn-play {
  background: var(--coral);
  color: #fffefa;
}

.btn-ghost {
  box-shadow: none;
  border-color: transparent;
  min-height: 40px;
  padding: 0.4rem 0.7rem;
}

.btn-ghost:hover {
  border-color: var(--ink);
  transform: none;
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: var(--step--1);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.chip-draw {
  background: var(--coral);
  color: #fffefa;
}
.chip-tap {
  background: var(--mustard);
  color: #16181c;
}
.chip-hold {
  background: var(--blue);
  color: #fffefa;
}
.chip-guess {
  background: var(--mint);
  color: #06251d;
}
.chip-type {
  background: var(--paper-sunk);
  color: var(--ink);
}
.chip-swipe {
  background: var(--paper-2);
  color: var(--ink);
}
.chip-daily {
  background: transparent;
  border-style: dashed;
}
.chip-soon {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--ink-soft);
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* --- hero ------------------------------------------------------------------ */

.hero {
  position: relative;
  border-bottom: var(--border);
  overflow: hidden;
  background: var(--paper-2);
}

.hero .halftone {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  display: grid;
  gap: 1.4rem;
  padding-block: clamp(1.6rem, 5vw, 3.2rem);
}

h1 {
  margin: 0;
  font-size: var(--step-3);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.94;
  text-wrap: balance;
  max-width: 22ch;
}

h1 em {
  font-style: normal;
  color: var(--coral);
}

.lede {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 600;
  max-width: 46ch;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

/* --- sections and grid ----------------------------------------------------- */

section {
  padding-block: clamp(1.6rem, 5vw, 2.8rem);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

h2 {
  margin: 0;
  font-size: var(--step-2);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  text-wrap: balance;
}

h3 {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.section-note {
  margin: 0;
  color: var(--ink-soft);
  max-width: 60ch;
  font-weight: 500;
}

.grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr;
}

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

@media (min-width: 1000px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- game card ------------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 110ms ease, box-shadow 110ms ease;
}

a.card:hover {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-press);
}

.card-art {
  position: relative;
  aspect-ratio: 16 / 10;
  border-bottom: var(--border);
  background: var(--paper-sunk);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-art .halftone {
  position: absolute;
  inset: 0;
}

.card-art svg {
  position: relative;
  width: 68%;
  height: 68%;
  overflow: visible;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1rem 1rem;
  flex: 1;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.card-blurb {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 500;
  flex: 1;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: var(--step--1);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

.card-cta {
  color: var(--blue);
}

.card.is-soon {
  box-shadow: none;
  background: transparent;
  border-style: dashed;
}

.card.is-soon .card-art {
  border-bottom-style: dashed;
  background: transparent;
}

.card.is-soon .card-art svg {
  opacity: 0.42;
}

/* --- game page ------------------------------------------------------------- */

.game-main {
  display: grid;
  gap: 1.2rem;
  padding-block: 1.2rem 6.5rem;
}

.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  justify-content: space-between;
}

.stage {
  position: relative;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--paper-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  aspect-ratio: 1;
  margin-inline: auto;
  touch-action: none;
  /* A drag on the canvas is game input, never text selection or the iOS
   * long-press "Select/Copy/Look Up" callout — several games are held or
   * dragged (nerve, wake, perfect-circle's stroke), and without this a hold
   * reads as a selection gesture instead of a press. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Size from the width only, so the box stays square and the drawing space is
   * never distorted. A max-height on an aspect-ratio box clips one axis, which
   * silently turns a circle into an ellipse. The 240px floor keeps the stage
   * playable in viewports where vh resolves to nothing. */
  width: min(100%, max(240px, min(70vh, 560px)));
  /* vh is the layout viewport, which on a lot of mobile browsers does not
   * shrink when the on-screen keyboard opens — so a stage sized off vh alone
   * can stay full height while the actually-visible area behind the keyboard
   * shrinks under it, forcing a much bigger scroll than the content needs to
   * bring a typing field into view. dvh tracks the real, current viewport.
   * Second declaration, not a replacement: a browser that does not recognise
   * `dvh` drops this whole line and keeps the vh rule above, rather than the
   * box going unsized. */
  width: min(100%, max(240px, min(70dvh, 560px)));
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* The one thing every game had before this was a line of small canvas-painted
 * text ("Tap the panel or press Space to play") — easy to miss on a first
 * visit. This sits on top of it as a real, unmissable badge and disappears the
 * instant a real press lands (see kit/input.js). Decorative only: pointer
 * events pass straight through to the stage underneath, and it is hidden from
 * assistive tech because the stage's own role="button"/aria-label already say
 * what it is — this would just be a second, redundant announcement. */
.start-indicator {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  pointer-events: none;
}

.start-indicator-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border: var(--border);
  border-radius: 999px;
  background: var(--coral);
  color: #fffefa;
  font-weight: 900;
  font-size: clamp(1.05rem, 4.5vw, 1.4rem);
  letter-spacing: -0.01em;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.6rem;
  text-align: center;
  padding: 1.4rem;
  background: color-mix(in srgb, var(--paper-2) 88%, transparent);
}

.stage-overlay[hidden] {
  display: none;
}

.score {
  font-size: clamp(3rem, 14vw, 5.5rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.score-rank {
  font-size: var(--step-1);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--coral);
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
  max-width: 32ch;
  margin-inline: auto;
}

.attempts {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.pip {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
}

.pip.is-used {
  background: var(--blue);
}

.statline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: center;
  font-size: var(--step--1);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

.statline b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* An arriving challenge, shown before the first attempt. Mustard rather than an
 * ink card, so it reads as a note somebody left you and not as site furniture. */
.challenge-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  align-items: baseline;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--mustard);
  color: #16181c;
  box-shadow: var(--shadow-sm);
  padding: 0.7rem 1rem;
  font-weight: 600;
}

.challenge-banner[hidden] {
  display: none;
}

.challenge-banner strong {
  font-weight: 900;
}

.verdict {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: var(--step--1);
}

.verdict-won {
  color: var(--mint);
}

.verdict-lost {
  color: var(--ink-soft);
}

/* thumb-reachable action bar */
.actionbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  border-top: var(--border);
  background: var(--paper);
  padding: 0.7rem var(--gutter) calc(0.7rem + env(safe-area-inset-bottom));
}

/* "Play again" and "Share score" mean nothing before the player has actually
 * played once — see kit/input.js's markStarted(), which reveals this the
 * moment a real press lands. No display value is set above for [hidden] to
 * beat, but every game module still lists this element as read-and-guarded
 * (removeAttribute rather than a style toggle), so the override is explicit
 * rather than assumed. */
.actionbar[hidden] {
  display: none;
}

.actionbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.actionbar .btn {
  flex: 1;
}

.actionbar .btn-icon {
  flex: none;
  width: 48px;
  padding: 0;
}

.mode-switch {
  display: inline-flex;
  border: var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-2);
}

.mode-switch button {
  appearance: none;
  font: inherit;
  font-weight: 800;
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  cursor: pointer;
}

.mode-switch button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  z-index: 40;
  border: var(--border);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  padding: 0.55rem 1rem;
  box-shadow: var(--shadow-sm);
}

.toast[hidden] {
  display: none;
}

/* --- prose and footer ------------------------------------------------------ */

.prose {
  max-width: 65ch;
}

.prose p {
  color: var(--ink-soft);
  font-weight: 500;
}

.steps {
  display: grid;
  gap: 0.9rem;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}

@media (min-width: 720px) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

.steps li {
  counter-increment: step;
  border: var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--paper-2);
  font-weight: 600;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.5rem;
  border: var(--border);
  border-radius: 999px;
  background: var(--mustard);
  color: #16181c;
  font-weight: 900;
}

footer {
  border-top: var(--border);
  background: var(--paper-2);
  padding-block: 1.6rem 2.4rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: var(--step--1);
}

.footer-inner a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  border-radius: 999px;
}

/* --- share sheet ------------------------------------------------------------
   Desktop fallback for the native share: a bottom panel of platform intents.
   Built by share.js at share time; never present in static HTML. */
.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
}

.share-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.45);
}

.share-sheet-panel {
  position: relative;
  width: min(92vw, 430px);
  margin: 0 0 max(1.1rem, env(safe-area-inset-bottom));
  padding: 1.1rem 1.1rem 1.2rem;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: share-sheet-rise 160ms ease-out;
}

.share-sheet-title {
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.share-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.share-sheet-grid .btn {
  text-align: center;
  justify-content: center;
}

@keyframes share-sheet-rise {
  from {
    transform: translateY(10px);
    opacity: 0.6;
  }
}

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