/* FlappyGir - the page around the game is the kit's (ui/ui.css); inside the frame the game has its own
   look: ink outlines, barn red, sun yellow and paper, with Lilita One for big words. Everything inside the
   frame is sized from the frame's width (cqw), so it looks the same on a phone and on a big screen. */
@font-face {
  font-family: 'Lilita One';
  src: url('fonts/lilita-one-latin.woff2') format('woff2');
  font-display: swap;
}
:root {
  --ink: #140b0e;
  --red: #e5121f;
  --sun: #ffd84a;
  --paper: #fff7e6;
  --fg-display: 'Lilita One', 'Arial Black', Impact, sans-serif;
}
html,
body {
  height: 100%;
}
body {
  min-height: 0;
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(700px 420px at 50% 30%, rgba(27, 159, 196, 0.22), transparent 70%), var(--bg);
}
.stage {
  height: 100%;
  display: grid;
  place-items: center;
  container-type: size;
}
.frame {
  position: relative;
  height: min(100cqh, 100cqw * 16 / 9);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #1b9fc4;
  box-shadow: 0 0 0 3px var(--ink), 0 0 0 4px rgba(79, 220, 255, 0.18), 0 24px 60px rgba(0, 0, 0, 0.55);
  container-type: size;
  font-family: var(--font);
  font-size: 4.4cqw;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* On a phone held upright the game fills the screen */
@media (max-width: 520px) and (orientation: portrait) {
  body { padding: 0; }
  .frame { border-radius: 0; box-shadow: none; height: 100%; width: 100%; aspect-ratio: auto; }
}
canvas:focus-visible { outline: none; }
canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.fg-preview-mode .frame { border-radius: 0; box-shadow: none; }
body.fg-embed { padding: 0; background: transparent; }
body.fg-embed .frame { border-radius: 0; box-shadow: none; height: 100%; width: 100%; aspect-ratio: auto; }

/* ---------- the top row: back, leaderboard, sound ---------- */
.fg-bar {
  position: absolute;
  z-index: 3;
  top: max(2.6cqw, env(safe-area-inset-top));
  left: 2.6cqw;
  right: 2.6cqw;
  display: flex;
  align-items: center;
  gap: 2cqw;
  pointer-events: none;
}
.fg-bar > * { pointer-events: auto; }
.fg-bar .spacer { flex: 1; pointer-events: none; }
.fg-round {
  width: 11cqw;
  height: 11cqw;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0.8cqw solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 0.8cqw 0 var(--ink);
  transition: transform 0.08s;
}
.fg-round:hover { background: #fff; color: var(--ink); }
.fg-round:active { transform: translateY(0.6cqw); box-shadow: 0 0.2cqw 0 var(--ink); }
.fg-round:focus-visible { outline: 0.8cqw solid var(--sun); outline-offset: 0.6cqw; }
.fg-round svg { width: 5.6cqw; height: 5.6cqw; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fg-round svg .fill,
.fg-btn svg .fill { fill: currentColor; }
#mute .off { display: none; }
#mute[aria-pressed='true'] .on { display: none; }
#mute[aria-pressed='true'] .off { display: block; }
.fg-tag {
  padding: 1cqw 2.6cqw;
  border: 0.6cqw solid var(--ink);
  border-radius: 99px;
  background: var(--sun);
  font: 3.4cqw var(--fg-display);
  letter-spacing: 0.03em;
}

/* ---------- screens over the game ---------- */
.fg-screen {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16cqw 5cqw 6cqw;
  background: rgba(12, 48, 64, 0.35);
  overflow-y: auto;
  animation: fg-in 0.22s ease-out;
}
@keyframes fg-in {
  from { opacity: 0; transform: translateY(3cqw); }
}
.fg-card {
  width: 100%;
  padding: 5cqw 5cqw 4.5cqw;
  border: 0.9cqw solid var(--ink);
  border-radius: 5cqw;
  background: var(--paper);
  box-shadow: 0 1.6cqw 0 var(--ink);
  text-align: center;
}
.fg-title {
  margin: 0;
  font: 13.5cqw/1 var(--fg-display);
  letter-spacing: 0.01em;
  color: var(--red);
  -webkit-text-stroke: 0.6cqw var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 1cqw 0 var(--ink);
  transform: rotate(-2deg);
  overflow-wrap: anywhere;
}
.fg-title.small { font-size: 10cqw; color: var(--sun); }
.fg-tagline { margin: 2.6cqw 0 0; font-size: 4.2cqw; line-height: 1.35; color: #3b2a2e; }
.fg-name { display: grid; gap: 2cqw; margin-top: 4.5cqw; text-align: left; }
.fg-name label { font-size: 3.6cqw; font-weight: 600; color: #3b2a2e; }
.fg-name input {
  width: 100%;
  min-width: 0;
  padding: 2.4cqw 3.2cqw;
  border: 0.7cqw solid var(--ink);
  border-radius: 3cqw;
  background: #fff;
  color: var(--ink);
  font: 600 4.6cqw var(--font);
  user-select: text;
  -webkit-user-select: text;
}
.fg-name input:focus { outline: 0.8cqw solid var(--sun); outline-offset: 0; }
.fg-row { display: flex; gap: 2cqw; }
.fg-row input { flex: 1; }

.fg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2cqw;
  padding: 2.4cqw 4.4cqw;
  border: 0.8cqw solid var(--ink);
  border-radius: 3.2cqw;
  background: var(--sun);
  color: var(--ink);
  font: 5cqw/1.1 var(--fg-display);
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 1cqw 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.fg-btn:hover { background: #ffe57d; }
.fg-btn:active { transform: translateY(0.8cqw); box-shadow: 0 0.2cqw 0 var(--ink); }
.fg-btn:focus-visible { outline: 0.8cqw solid var(--red); outline-offset: 0.6cqw; }
.fg-btn:disabled { opacity: 0.6; cursor: default; }
.fg-btn.big { padding: 3.2cqw 6cqw; font-size: 6.4cqw; }
.fg-btn.ghost { background: #fff; }
.fg-btn.ghost:hover { background: #fff2d1; }
.fg-btn svg { width: 5.6cqw; height: 5.6cqw; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.fg-start-form { display: grid; justify-items: center; margin-top: 5cqw; }
.fg-start-form .fg-btn.big { min-width: 56%; }
.fg-link {
  padding: 0;
  border: 0;
  background: none;
  color: #a10d17;
  font: 600 3.5cqw var(--font);
  text-decoration: underline;
  text-underline-offset: 0.5cqw;
  cursor: pointer;
}
.fg-mybest { margin: 3.2cqw 0 0; font-size: 3.8cqw; color: #3b2a2e; }
.fg-mybest b { color: var(--ink); }

.fg-mini { margin-top: 4cqw; padding-top: 3.2cqw; border-top: 0.5cqw dashed rgba(20, 11, 14, 0.25); text-align: left; }
.fg-mini-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.6cqw; font: 4.6cqw var(--fg-display); letter-spacing: 0.02em; }

/* the leaderboard list (mini on the start screen, full in its own screen) */
.fg-list { margin: 0; padding: 0; list-style: none; text-align: left; }
.fg-list li {
  display: grid;
  grid-template-columns: 8cqw 1fr auto;
  align-items: center;
  gap: 2cqw;
  padding: 1.6cqw 2.4cqw;
  border-radius: 2.4cqw;
  font-size: 4.2cqw;
}
.fg-list li:nth-child(odd) { background: rgba(20, 11, 14, 0.05); }
.fg-list li.me { background: var(--sun); box-shadow: inset 0 0 0 0.5cqw var(--ink); }
.fg-list .rank { font: 4.4cqw var(--fg-display); text-align: center; color: #5b4a4e; }
.fg-list .medal {
  display: inline-grid;
  place-items: center;
  width: 6.6cqw;
  height: 6.6cqw;
  border: 0.5cqw solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font-size: 3.6cqw;
}
.fg-list .m1 { background: #ffd84a; }
.fg-list .m2 { background: #d9dde4; }
.fg-list .m3 { background: #e7a46a; }
.fg-list .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fg-list .pts { font: 5cqw var(--fg-display); }
.fg-list.small li { padding: 1.1cqw 2.2cqw; font-size: 3.8cqw; }
.fg-list .empty-row { display: block; padding: 2.4cqw; text-align: center; color: #5b4a4e; background: none; }

.fg-lang { display: flex; justify-content: center; gap: 1cqw; margin-top: 4cqw; }
.fg-lang button {
  padding: 0.8cqw 2.4cqw;
  border: 0.5cqw solid transparent;
  border-radius: 99px;
  background: none;
  color: #5b4a4e;
  font: 600 3.2cqw var(--font);
  cursor: pointer;
}
.fg-lang button[aria-pressed='true'] { border-color: var(--ink); color: var(--ink); background: #fff; }

/* ---------- ready / paused ---------- */
.fg-ready {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 58%;
  display: grid;
  justify-items: center;
  gap: 2cqw;
  pointer-events: none;
  text-align: center;
}
#paused { top: 40%; }
.fg-hint { padding: 0.8cqw 3cqw; border-radius: 99px; background: rgba(20, 11, 14, 0.55); color: var(--paper); font: 600 3.4cqw var(--font); }
.fg-ready p {
  margin: 0;
  padding: 1.6cqw 4.4cqw;
  border: 0.7cqw solid var(--ink);
  border-radius: 99px;
  background: var(--paper);
  font: 5cqw var(--fg-display);
  letter-spacing: 0.02em;
  box-shadow: 0 1cqw 0 var(--ink);
}
.fg-tap { width: 14cqw; height: 14cqw; color: var(--paper); filter: drop-shadow(0 0.8cqw 0 var(--ink)); animation: fg-tap 1s ease-in-out infinite; }
.fg-tap svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes fg-tap {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.4cqw); }
}

/* ---------- game over ---------- */
.fg-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 3cqw; margin-top: 3cqw; }
.fg-scores div {
  display: grid;
  gap: 0.6cqw;
  padding: 2.4cqw;
  border: 0.6cqw solid var(--ink);
  border-radius: 3.4cqw;
  background: #fff;
}
.fg-scores span { font-size: 3.4cqw; font-weight: 600; color: #5b4a4e; text-transform: uppercase; letter-spacing: 0.06em; }
.fg-scores b { font: 11cqw/1 var(--fg-display); color: var(--ink); }
.fg-note { min-height: 1.4em; margin: 3cqw 0 0; font-size: 4cqw; line-height: 1.35; color: #3b2a2e; }
.fg-note .new {
  display: inline-block;
  padding: 0.6cqw 2.4cqw;
  border: 0.5cqw solid var(--ink);
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font: 4.2cqw var(--fg-display);
  letter-spacing: 0.03em;
  transform: rotate(-3deg);
  animation: fg-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1);
}
.fg-note.bad { color: #a10d17; font-weight: 600; }
@keyframes fg-pop {
  from { transform: rotate(-3deg) scale(0.3); }
}
.fg-actions { display: grid; grid-template-columns: 1fr; gap: 3cqw; margin-top: 4.5cqw; }
.fg-actions .fg-btn { width: 100%; }

.fg-board { display: grid; gap: 1cqw; max-height: 100%; }
.fg-board .fg-list { max-height: 60cqh; overflow-y: auto; margin: 1cqw 0 3cqw; }
.fg-board .fg-btn { justify-self: center; min-width: 50%; }

/* ---------- difficulty: the picker (start and game over), the tag, the leaderboard's tabs ---------- */
.fg-level,
.fg-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2cqw;
  margin-top: 4cqw;
  padding: 1.2cqw;
  border: 0.6cqw solid var(--ink);
  border-radius: 3.4cqw;
  background: #fff;
}
.fg-tabs { margin: 2.4cqw 0 0; }
.fg-level button,
.fg-tabs button {
  min-width: 0;
  padding: 1.8cqw 1cqw;
  border: 0;
  border-radius: 2.2cqw;
  background: none;
  color: #5b4a4e;
  font: 4.2cqw var(--fg-display);
  letter-spacing: 0.02em;
  cursor: pointer;
}
.fg-level button:hover,
.fg-tabs button:hover { background: rgba(20, 11, 14, 0.06); color: var(--ink); }
.fg-level button[aria-pressed='true'],
.fg-tabs button[aria-selected='true'] { background: var(--sun); color: var(--ink); box-shadow: inset 0 0 0 0.5cqw var(--ink); }
.fg-level button:focus-visible,
.fg-tabs button:focus-visible { outline: 0.7cqw solid var(--red); outline-offset: 0.3cqw; }
.fg-over .fg-level { margin-top: 3.4cqw; }
.fg-level-tag {
  display: inline-block;
  margin-top: 2cqw;
  padding: 0.6cqw 2.6cqw;
  border: 0.5cqw solid var(--ink);
  border-radius: 99px;
  background: #fff;
  font: 3.6cqw var(--fg-display);
  letter-spacing: 0.03em;
}
.fg-level-tag:empty { display: none; }

/* ---------- Customize (the game plays itself above it) ---------- */
.fg-menu-screen { place-items: start center; padding: 15cqw 4cqw 4cqw; overflow: hidden; background: linear-gradient(transparent 10%, rgba(12, 48, 64, 0.45)); }
.fg-menu { display: grid; gap: 2.6cqw; padding: 3.6cqw 4cqw 0; max-height: 100%; overflow-y: auto; }
.fg-menu .fg-title.small { font-size: 8.5cqw; }
.fg-pick-group { display: grid; gap: 1.8cqw; text-align: left; }
.fg-pick-group h3 { margin: 0; font: 4.4cqw var(--fg-display); letter-spacing: 0.02em; color: var(--ink); }
.fg-picks { display: grid; gap: 2cqw; }
.fg-picks.chars { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fg-picks.swatches { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.fg-picks.bgs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fg-pick {
  display: grid;
  justify-items: center;
  gap: 1cqw;
  min-width: 0;
  padding: 1.4cqw;
  border: 0.6cqw solid transparent;
  border-radius: 3cqw;
  background: rgba(20, 11, 14, 0.05);
  color: var(--ink);
  font: 600 3.2cqw var(--font);
  cursor: pointer;
}
.fg-pick:hover { background: rgba(20, 11, 14, 0.1); }
.fg-pick[aria-pressed='true'] { border-color: var(--ink); background: var(--sun); box-shadow: 0 0.8cqw 0 var(--ink); }
.fg-pick:focus-visible { outline: 0.7cqw solid var(--red); outline-offset: 0.4cqw; }
.fg-pick-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-pick-pic { display: grid; place-items: center; width: 100%; aspect-ratio: 1; }
.fg-pick-pic img { max-width: 100%; max-height: 100%; }
/* a pillar colour: the colour with its trim on top */
.fg-pick.swatch { padding: 1.2cqw; }
.fg-swatch {
  width: 9.5cqw;
  aspect-ratio: 1;
  border: 0.6cqw solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(var(--t) 0 30%, var(--ink) 30% 36%, var(--p) 36%);
}
/* a background: its sky, a mountain and the ground */
.fg-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0.6cqw solid var(--ink);
  border-radius: 2cqw;
  overflow: hidden;
  background: linear-gradient(var(--a), var(--b));
}
.fg-tile::before {
  content: '';
  position: absolute;
  inset: 30% 0 18% 0;
  background: var(--m);
  clip-path: polygon(0 100%, 0 55%, 18% 20%, 34% 60%, 52% 0, 70% 50%, 86% 25%, 100% 50%, 100% 100%);
}
.fg-tile::after {
  content: '';
  position: absolute;
  inset: 82% 0 0 0;
  background: var(--g);
  border-top: 0.5cqw solid var(--ink);
}
.fg-tile[data-extra='stars'],
.fg-tile[data-extra='aurora'] { background-image: radial-gradient(circle at 20% 22%, #fff 0 0.5cqw, transparent 0.6cqw), radial-gradient(circle at 62% 14%, #fff 0 0.4cqw, transparent 0.5cqw), radial-gradient(circle at 84% 30%, #fff 0 0.5cqw, transparent 0.6cqw), linear-gradient(var(--a), var(--b)); }
.fg-tile[data-extra='aurora'] { background-image: radial-gradient(ellipse 60% 22% at 45% 26%, rgba(80, 255, 170, 0.55), transparent 70%), radial-gradient(circle at 84% 30%, #fff 0 0.5cqw, transparent 0.6cqw), linear-gradient(var(--a), var(--b)); }
.fg-tile[data-extra='snow'] { background-image: radial-gradient(circle at 15% 30%, #fff 0 0.6cqw, transparent 0.7cqw), radial-gradient(circle at 45% 15%, #fff 0 0.5cqw, transparent 0.6cqw), radial-gradient(circle at 75% 40%, #fff 0 0.6cqw, transparent 0.7cqw), linear-gradient(var(--a), var(--b)); }
.fg-tile[data-extra='leaves'] { background-image: radial-gradient(ellipse 1.2cqw 0.7cqw at 22% 30%, #e8551c 98%, transparent), radial-gradient(ellipse 1.2cqw 0.7cqw at 70% 20%, #f2a516 98%, transparent), linear-gradient(var(--a), var(--b)); }
/* Done stays in view at the bottom of the card when it has to scroll */
.fg-menu-foot { position: sticky; bottom: 0; display: grid; justify-items: center; margin: 0 -4cqw; padding: 2.4cqw 4cqw 4cqw; background: linear-gradient(rgba(255, 247, 230, 0), var(--paper) 30%); }
.fg-menu-foot .fg-btn { min-width: 50%; }

@media (prefers-reduced-motion: reduce) {
  .fg-screen, .fg-note .new, .fg-tap { animation: none; }
}
