:root {
  --bg: #04120c;
  --green: #34d399;
  --green2: #059669;
  --gold: #f5d07a;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --violet: #a78bfa;
  --text: #ecfdf5;
  --muted: #86a89a;
  --border: rgba(52, 211, 153, 0.2);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}
.back-link {
  position: fixed; z-index: 80;
  top: max(10px, var(--safe-t)); left: 12px;
  color: rgba(236,253,245,0.8);
  font: 700 12px system-ui; text-decoration: none;
  padding: 8px 12px; border-radius: 999px;
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--border);
}
#app { height: 100%; height: 100dvh; position: relative; }
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.screen.active {
  display: flex; opacity: 1; pointer-events: auto;
}

#screen-title {
  align-items: center; justify-content: center;
  text-align: center; padding: 24px;
}
.title-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(52,211,153,0.25), transparent 55%),
    radial-gradient(ellipse 40% 30% at 90% 80%, rgba(34,211,238,0.12), transparent),
    radial-gradient(ellipse 40% 30% at 10% 70%, rgba(167,139,250,0.1), transparent),
    var(--bg);
}
.title-inner { position: relative; z-index: 1; max-width: 400px; }
.eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--green);
  border: 1px solid var(--border);
  background: rgba(52,211,153,0.1);
  padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}
h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 10vw, 3.8rem);
}
h1 em {
  font-style: italic;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede {
  color: var(--muted); margin: 12px 0 26px;
  font-size: 1.02rem; line-height: 1.5;
}
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 1rem;
  padding: 16px 20px; border-radius: 14px; min-height: 52px;
  width: 100%; margin-top: 10px;
  transition: transform 0.1s;
  text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center;
}
.btn:active { transform: scale(0.98); }
.btn-green {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #042f1a;
  box-shadow: 0 10px 28px rgba(52,211,153,0.28);
}
.btn-ghost {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Play */
.hud {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  /* Leave a lane for the fixed ← Games chip (z-index 80) */
  padding: calc(8px + var(--safe-t)) 10px 8px 108px;
  border-bottom: 1px solid var(--border);
  background: rgba(4,18,12,0.95);
  z-index: 5;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text); font-size: 16px; cursor: pointer;
}
.hud-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#hud-hole { font-weight: 800; font-size: 0.95rem; }
#hud-par { font-size: 12px; color: var(--muted); }
.hud-right { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.pill b { color: var(--text); }
.pill.wind { color: var(--cyan); max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.wind.active { border-color: rgba(34,211,238,0.45); background: rgba(34,211,238,0.08); }
#course {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  touch-action: none;
  cursor: crosshair;
  background: #062218;
}
.play-hint {
  flex-shrink: 0;
  text-align: center;
  font-size: 12px; color: var(--muted);
  padding: 8px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--border);
  background: rgba(4,18,12,0.95);
}

/* Result panels */
#screen-hole, #screen-end {
  align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(4,18,12,0.88);
  backdrop-filter: blur(8px);
}
.card-panel {
  width: min(380px, 100%);
  background: #0a1f16;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.card-panel h2 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400; font-size: 1.9rem; margin: 8px 0 10px;
}
.sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 18px; line-height: 1.45; }
.scorecard {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-bottom: 18px; text-align: center;
}
.scorecard div {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 4px;
  font-size: 11px; color: var(--muted);
}
.scorecard b { display: block; color: var(--text); font-size: 1rem; margin-top: 2px; }

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
}
.modal.hidden { display: none; }
.modal-card {
  position: relative; width: min(400px, 100%);
  background: #0a1f16; border: 1px solid var(--border);
  border-radius: 20px; padding: 26px 20px 20px;
}
.modal-x {
  position: absolute; top: 10px; right: 12px;
  border: none; background: transparent; color: var(--muted);
  font-size: 28px; cursor: pointer;
}
.modal-card h2 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400; text-align: center; margin-bottom: 12px;
}
.modal-card ol {
  color: var(--muted); font-size: 0.92rem; line-height: 1.55;
  padding-left: 18px; margin-bottom: 12px;
}
.modal-card strong { color: var(--text); }
.tip { font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }
