:root {
  --river: #1d3557;
  --river-light: #2a6f77;
  --paper: #fffdf6;
  --paper-edge: #e6dfcc;
  --ink: #1d3557;
  --lantern: #f2a93b;
  --foam: #cfe8e4;
  --title: "Gluten", "Trebuchet MS", ui-rounded, sans-serif;
  --text: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--river);
  color: var(--ink);
  font: 17px/1.45 var(--text);
  /* No scrolling, zooming, text selection or grey tap flashes while playing. */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

[hidden] { display: none !important; }

/* ---- The folded paper note that holds the title and end screens ---- */
.card {
  position: fixed;
  left: 50%;
  top: 46%;
  width: min(86vw, 360px);
  padding: 30px 26px 26px;
  transform: translate(-50%, -50%) rotate(-1.6deg);
  background: linear-gradient(135deg, var(--paper) 0 49.6%, #f6f1e2 50% 100%);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--paper-edge), 0 18px 40px -12px rgba(8, 22, 40, 0.55);
  text-align: center;
  animation: float 5s ease-in-out infinite;
}

/* The folded corner. */
.card::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 34px; height: 34px;
  background: linear-gradient(225deg, var(--river) 0 50%, #e9e2cf 50% 100%);
  border-bottom-left-radius: 4px;
}

@keyframes float {
  0%, 100% { transform: translate(-50%, -50%) rotate(-1.6deg); }
  50% { transform: translate(-50%, calc(-50% - 6px)) rotate(-0.4deg); }
}

h1, h2 {
  font-family: var(--title);
  font-weight: 800;
  margin: 0 0 10px;
  line-height: 1;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(48px, 15vw, 64px); }
h2 { font-size: clamp(32px, 9vw, 40px); }

.card p { margin: 0 auto 22px; max-width: 28ch; color: #3d4d63; }
.card .best { margin: 16px 0 0; font-size: 15px; }

button { font: inherit; cursor: pointer; border: 0; }
button:focus-visible { outline: 3px solid var(--lantern); outline-offset: 3px; }

.play {
  display: block;
  width: 100%;
  min-height: 60px;
  border-radius: 14px;
  background: var(--lantern);
  color: #2b1a02;
  font-family: var(--title);
  font-weight: 800;
  font-size: 26px;
  box-shadow: 0 4px 0 #c47f17;
}
.play:active { transform: translateY(3px); box-shadow: 0 1px 0 #c47f17; }

.quiet {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---- Score, boats left and pause, kept clear of the notch ---- */
.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: calc(var(--side, 0px) + max(14px, env(safe-area-inset-left)));
  right: calc(var(--side, 0px) + max(14px, env(safe-area-inset-right)));
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper);
  pointer-events: none;
}
.lives { display: flex; gap: 6px; }
.lives svg { width: 30px; height: 20px; }
.score {
  margin-left: auto;
  font-family: var(--title);
  font-weight: 800;
  font-size: 30px;
  text-shadow: 0 2px 0 rgba(8, 22, 40, 0.45);
  font-variant-numeric: tabular-nums;
}
.pause, .sound {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.16);
  display: grid;
  place-items: center;
  pointer-events: auto;
}
.pause svg, .sound svg { width: 24px; height: 24px; fill: var(--paper); stroke: var(--paper); }
.sound {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  right: calc(var(--side, 0px) + max(14px, env(safe-area-inset-right)));
}
.sound[aria-pressed="false"] .wave { display: none; }
.sound[aria-pressed="false"] { opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}
