@font-face { font-family: Fredoka; src: url(/fonts/fredoka.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --ink: #2b1d3a;      /* outlines and text */
  --cream: #fff7e8;
  --orange: #ff9a3c;
  --pink: #ff6f91;
  --teal: #3ec9b5;
  --sky: #bfdcff;
  --shadow: 0 5px 0 var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); font: 500 16px/1.3 Fredoka, system-ui, sans-serif; }
canvas { display: block; }
kbd { display: inline-block; min-width: 1.7em; padding: 1px 6px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 7px; background: var(--cream); font: 600 13px Fredoka, sans-serif; text-align: center; }

/* --- overlay: loading → pick → joining --- */
#overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, #ffd9a8 0 8%, transparent 8.5%) 0 0 / 120px 120px,
              radial-gradient(circle at 75% 65%, #ffc7d6 0 7%, transparent 7.5%) 0 0 / 150px 150px,
              linear-gradient(160deg, #ffe3b8, #ffb8c9 55%, #c9b6ff);
  transition: opacity .35s, visibility .35s;
}
#overlay.gone { opacity: 0; visibility: hidden; }
.card {
  width: min(380px, 100%); padding: 22px 26px 26px; text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 28px; box-shadow: 0 10px 0 var(--ink);
  animation: pop .45s cubic-bezier(.3, 1.6, .5, 1);
}
.logo { margin: 0 0 14px; font-size: 44px; font-weight: 700; letter-spacing: -1px; color: var(--orange);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.logo span { display: inline-block; color: var(--pink); transform: rotate(-14deg) translateY(4px); animation: wobble 2.4s ease-in-out infinite; }
#overlay section, #overlay form { display: none; }
#overlay[data-state=loading] .loading, #overlay[data-state=pick] .pick, #overlay[data-state=joining] .joining { display: grid; gap: 14px; }

.bar { height: 22px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.bar div { height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--orange) 0 12px, #ffb366 12px 24px);
  border-right: 3px solid var(--ink); transition: width .2s; animation: stripes .6s linear infinite; }
.loading p, .joining p { margin: 0; font-weight: 600; }
.paws { display: flex; justify-content: center; gap: 12px; height: 34px; }
.paws i { width: 22px; height: 22px; border-radius: 50% 50% 45% 45%; background: var(--ink); position: relative; animation: step 1.2s ease-in-out infinite; }
.paws i::before { content: ''; position: absolute; left: -2px; top: -11px; width: 26px; height: 9px;
  background: radial-gradient(circle, var(--ink) 3.6px, transparent 4px) 0 0 / 8.6px 9px repeat-x; }
.paws i:nth-child(2) { animation-delay: .2s; } .paws i:nth-child(3) { animation-delay: .4s; }

/* --- cat picker --- */
#preview { justify-self: center; width: 240px; height: 180px; border-radius: 20px; border: 3px solid var(--ink); background: linear-gradient(#fff2db, #ffd9b0); }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; padding: 0; border: 0; }
.swatches legend, .chonk b { font-weight: 700; margin-bottom: 6px; padding: 0; width: 100%; }
.swatches button, .swatches label {
  width: 34px; height: 34px; padding: 0; border: 3px solid var(--ink); border-radius: 50%; cursor: pointer;
  box-shadow: 0 3px 0 var(--ink); transition: transform .12s;
}
.swatches button:hover, .swatches label:hover { transform: translateY(-2px) rotate(-8deg); }
.swatches [aria-pressed=true] { outline: 4px solid var(--pink); outline-offset: 2px; }
.swatches label { display: grid; place-items: center; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); position: relative; }
.swatches label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chonk { display: grid; gap: 4px; text-align: left; }
.chonk .row { display: flex; justify-content: space-between; align-items: baseline; }
.chonk output { font-weight: 700; color: var(--pink); }
.chonk .ends small { opacity: .7; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; border: 3px solid var(--ink); border-radius: 99px;
  background: linear-gradient(90deg, #ffe0b8, var(--orange)); cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream); box-shadow: 0 3px 0 var(--ink); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream); }
.go {
  margin-top: 4px; padding: 13px; font: 700 20px Fredoka, sans-serif; color: #fff; cursor: pointer;
  background: var(--pink); border: 4px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow);
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; transition: transform .1s, box-shadow .1s;
}
.go:hover { transform: translateY(-2px) rotate(-1deg); box-shadow: 0 7px 0 var(--ink); }
.go:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
:focus-visible { outline: 4px solid var(--teal); outline-offset: 3px; }

/* --- HUD --- */
#hud { position: fixed; top: 14px; left: 14px; right: 14px; display: flex; gap: 10px; align-items: center; pointer-events: none; z-index: 5; }
.pill { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; background: var(--cream);
  border: 3px solid var(--ink); border-radius: 99px; box-shadow: 0 4px 0 var(--ink); font-size: 19px; }
.pill b { font-weight: 700; font-variant-numeric: tabular-nums; }
.mess .meter { width: 120px; height: 16px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.mess .meter div { height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), #ffd23f 50%, var(--pink)); transition: width .25s cubic-bezier(.3, 1.5, .5, 1); }
.ping { margin-left: auto; font-size: 15px; }
.ping i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #9be15d; }
.ping i.meh { background: #ffd23f; } .ping i.bad { background: var(--pink); }
.bump { animation: bump .35s cubic-bezier(.3, 1.8, .5, 1); }

#hint { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 5; text-align: center; pointer-events: none;
  padding: 10px 18px 12px; background: var(--cream); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink); }
#hint p { margin: 0; } #hint .click { font-size: 22px; font-weight: 700; margin-bottom: 6px; animation: wobble 1.6s ease-in-out infinite; }
#hint .party { margin-top: 6px; font-size: 14px; font-weight: 600; }
#hint.playing .click { display: none; } #hint.playing { opacity: .85; transform: translateX(-50%) scale(.85); transform-origin: bottom; }

#toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 10px 18px; font-size: 20px; font-weight: 700;
  background: #ffd23f; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
#toast.error { background: var(--pink); color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; pointer-events: auto; }
#toast button { margin-left: 10px; font: 700 16px Fredoka, sans-serif; padding: 4px 12px; border: 3px solid var(--ink); border-radius: 12px; background: var(--cream); cursor: pointer; }

@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.18) rotate(-4deg); } }
@keyframes wobble { 50% { transform: rotate(6deg) translateY(-2px); } }
@keyframes step { 0%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-8px); opacity: 1; } }
@keyframes stripes { to { background-position: 34px 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
@media (max-width: 560px) { .mess .meter { width: 70px; } .pill { font-size: 16px; height: 38px; } #hint .keys { display: none; } }

/* --- comic onomatopoeia over the 3D view --- */
#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bam {
  position: absolute; translate: -50% -50%; padding: .35em .6em; white-space: nowrap;
  font: 700 calc(30px * var(--s, 1)) / 1 Fredoka, sans-serif; letter-spacing: 1px; color: #ffe14d;
  -webkit-text-stroke: calc(4px * var(--s, 1)) var(--ink); paint-order: stroke fill; text-shadow: 0 calc(4px * var(--s, 1)) 0 var(--ink);
  animation: bam 0.9s cubic-bezier(.2, 1.6, .4, 1) forwards;
}
/* the jagged burst behind the word */
.bam::before {
  content: ''; position: absolute; inset: -40% -18%; z-index: -1; background: #fff4c9;
  border: none; filter: drop-shadow(0 0 0 var(--ink)) drop-shadow(3px 4px 0 var(--ink));
  clip-path: polygon(50% 0, 60% 22%, 85% 6%, 76% 32%, 100% 38%, 79% 55%, 96% 80%, 68% 72%, 60% 100%, 46% 76%, 22% 96%, 26% 68%, 0 64%, 20% 46%, 4% 18%, 32% 26%);
}
.bam.swat { color: #fff; } .bam.swat::before { background: var(--pink); }
.bam.crash { color: #ffe14d; } .bam.crash::before { background: var(--orange); }
.bam.hit { color: #fff; } .bam.hit::before { background: #8fa3b8; }
.bam.pole { color: #ffe14d; } .bam.pole::before { background: #a0663f; }
.bam.zap { color: #fff36b; } .bam.zap::before { background: #4b6cff; }
.bam.hydrant { color: #fff; } .bam.hydrant::before { background: #3fb6ff; }
.bam.litter { color: #fff; } .bam.litter::before { background: #c9a35c; }
.bam.mail { color: #fff; } .bam.mail::before { background: #3d6fb8; }
.bam.boing { color: #fff; } .bam.boing::before { background: #2c6fd6; }
.bam.dog { color: #fff; } .bam.dog::before { background: #8a5a35; }
.bam.grr { color: #ffe14d; } .bam.grr::before { background: #2b1d14; }
.bam.nom { color: #fff; } .bam.nom::before { background: #f2a33a; }
.bam.reset { color: #fff; } .bam.reset::before { background: #e02020; }
.bam.boom { color: #ffe14d; animation-duration: 1.5s; } .bam.boom::before { background: #ff4a1c; inset: -60% -30%; }
@keyframes bam {
  0% { transform: scale(.2) rotate(calc(var(--r) - 25deg)); opacity: 0; }
  18% { transform: scale(1.25) rotate(var(--r)); opacity: 1; }
  30% { transform: scale(1) rotate(var(--r)); }
  75% { opacity: 1; }
  100% { transform: translateY(-60px) scale(1.05) rotate(var(--r)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .bam { animation-duration: 1.2s; animation-timing-function: ease-out; } }
