@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --cream: #fbf0f6;
  --paper: #fffafd;
  --ink: #2a1640;
  --muted: #6a5878;
  --tabby: #ff5c8f;
  --tabby-d: #c2275a;
  --blush: #ffd84d;
  --sage: #7fd6c2;
  --line: #efd9e8;
  --r: 22px;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font: 400 16px/1.5 Nunito, system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

#app, .screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.screen { display: flex; flex-direction: column; }
.screen.hidden, .hidden, .overlay.hidden { display: none !important; }

h1, h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.4em;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

/* ----- Home ----- */
#screen-home, #screen-shop {
  background: var(--cream);
  touch-action: pan-y;
}

.home-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.55;
}
.blob-a {
  width: 58vw; height: 58vw; max-width: 420px; max-height: 420px;
  background: #ffd0e0;
  top: -12%; left: -18%;
}
.blob-b {
  width: 48vw; height: 48vw; max-width: 340px; max-height: 340px;
  background: #c8f3ea;
  bottom: -10%; right: -16%;
}

.paw {
  position: absolute;
  width: 44px; height: 44px;
  opacity: 0.18;
  background: var(--tabby-d);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><circle cx='16' cy='20' r='8'/><circle cx='32' cy='12' r='8'/><circle cx='48' cy='20' r='8'/><circle cx='10' cy='36' r='7'/><ellipse cx='34' cy='42' rx='18' ry='16'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><circle cx='16' cy='20' r='8'/><circle cx='32' cy='12' r='8'/><circle cx='48' cy='20' r='8'/><circle cx='10' cy='36' r='7'/><ellipse cx='34' cy='42' rx='18' ry='16'/></svg>") center / contain no-repeat;
}
.paw-a { top: 12%; right: 10%; transform: rotate(18deg); }
.paw-b { bottom: 22%; left: 8%; transform: rotate(-24deg); width: 36px; height: 36px; }
.paw-c { top: 44%; right: 22%; transform: rotate(8deg); width: 28px; height: 28px; opacity: 0.12; }

.home-inner, .shop-inner {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px 16px;
  text-align: center;
  overflow: auto;
  touch-action: pan-y;
}

.brand-logo {
  width: min(86vw, 420px);
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 18px rgba(42, 22, 64, 0.18));
}

.tagline, .shop-lede {
  margin: 10px 0 28px;
  color: var(--muted);
  font-weight: 700;
  font-size: 1.05rem;
  max-width: 28ch;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(86vw, 320px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 1.15rem;
  font-family: inherit;
  text-decoration: none;
  border: 2px solid var(--ink);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tabby-d); }
.btn-primary {
  background: var(--tabby);
  color: var(--ink);
  border-color: var(--tabby-d);
  box-shadow: 0 5px 0 var(--tabby-d);
}
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.btn-ghost:active { box-shadow: 0 1px 0 var(--ink); }

.site-foot {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  font-weight: 800;
  font-size: 0.95rem;
}
.site-foot a {
  color: var(--tabby-d);
  text-decoration: none;
}

/* ----- Shop ----- */
#screen-shop .shop-inner { justify-content: flex-start; align-items: stretch; text-align: left; max-width: 520px; margin: 0 auto; width: 100%; }
#screen-shop h1 { font-size: 2.1rem; }

.btn-back {
  align-self: flex-start;
  background: none;
  border: 0;
  color: var(--ink);
  font: 800 1rem Nunito, system-ui, sans-serif;
  padding: 8px 0 16px;
  cursor: pointer;
}

.shop-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 0 var(--ink);
}
.shop-card.is-disabled {
  opacity: 0.78;
  box-shadow: none;
  background: #f6edf3;
  pointer-events: none;
}
.shop-badge {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 1.6rem;
  flex: 0 0 auto;
}
.shop-badge.merch { background: #ffd0e0; }
.shop-badge.books { background: #fff0b3; }
.shop-copy h2 { margin: 0 0 2px; font-size: 1.35rem; }
.shop-copy p { margin: 0 0 6px; color: var(--muted); font-weight: 700; }
.shop-go { color: var(--tabby-d); font-weight: 800; font-size: 0.92rem; white-space: nowrap; }
.shop-soon {
  display: inline-block;
  background: var(--blush);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 99px;
}

/* ----- Game ----- */
#screen-game { background: #7ec8e3; }
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100% - 120px - env(safe-area-inset-right));
}
#catch-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 250, 253, 0.88);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 6px 14px 6px 8px;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 3px 0 rgba(42, 22, 64, 0.25);
}
#catch-chip.light-on-dark {
  background: rgba(42, 22, 64, 0.72);
  color: #fff;
  border-color: #fff;
}
.catch-paw {
  width: 26px; height: 26px;
  background: var(--tabby);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><circle cx='16' cy='20' r='8'/><circle cx='32' cy='12' r='8'/><circle cx='48' cy='20' r='8'/><circle cx='10' cy='36' r='7'/><ellipse cx='34' cy='42' rx='18' ry='16'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><circle cx='16' cy='20' r='8'/><circle cx='32' cy='12' r='8'/><circle cx='48' cy='20' r='8'/><circle cx='10' cy='36' r='7'/><ellipse cx='34' cy='42' rx='18' ry='16'/></svg>") center / contain no-repeat;
}

