:root {
  --bg: #f1fbe9;
  --card: #ffffff;
  --panel: #f4f4f2;
  --ink: #121212;
  --muted: #6b6b6b;
  --line: #e2e2e2;
  --accent: #121212;
  --accent-ink: #ffffff;
  --flag: #e5483b;
  --fairway: #1c8538;
  --you: #ff8a3d;
  --danger: #b3261e;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Libre Franklin", system-ui, sans-serif;
  line-height: 1.5;
}

.site-header { border-bottom: 2px solid var(--fairway); margin-bottom: 8px; }
.site-header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -.03em;
  color: var(--ink);
  text-decoration: none;
}
.brand-flag {
  flex: none;
  width: 26px;
  height: 26px;
  fill: var(--flag);
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}


.header-date { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; color: var(--ink); }
.header-right { display: flex; align-items: center; gap: 12px; }
.help-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--ink); border: 1.5px solid var(--ink);
  font-size: 17px; font-weight: 600; line-height: 1;
}
.help-btn:hover { background: rgba(0, 0, 0, .06); }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  display: grid;
  gap: 16px;
}

.question-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.hole-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fairway);
}

h1 {
  margin: 0 0 14px;
  font-weight: 700;
  letter-spacing: -.015em;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.15;
}

.input-row { display: flex; gap: 10px; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
}

input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 0, 0, .1); }
input[type="text"][aria-invalid="true"] { border-color: var(--danger); }

button {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}

button:hover { background: #333333; }
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: default; }

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

button.secondary:hover { background: #f2f2f2; }

.hole-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hole-meta .hole-label { margin-bottom: 4px; }

.clues { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.clue-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#clueBtn { padding: 8px 14px; font-size: 14px; }
#clueBtn .cost { font-weight: 400; opacity: .75; margin-left: 4px; }
.clue-locked { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); padding: 8px 0; }
.clue-locked[hidden] { display: none; }
.clue-locked svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.strokes { font-size: 14px; color: var(--muted); }
.strokes strong { color: var(--ink); }

#shotLog { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#shotLog:not(:empty) { margin-top: 12px; }
#shotLog li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 10px;
  font-size: 15px;
  animation: clueIn .3s ease-out;
}
#shotLog li.shot { background: var(--panel); }
#shotLog li.holed { background: #fdecea; }
#shotLog li .num { flex: none; font-size: 12px; font-weight: 600; color: var(--flag); text-transform: uppercase; letter-spacing: .06em; }
@keyframes clueIn { from { opacity: 0; transform: translateY(-4px); } }

.hint { margin: 8px 2px 0; font-size: 14px; color: var(--muted); min-height: 1.5em; }
.hint.error { color: var(--danger); }
.hint.feedback { color: var(--ink); font-weight: 600; }

.course-wrap { margin: 0; }

#course {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(0, 0, 0, .12);
  overflow: hidden;
}


.flag { transform-origin: 651px 188px; animation: wave 1.6s ease-in-out infinite; }
@keyframes wave { 50% { transform: scaleX(.82) skewY(4deg); } }

.answer-tag text, #youText { font: 600 13px "Libre Franklin", sans-serif; fill: #fff; }
.answer-tag { transition: opacity .4s ease; }

.other-ball { transform-box: fill-box; transform-origin: center; animation: drop .35s ease-out backwards; cursor: help; }
@keyframes drop { from { transform: scale(0); opacity: 0; } }

#youRing { animation: pulse 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

.countdown { margin: 0; color: var(--muted); font-size: 15px; }
.countdown strong { color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .input-row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .flag, #youRing, .other-ball, #shotLog li, .modal[open], .results-card { animation: none; }
  .confetti { display: none; }
}

.clue-bar[hidden] { display: none; }

/* ---- Modal (how to play) ---- */
.modal {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 28px 24px 22px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
  overflow-x: hidden;
  text-align: center;
}
.modal[open] { animation: popIn .35s cubic-bezier(.2, .9, .3, 1.2); }
.modal::backdrop { background: rgba(0, 0, 0, .5); }
@keyframes popIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }

.close-btn {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--panel); color: var(--ink);
}
.close-btn:hover { background: var(--line); }
.close-btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }

