:root {
  --page: #DCE3EA;
  --paper: #FBFCF8;
  --rule: #C8DAEA;
  --margin: #E8A0A0;
  --ink: #1D2946;
  --ink-soft: #6D7894;
  --red: #CF3B33;
  --hl: #F7E36A;
  --panel: #FFFFFF;
  --shadow: 0 1px 0 rgba(29, 41, 70, .08), 0 18px 40px -18px rgba(29, 41, 70, .45);
  --hand: "Patrick Hand", "Segoe Print", "Comic Sans MS", system-ui, sans-serif;
  --display: "Caveat Brush", "Segoe Print", "Comic Sans MS", cursive;
  --sketch-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --card-radius: 6px 14px 8px 12px / 12px 6px 14px 8px;
  --gutter: clamp(18px, 5vw, 44px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #101714;
    --paper: #1E2B25;
    --rule: #2A3B33;
    --margin: #744848;
    --ink: #EEF1EA;
    --ink-soft: #9AA79F;
    --red: #F28B7D;
    --hl: #D9C757;
    --panel: #24332C;
    --shadow: 0 18px 40px -18px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101714;
  --paper: #1E2B25;
  --rule: #2A3B33;
  --margin: #744848;
  --ink: #EEF1EA;
  --ink-soft: #9AA79F;
  --red: #F28B7D;
  --hl: #D9C757;
  --panel: #24332C;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .8);
}

[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 18px;
}
:focus-visible { outline: 3px dashed var(--red); outline-offset: 3px; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }

/* ---------- page ---------- */
.page {
  box-sizing: border-box;
  max-width: 960px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px));
  padding-inline: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1;
  text-decoration: none;
  transform: rotate(-2deg);
}
.brand span { color: var(--red); }
.account-btn {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--hand);
  font-size: 18px;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: var(--sketch-radius);
  padding: 4px 14px;
  cursor: pointer;
}
.account-btn:hover { background: color-mix(in srgb, var(--hl) 55%, transparent); }

/* The page's content sits on one big sheet of ruled notebook paper. */
main {
  flex: 1;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent 0 calc(var(--gutter) - 12px), var(--margin) calc(var(--gutter) - 12px) calc(var(--gutter) - 10.5px), transparent calc(var(--gutter) - 10.5px)),
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 32px var(--gutter) 40px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: start;
  gap: 32px;
}
.intro h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 60px);
  line-height: 1.05;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.intro p { margin: 16px 0 0; font-size: 20px; line-height: 32px; color: var(--ink-soft); max-width: 30em; }
.intro .next-note {
  width: fit-content;
  color: var(--ink);
  padding: 0 10px;
  background: color-mix(in srgb, var(--hl) 60%, transparent);
  border-radius: 3px;
  transform: rotate(-.6deg);
}

/* ---------- sign-in card ---------- */
.card {
  background: var(--panel);
  border: 2.5px solid var(--ink);
  border-radius: var(--card-radius);
  padding: 22px 22px 20px;
  box-shadow: 6px 7px 0 color-mix(in srgb, var(--ink) 18%, transparent);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; }
.card .sub { margin: 0; color: var(--ink-soft); line-height: 1.35; }
.card .error { margin: 0; color: var(--red); }
.card .fine { margin: 0; font-size: 14px; color: var(--ink-soft); line-height: 1.35; }
.card .fine a:hover { color: var(--ink); }

.providers { display: grid; gap: 10px; }
.provider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--hand);
  font-size: 19px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px 4px 12px 5px / 5px 12px 4px 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.provider svg { width: 20px; height: 20px; flex: none; }
.provider:hover { background: color-mix(in srgb, var(--hl) 45%, var(--paper)); }
.provider:disabled { opacity: .6; cursor: progress; }
/* Google's own button, drawn by Google in an iframe at a fixed 40px height. */
.google-btn { display: flex; justify-content: center; min-height: 44px; align-items: center; color-scheme: normal; }

/* Google's button can't be restyled, so while it's shown the other buttons copy its look:
   hub.js adds .google-style once Google's button is drawn. Light matches Google's "outline"
   theme, dark its "filled_black" theme. */
