/* Shared site styles for all games. Each game can override the colour tokens in :root.
   Token roles: --night = ink/dark background, --moon = paper/light text, --itch = primary (yellow),
   --sheet = accent (pink), --coil = success (green), --bite = danger (red). */

/* Self-hosted fonts (SIL Open Font License, see assets/fonts/OFL-*.txt). No requests to Google. */
@font-face { font-family: 'Modak'; src: url(fonts/modak-latin.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Grandstander'; src: url(fonts/grandstander-latin.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Bangers'; src: url(fonts/bangers-latin.woff2) format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --night: #1A1446; --coil: #2FBF4A; --itch: #FFE14D; --sheet: #FF5FA2; --bite: #E8263B; --moon: #FFF4C2;
  --display: 'Modak', 'Arial Rounded MT Bold', system-ui, sans-serif; --body: 'Grandstander', system-ui, sans-serif;
  --comic: 'Bangers', Impact, sans-serif;
  --outline: -3px -3px 0 var(--night), 3px -3px 0 var(--night), -3px 3px 0 var(--night), 3px 3px 0 var(--night);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); overflow: hidden; font-family: var(--body); color: var(--moon);
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: none; touch-action: none; }
button { font-family: inherit; }
button:focus-visible { outline: 4px dashed var(--coil); outline-offset: 5px; }
.hidden { display: none !important; }

/* ---------- Shared type + buttons ---------- */
.title { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.05; color: var(--itch);
  font-size: clamp(40px, 10vw, 84px); text-shadow: var(--outline), 7px 7px 0 var(--sheet); transform: rotate(-3deg); }
.title2 { font-family: var(--display); font-weight: 400; margin: 0; color: var(--itch); font-size: clamp(30px, 7vw, 50px);
  text-shadow: var(--outline), 5px 5px 0 var(--sheet); transform: rotate(-2deg); line-height: 1.1; }
h3 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 18px 0 0; color: var(--coil); text-shadow: var(--outline); }
p { margin: 0; max-width: 34em; line-height: 1.5; font-size: 17px; font-weight: 500; }
.lede { font-size: 19px; font-weight: 700; }
.kicker { font-weight: 700; opacity: .85; }

.big { font-family: var(--display); font-size: clamp(22px, 5vw, 28px); color: var(--night); background: var(--itch);
  border: 4px solid var(--night); border-radius: 20px; padding: 12px 34px 14px; cursor: pointer; min-height: 56px;
  box-shadow: 0 8px 0 var(--night), 0 8px 0 4px var(--coil); transform: rotate(-1.5deg); margin: 4px 0 10px; }
.big:active { transform: translateY(6px) rotate(-1.5deg); box-shadow: 0 2px 0 var(--night), 0 2px 0 4px var(--coil); }
.ghost { font-weight: 800; font-size: 17px; color: var(--night); background: var(--moon); border: 3px solid var(--night);
  border-radius: 16px; padding: 9px 20px; cursor: pointer; box-shadow: 0 5px 0 var(--night); min-height: 46px; }
.ghost:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--night); }
.ghost:disabled { background: var(--coil); cursor: default; transform: none; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--night); background: var(--itch); font-size: 18px;
  cursor: pointer; box-shadow: 0 4px 0 var(--night); padding: 0; }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--night); }
