/* Paperboys putting game page. Pixel fonts: ByteBounce for the score and headings,
   Silkscreen Regular for everything else. Sizes are multiples of the fonts' 8px native grid. */

@font-face {
  font-family: 'Silkscreen';
  src: url('fonts/Silkscreen-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'ByteBounce';
  src: url('fonts/ByteBounce.ttf') format('truetype');
  font-weight: 400;
  font-display: block;
}

:root {
  --bg: #578a4a;          /* lawn: Safari tints its bars from this */
  --fg: #ffffff;
  --ink: #000000;
  --font-head: 'ByteBounce', monospace;       /* the heavy one: score, headings */
  --font-body: 'Silkscreen', monospace;        /* everything else */
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.25;
  -webkit-font-smoothing: none;
  font-smooth: never;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* the stage is always the whole window; the canvas paints the lawn edge to edge */
.stage {
  position: fixed;
  inset: 0;
  width: 100vw; width: 100dvw;
  height: 100vh; height: 100dvh;
  background: var(--bg);
  line-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  height: 100%;
}

/* the court: everything the player reads sits in here. Sized in JS (layout) to the play
   area; on desktop it sits unframed in the middle of the lawn, which carries on to the
   window edges. Overlay sizes use container units so the UI is identical on a phone and
   in the desktop court. */
.court {
  position: absolute;
  container-type: size;
}
/* on desktop, dark backdrops (game over, modals) spread past the court to the window edges */
.stage.framed .overlay.dead,
.stage.framed .modal { box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.6); }

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.score {
  position: absolute;
  top: 10px;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 96px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--fg);
}

/* overlays sit on the canvas */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  line-height: 1.25;
  padding: 24px;
  color: var(--fg);
  pointer-events: none;
}
.overlay.dead {
  background: rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  padding: 0;
  gap: 0;
  justify-content: stretch;
}
/* everything above the footer: centered in whatever height is left, scrolls only as a last resort */
.dead-main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(4px, 1.4cqh, 12px);
  padding: calc(24px + env(safe-area-inset-top)) 24px 24px;   /* top and bottom breathing room are equal */
  overflow: hidden;
}
.hidden { display: none !important; }
.stage.is-dead .score { display: none; }   /* the streak line carries the number on the death screen */

