@font-face { font-family: "Jersey 20"; src: url("assets/fonts/jersey-20-ext.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0100-024F; }
@font-face { font-family: "Jersey 20"; src: url("assets/fonts/jersey-20.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+2122; }

:root { --ink: #1a1430; --night: #141a45; --cream: #fff3d6; --amber: #ffc857; --muted: #c5bfe0; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--ink); }
body { color: var(--cream); font: 400 21px/1.35 "Jersey 20", "Courier New", monospace; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

#app {
  position: fixed; inset: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#app.portrait { justify-content: flex-start; }
#stage { position: relative; flex: none; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; }

#tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
#tools button { min-height: 36px; padding: 4px 9px; border: 2px solid var(--amber); background: var(--ink); font-size: 18px; }
/* Leaves room for the progress bar on narrow screens */
.portrait #tools { top: auto; bottom: 8px; }
[data-state="title"] #tools, [data-state="end"] #tools, [data-state="mini"].portrait #tools, [data-state="lapse"].portrait #tools { display: none; }

#toast {
  position: absolute; top: 17%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 90%;
  padding: 8px 14px; border: 3px solid var(--ink); background: #7bd88f; color: var(--ink); font-weight: 700; text-align: center; pointer-events: none;
}

/* Touch controls */
#controls { display: none; pointer-events: none; }
.touch [data-state="run"] #controls {
  position: absolute; display: flex; justify-content: space-between; align-items: flex-end;
  left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom));
}
.touch .portrait[data-state="run"] #controls { bottom: max(40px, calc(env(safe-area-inset-bottom) + 20px)); }
#controls .pad { display: flex; gap: 12px; }
#controls button {
  width: 76px; height: 76px; padding: 0; pointer-events: auto; touch-action: none;
  border: 3px solid var(--cream); background: rgb(26 20 48 / .6); font-size: 32px; font-weight: 700;
}
#controls .jump { width: 104px; font-size: 24px; border-color: var(--amber); color: var(--amber); }
#controls button.down { background: var(--amber); color: var(--ink); }

#padhint { display: none; margin: auto; padding: 0 20px; color: var(--muted); text-align: center; text-wrap: balance; }
#how { color: var(--cream); font-size: 25px; line-height: 1.2; }
.portrait[data-state="mini"] #padhint { display: block; }
#taphere { display: none; }
.touch #taphere { display: block; }

/* Screens */
#overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; background: rgb(20 15 42 / .62); }
#overlay.end { background: none; place-items: center start; padding-left: max(4vw, 16px); }
.portrait #overlay.end { place-items: end center; padding: 16px 16px 40px; }
#card {
  width: min(520px, 100%); max-height: 100%; overflow-y: auto; padding: 20px 24px; touch-action: pan-y;
  border: 4px solid var(--amber); background: var(--ink); text-align: center;
}
#overlay.end #card { width: min(430px, 100%); }
#card h1, #card h2, #card p { margin: 0 0 10px; text-wrap: balance; }
#card h1 { font-size: clamp(38px, 9vmin, 64px); line-height: 1; color: var(--amber); }
#card h2 { font-size: 34px; line-height: 1.1; color: var(--amber); }
#card .quote { font-size: 25px; }
#card .small { font-size: 19px; color: var(--muted); }
#card .best { color: #7bd88f; }
.touch #card .keys { display: none; }
#card .touchonly { display: none; }
.touch #card .touchonly { display: block; }
.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.buttons button { min-height: 48px; padding: 8px 20px; border: 3px solid var(--amber); background: transparent; font-weight: 700; font-size: 23px; }
.buttons .primary { background: var(--amber); color: var(--ink); }
.buttons button:hover { border-color: var(--cream); }

@media (max-height: 420px) {
  #card { padding: 10px 18px; }
  #card h1, #card h2, #card p { margin-bottom: 5px; }
  #card h1 { font-size: 36px; }
  #card h2 { font-size: 24px; }
  #card p { line-height: 1.2; }
  #card .small { font-size: 18px; }
  .buttons { margin-top: 8px; }
  .buttons button { min-height: 44px; padding: 4px 12px; font-size: 21px; }
}
#card .links { display: flex; justify-content: center; gap: 14px; margin-top: 12px; }
#card .gallery { display: inline-block; padding: 4px 8px; border: 0; background: none; color: var(--muted); font-size: 19px; text-decoration: underline; font-weight: 400; }
#overlay.dev #card { width: min(640px, 100%); }
.devlist .buttons { margin-top: 6px; }
.devlist .buttons button { min-height: 40px; padding: 4px 12px; font-size: 19px; }
@media (max-height: 420px) { #card .links { margin-top: 4px; } }

/* High score list on the end screen (only with server.js) */
#card .scores { margin-top: 10px; text-align: left; }
#card .scores h3 { margin: 0 0 4px; color: var(--amber); font-size: 22px; text-align: center; }
#card .scores .scroll { max-height: 230px; overflow: auto; }
#card .scores table { width: 100%; border-collapse: collapse; font-size: 19px; }
#card .scores caption { color: var(--muted); text-align: left; }
#card .scores th { color: var(--muted); font-size: 16px; font-weight: 400; }
#card .scores th, #card .scores td { padding: 1px 4px; text-align: right; white-space: nowrap; }
#card .scores .place { width: 1%; }
#card .scores .who { text-align: left; white-space: normal; overflow-wrap: anywhere; }
#card .scores td.when { color: var(--amber); }
#card .scores .mine td { color: #7bd88f; }
#card .scores form { display: flex; gap: 8px; margin-top: 8px; }
#card .scores input {
  flex: 1; min-width: 0; min-height: 44px; padding: 4px 10px; border: 3px solid var(--amber); background: var(--ink);
  color: var(--cream); font: inherit; user-select: text; -webkit-user-select: text;
}
#card .scores form button { min-height: 44px; padding: 4px 14px; border: 3px solid var(--amber); background: var(--amber); color: var(--ink); font-weight: 700; }
