:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  --page: #1d1838;
  --bar: #120e2b;
  --bar-ink: #f4f1ff;
  --bar-soft: #9c95d4;
  --card: #2a2452;
  --soft: #342d66;
  --ink: #f4f1ff;
  --ink-soft: #b8b1e8;
  --line: #463e85;
  --primary: #f9dc6a;
  --primary-ink: #2a2360;
  --focus: #f9dc6a;
  --backdrop: rgba(8, 5, 25, 0.65);
  --font: "Fredoka", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: #463e85 #1d1838; }
body {
  min-height: 100%; margin: 0; overflow-x: hidden;
  background: var(--page); color: var(--ink); font-family: var(--font);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
#app { height: 100vh; height: 100svh; display: flex; align-items: center; justify-content: center; padding: 12px; }
#wrap { display: flex; flex-direction: column; border-radius: 22px; overflow: hidden; background: var(--bar); }
.hud { position: relative; display: flex; align-items: center; gap: 26px; min-height: 54px; padding: 7px 9px 7px 20px; color: var(--bar-ink); }
/* The site name, centered in the score bar. When it doesn't fit, the bar gets a second line for it. */
.brand {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  margin: 0; font-size: 21px; font-weight: 700; line-height: 1; letter-spacing: 0.01em;
  color: var(--bar-ink); white-space: nowrap; pointer-events: none;
}
.brand span { color: var(--primary); }
.hud.two-rows { flex-wrap: wrap; row-gap: 5px; gap: 5px 16px; padding: 9px 8px 6px 14px; }
.hud.two-rows .brand { position: static; transform: none; flex: 0 0 100%; text-align: center; font-size: 18px; }
.hud.two-rows .stat .v { font-size: 18px; }
.hud.two-rows .icon { width: 34px; height: 34px; }
.hud.two-rows .tools { gap: 5px; }
.stat { display: flex; flex-direction: column; line-height: 1.05; }
.stat .k { font-size: 12px; font-weight: 500; color: var(--bar-soft); }
.stat .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tools { margin-left: auto; display: flex; gap: 6px; }
.icon {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, 0.1); color: var(--bar-ink);
}
.icon:hover { background: rgba(255, 255, 255, 0.2); }
.icon svg { width: 22px; height: 22px; }
#game { display: block; touch-action: none; cursor: crosshair; outline: none; }
#game:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

#version {
  position: absolute; left: 0; bottom: 0;                /* bottom of the first screen, scrolls away with the game */
  padding: 0 0 calc(6px + env(safe-area-inset-bottom, 0px)) 10px;
  font-size: 12px; color: var(--ink-soft); opacity: 0.8; pointer-events: none;
}

/* Overlay screens */
#overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; overflow-y: auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--backdrop);
}
#overlay[hidden] { display: none; }
.card { width: min(480px, 100%); padding: 24px 24px 20px; border-radius: 24px; background: var(--card); color: var(--ink); -webkit-user-select: text; user-select: text; }
.card h1, .card h2 { margin: 0 0 10px; font-size: 32px; line-height: 1.05; font-weight: 700; letter-spacing: -0.01em; }
.card h2.subhead { margin: 16px 0 8px; font-size: 19px; line-height: 1.25; font-weight: 600; letter-spacing: 0; }
.card p { margin: 0 0 10px; font-size: 16px; line-height: 1.45; }
.muted { color: var(--ink-soft); }
.tally { display: grid; gap: 4px; max-width: 300px; margin: 4px 0 14px; }
.tally div { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.tally dt { color: var(--ink-soft); }
.tally dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tally .total { margin-top: 2px; padding-top: 6px; border-top: 2px solid var(--line); font-size: 21px; }
.tally .total dt { color: var(--ink); font-weight: 600; }
.actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.solid, .ghost { border-radius: 999px; padding: 10px 20px; font-size: 16px; font-weight: 600; line-height: 1.15; border: 2px solid var(--primary); cursor: pointer; }
.solid { background: var(--primary); color: var(--primary-ink); }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.ghost:hover { border-color: var(--primary); }

/* The text below the game */
.about {
  max-width: 640px; margin: 0 auto; padding: 30px 20px calc(48px + env(safe-area-inset-bottom, 0px));
  color: var(--ink-soft); -webkit-user-select: text; user-select: text;
}
.about h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.15; font-weight: 700; color: var(--ink); }
.about h2 { margin: 26px 0 8px; font-size: 20px; line-height: 1.25; font-weight: 600; color: var(--ink); }
.about p { margin: 0 0 12px; font-size: 16px; line-height: 1.6; }

@media (max-width: 520px) and (max-height: 700px) {
  .card { padding: 16px 16px 14px; }
  #menuTitle { font-size: 24px; margin-bottom: 8px; }
  .card p { font-size: 14px; line-height: 1.38; margin-bottom: 8px; }
  .card h2.subhead { font-size: 16px; margin: 10px 0 6px; }
  .actions { margin-top: 12px; }
}
@media (max-width: 480px) {
  .hud { gap: 18px; min-height: 48px; padding: 6px 8px 6px 14px; }
  .stat .v { font-size: 18px; }
  .icon { width: 36px; height: 36px; }
  .card { padding: 20px 18px 18px; border-radius: 20px; }
  .card h1, .card h2 { font-size: 28px; }
  .card h2.subhead { font-size: 18px; }
  .card p { font-size: 15px; }
}
