/* The overlay UI. Everything here has to survive being read at arm's length,
   outdoors, on a phone, in afternoon sun — so: heavy weights, high contrast,
   and a scrim behind any text that sits over the sky. */

:root {
  --accent: #c8a24a;
  --ink: #0d1319;
  --paper: #f4f6f2;
  --scrim: rgba(8, 13, 18, .58);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #10151a;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--paper);
  /* Stops iOS inflating text in landscape and breaking every layout below. */
  -webkit-text-size-adjust: 100%;
}

#view, #meter {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#view { z-index: 0; }

/* The meter canvas is the control surface — it takes the taps. touch-action
   none is not optional: without it a swing drag scrolls the page and a double
   tap zooms the whole UI on every phone. */
#meter { z-index: 2; touch-action: none; }

#ui {
  position: fixed;
  inset: 0;
  z-index: 3;
  /* The overlay is a stencil: it must not eat the taps meant for the meter
     underneath. Individual controls opt back in. */
  pointer-events: none;
  display: grid;
}

#ui button, #ui a { pointer-events: auto; }

.hide { display: none !important; }

/* ----------------------------------------------------------- attract screen */

/* Anchored to the bottom, not centred. Centred, the prize amount landed square
   on the island — the two heroes of the frame fighting each other. Down here
   the green sits in clear water above the type, which is the composition that
   actually sells it. */
#attract {
  place-self: end stretch;
  text-align: center;
  padding: 0 24px calc(46px + env(safe-area-inset-bottom));
  /* A bottom-up scrim rather than a radial one: it reads as light falling off
     toward the deck instead of as a soft-edged box floating in the sky. */
  background: linear-gradient(to top,
              rgba(8, 13, 18, .90) 0%,
              rgba(8, 13, 18, .74) 38%,
              rgba(8, 13, 18, .30) 72%,
              transparent 100%);
  padding-top: 90px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: clamp(11px, 2.6vw, 13px);
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(244, 246, 242, .72);
}

.win {
  margin: 0;
  font-size: clamp(13px, 3.4vw, 17px);
  font-weight: 700;
  letter-spacing: .42em;
  text-indent: .42em;
  color: var(--accent);
}

#prize-amount {
  margin: 2px 0 8px;
  font-size: clamp(52px, 13vw, 104px);
  font-weight: 800;
  line-height: .92;
  letter-spacing: -.03em;
  /* Numerals in a price want to be even width or the amount jitters between
     courses configured with different digit counts. */
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 26px rgba(0, 0, 0, .6);
}

.sub {
  margin: 0 0 24px;
  font-size: clamp(13px, 3.6vw, 16px);
  font-weight: 500;
  color: rgba(244, 246, 242, .84);
}

#play, #result-again {
  pointer-events: auto;
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: .16em;
  font-size: clamp(14px, 3.6vw, 16px);
  color: var(--ink);
  background: var(--accent);
  /* 56px minimum so it is a comfortable thumb target with gloves or wet hands,
     which is the actual condition on a golf course. */
  min-height: 58px;
  padding: 0 clamp(34px, 9vw, 58px);
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  transition: transform .12s ease, filter .12s ease;
}
#play:active, #result-again:active { transform: scale(.965); filter: brightness(1.08); }
#play:disabled { background: rgba(244, 246, 242, .22); color: rgba(244,246,242,.6); cursor: default; }

.price {
  margin: 16px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(244, 246, 242, .6);
}

.credits-line {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  color: rgba(244, 246, 242, .55);
}
.credits-line b { color: var(--paper); font-variant-numeric: tabular-nums; }
.credits-line.empty b { color: #e0563c; }

/* -------------------------------------------------------------- shot readout */

#shot-info {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}
.chip .k {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .16em;
  color: rgba(244, 246, 242, .58);
}
.chip b { font-size: 16px; font-weight: 800; white-space: nowrap; }
/* The wind chip wrapped to two lines on a 390px phone and shoved the readouts
   off the top of the scene. */
.chip { white-space: nowrap; }
.chip svg { width: 15px; height: 15px; color: var(--accent); transition: transform .35s ease; }

/* ------------------------------------------------------------- result card */

/* Same reasoning as the attract screen: keep the middle of the frame clear so
   the player can see where their ball actually finished while they read it. */
#result {
  place-self: end stretch;
  text-align: center;
  padding: 90px 24px calc(46px + env(safe-area-inset-bottom));
  background: linear-gradient(to top,
              rgba(8, 13, 18, .90) 0%,
              rgba(8, 13, 18, .74) 38%,
              rgba(8, 13, 18, .30) 72%,
              transparent 100%);
}

#result-title {
  margin: 0 0 8px;
  font-size: clamp(30px, 9vw, 62px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  text-shadow: 0 3px 26px rgba(0, 0, 0, .6);
}
#result.win #result-title { color: var(--accent); }

