/* GridWits — design system.
   No build step, no external fonts, no CDN. Every colour has a light and a
   dark value; the palette follows the visitor's system setting and
   [data-theme] on <html> overrides it.

   Brand colours are the app's, from GridWits/Utilities/AppColors.swift — teal
   #2DD4BF, indigo #6366F1, amber #F5A623. The surfaces around them are the
   website's own: warm paper in light, a blue-black in dark. */

:root {
  /* ---- brand ---- */
  --teal: #2DD4BF;
  --indigo: #6366F1;
  --brand-indigo: #6366F1;
  --brand-amber: #F5A623;
  --danger: #E24B4A;

  /* Board mark semantics, taken from the app's SudokuBoardTheme. These carry
     MEANING (kept / ruled out / sea / ship) and stay constant across games,
     unlike --hue, which is a game's branding. */
  --mark-keep: #4CD97B;   /* hitoriIncludeMarkColor, nurikabeLandMarkColor */
  --mark-drop: #E24B4A;   /* hitoriExcludeMarkColor */
  --mark-sea:  #333D52;   /* nurikabeSeaColor */
  --mark-ship: #2D527A;   /* battleshipShipColor */

  /* Kakuro needs its own pair. Its board is mostly UNPLAYABLE, so the few
     cells you can type in have to stand out at a glance — the generic
     on/off surfaces put block and white within a few points of each other
     and the whole grid read as one flat rectangle. */
  --kakuro-block: #1B1E26;
  --kakuro-white: #FFFFFF;
  --kakuro-grid:  #9AA0AC;

  /* Bridges draws its grid straight onto the PAGE background rather than onto
     filled cells, so --line (tuned against panels) all but vanishes there.
     This is the one value picked against --bg. */
  --bridges-grid: #D6D1C5;

  /* Per-tier temperature ramp, same values the app's difficulty picker uses. */
  --tier-easy: #4CD97B;
  --tier-medium: #2DD4BF;
  --tier-hard: #F5A623;
  --tier-expert: #FF6B6B;
  --tier-extreme: #C77DFF;

  /* ---- light surfaces ---- */
  --bg: #FBFAF8;
  --bg-raised: #FFFFFF;
  --bg-sunken: #F1EFEA;
  --ink: #14161C;
  --ink-soft: #4E535E;
  --ink-faint: #8B909B;
  --line: #E3E0D9;
  --line-strong: #23262E;
  --accent: #0E7C6B;
  --accent-soft: #DCF0EC;
  --warn: #B2541F;

  /* Painted cell states for the tool games. `off` is the heavy state (shaded,
     sea, water); `on` is the light one. Defined per theme rather than derived,
     so the polarity never inverts. */
  --state-on: #FFFFFF;
  --state-off: #23262E;
  --state-off-ink: #F4F1EA;

  /* ---- form ---- */
  --radius: 14px;
  --radius-lg: 20px;
  --maxw: 1120px;
  --shadow: 0 1px 2px rgba(20, 22, 28, .05), 0 10px 30px -12px rgba(20, 22, 28, .16);
  --shadow-lift: 0 2px 4px rgba(20, 22, 28, .06), 0 22px 48px -18px rgba(20, 22, 28, .28);
  --ring: 0 0 0 1px var(--line);
  --ease: cubic-bezier(.22, .8, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0C12;
    --bg-raised: #141821;
    --bg-sunken: #06080D;
    --ink: #EDEFF4;
    --ink-soft: #A2A8B8;
    --ink-faint: #6B7183;
    --line: #232833;
    --line-strong: #6E7689;
    --accent: #2DD4BF;
    --accent-soft: #10302B;
    --warn: #E0894F;
    --state-on: #243936;
    --state-off: #04060B;
    --state-off-ink: #6E7689;
    --kakuro-block: #05070C;
    --kakuro-white: #222A38;
    --kakuro-grid:  #6C7794;
    --bridges-grid: #2C3444;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -14px rgba(0, 0, 0, .8);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .6), 0 28px 60px -20px rgba(0, 0, 0, .9);
  }
}

:root[data-theme="light"] {
  --bg: #FBFAF8; --bg-raised: #FFFFFF; --bg-sunken: #F1EFEA;
  --ink: #14161C; --ink-soft: #4E535E; --ink-faint: #8B909B;
  --line: #E3E0D9; --line-strong: #23262E;
  --accent: #0E7C6B; --accent-soft: #DCF0EC; --warn: #B2541F;
  --state-on: #FFFFFF; --state-off: #23262E; --state-off-ink: #F4F1EA;
  --kakuro-block: #1B1E26; --kakuro-white: #FFFFFF; --kakuro-grid: #9AA0AC;
  --bridges-grid: #D6D1C5;
  --shadow: 0 1px 2px rgba(20, 22, 28, .05), 0 10px 30px -12px rgba(20, 22, 28, .16);
  --shadow-lift: 0 2px 4px rgba(20, 22, 28, .06), 0 22px 48px -18px rgba(20, 22, 28, .28);
}
:root[data-theme="dark"] {
  --bg: #0A0C12; --bg-raised: #141821; --bg-sunken: #06080D;
  --ink: #EDEFF4; --ink-soft: #A2A8B8; --ink-faint: #6B7183;
  --line: #232833; --line-strong: #6E7689;
  --accent: #2DD4BF; --accent-soft: #10302B; --warn: #E0894F;
  --state-on: #243936; --state-off: #04060B; --state-off-ink: #6E7689;
  --kakuro-block: #05070C; --kakuro-white: #222A38; --kakuro-grid: #6C7794;
  --bridges-grid: #2C3444;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -14px rgba(0, 0, 0, .8);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .6), 0 28px 60px -20px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.narrow { max-width: 720px; }

::selection { background: color-mix(in srgb, var(--teal) 30%, transparent); }

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

.site-head {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.site-head .wrap { display: flex; align-items: center; gap: 20px; height: 66px; }

.brand {
  display: flex; align-items: center; gap: 11px;
  font-weight: 680; letter-spacing: -.02em; font-size: 17.5px;
  color: var(--ink); text-decoration: none;
}
.brand .mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(140deg, var(--teal), var(--indigo));
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 2px; padding: 5px;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--teal) 60%, transparent);
}
.brand .mark i { background: #06080D; border-radius: 1.5px; opacity: .3; }
.brand .mark i:nth-child(1), .brand .mark i:nth-child(5), .brand .mark i:nth-child(9) { opacity: .95; }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.site-nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 15px; font-weight: 520;
  padding: 8px 13px; border-radius: 9px; transition: color .18s var(--ease), background .18s var(--ease);
}
.site-nav a:hover { color: var(--ink); background: var(--bg-sunken); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--bg-sunken); }
.theme-toggle {
  margin-left: 6px;
  background: none; border: 1px solid var(--line); color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center;
  transition: color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); transform: rotate(-12deg); }
@media (max-width: 640px) {
  .site-head .wrap { gap: 10px; height: 60px; }
  .site-nav { gap: 1px; min-width: 0; }
  .site-nav a { padding: 7px 9px; font-size: 13.5px; }
  .site-nav .hide-sm { display: none; }
  .theme-toggle { margin-left: 3px; width: 32px; height: 32px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand .mark { width: 25px; height: 25px; border-radius: 8px; }
  .wrap { padding: 0 16px; }
}

/* Nothing on this site is meant to scroll sideways. Any element that manages
   to exceed the viewport is a bug, but a phone should not be left with a
   broken-feeling page while it goes unnoticed. */
html, body { overflow-x: clip; }

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

.hero {
  position: relative;
  padding: clamp(56px, 9vw, 104px) 0 clamp(40px, 6vw, 64px);
  overflow: hidden;
}
/* A grid, faded out — the site is about grids, so the page should say so
   without an image asset. */
.hero::before {
  content: ""; position: absolute; inset: -10% -20% auto -20%; height: 150%;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line-strong) 22%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line-strong) 22%, transparent) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 70% at 78% 22%, #000 0%, transparent 68%);
  mask-image: radial-gradient(120% 70% at 78% 22%, #000 0%, transparent 68%);
  pointer-events: none;
}
/* A soft brand bloom behind the headline. */
.hero::after {
  content: ""; position: absolute; top: -28%; right: -10%;
  width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--teal) 20%, transparent) 0%,
    color-mix(in srgb, var(--indigo) 12%, transparent) 42%,
    transparent 68%);
  filter: blur(20px); pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(38px, 7.2vw, 68px); line-height: 1.03;
  letter-spacing: -.042em; margin: 0 0 20px; font-weight: 700; max-width: 15ch;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--teal), var(--indigo) 78%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lede {
  font-size: clamp(17px, 2vw, 20.5px); color: var(--ink-soft);
  max-width: 58ch; margin: 0 0 32px; line-height: 1.6;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 11px; font-weight: 580; font-size: 15.5px;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; letter-spacing: -.01em;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              opacity .18s var(--ease), border-color .18s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--teal), #14B8A6 60%, var(--indigo) 190%);
  color: #04100E;
  box-shadow: 0 8px 24px -10px color-mix(in srgb, var(--teal) 80%, transparent);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--teal) 90%, transparent);
}
.btn-ghost {
  border-color: var(--line); color: var(--ink); background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.btn-ghost:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* Honest status line for a product with no App Store listing yet. */
.soon {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 0; font-size: 14.5px; color: var(--ink-faint);
}
.soon-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--brand-amber);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-amber) 16%, transparent);
}

