﻿/* Doodle Chomp — full-screen canvas game (a hay maze on the farm), with paper-note DOM overlays */
:root { --paper: #fbf7ea; --ink: #1f3a93; --pencil: #3a3a46; --muted: #6d6a62; --hi: #ffd23f; --red: #e5383b; --green: #6cc04a;
  font-family: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7db148; color: var(--pencil); overscroll-behavior: none; }
h1, h2 { margin: 0; font-weight: 400; }
a { color: var(--ink); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.game { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
.hud { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: flex; align-items: center; justify-content: center; gap: clamp(8px, 3vw, 28px);
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none;
  background: rgba(251, 247, 234, .92); border-bottom: 3px solid #8b5a2b; box-shadow: 0 2px 6px rgba(40, 60, 20, .25); }
.h-box { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.h-box span { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.h-box b { font-weight: 400; font-size: 26px; color: var(--ink); min-width: 2ch; text-align: center; }
.lives b { color: var(--red); letter-spacing: 2px; font-size: 22px; }
.btns { display: flex; gap: 6px; pointer-events: auto; }
.hb { width: 40px; height: 40px; border-radius: 12px 14px 11px 15px; border: 2px solid var(--pencil); background: #fff; font-size: 15px; display: grid; place-items: center; box-shadow: 2px 2px 0 rgba(0, 0, 0, .12); }
@media (max-width: 420px) { .h-box b { font-size: 21px; } .h-box span { font-size: 12px; } .hb { width: 34px; height: 34px; font-size: 13px; } .hud { gap: 9px; } }

/* ---------- D-pad ---------- */
.dpad { position: absolute; left: 50%; width: 156px; height: 156px; transform: translateX(-50%); display: grid;
  grid-template: 'a u b' 1fr 'l c r' 1fr 'd w e' 1fr / 1fr 1fr 1fr; gap: 4px; }
.dpad button { border: 2.5px solid var(--pencil); background: rgba(255, 255, 255, .85); border-radius: 14px 11px 15px 12px; font-size: 20px; color: var(--ink);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .12); touch-action: none; }
.dpad button.on { background: var(--hi); transform: translateY(1px); }
.dpad .up { grid-area: u; } .dpad .left { grid-area: l; } .dpad .right { grid-area: r; } .dpad .down { grid-area: w; }

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: rgba(40, 60, 20, .35); }
.card { position: relative; width: min(520px, 100%); background: #fffef8; border: 2.5px solid var(--pencil); border-radius: 18px 22px 16px 24px / 22px 16px 24px 18px;
  padding: 26px 22px 16px; text-align: center; box-shadow: 5px 6px 0 rgba(31, 58, 147, .14); transform: rotate(-.6deg); margin: auto; }
.card::before { content: ''; position: absolute; top: -13px; left: 50%; width: 110px; height: 26px; transform: translateX(-50%) rotate(2deg);
  background: rgba(255, 210, 63, .55); border-left: 1px dashed rgba(0, 0, 0, .15); border-right: 1px dashed rgba(0, 0, 0, .15); }
.card.small { width: min(340px, 100%); }
.kicker { margin: 0; font-size: 15px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
h1 { font-size: clamp(46px, 11vw, 64px); line-height: 1; color: var(--ink); transform: rotate(-1.5deg); }
h2 { font-size: 40px; color: var(--ink); margin-bottom: 8px; }
.tagline { margin: 4px 0 10px; font-size: 21px; }
.cast { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 6px 0 4px; }
.cast figure { margin: 0; width: 76px; font-size: 18px; line-height: 1; color: var(--ink); }
.cast canvas { width: 52px; height: 52px; display: block; margin: 0 auto 3px; }
.cast small { font-size: 13px; color: var(--muted); }
.rules { text-align: left; margin: 10px auto; padding-left: 22px; font-size: 18px; line-height: 1.3; max-width: 430px; }
.rules li { margin: 3px 0; }
.rules b { font-weight: 400; color: var(--ink); background: linear-gradient(transparent 55%, rgba(255, 210, 63, .6) 55%); }
.controls { font-size: 17px; color: var(--muted); margin: 6px 0 14px; }
kbd { display: inline-block; min-width: 22px; padding: 0 5px; border: 1.5px solid var(--pencil); border-radius: 5px 6px 5px 7px; background: #fff; font: inherit; font-size: 15px; line-height: 20px; color: var(--pencil); margin: 0 1px; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: block; } .key-only { display: none; } }

.btn { display: block; width: 100%; margin: 8px 0; padding: 10px 14px; font-size: 22px; background: #fff; border: 2.5px solid var(--pencil);
  border-radius: 14px 18px 12px 20px / 18px 12px 20px 14px; box-shadow: 3px 4px 0 rgba(0, 0, 0, .14); transition: transform .08s; }
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .14); }
.btn.primary { background: var(--hi); color: var(--pencil); }
.btn.big { font-size: 27px; padding: 12px 14px; }
.best-line { min-height: 1em; margin: 6px 0 0; font-size: 18px; color: var(--ink); }
.links { font-size: 16px; margin: 12px 0 0; color: var(--muted); }

.o-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 10px; }
.o-stats div { border: 2px dashed rgba(58, 58, 70, .35); border-radius: 12px; padding: 6px 4px; }
.o-stats span { display: block; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.o-stats b { font-weight: 400; font-size: 30px; color: var(--ink); }
.new-best { font-size: 22px; color: var(--red); margin: 4px 0; transform: rotate(-2deg); }

.ad-wrap { width: 100%; text-align: center; margin-top: 10px; font-family: system-ui, sans-serif; }
.ad-wrap.ad-on { min-height: 100px; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
