@font-face { font-family: "Pixelify Sans"; src: url("fonts/pixelify-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #3b2c1c;
  --ink-2: #66553f;
  --paper: #fff8e1;
  --paper-2: #f8ebc4;
  --paper-3: #e7cf95;
  --white: #fffdf4;
  --mallard: #2fae55;
  --mallard-2: #1f7f3e;
  --bill: #ffc93a;
  --bill-2: #d8901a;
  --sea: #3d98de;
  --pw: 3px;
  --body: "Pixelify Sans", ui-rounded, system-ui, sans-serif;
  /* Because Silkscreen has 8 font pixels per em, sizes stay at multiples of 8px to land its pixels on whole screen pixels.
     Its bold fills the one-pixel gaps in 4, M, W and R. Text uses the regular weight, and only the logo and titles are bold. */
  --head: "Silkscreen", "Pixelify Sans", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sea);
  color: var(--ink);
  font: 17px/1.35 var(--body);
  -webkit-font-smoothing: antialiased;
}
body:not(.ready) .hud, body:not(.ready) .panel { opacity: 0; }
.hud, .panel { transition: opacity 0.4s steps(4); }
button, input { font: inherit; color: inherit; }
a { color: var(--mallard-2); }
[hidden] { display: none !important; }
:focus-visible { outline: var(--pw) solid var(--bill); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#map { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; image-rendering: pixelated; touch-action: none; cursor: grab; }

/* The pixel box: ink edges with notched corners, a light top bevel and a hard drop shadow. */
.pbox {
  background: var(--paper);
  box-shadow:
    0 calc(-1 * var(--pw)) 0 0 var(--ink), 0 var(--pw) 0 0 var(--ink),
    calc(-1 * var(--pw)) 0 0 0 var(--ink), var(--pw) 0 0 0 var(--ink),
    inset 0 var(--pw) 0 0 var(--white), inset 0 calc(-1 * var(--pw)) 0 0 var(--paper-3),
    calc(var(--pw) * 2) calc(var(--pw) * 3) 0 0 rgba(16, 40, 80, 0.35);
}

/* ---------- top bar ---------- */
.hud { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 18px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.logo-duck { width: 51px; height: 36px; image-rendering: pixelated; filter: drop-shadow(3px 3px 0 rgba(16, 40, 80, 0.4)); animation: bob 1.2s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
.brand-text { display: flex; flex-direction: column; }
.logo {
  font: 700 32px/1 var(--head);
  color: var(--bill);
  text-shadow:
    -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink),
    -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink),
    6px 6px 0 var(--mallard-2);
}
.tagline { margin-top: 8px; font-size: 16px; color: #fff; text-shadow: -2px 0 0 var(--ink), 2px 0 0 var(--ink), 0 -2px 0 var(--ink), 0 2px 0 var(--ink), 2px 2px 0 var(--ink); }
.tools { display: flex; gap: 12px; padding: 3px; }
.tool {
  min-width: 42px; height: 42px; padding: 0 10px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 400 16px/1 var(--head); background: var(--paper);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -3px 0 0 var(--paper-3), 4px 6px 0 0 rgba(16, 40, 80, 0.35);
}
.tool:hover { background: #fff; }
.tool:active { transform: translateY(2px); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), 2px 3px 0 0 rgba(16, 40, 80, 0.35); }
.tool svg { width: 18px; height: 18px; }
.tool-wide .ico svg { width: 16px; height: 16px; display: block; }

/* ---------- panel ---------- */
.panel {
  position: fixed; z-index: 10; right: 22px; top: 84px; max-height: calc(100vh - 106px); max-height: calc(100dvh - 106px); width: min(400px, 36vw);
  display: flex; flex-direction: column; padding: 16px 16px 14px;
}
.kicker a { color: inherit; text-decoration: none; }
.kicker { margin: 0; font: 400 16px/24px var(--head); letter-spacing: 0.125em; text-transform: uppercase; color: var(--ink-2); }
.eggs { display: flex; gap: 6px; margin: 0 0 10px 4px; }
.egg { width: 20px; height: 20px; }
.egg.next { animation: wobble 0.8s steps(2) infinite; }
@keyframes wobble { 50% { transform: rotate(-10deg) translateY(-1px); } }

.clues { list-style: none; margin: 0; padding: 4px 6px 4px 3px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.clue {
  display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start;
  margin: 3px 3px 12px; padding: 10px 12px 10px 10px; background: var(--white);
  box-shadow: 0 -2px 0 0 var(--ink-2), 0 2px 0 0 var(--ink-2), -2px 0 0 0 var(--ink-2), 2px 0 0 0 var(--ink-2), 3px 4px 0 0 rgba(59, 44, 28, 0.18);
}
.clue .num {
  display: grid; place-items: center; width: 30px; height: 30px; font: 400 24px/1 var(--head);
  background: var(--bill); box-shadow: inset -3px -3px 0 0 var(--bill-2), 0 0 0 2px var(--ink);
}
.clue .num svg { width: 14px; height: 14px; color: var(--ink-2); }
.clue-text { margin: 0; }
.clue-text p { margin: 0; }
.clue-text .src { display: inline-block; margin-top: 6px; }
.src { font-size: 16px; color: var(--ink-2); text-decoration: underline dotted; text-underline-offset: 3px; }
.src:hover { color: var(--mallard-2); }
.clue.fresh { animation: drop 0.5s steps(5); }
@keyframes drop { 0% { transform: translateY(-14px); opacity: 0; } 60% { transform: translateY(3px); opacity: 1; } }
.flag-px { display: block; width: 195px; height: 145px; image-rendering: pixelated; margin: 4px 0 8px; }

.guess { position: relative; display: flex; gap: 12px; margin: 8px 3px 4px; }
.guess.shake { animation: shake 0.3s steps(6); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.combo { position: relative; flex: 1; }
#guess {
  width: 100%; height: 48px; padding: 0 12px; border: 0; background: #fff; font-size: 18px;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 3px 3px 0 0 #e9e2cf;
}
#guess:focus { outline: none; box-shadow: 0 -3px 0 0 var(--mallard-2), 0 3px 0 0 var(--mallard-2), -3px 0 0 0 var(--mallard-2), 3px 0 0 0 var(--mallard-2), inset 3px 3px 0 0 #e9e2cf; }
#guess:disabled { background: var(--paper-2); }
.suggest { position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); z-index: 5; list-style: none; margin: 0; padding: 6px; }
.suggest li { padding: 8px 10px; cursor: pointer; font-size: 17px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--bill); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border: 0; cursor: pointer;
  font: 400 16px/1 var(--head); text-transform: uppercase; background: var(--paper); text-decoration: none; color: var(--ink);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -4px 0 0 var(--paper-3), 4px 6px 0 0 rgba(16, 40, 80, 0.3);
}
.btn:active { transform: translateY(3px); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -2px 0 0 var(--paper-3), 2px 3px 0 0 rgba(16, 40, 80, 0.3); }
.btn-yellow { background: var(--bill); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -4px 0 0 var(--bill-2), 4px 6px 0 0 rgba(16, 40, 80, 0.3); }
.btn-yellow:hover { background: #ffd65c; }
.btn:disabled { opacity: 0.55; cursor: default; }
.fly { min-width: 96px; }
.fly.ready { animation: nudge 0.7s steps(2) infinite; }
@keyframes nudge { 50% { transform: translateY(-3px); } }
.guess.over .combo { display: none; }
.guess.over .fly { flex: 1; }

.guesses { list-style: none; margin: 10px 3px 0; padding: 0; max-height: 30%; overflow-y: auto; flex-shrink: 0; }
.guess-row { display: grid; grid-template-columns: 18px 1fr; grid-template-areas: "s n" "s t"; column-gap: 10px; align-items: center; padding: 6px 4px; border-top: 2px dashed var(--paper-3); }
.guess-row:first-child { border-top: 0; }
.swatch { grid-area: s; width: 16px; height: 16px; background: var(--c); box-shadow: 0 0 0 2px var(--r), inset -3px -3px 0 0 rgba(0, 0, 0, 0.12); display: inline-block; }
.g-name { grid-area: n; font-weight: 700; }
.g-tier { grid-area: t; font-size: 16px; color: var(--ink-2); }

/* ---------- bonus round: the finished panel becomes the game ---------- */
.bonus, .bonus-exit { display: none; }
.bonus-btn { width: calc(100% - 6px); margin: 10px 3px 4px; }
.panel.bonus-on { bottom: 22px; padding: 0; background: #8fd3ff; }
.panel.bonus-on > :not(.bonus):not(.bonus-exit) { display: none; }
.panel.bonus-on .bonus-exit { display: grid; place-items: center; position: absolute; top: 10px; right: 10px; z-index: 1; width: 34px; height: 34px; padding: 0; border: 0; cursor: pointer; color: var(--ink); background: var(--paper); box-shadow: 0 0 0 3px var(--ink), inset 0 -3px 0 0 var(--paper-3), 3px 4px 0 0 rgba(16, 40, 80, 0.35); }
.bonus-exit svg { width: 16px; height: 16px; }
.panel.bonus-on .bonus { display: block; flex: none; margin: auto auto 0; image-rendering: pixelated; cursor: pointer; touch-action: manipulation; }
.panel.bonus-on .bonus:focus-visible { outline: none; }

/* ---------- floating bits ---------- */
.tip { position: fixed; z-index: 30; pointer-events: none; padding: 6px 10px; font-size: 16px; white-space: nowrap; }
.tip span { color: var(--ink-2); font-size: 16px; }
.callout {
  position: fixed; z-index: 15; pointer-events: none; transform-origin: 50% 100%;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px 9px; white-space: nowrap;
  background: var(--c); color: var(--ink);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 -4px 0 0 rgba(0, 0, 0, 0.12), 5px 7px 0 0 rgba(16, 40, 80, 0.35);
}
.callout::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 12px; height: 9px; transform: translateX(-50%); background: var(--ink); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.callout strong { font: 400 24px/1 var(--head); text-transform: uppercase; }
.callout span { font-size: 16px; }
.callout.pop { animation: pop 0.45s steps(5); }
@keyframes pop { 0% { transform: translateY(40%) scale(0.4); opacity: 0; } 60% { transform: translateY(-8%) scale(1.08); opacity: 1; } }

/* The toast sits above the modals to show "Copied!" over the results card. */
.toast { position: fixed; z-index: 55; left: 50%; bottom: 28px; transform: translate(-50%, 160%); padding: 10px 16px; font-size: 16px; max-width: min(92vw, 460px); text-align: center; pointer-events: none; opacity: 0; }
.toast.show { animation: toast 2.6s steps(1, end) forwards; }
@keyframes toast { 0% { transform: translate(-50%, 0); opacity: 1; } 92% { transform: translate(-50%, 0); opacity: 1; } 100% { opacity: 0; } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(16, 40, 80, 0.45); }
.modal-box { position: relative; width: min(540px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px 26px 22px; animation: rise 0.35s steps(5); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.big { margin: 6px 0 12px; font: 700 40px/1 var(--head); color: var(--bill); text-shadow: -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 6px 6px 0 var(--mallard-2); }
.big.lost { color: #d9d4c9; }
.how { padding-left: 22px; margin: 8px 0 14px; }
.how li { margin: 6px 0; }
.ladder { list-style: none; margin: 0 0 18px; padding: 0; }
.ladder li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 16px; color: var(--ink-2); }
.ladder strong { color: var(--ink); min-width: 118px; font-size: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0 6px; }
.answer { font-size: 19px; margin: 0 0 14px; }
.reveal { display: flex; flex-wrap: wrap; gap: 18px 20px; }
.reveal-flag { flex: 0 0 234px; }
.flag-big { display: block; width: 234px; height: 174px; image-rendering: pixelated; margin: 0 0 12px; }
.pemojis { display: flex; gap: 3px; }
.pemoji { display: block; width: 36px; height: 36px; }
.record { flex: 1 1 200px; min-width: 0; }
.modal .record h3 { margin-top: 0; }
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dist li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; font: 400 16px/16px var(--head); }
.dist b { justify-self: start; font-weight: 400; min-width: 32px; padding: 4px 6px 4px 4px; text-align: right; background: var(--paper-3); box-shadow: inset 0 -2px 0 0 rgba(59, 44, 28, 0.18); }
.dist .mine b { background: var(--bill); box-shadow: inset 0 -3px 0 0 var(--bill-2); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 0; text-align: center; }
.stat-row div { display: grid; align-content: start; }
.stat-row dd { grid-row: 1; margin: 0; font: 400 32px/32px var(--head); }
.stat-row dt { grid-row: 2; margin-top: 6px; font-size: 16px; line-height: 1.15; color: var(--ink-2); }
.rk-canvas { position: fixed; inset: 0; z-index: 60; width: 100vw; height: 100vh; pointer-events: none; image-rendering: pixelated; }
.flash { position: fixed; inset: 0; z-index: 61; background: #fffdf4; pointer-events: none; }
#map.quake { animation: quake 0.32s steps(8); }
@keyframes quake { 12% { transform: translate(-6px, 3px); } 25% { transform: translate(5px, -4px); } 37% { transform: translate(-4px, -3px); } 50% { transform: translate(4px, 4px); } 62% { transform: translate(-3px, 2px); } 75% { transform: translate(2px, -2px); } 87% { transform: translate(-1px, 1px); } }
.modal h3 { font: 400 16px/1 var(--head); text-transform: uppercase; margin: 20px 0 8px; color: var(--ink-2); }
.explore { display: inline-block; margin-top: 12px; font: 400 16px/24px var(--head); color: var(--mallard-2); }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; color: #fff; font-size: 22px; }

/* ---------- phones: the panel becomes a bottom sheet ---------- */
@media (max-width: 820px) {
  .hud { padding: 10px 12px; }
  .logo { font-size: 24px; }
  .logo-duck { width: 34px; height: 24px; }
  .tagline { display: none; }
  .tools { gap: 6px; }
  .tool { min-width: 36px; height: 36px; padding: 0 8px; }
  .tool-wide span:last-child { display: none; }
  .panel { left: 10px; right: 10px; top: auto; bottom: calc(10px + var(--safe-b)); width: auto; max-height: 52dvh; padding: 12px 12px 10px; }
  .clue { margin-bottom: 8px; padding: 8px 10px 8px 8px; font-size: 16px; }
  .guesses { display: flex; gap: 8px; flex-wrap: wrap; max-height: none; margin-top: 8px; }
  .guess-row { display: flex; gap: 6px; padding: 4px 8px 4px 4px; border: 0; background: var(--white); font-size: 16px; box-shadow: 0 0 0 2px var(--paper-3); }
  .g-tier { display: none; }
  .g-name { font-weight: 400; }
  .flag-px { width: 156px; height: 116px; }
  .toast { bottom: auto; top: 70px; }
  .panel.bonus-on { height: 46dvh; }
  .stat-row dd { font: 400 24px/24px var(--head); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; }
}
