/* Flappy Bird — shell + overlay UI.
   The playfield is a fixed 288x512 box; every UI size is expressed as
   `px * var(--s)` so the overlay scales exactly like the canvas does. */

:root {
  --sky: #4ec0ca;
  --ink: #3b2a1a;
  --paper: #ded895;
  --paper-edge: #7e6b4c;
  --green: #57b43a;
  --green-dark: #3f8a2a;
  --orange: #ef7d1a;
  --orange-dark: #b85a0d;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 22%, #24404a 0%, #101a1f 70%, #080d10 100%);
  font-family: var(--font);
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

/* ---------------- stage ---------------- */

#stage {
  --s: 1; /* px-per-world-unit, kept in sync by main.js */
  position: relative;
  width: min(100vw, calc(100vh * 288 / 512));
  width: min(100vw, calc(100dvh * 288 / 512));
  aspect-ratio: 288 / 512;
  overflow: hidden;
  background: var(--sky);
  box-shadow: 0 calc(4px * var(--s)) calc(14px * var(--s)) rgba(0, 0, 0, 0.55);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ---------------- screens ---------------- */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(10px * var(--s));
  padding: calc(16px * var(--s));
  text-align: center;
}

.screen.is-open {
  display: flex;
  pointer-events: auto;
}

#screen-loading,
#screen-over,
#screen-paused {
  background: rgba(8, 16, 20, 0.55);
  backdrop-filter: blur(calc(1px * var(--s)));
}

#screen-start {
  background: linear-gradient(rgba(8, 16, 20, 0.42), rgba(8, 16, 20, 0.62));
  justify-content: flex-start;
  padding-top: calc(70px * var(--s));
}

.loading-text,
.paused-text {
  font-size: calc(12px * var(--s));
  font-weight: 800;
  letter-spacing: calc(0.5px * var(--s));
  text-shadow: 0 calc(2px * var(--s)) 0 rgba(0, 0, 0, 0.6);
}

.paused-text small {
  font-size: calc(7px * var(--s));
  opacity: 0.8;
}

/* The original title, cropped out of the shipped message.png sheet. */
.logo {
  width: calc(184px * var(--s));
  height: calc(48px * var(--s));
  background-image: url(assets/sprites/message.png);
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: calc(184px * var(--s)) calc(267px * var(--s));
  image-rendering: pixelated;
  filter: drop-shadow(0 calc(2px * var(--s)) 0 rgba(0, 0, 0, 0.35));
}

.banner {
  width: calc(192px * var(--s));
  height: calc(42px * var(--s));
  image-rendering: pixelated;
}

/* ---------------- address form ---------------- */

#address-form {
  width: 100%;
  max-width: calc(240px * var(--s));
  margin-top: calc(18px * var(--s));
  display: flex;
  flex-direction: column;
  gap: calc(5px * var(--s));
  align-items: stretch;
}

#address-form label {
  font-size: calc(7.5px * var(--s));
  font-weight: 700;
  letter-spacing: calc(0.4px * var(--s));
  text-transform: uppercase;
  opacity: 0.92;
  text-align: left;
}

#address-form label .muted {
  opacity: 0.55;
  text-transform: none;
  font-weight: 600;
}

#address {
  width: 100%;
  padding: calc(7px * var(--s)) calc(8px * var(--s));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: calc(6.5px * var(--s)); /* a full 44-char pubkey fits without scrolling */
  color: var(--ink);
  background: var(--paper);
  border: calc(2px * var(--s)) solid var(--paper-edge);
  border-radius: 0;
  outline: none;
  min-width: 0;
}

#address:focus {
  border-color: var(--orange);
}

#address.is-invalid {
  border-color: #d63a2f;
  background: #f3d5cf;
}

.error {
  margin: 0;
  min-height: calc(10px * var(--s));
  font-size: calc(7px * var(--s));
  font-weight: 700;
  color: #ffb3ab;
  text-align: left;
}

/* ---------------- buttons ---------------- */

.btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: calc(10px * var(--s));
  font-weight: 800;
  letter-spacing: calc(0.6px * var(--s));
  color: #fff;
  padding: calc(8px * var(--s)) calc(20px * var(--s));
  background: var(--green);
  border: calc(2px * var(--s)) solid rgba(0, 0, 0, 0.55);
  border-radius: 0;
  box-shadow: 0 calc(3px * var(--s)) 0 var(--green-dark);
  text-shadow: 0 calc(1.5px * var(--s)) 0 rgba(0, 0, 0, 0.35);
  transition: transform 60ms ease, box-shadow 60ms ease;
}

.btn:active {
  transform: translateY(calc(3px * var(--s)));
  box-shadow: 0 0 0 var(--green-dark);
}

.btn-primary {
  background: var(--orange);
  box-shadow: 0 calc(3px * var(--s)) 0 var(--orange-dark);
}

.btn-primary:active {
  box-shadow: 0 0 0 var(--orange-dark);
}

#btn-play {
  margin-top: calc(14px * var(--s));
  padding-inline: calc(34px * var(--s));
}

.buttons {
  display: flex;
  gap: calc(10px * var(--s));
  margin-top: calc(4px * var(--s));
}

.hint {
  margin: calc(10px * var(--s)) 0 0;
  font-size: calc(7.5px * var(--s));
  line-height: 1.7;
  opacity: 0.85;
}

/* ---------------- score panel ---------------- */

.panel {
  width: calc(180px * var(--s));
  padding: calc(12px * var(--s));
  background: var(--paper);
  border: calc(2px * var(--s)) solid var(--paper-edge);
  box-shadow: inset 0 0 0 calc(2px * var(--s)) rgba(255, 255, 255, 0.35);
  color: var(--ink);
}

.panel .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: calc(9px * var(--s));
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: calc(0.4px * var(--s));
  padding: calc(3px * var(--s)) 0;
}

.panel .row b {
  font-size: calc(16px * var(--s));
}

.new-best {
  margin: calc(4px * var(--s)) 0 0;
  font-size: calc(8px * var(--s));
  font-weight: 800;
  color: var(--orange-dark);
  text-transform: uppercase;
}

.verify {
  margin: calc(6px * var(--s)) 0 0;
  font-size: calc(6.5px * var(--s));
  font-weight: 700;
  letter-spacing: calc(0.3px * var(--s));
  color: #3f7a2a;
}

.verify.is-bad {
  color: #b32d22;
}

.verify-server {
  color: #5a4a2e;
  opacity: 0.9;
}

/* ---------------- leaderboard ---------------- */

.leaderboard {
  width: 100%;
  max-width: calc(200px * var(--s));
  margin-top: calc(10px * var(--s));
  padding: calc(8px * var(--s)) calc(10px * var(--s));
  background: rgba(8, 16, 20, 0.55);
  border: calc(1.5px * var(--s)) solid rgba(255, 255, 255, 0.25);
}

.leaderboard h2 {
  margin: 0 0 calc(5px * var(--s));
  font-size: calc(7px * var(--s));
  font-weight: 800;
  letter-spacing: calc(0.6px * var(--s));
  text-transform: uppercase;
  opacity: 0.75;
}

.leaderboard ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: calc(3px * var(--s));
}

.leaderboard li {
  display: flex;
  align-items: baseline;
  gap: calc(6px * var(--s));
  font-size: calc(8px * var(--s));
  font-weight: 700;
}

.leaderboard .rank {
  width: calc(10px * var(--s));
  opacity: 0.6;
  text-align: right;
}

.leaderboard .who {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: calc(7.5px * var(--s));
  text-align: left;
  opacity: 0.9;
}

.btn-ghost {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: none;
  font-size: calc(8px * var(--s));
  padding: calc(6px * var(--s)) calc(14px * var(--s));
}

.btn-ghost:active {
  box-shadow: none;
}

/* ---------------- mute ---------------- */

#mute {
  position: absolute;
  top: calc(8px * var(--s));
  right: calc(8px * var(--s));
  z-index: 5;
  pointer-events: auto;
  cursor: pointer;
  width: calc(28px * var(--s));
  height: calc(28px * var(--s));
  display: grid;
  place-items: center;
  font-size: calc(13px * var(--s));
  line-height: 1;
  background: rgba(0, 0, 0, 0.35);
  border: calc(1.5px * var(--s)) solid rgba(255, 255, 255, 0.35);
  border-radius: 0;
  padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}