.end-actions { margin-top: 22px; display: grid; gap: 10px; justify-items: center; }

@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; padding: 26px 16px 20px; }
}

/* ---- Results card (replaces the question card when the hole is done) ---- */
.question-card[hidden] { display: none; }
.results-card { animation: cardIn .45s ease-out; }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } }

.res-question { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
.res-main { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; margin-top: 10px; }
#resTitle { margin: 0; font-weight: 800; font-size: 44px; line-height: 1.05; letter-spacing: -.02em; }
.res-sub { margin: 6px 0 0; font-size: 16px; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res-marks { font-size: 20px; letter-spacing: 3px; }

.res-answer { padding: 12px 18px; background: var(--panel); border-radius: 12px; display: grid; gap: 2px; text-align: center; min-width: 190px; }
.res-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
#resAnswer { font-size: 26px; font-variant-numeric: tabular-nums; }
.res-source { font-size: 13px; color: var(--muted); }

.res-note { margin: 14px 0 0; font-size: 15px; }
.res-actions { margin-top: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#shareBtn { padding: 13px 28px; font-size: 17px; }
.countdown { margin: 0; color: var(--muted); font-size: 15px; }
.countdown strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- Stats card ---- */
.stats-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px 22px; }
.stats-card[hidden] { display: none; }
.stats-card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#distributionWrap h3 { margin-top: 22px; }

.end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.end-stats div { display: grid; gap: 2px; }
.end-stats strong { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.end-stats span { font-size: 12px; color: var(--muted); line-height: 1.25; }

.distribution { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; max-width: 520px; }
.distribution li { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.distribution .bar {
  min-width: 26px; width: 0; padding: 3px 8px; border-radius: 5px;
  background: #dcdcdc; color: var(--ink); font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums; transition: width .6s ease;
}
.distribution li.today .bar { background: var(--you); color: #fff; }

/* ---- Confetti ---- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
  animation: fall var(--dur) ease-in var(--delay) forwards;
}
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0; } }

@media (max-width: 560px) {
  .res-main { grid-template-columns: 1fr; gap: 12px; }
  #resTitle { font-size: 40px; }
  .res-answer { min-width: 0; }
  .res-actions { flex-direction: column; align-items: stretch; text-align: center; gap: 10px; }
  .end-stats strong { font-size: 22px; }
  .stats-card { padding: 16px; }
}

/* ---- How to play ---- */
#howToTitle { margin: 4px 0 0; font-weight: 800; font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
.howto-intro { margin: 8px 0 0; color: var(--muted); }
.howto-diagram { display: block; width: 100%; height: auto; margin: 16px 0 4px; }
.howto-diagram text { font: 600 11px "Libre Franklin", sans-serif; fill: var(--muted); }
.howto-steps { list-style: none; margin: 12px auto 0; padding: 0; display: grid; gap: 10px; text-align: left; width: fit-content; }
.howto-steps li { display: flex; gap: 12px; align-items: center; font-size: 16px; }
.howto-steps .step {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
}
#startPlayingBtn { width: 100%; padding: 14px; font-size: 17px; }

@media (max-width: 560px) {
  #howToTitle { font-size: 28px; }
}

/* ---- Footer ---- */
.site-footer {
  max-width: 1040px; margin: 32px auto 0; padding: 20px 16px 32px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 32px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}
.footer-about { margin: 0; max-width: 560px; line-height: 1.5; }
.footer-about strong { color: var(--ink); font-weight: 600; }
.footer-meta { margin: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.link-btn {
  padding: 0; border: none; background: none; color: var(--accent);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { background: none; color: var(--flag); }
.link-btn:active { transform: none; }
.noscript { padding: 16px; background: #fdecea; border-radius: 10px; }

/* ---- 404 page ---- */
.not-found { text-align: center; padding: 32px 22px 36px; }
.lost-ball { display: block; width: 220px; height: auto; margin: 0 auto 12px; }
.not-found h1 { margin-bottom: 8px; }
.not-found-text { margin: 0 auto 22px; max-width: 420px; color: var(--muted); }
.button-link {
  display: inline-block; padding: 12px 22px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.button-link:hover { background: #333333; }