.prompt, .verdict {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 40px;
  line-height: 1;
  margin: 0;
  text-transform: uppercase;
}
.verdict { font-size: clamp(32px, 6.5cqh, 56px); }
.overlay.start { gap: 4px; }
.hint {
  margin: 0;
  font-size: 16px;
  animation: breathe 2.2s steps(4) infinite;
}
.result {
  margin: -6px 0 0;      /* hugs the verdict */
  font-size: 16px;
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* buttons: hard pixel slabs */
.btn {
  appearance: none;
  border: 3px solid var(--ink);
  background: var(--fg);
  color: var(--ink);
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 24px;
  line-height: 1;
  text-transform: uppercase;
  padding: 12px 16px 10px;
  border-radius: 0;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
@media (hover: hover) {
  .btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #000; }
  #retry:hover { box-shadow: 7px 7px 0 #000; }
  .btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
  .btn.ghost:hover { background: rgba(255, 255, 255, 0.12); box-shadow: none; }
  .slot .arrow:hover .px { fill: #fec200; }
  .slot .glyph { cursor: pointer; }
}
/* leaderboard: the frame holds the scrolling top 100 and the pinned Paperboys section */
.board {
  flex: 1 1 auto;          /* fills the height between the streak line and AGAIN */
  min-height: 0;
  width: 100%;
  max-width: 300px;
  margin: 10px 0;        /* equal breathing room above and below the board */
  text-align: left;
  display: flex;
  flex-direction: column;
  background: #172614;     /* darker than the dimmed lawn */
  border: 3px solid var(--fg);
  font-size: 16px;
  line-height: clamp(1.15, 2.4cqh, 1.5);
}
.board-title {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(24px, 3.5cqh, 32px);
  line-height: 1;
  margin: 0 0 6px;
  text-align: center;
  text-transform: uppercase;
}
.board ol { list-style: none; margin: 0; padding: 0; }
.board-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;        /* scrolls, no visible bar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.board .board-rows { padding: 8px 12px; }
.board-rows::-webkit-scrollbar { display: none; }
.board li { display: flex; gap: 10px; }
.board .rank { width: 3ch; opacity: 0.7; }
.board .name { flex: 1; display: flex; align-items: center; gap: 4px; }
.board .pb { display: block; flex: none; position: relative; top: 0.5px; }   /* Paperboys' badge, centered on the caps */
.board .pts { text-align: right; }
.board li.you { color: #fec200; }
.board-pb {
  flex: none;
  border-top: 3px solid var(--fg);
  padding: 6px 12px 8px;
}
.board-pb-title {
  font-family: var(--font-head);
  font-size: 16px;
  line-height: 1;
  margin: 0 0 4px;
  text-transform: uppercase;
}
#retry { font-size: 32px; padding: clamp(12px, 2cqh, 18px) 36px clamp(10px, 1.8cqh, 16px); margin-top: 0; flex: none; border-width: 4px; box-shadow: 6px 6px 0 #000; }

/* signup */
.signup {
  flex: none;
  width: 100%;
  padding: 12px min(16px, 2.5cqw) calc(14px + env(safe-area-inset-bottom));
  background: #578a4a;
  border-top: 3px solid var(--fg);
  text-align: center;
  line-height: 1.25;
}
.stage.framed .signup { border: 3px solid var(--fg); }   /* no court edge under it on desktop: a full card */
.sub {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(20px, 8cqw, 32px);  /* measured: fits one line down to 320px wide */
  white-space: nowrap;
  line-height: 1;
  margin: 0 0 2px;
  text-transform: uppercase;
}
.blurb { margin: 0 0 10px; font-size: 16px; white-space: nowrap; }
.form {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
}
.form input { flex: 1; min-width: 0; }
.btn.small { font-size: 24px; padding: 10px 14px 8px; }
.form input {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1;
  padding: 12px 12px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.form input:focus { box-shadow: 4px 4px 0 #000; }
.form .btn { flex: none; white-space: nowrap; }
.thanks {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: 40px;
  margin: 0;
  text-transform: uppercase;
  color: #fec200;
}
.err { margin: 8px 0 0; color: #ffb3b3; }

/* high score modal */
.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: min(24px, 4cqw);
  background: rgba(0, 0, 0, 0.6);
  z-index: 5;
  pointer-events: auto;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  padding: 28px min(20px, 4cqw) 24px;
  background: #172614;
  border: 3px solid var(--fg);
  text-align: center;
}
.hs-title {
  font-family: var(--font-head);
  font-size: 48px;
  line-height: 1;
  margin: 0 0 6px;
  text-transform: uppercase;
  color: #fec200;
}
.hs-sub { margin: 0 0 20px; font-size: 16px; }
.letters {
  display: flex;
  justify-content: center;
  gap: min(12px, 3cqw);
  margin-bottom: 20px;
}
.slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.slot .glyph {
  width: min(60px, 16cqw); height: 72px;
  border: 3px solid var(--fg);
  background: #000;
  font-family: var(--font-head);
  font-size: 48px;
  line-height: 66px;
  text-transform: uppercase;
}
.slot.on .glyph { border-color: #fec200; }
.slot .arrow {
  appearance: none;
  width: min(60px, 16cqw); height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  display: flex; align-items: center; justify-content: center;
}
.slot .arrow .px { width: 28px; height: 16px; fill: var(--fg); }
.slot .arrow:active .px { fill: #fec200; }
.slot .arrow:active { transform: translateY(1px); }
.hs-err { margin: 0 0 10px; color: #ffb3b3; font-size: 16px; }
.hs-actions { display: flex; gap: 12px; justify-content: center; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--fg); box-shadow: none; }

.score { top: calc(12px + env(safe-area-inset-top)); }
.stage.framed .score { top: 12px; }

/* phones held sideways: cover everything and ask for portrait */
.rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
  text-align: center;
  line-height: 1.25;
}
.rotate-msg {
  margin: 0;
  font-family: var(--font-head);
  font-size: 48px;
  line-height: 1;
  text-transform: uppercase;
}
.rotate-sub { margin: 0; font-size: 16px; }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 540px) {
  .rotate { display: flex; }
}

/* honeypot: off-screen field only bots fill in */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
