:root {
  --bg: #fbfaf6;
  --text: #22211c;
  --muted: #625f55;
  --field: #e3efd9;
  --veil: rgba(227, 239, 217, 0.94);
  --border: #c5d7b5;
  --accent: #ffd23f;
  --gap: 0.75rem;
  --size: 4.5rem;
  --vh: 100vh;
  color-scheme: light dark;
}

/* On a phone vh counts the space under the address bar too, and the hint would fall below the screen. */
@supports (height: 100dvh) {
  :root { --vh: 100dvh; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181a18;
    --text: #ecebe6;
    --muted: #a3a19a;
    --field: #1c2a1c;
    --veil: rgba(28, 42, 28, 0.94);
    --border: #34483a;
  }
}

* { box-sizing: border-box; }

/* Otherwise a rule that sets display, like .over's, shows what is hidden. */
[hidden] { display: none !important; }

html, body { overscroll-behavior: none; }

body {
  display: flex;
  flex-direction: column;
  min-height: var(--vh);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Auto margins centre it without pushing its top off a screen too short for it. */
.game {
  display: grid;
  grid-template-rows: auto minmax(15rem, 1fr) auto;
  gap: var(--gap);
  width: min(100%, 40rem);
  height: min(var(--vh), 46rem);
  margin: auto;
  padding: var(--gap);
}

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
}

h1 { margin: 0; font-size: 1.25rem; }

.stats {
  display: flex;
  gap: 1rem;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.field {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--field);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* --x and --y, from play.js, are fractions of the room the field leaves beside the banana. */
#banana {
  position: absolute;
  left: calc(var(--x, 0.5) * (100% - var(--size)));
  top: calc(var(--y, 0.5) * (100% - var(--size)));
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: calc(var(--size) * 0.75);
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--veil);
  text-align: center;
}

.over h2 { margin: 0; font-size: 1.5rem; }
.over p { margin: 0 0 0.5rem; font-size: 1.25rem; }

.over button {
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #22211c;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.over button:disabled { opacity: 0.5; cursor: default; }

.hint { margin: 0; color: var(--muted); text-align: center; }