.providers.google-style .provider {
  box-sizing: border-box;
  justify-self: center;
  width: 100%;
  max-width: 400px;
  height: 40px;
  gap: 8px;
  padding: 0 12px;
  font-family: Roboto, "Google Sans", system-ui, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .25px;
  color: #3C4043;
  background: #FFFFFF;
  border: 1px solid #DADCE0;
  border-radius: 4px;
}
.providers.google-style .provider:hover { background: #F8FAFF; border-color: #D2E3FC; }
.providers.google-style .provider svg { width: 18px; height: 18px; color: #000000; }
@media (prefers-color-scheme: dark) {
  .providers.google-style .provider { gap: 12px; color: #FFFFFF; background: #202124; border-color: #202124; }
  .providers.google-style .provider:hover { background: #303134; border-color: #303134; }
  /* Google's dark button puts its logo on a white square. */
  .providers.google-style .provider svg { padding: 9px; background: #FFFFFF; border-radius: 3px; }
}

/* ---------- games ---------- */
.games h2 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 34px;
  line-height: 32px;
}
.game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 24px;
}
.game {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
  border: 2.5px solid var(--ink);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: 5px 6px 0 color-mix(in srgb, var(--ink) 18%, transparent);
  transition: transform .15s ease, box-shadow .15s ease;
}
.game:hover, .game:focus-visible {
  transform: translate(-2px, -2px) rotate(-.6deg);
  box-shadow: 8px 9px 0 color-mix(in srgb, var(--ink) 22%, transparent);
}
.game img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-bottom: 2.5px solid var(--ink);
}
.game-body { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; }
.game h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1.05; }
.game p { margin: 0; color: var(--ink-soft); line-height: 1.35; }
.play {
  align-self: flex-start;
  margin-top: auto;
  padding: 3px 20px;
  font-family: var(--display);
  font-size: 22px;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-radius);
  translate: 0 6px;
}
.game:hover .play { background: color-mix(in srgb, var(--hl) 60%, transparent); }
.soon {
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 16px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 20px;
  border: 2px dashed color-mix(in srgb, var(--ink-soft) 60%, transparent);
  border-radius: var(--card-radius);
}

footer { display: flex; justify-content: center; color: var(--ink-soft); font-size: 15px; }
footer a:hover { color: var(--ink); }

@media (max-width: 720px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- buttons ---------- */
.pen-btn {
  font-family: var(--display);
  font-size: 22px;
  color: var(--ink);
  background: transparent;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-radius);
  padding: 3px 18px;
  cursor: pointer;
}
.pen-btn:hover { background: color-mix(in srgb, var(--hl) 60%, transparent); }
.pen-btn:disabled { opacity: .55; cursor: progress; }
.link-btn {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--ink-soft);
  background: none;
  border: none;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  padding: 2px 4px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

/* ---------- dialogs ---------- */
.sheet {
  box-sizing: border-box;
  width: min(calc(100vw - 32px), 380px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: var(--card-radius);
  padding: 24px 22px 22px;
  box-shadow: 6px 7px 0 color-mix(in srgb, var(--ink) 18%, transparent);
}
.sheet[open] { display: flex; flex-direction: column; gap: 14px; }
.sheet::backdrop { background: color-mix(in srgb, var(--page) 72%, transparent); }
.sheet h2 {
  margin: 0;
  padding-right: 32px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.sheet-sub { margin: 0; color: var(--ink-soft); line-height: 1.35; }
.sheet-close { position: absolute; top: 8px; right: 8px; margin: 0; }
.x-btn {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.x-btn:hover { color: var(--ink); }
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 6px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
}
.field input {
  box-sizing: border-box;
  width: 100%;
  font-family: var(--hand);
  font-size: 24px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 2px 2px 4px;
}
.field input:focus-visible { outline: none; border-bottom-color: var(--red); box-shadow: 0 2px 0 var(--red); }
.field-hint { margin: 0; font-size: 15px; color: var(--ink-soft); }
.field-hint.error { color: var(--red); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) rotate(-1deg);
  box-sizing: border-box;
  max-width: calc(100vw - 32px);
  width: max-content;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--card-radius);
  padding: 8px 14px;
  box-shadow: 4px 5px 0 color-mix(in srgb, var(--ink) 18%, transparent);
  z-index: 10;
}

/* ---------- privacy & terms pages ---------- */
/* Text sits on ruled notebook lines: every line box and vertical gap is a multiple of 32px. */
.doc {
  box-sizing: border-box;
  max-width: 760px;
  margin: 0 auto;
  padding-block: 24px 56px;
  padding-inline: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.doc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.doc-top a { color: var(--ink-soft); font-size: 17px; }
.doc-top a:hover { color: var(--ink); }
.doc-top .brand { color: var(--ink); font-size: 30px; }
.doc-paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent 0 calc(var(--gutter) - 12px), var(--margin) calc(var(--gutter) - 12px) calc(var(--gutter) - 10.5px), transparent calc(var(--gutter) - 10.5px)),
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 32px var(--gutter) 32px;
  font-size: 18px;
  line-height: 32px;
  overflow-wrap: anywhere;
}
.doc-paper > * { max-width: 65ch; }
.doc-paper h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 44px;
  line-height: 64px;
  text-wrap: balance;
}
.doc-paper h2 {
  margin: 32px 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 27px;
  line-height: 32px;
  text-wrap: balance;
}
.doc-paper p, .doc-paper ul { margin: 0 0 32px; }
.doc-paper h2 + p, .doc-paper h2 + ul { margin-top: 0; }
.doc-paper ul { padding-left: 1.2em; }
.doc-paper .updated { color: var(--ink-soft); }
.doc-paper a { color: var(--ink); }
.doc-paper a:hover { background: color-mix(in srgb, var(--hl) 55%, transparent); }
.doc-paper > :last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .game, .game:hover, .game:focus-visible { transition: none; transform: none; }
}
