/* The shared look of a katalogue game page (site/GAMES.md): the page, its start and score
   screens, the round buttons, the scoreboard and Finish. Load it before the game's own <style>,
   which sets its colors and can override anything here:
     --bg           page background
     --ink          text
     --card         the scoreboard and score card
     --accent, --accent-dark   buttons
     --ring         the ring that fills on a round button
     --screen-tint  behind the start and score screens (default none)
     --btn-glow     the round buttons' highlight (default a soft white)
     --btn-ink      the round buttons' text (default white)
     --btn-size     the round buttons' width (default min(220px, 60vw)) */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

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

/* Start and score screens. */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.25rem;
  padding: 16px;
  text-align: center;
  z-index: 10;
  background: var(--screen-tint, transparent);
}
.screen[hidden] { display: none; }

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 5rem);
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 3px 0 var(--accent-dark), 0 6px 18px rgba(0, 0, 0, 0.2);
}
.lede { margin: 0; font-size: clamp(1.15rem, 3.5vw, 1.5rem); font-weight: 600; max-width: 34rem; }
.hint { margin: 0; font-size: 1.05rem; font-weight: 600; }

/* Big round button: click it, or rest the pointer on it while the ring fills (js/dwell.js). */
.dwell-btn {
  position: relative;
  width: var(--btn-size, min(220px, 60vw));
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--btn-glow, rgba(255, 255, 255, 0.55)), var(--accent) 55%, var(--accent-dark));
  color: var(--btn-ink, #fff);
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 800;
  box-shadow: 0 10px 0 var(--accent-dark), 0 18px 30px rgba(0, 0, 0, 0.18);
  transform: scale(calc(1 + var(--p, 0) * 0.07));
  cursor: pointer;
  transition: filter 0.4s;
}
.dwell-btn svg {
  position: absolute; inset: -18px;
  width: calc(100% + 36px); height: calc(100% + 36px);
  transform: rotate(-90deg);
  overflow: visible;
}
.dwell-btn circle {
  fill: none;
  stroke: var(--ring);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.25));
}
/* Again, before it can be pressed (just after the score shows): faded, but still solid. */
.dwell-btn.waiting { filter: saturate(0.25) brightness(1.15); }

/* The scoreboard: a card in the top right corner while playing. */
#hud[hidden] { display: none; }
#scoreboard {
  position: fixed; top: 16px; right: 16px;
  z-index: 10;
  min-width: 190px;
  padding: 12px 18px 14px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  font-weight: 700;
}
#scoreboard .row { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.25rem; }
#scoreboard .row.score { font-size: 1.9rem; } /* .row.score: a game's own .row size mustn't shrink it */

/* Finish: two presses (clicks or looks). In the scoreboard, or on its own in the corner. */
.finish-btn {
  margin-top: 8px; width: 100%;
  font: inherit; font-size: 0.95rem;
  padding: 6px 10px; border-radius: 12px;
  border: 2px solid var(--accent); background: #fff; color: var(--accent-dark);
  cursor: pointer;
  /* Fills left to right while she looks at it. */
  background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.16) calc(var(--p, 0) * 100%), transparent 0);
}
.finish-btn.sure { background-color: var(--accent); color: #fff; }
.finish-btn[hidden] { display: none; }
.finish-btn.alone {
  position: fixed; right: 16px; bottom: 14px;
  z-index: 10;
  margin: 0; width: auto;
  font-weight: 700;
  padding: 8px 14px;
}

/* Finish by looking: a long look at the scoreboard fills a bar along its bottom. */
.kg-look-finish { overflow: hidden; }
.kg-look-finish .finish { font-size: 0.85rem; font-weight: 600; opacity: 0; margin-top: 4px; }
.kg-look-finish .bar {
  position: absolute; left: 0; bottom: 0; height: 6px;
  width: calc(var(--p, 0) * 100%);
  background: var(--accent);
}

/* The score screen: the score on the left, Again on the right, well apart, so her eyes can rest
   on the score without starting another round. Stacked on a tall, narrow screen. */
#end-screen { flex-direction: row; gap: min(18vw, 240px); }
@media (max-aspect-ratio: 1/1) {
  #end-screen { flex-direction: column; gap: 3rem; }
  #end-screen .card { max-width: none; }
}
#end-screen .card {
  background: var(--card);
  border-radius: 28px;
  padding: 24px 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  max-width: min(32rem, 45vw);
}
.big-score { font-size: clamp(3.5rem, 14vw, 6rem); font-weight: 800; line-height: 1; color: var(--accent-dark); }
.eyebrow { margin: 0 0 8px; font-size: 1.3rem; font-weight: 700; }
.detail { margin: 8px 0 0; font-size: 1.1rem; }