/* -------------------------------------------------------------- sections */

section { padding: clamp(44px, 6vw, 72px) 0; scroll-margin-top: 84px; }

h2 {
  font-size: clamp(26px, 3.6vw, 36px); letter-spacing: -.028em;
  margin: 0 0 14px; font-weight: 680;
}
h3 { font-size: 18px; letter-spacing: -.014em; margin: 0 0 8px; font-weight: 630; }
.section-lede { color: var(--ink-soft); max-width: 62ch; margin: 0 0 36px; font-size: 16.5px; }

/* ----------------------------------------------------------- game cards */

.games {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}

.game {
  position: relative; overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease),
              border-color .22s var(--ease);
  /* Each game gets its own hue; the card tints itself from this one value. */
  --hue: var(--teal);
}
/* A card that is itself a link must not underline its heading and body. */
a.game { text-decoration: none; color: inherit; }
a.game:hover, .game:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: color-mix(in srgb, var(--hue) 45%, var(--line));
}
/* A wash of the game's hue, revealed on hover. */
.game::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -20%,
    color-mix(in srgb, var(--hue) 16%, transparent), transparent 62%);
  opacity: 0; transition: opacity .22s var(--ease);
}
.game:hover::before { opacity: 1; }
.game > * { position: relative; z-index: 1; }

/* App-Store-shaped game icon: a rounded tile in the game's hue with a white
   motif on top. The gradient lives here rather than in each SVG so nine icons
   on one page cannot collide over gradient ids. */
.gicon {
  width: 66px; height: 66px; border-radius: 16px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--hue) 92%, #fff 8%),
    color-mix(in srgb, var(--hue) 62%, #1B1E28 38%));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 45%, transparent),
    0 8px 20px -8px color-mix(in srgb, var(--hue) 70%, transparent);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.gicon svg { width: 46px; height: 46px; display: block; }
.game:hover .gicon {
  transform: translateY(-2px) rotate(-3deg) scale(1.04);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent),
    0 14px 28px -8px color-mix(in srgb, var(--hue) 85%, transparent);
}

.game h3 { margin: 0; letter-spacing: -.018em; }
.game p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.game .tag {
  align-self: flex-start; margin-top: auto; padding-top: 10px;
  font-size: 13px; color: var(--hue); font-weight: 600; letter-spacing: -.01em;
  display: inline-flex; align-items: center; gap: 5px;
}
/* The arrow lives here so it can animate; markup carries the label only. */
.game .tag::after { content: "\2192"; transition: transform .22s var(--ease); }
.game:hover .tag::after { transform: translateX(3px); }

/* Per-game hues. Distinct enough to tell apart at a glance, all legible on
   both themes. */