#settings-hotspot {
  position: absolute;
  top: env(safe-area-inset-top);
  right: env(safe-area-inset-right);
  width: 88px;
  height: 88px;
  z-index: 4;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#settings-hotspot::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(42, 22, 64, 0.18);
}

#hold-ring {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  z-index: 5;
  pointer-events: none;
}
#hold-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hold-bg { fill: none; stroke: rgba(255,255,255,0.45); stroke-width: 4; }
#hold-arc {
  fill: none;
  stroke: var(--tabby);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(42, 22, 64, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  touch-action: auto;
}

.panel {
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  max-width: 520px;
  border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(42, 22, 64, 0.2);
  touch-action: pan-y;
}

.tip-card {
  margin: auto 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px;
  padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  width: min(100% - 32px, 420px);
}
.tip-card h2 { font-size: 1.7rem; }
.tip-card p { margin: 0 0 10px; font-weight: 650; }
.tip-card .btn { width: 100%; margin-top: 10px; }

.settings-sheet {
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.settings-head h2 { margin: 0; font-size: 1.6rem; }
.icon-btn {
  width: 44px; height: 44px;
  border: 0;
  background: var(--cream);
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
}
.settings-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  touch-action: pan-y;
  padding: 8px 2px 16px;
  -webkit-overflow-scrolling: touch;
}
.settings-foot { padding-top: 8px; }
.settings-foot .btn { width: 100%; }

fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}
legend {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 8px;
  display: block;
  width: 100%;
}

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches.compact { flex: 1; }
.swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(42, 22, 64, 0.25);
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #fff;
}
.swatch[aria-pressed="true"], .swatch.is-on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--ink);
}

.picker-row, .color-block {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}
.color-block { margin-top: 10px; }
.color-block > span { width: 64px; flex: 0 0 auto; }
input[type="color"] {
  width: 40px; height: 32px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  cursor: pointer;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--tabby);
  height: 28px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  padding: 6px 0;
  font-size: 1rem;
}
.check input { width: 22px; height: 22px; accent-color: var(--tabby); }

.seg {
  display: flex;
  background: var(--cream);
  border-radius: 99px;
  padding: 4px;
  border: 2px solid var(--line);
}
.seg label {
  flex: 1;
  text-align: center;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 8px 4px;
  border-radius: 99px;
  cursor: pointer;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) {
  background: var(--tabby);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--tabby-d);
}

@media (min-width: 700px) {
  .overlay { align-items: center; }
  .settings-sheet, .tip-card { border-radius: 28px; margin: 24px; }
}

/* Shop is a long scrolling page (books + merch) */
#screen-shop {
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
#screen-shop .shop-inner {
  flex: 1 0 auto;
  justify-content: flex-start;
}
#screen-shop .site-foot { padding-top: 20px; }

.shop-heading {
  font-size: 1.35rem;
  margin: 10px 0 10px;
  text-align: left;
  width: 100%;
}
.shop-lede.tight { margin: 0 0 12px; text-align: left; max-width: none; }
.shop-badge.etsy { background: #d7f3ea; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 16px;
}
.book-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 3px 0 var(--ink);
  min-width: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}
.book-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.book-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  display: block;
  pointer-events: none;
}
.book-card h3 {
  font-family: Nunito, system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
  padding: 8px 8px 10px;
  letter-spacing: 0;
  font-variation-settings: normal;
}
.shop-all-books { width: 100%; margin: 4px 0 8px; }

@media (min-width: 700px) {
  .book-grid { grid-template-columns: repeat(3, 1fr); }
  .book-card h3 { font-size: 0.9rem; }
}

.btn-arcade {
  background: var(--blush);
  color: var(--ink);
  border-color: #d4a81c;
  box-shadow: 0 5px 0 #d4a81c;
}
.btn-arcade:active { box-shadow: 0 1px 0 #d4a81c; }

#timer-chip {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 250, 253, 0.88);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 99px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  box-shadow: 0 3px 0 rgba(42, 22, 64, 0.25);
  line-height: 1;
}
#timer-chip.light-on-dark {
  background: rgba(42, 22, 64, 0.72);
  color: #fff;
  border-color: #fff;
}
#timer-chip.hidden { display: none !important; }
#timer-chip.urgent { color: var(--tabby-d); }

.arcade-card {
  text-align: center;
}
.arcade-score {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 8px 0 4px;
}
.arcade-best {
  margin: 0 0 16px;
  font-weight: 700;
  color: var(--muted);
}
.arcade-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.arcade-card .btn {
  width: 100%;
  min-height: 56px;
  font-size: 1.2rem;
  padding: 16px 24px;
  margin-top: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.share-note {
  margin: 0;
  font-weight: 800;
  color: var(--tabby-d);
}
.arcade-card.locked .arcade-actions .btn {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-height: 500px) and (orientation: landscape) {
  .arcade-card, .tip-card {
    margin: 12px auto;
    max-height: calc(100dvh - 24px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  #timer-chip { font-size: 1.3rem; padding: 6px 12px; }
}