#result-detail {
  margin: 0 0 26px;
  font-size: clamp(15px, 4.2vw, 19px);
  font-weight: 600;
  color: rgba(244, 246, 242, .86);
  font-variant-numeric: tabular-nums;
}

#claim {
  margin: 0 0 26px;
  padding: 16px 22px;
  border: 1px dashed rgba(200, 162, 74, .55);
  border-radius: 12px;
}
.claim-label {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(244, 246, 242, .6);
}
#claim-code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(22px, 6.5vw, 32px);
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--accent);
}

/* A white bloom on a win. One frame of pure light sells the moment better than
   any particle system, and it costs nothing. */
#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#flash.go { animation: bloom 1.1s ease-out; }
@keyframes bloom {
  0% { opacity: .85; }
  100% { opacity: 0; }
}

#powered {
  position: fixed;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(244, 246, 242, .34);
}

#hud {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  /* Clear of the "Powered by" line, which it used to sit on top of. */
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
  z-index: 10;
  padding: 5px 9px;
  border-radius: 6px;
  background: rgba(10, 16, 22, .55);
  color: #9fb3c2;
  font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .04em;
  pointer-events: none;
}

/* Someone who has asked the OS to stop animating things should not be given a
   full-screen white bloom. The win still reads — it just does not strobe. */
@media (prefers-reduced-motion: reduce) {
  #flash.go { animation: none; }
  #play, #result-again { transition: none; }
  .chip svg { transition: none; }
}

/* ------------------------------------------------------------- how to play */

#howto {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 14, .88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  /* The whole overlay is interactive — it deliberately blocks the meter
     underneath so a stray tap cannot start a swing while the tutorial is up. */
  pointer-events: auto;
}

.howto-card {
  width: min(430px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  /* iPhone SE at 568px tall has to fit the whole card without the button
     falling off the bottom, which is why everything below is clamped. */
  padding: 4px;
}

.howto-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .3em;
  text-indent: .3em;
  color: var(--accent);
}

#howto-canvas {
  width: min(260px, 62vw);
  height: clamp(140px, 24vh, 190px);
  display: block;
  margin: 0 auto 6px;
}

.howto-steps {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.step {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background .25s ease, opacity .25s ease;
  opacity: .45;
}
/* The active step is lit in time with the demo, so the caption and the thing
   it describes are never more than a moment apart. */
.step.on { opacity: 1; background: rgba(255, 255, 255, .07); }

.step-n {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(244, 246, 242, .55);
}
.step.on .step-n { background: var(--accent); }

.step-t {
  font-size: clamp(12.5px, 3.4vw, 14px);
  line-height: 1.42;
  font-weight: 500;
  color: rgba(244, 246, 242, .9);
}
.step-t b { color: var(--accent); font-weight: 800; }

.howto-note {
  margin: 0 0 18px;
  font-size: 11.5px;
  font-weight: 600;
  font-style: italic;
  color: rgba(244, 246, 242, .55);
}

#howto-close {
  pointer-events: auto;
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: .16em;
  font-size: 14px;
  color: var(--ink);
  background: var(--accent);
  min-height: 54px;
  padding: 0 46px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
}
#howto-close:active { filter: brightness(1.08); }

/* A text button that reads as a link but keeps the 44px touch target a real
   anchor would not have here. */
.linkish {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(244, 246, 242, .62);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 12px 16px;
  margin-top: 2px;
}
.linkish:active { color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  .step { transition: none; }
}

/* -------------------------------------------------------------- connection */

/* Deliberately plain and grey — see Hud.showConnError's comment. This screen
   must never be mistaken for the result card, because the result card is
   where a real cash claim can appear and this one never does. */
#conn-error {
  place-self: center;
  text-align: center;
  padding: 28px 26px;
  max-width: 380px;
  background: rgba(20, 22, 25, .92);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 16px;
}
.conn-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .14em;
  color: rgba(244, 246, 242, .78);
}
#conn-msg {
  margin: 0 0 22px;
  font-size: 13.5px;
  line-height: 1.5;
  font-weight: 500;
  color: rgba(244, 246, 242, .68);
}
#conn-retry {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(244, 246, 242, .3);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: .1em;
  font-size: 13px;
  min-height: 48px;
  padding: 0 30px;
  border-radius: 999px;
}
#conn-retry:active { background: rgba(244, 246, 242, .08); }

/* ------------------------------------------------------------ session code */

.session-code-line {
  margin: 14px 0 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: rgba(244, 246, 242, .42);
}
.session-code-line b {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(244, 246, 242, .10);
  color: rgba(244, 246, 242, .82);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
}

/* ------------------------------------------------------------------- mute */

#mute-btn {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 15;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 16, 22, .55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  pointer-events: auto;
}
#mute-btn svg { width: 19px; height: 19px; color: rgba(244, 246, 242, .85); }
#mute-btn:active { background: rgba(10, 16, 22, .75); }