.game[data-game="sudoku"]          { --hue: #2DD4BF; }
.game[data-game="kakuro"]          { --hue: #6366F1; }
.game[data-game="hitori"]          { --hue: #F5A623; }
.game[data-game="bridges"]         { --hue: #38BDF8; }
.game[data-game="nurikabe"]        { --hue: #4CD97B; }
.game[data-game="slitherlink"]     { --hue: #C77DFF; }
.game[data-game="battleship"]      { --hue: #FF6B6B; }
.game[data-game="skyscrapers"]     { --hue: #FBBF24; }
.game[data-game="skyscrapersplus"] { --hue: #F472B6; }

/* -------------------------------------------------------------- features */

.feature-grid { display: grid; gap: 30px; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.feature h3 { display: flex; align-items: center; gap: 8px; }
.feature p { color: var(--ink-soft); margin: 0; font-size: 15.5px; }

/* ---------------------------------------------------------------- footer */

.site-foot {
  border-top: 1px solid var(--line); margin-top: 56px;
  padding: 38px 0; color: var(--ink-faint); font-size: 14px;
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center; }
.site-foot a { color: var(--ink-soft); text-decoration: none; }
.site-foot a:hover { color: var(--ink); }
.site-foot .spacer { margin-left: auto; }

/* ------------------------------------------- long-form docs (privacy/terms) */

.doc { padding: 52px 0 24px; }
.doc h1 { font-size: clamp(30px, 4.6vw, 42px); letter-spacing: -.032em; margin: 0 0 8px; font-weight: 700; }
.doc .updated { color: var(--ink-faint); font-size: 14px; margin: 0 0 36px; }
.doc h2 { font-size: 21px; margin: 38px 0 10px; }
.doc h3 { font-size: 16.5px; margin: 24px 0 6px; }
.doc p, .doc li { color: var(--ink-soft); }
.doc li { margin-bottom: 7px; }
.doc strong { color: var(--ink); font-weight: 620; }
.doc table { border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 14px; }
.doc th, .doc td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--ink); font-weight: 620; }
.doc td { color: var(--ink-soft); }
.doc .scroll { overflow-x: auto; }

.callout {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--teal) 9%, var(--bg-raised)),
    color-mix(in srgb, var(--indigo) 7%, var(--bg-raised)));
  border: 1px solid color-mix(in srgb, var(--teal) 26%, transparent);
  border-radius: var(--radius); padding: 16px 18px; margin: 22px 0; font-size: 14.5px;
}
.callout p { margin: 0; color: var(--ink); }

/* ------------------------------ shared chrome: toolbars and segmented sets */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }

.seg {
  display: inline-flex; flex-wrap: wrap; background: var(--bg-sunken);
  border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px;
  max-width: 100%;
}
.seg button {
  border: 0; background: none; color: var(--ink-soft); font: inherit;
  font-size: 13.5px; font-weight: 520; padding: 7px 13px; border-radius: 8px;
  cursor: pointer; transition: color .16s var(--ease), background .16s var(--ease);
}
.seg button[aria-pressed="true"] {
  background: var(--bg-raised); color: var(--ink); box-shadow: var(--shadow);
}
.seg button:hover { color: var(--ink); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* The board-size picker sits beside difficulty. Its labels are numeric and all
   the same shape, so they can be tighter than the tier words — Bridges shows
   six sizes next to five tiers, which is a long row otherwise. */
#sizes button { padding: 7px 10px; font-variant-numeric: tabular-nums; }

.timer {
  margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-soft);
  font-size: 15.5px; letter-spacing: .01em;
}
@media (max-width: 560px) { .timer { margin-left: 0; } }

/* ================================================= ambient page background
   The hero has its own grid and bloom. Every other page gets a quieter
   version of the same idea so the site reads as one surface rather than a
   bright front page bolted to plain documents. */

body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line-strong) 13%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line-strong) 13%, transparent) 1px, transparent 1px);
  background-size: 54px 54px;
  -webkit-mask-image: radial-gradient(130% 90% at 50% 0%, #000 0%, transparent 62%);
  mask-image: radial-gradient(130% 90% at 50% 0%, #000 0%, transparent 62%);
}
body::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  top: -320px; left: 50%; transform: translateX(-50%);
  width: min(1200px, 130vw); height: 720px; border-radius: 50%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--teal) 11%, transparent) 0%,
    color-mix(in srgb, var(--indigo) 8%, transparent) 40%,
    transparent 70%);
  filter: blur(30px);
}
/* The hero paints its own, brighter version — don't double up behind it. */
.hero::before { opacity: .85; }

/* Daily cards carry the day's tier instead of a blurb. */
.daily-meta { display: flex; align-items: center; gap: 9px; }
.tier-pill {
  font-size: 12px; font-weight: 620; padding: 3px 9px; border-radius: 999px;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 13%, transparent);
}
.tier-pill.tier-easy { color: var(--tier-easy); }
.tier-pill.tier-medium { color: var(--tier-medium); }
.tier-pill.tier-hard { color: var(--tier-hard); }
.tier-pill.tier-expert { color: var(--tier-expert); }
.tier-pill.tier-extreme { color: var(--tier-extreme); }

/* The meta row sits between the blurb and the Play tag, so it needs its own
   spacing rather than inheriting a paragraph's. */
.daily-meta { margin: 2px 0 0; }