.back { align-self: flex-start; background: none; border: 0; color: var(--moon); font-weight: 800; font-size: 17px; cursor: pointer; padding: 8px 4px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; }
a.big, a.ghost { display: inline-block; text-decoration: none; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; z-index: 5; overflow-y: auto; display: flex; padding: max(20px, env(safe-area-inset-top)) 16px 28px;
  background: radial-gradient(circle at 50% 38%, #2b2378 0%, var(--night) 70%); }
.screen.dim { background: radial-gradient(circle at 50% 42%, rgba(43,35,120,.93) 0%, rgba(26,20,70,.97) 70%); }
.wrap { position: relative; z-index: 1; margin: auto; width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.coil { position: fixed; left: 50%; top: 50%; width: 150vmax; height: 150vmax; transform: translate(-50%, -50%); pointer-events: none; z-index: 0; }
.coil path { fill: none; stroke: var(--coil); stroke-width: 13; stroke-linecap: round; opacity: .14; }
.topbar { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 14px; z-index: 2; display: flex; gap: 10px; align-items: center; }
.coins { background: var(--night); border: 3px solid var(--itch); border-radius: 30px; padding: 4px 14px; font-weight: 800; font-size: 17px; }

/* Title */
.mascot { display: flex; align-items: flex-end; gap: 4px; margin: 26px 0 -8px; }
.mascot svg { width: clamp(100px, 22vw, 160px); height: auto; animation: hover 1.8s ease-in-out infinite; }
.bubble { background: #fff; color: var(--night); border: 4px solid var(--night); border-radius: 22px; padding: 8px 14px; font-weight: 800;
  font-size: 16px; line-height: 1.3; margin-bottom: 64px; position: relative; transform: rotate(3deg); max-width: 190px; }
.bubble::after { content: ""; position: absolute; left: -17px; bottom: 12px; border: 10px solid transparent; border-right: 14px solid var(--night); }
@keyframes hover { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
.logo { display: flex; flex-direction: column; align-items: center; font-size: clamp(54px, 13vw, 110px); }
.subtitle { font-family: var(--body); font-weight: 900; font-size: clamp(17px, 3.6vw, 24px); color: var(--night); background: var(--coil);
  border: 3px solid var(--night); border-radius: 30px; padding: 2px 18px 4px; margin-top: 6px; text-shadow: none; transform: rotate(4deg);
  box-shadow: 0 4px 0 var(--night); white-space: nowrap; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: 100%; max-width: 520px; }
.menu-grid .ghost { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 10px; font-size: 18px; }
.menu-grid small { font-weight: 600; font-size: 13px; opacity: .75; }

/* Week map: tear-off calendar pages */
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; width: 100%; margin-top: 8px; }
.page { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 10px 14px; cursor: pointer;
  background: var(--moon); color: var(--night); border: 4px solid var(--night); border-radius: 6px 6px 16px 16px; box-shadow: 0 7px 0 var(--night);
  font-family: var(--body); transform: rotate(-2deg); }
.page:nth-child(even) { transform: rotate(1.5deg); }
.page:active { box-shadow: 0 2px 0 var(--night); translate: 0 5px; }
.page::before { content: ""; position: absolute; top: 8px; left: 22%; right: 22%; height: 9px;
  background: radial-gradient(circle, var(--night) 4px, transparent 4.5px) 0 0 / 33.3% 100% repeat-x; }
.page .day { font-family: var(--display); font-size: 30px; color: var(--bite); line-height: 1.1; }
.page .room { font-weight: 700; font-size: 14px; line-height: 1.25; min-height: 2.5em; display: flex; align-items: center; }
.page .stars { font-size: 24px; color: #e0a800; letter-spacing: 2px; -webkit-text-stroke: 1px var(--night); }
.page .stars i { font-style: normal; color: transparent; }
.page.boss { background: var(--bite); color: var(--moon); }
.page.boss .day { color: var(--itch); text-shadow: var(--outline); }
.page.locked { background: #8f8bc0; cursor: not-allowed; box-shadow: 0 4px 0 var(--night); }
.page.locked .day { color: var(--night); opacity: .55; }

/* Intro + pest cards */
.quote { background: #fff; color: var(--night); border: 4px solid var(--night); border-radius: 22px; padding: 12px 20px; font-weight: 800;
  font-size: 18px; transform: rotate(-1deg); box-shadow: 6px 6px 0 var(--sheet); }
.goal { font-weight: 800; color: var(--itch); }
.pests { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; width: 100%; }
.pest { position: relative; width: 170px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 12px 14px;
  background: var(--itch); color: var(--night); border: 4px solid var(--night); border-radius: 14px; box-shadow: 0 6px 0 var(--night); transform: rotate(-2deg); }
.pest:nth-child(even) { transform: rotate(2deg); }
.pest img { width: 110px; height: 110px; }
.pest b { font-family: var(--display); font-weight: 400; font-size: 19px; line-height: 1.15; }
.pest span { font-size: 14px; font-weight: 600; line-height: 1.3; }
.pest .ribbon { position: absolute; top: -14px; right: -10px; background: var(--sheet); color: #fff; border: 3px solid var(--night);
  border-radius: 10px; padding: 1px 10px; font-weight: 800; font-size: 13px; transform: rotate(8deg); }
.pest.unknown { background: #8f8bc0; }
.pest .q { font-family: var(--display); font-size: 70px; line-height: 110px; height: 110px; color: var(--night); opacity: .5; }

/* Shop */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; width: 100%; }
.item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; background: rgba(255,244,194,.08);
  border: 3px dashed rgba(255,244,194,.35); border-radius: 18px; }
.item.on { border: 3px solid var(--coil); background: rgba(47,191,74,.15); }
.item .emoji { font-size: 48px; line-height: 1.1; }
.item b { font-weight: 800; font-size: 16px; }
.item .ghost { font-size: 15px; padding: 6px 14px; min-height: 40px; }
.item .try { background: var(--sheet); color: #fff; }
.trial-tag { font-weight: 800; font-size: 14px; color: var(--itch); }
#trialNote:empty { display: none; }

/* Help */
.rules { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; max-width: 34em; }
.rules li { display: flex; gap: 12px; align-items: flex-start; font-size: 17px; line-height: 1.45; font-weight: 600; }
.rules .emoji { font-size: 24px; line-height: 1.1; flex: none; }
.rules b { color: var(--itch); margin-right: 4px; }

/* Results */
.stars { display: flex; gap: 10px; justify-content: center; min-height: 0; }
.star { font-size: 64px; line-height: 1; color: var(--itch); -webkit-text-stroke: 3px var(--night); transform: scale(0); }
.star.on { animation: pop .45s cubic-bezier(.3, 1.8, .5, 1) forwards; }
.star.off { color: rgba(255,244,194,.18); -webkit-text-stroke: 3px rgba(255,244,194,.3); transform: scale(1); }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
#resTitle { color: var(--coil); font-size: clamp(36px, 8vw, 68px); }
.msg { font-size: 18px; font-weight: 700; color: #fff; }
.tally { display: flex; align-items: baseline; justify-content: center; gap: 12px; flex-wrap: wrap; font-weight: 700; }
#resScore { font-family: var(--display); font-size: clamp(48px, 12vw, 90px); color: var(--itch); text-shadow: var(--outline), 6px 6px 0 var(--sheet); line-height: 1; }
.coinsWon { font-weight: 800; color: var(--itch); white-space: pre; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 4; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) 14px 0; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-left { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
#score { font-family: var(--display); font-size: 28px; color: var(--itch); text-shadow: var(--outline), 4px 4px 0 var(--sheet); line-height: 1; padding-left: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--night); border: 3px solid var(--moon); border-radius: 30px;
  padding: 2px 12px; font-weight: 800; font-size: 15px; white-space: nowrap; }
#bumps { display: flex; gap: 7px; align-items: center; padding-top: 10px; }
.bump { width: 15px; height: 15px; border-radius: 50%; border: 3px solid var(--moon); background: rgba(255,244,194,.12); transition: transform .2s, background .2s; }
.bump.hit { background: var(--bite); border-color: var(--night); transform: scale(1.35); box-shadow: 0 0 0 3px var(--bite); }
.hud-right { display: flex; align-items: center; gap: 8px; }
#sib { font-size: 26px; line-height: 1; }
#wake { width: 80px; height: 12px; border: 3px solid var(--night); background: var(--moon); border-radius: 8px; overflow: hidden; }
#wakeFill { display: block; height: 100%; width: 0; background: var(--sheet); transition: width .15s; }
#pauseBtn { pointer-events: auto; }
#bossBar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-weight: 800; }
#bossBar .bar { width: min(320px, 55vw); height: 16px; border: 3px solid var(--night); background: var(--moon); border-radius: 10px; overflow: hidden; }
#bossFill { display: block; height: 100%; width: 100%; background: var(--bite); transition: width .3s; }
#powers { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
#powers .chip { border-color: var(--coil); font-size: 17px; }

/* ---------- Rewarded ad offers + test ad screen ---------- */
.reward { display: flex; flex-direction: column; align-items: center; font-family: var(--body); font-weight: 900; font-size: 18px; line-height: 1.25;
  color: #fff; background: var(--sheet); border: 4px solid var(--night); border-radius: 18px; padding: 10px 22px; cursor: pointer;
  box-shadow: 0 6px 0 var(--night); transform: rotate(1deg); animation: pop .4s cubic-bezier(.3, 1.8, .5, 1); max-width: 100%; }
.reward small { font-weight: 700; font-size: 13px; opacity: .9; }
.reward:active { transform: translateY(4px) rotate(1deg); box-shadow: 0 2px 0 var(--night); }
.reward:disabled { background: var(--coil); color: var(--night); cursor: default; transform: rotate(1deg); }
.adscreen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10,6,40,.92); }
.adbox { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px; text-align: center;
  background: #fff; color: var(--night); border: 4px solid var(--night); border-radius: 20px; box-shadow: 8px 8px 0 var(--coil); }
.adbox b { font-family: var(--display); font-weight: 400; font-size: 28px; }
.adtag { align-self: flex-start; background: var(--itch); border: 2px solid var(--night); border-radius: 8px; padding: 0 8px; font-weight: 800; font-size: 13px; }
.adbar { width: 100%; height: 14px; border: 3px solid var(--night); border-radius: 8px; overflow: hidden; }
.adbar i { display: block; height: 100%; width: 0; background: var(--coil); }

/* ---------- Site links on the title screen ---------- */
.site-links { display: flex; gap: 22px; justify-content: center; margin-top: 4px; }
.site-links a { color: var(--moon); opacity: .75; font-weight: 700; font-size: 15px; }

/* ---------- Content pages (About, Privacy) ---------- */
html.doc, html.doc body { overflow: auto; height: auto; min-height: 100%; user-select: text; -webkit-user-select: text; }
html.doc body { background: radial-gradient(circle at 50% 0, #2b2378, var(--night) 60%) fixed; }
.doc main { max-width: 680px; margin: 0 auto; padding: 28px 20px 64px; }
.doc .back { display: block; width: fit-content; margin-bottom: 18px; text-decoration: none; color: var(--moon); }
.doc .title2 { display: inline-block; margin-bottom: 8px; }
.doc h2 { font-family: var(--display); font-weight: 400; color: var(--coil); font-size: 24px; margin: 34px 0 8px; text-shadow: var(--outline); }
.doc p, .doc li { font-size: 17px; line-height: 1.65; max-width: none; margin: 0 0 12px; }
.doc ul { padding-left: 22px; margin: 0 0 12px; }
.doc a { color: var(--itch); font-weight: 700; }
.doc code { background: rgba(255,244,194,.12); padding: 1px 6px; border-radius: 6px; font-size: 15px; }
.doc .note { background: var(--moon); color: var(--night); border: 3px solid var(--night); border-radius: 14px; padding: 12px 16px;
  box-shadow: 5px 5px 0 var(--sheet); font-weight: 600; margin: 18px 0; }
.doc .note a { color: var(--bite); }
.doc .play { display: inline-block; text-decoration: none; margin-top: 18px; }
.doc footer { margin-top: 44px; font-size: 14px; opacity: .7; }

/* ---------- Home page (game portal) ---------- */
.doc main.home-main { max-width: 1040px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 18px 48px; }
.home-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin: 10px 0 34px; }
.clock { font-family: var(--comic); font-size: 22px; letter-spacing: .1em; color: var(--bite); background: #111; border: 3px solid var(--night);
  border-radius: 10px; padding: 2px 14px; margin: 0; box-shadow: 0 0 18px rgba(232,38,59,.45); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 26px; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 24px 22px 26px;
  background: radial-gradient(circle at 50% 20%, var(--glow), var(--night) 75%); color: var(--moon); border: 4px solid var(--night);
  border-radius: 26px; box-shadow: 0 10px 0 var(--night), 0 10px 0 4px var(--itch); }
.card.bzzz { --night: #1A1446; --moon: #FFF4C2; --itch: #FFE14D; --sheet: #FF5FA2; --coil: #2FBF4A; --glow: #3a2f9a; transform: rotate(-1deg); }
.card.shhh { --night: #0E2433; --moon: #FDF1DC; --itch: #FFB627; --sheet: #FF6B6B; --coil: #3DDC97; --glow: #22617a; transform: rotate(1deg); }
.card-art { width: 140px; height: auto; margin-bottom: -6px; }
.card h2 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 6vw, 54px); line-height: 1; margin: 0; color: var(--itch);
  text-shadow: var(--outline), 5px 5px 0 var(--sheet); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.card h2 small { font-family: var(--body); font-weight: 900; font-size: 17px; color: var(--night); background: var(--coil); border: 3px solid var(--night);
  border-radius: 30px; padding: 1px 14px 3px; text-shadow: none; transform: rotate(3deg); }
.card p { font-size: 16.5px; line-height: 1.55; max-width: 32em; }
.tags { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0; margin: 0; }
.tags li { font-weight: 800; font-size: 14px; border: 2px solid var(--moon); border-radius: 20px; padding: 2px 10px; }
.card .big { text-decoration: none; margin-top: 6px; color: var(--night); }
.home-text { margin-top: 54px; }
.home-text h2 { font-family: var(--display); font-weight: 400; font-size: 34px; color: var(--itch); text-shadow: var(--outline); margin: 30px 0 10px; }
.home-text h3 { margin: 6px 0 6px; }
.home-text p, .home-text li { font-size: 17px; line-height: 1.65; max-width: none; }
.home-text ul { padding-left: 22px; margin: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px 34px; }
.home-footer { display: flex; gap: 22px; justify-content: center; margin-top: 44px; }
.home-footer a { color: var(--moon); font-weight: 700; opacity: .8; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .bubble { margin-bottom: 44px; font-size: 14px; max-width: 160px; }
  .menu-grid { gap: 10px; }
  .menu-grid .ghost { font-size: 16px; padding: 10px 6px; }
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .page .day { font-size: 26px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pest { width: 150px; }
  .pest img { width: 90px; height: 90px; }
  #hud { padding-left: 10px; padding-right: 10px; }
  #score { font-size: 22px; }
  .chip { font-size: 13px; padding: 1px 9px; }
  #bumps { gap: 5px; }
  .bump { width: 12px; height: 12px; border-width: 2px; }
  #wake { width: 46px; }
  #sib { font-size: 20px; }
  .round { width: 40px; height: 40px; }
}
@media (max-width: 400px) {
  .home-hero .subtitle { font-size: 15px; padding: 2px 12px 3px; }
}
@media (max-height: 640px) and (orientation: landscape) {
  .mascot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reward { animation: none; }
  .mascot svg { animation: none; }
  .star.on { animation: none; transform: scale(1); }
}

/* Modak's digits fill in under the thick outline, so scores use extra-bold Grandstander */
#score, #resScore { font-family: var(--body); font-weight: 900; letter-spacing: .02em; }
