/* Paper Golf — desk-and-paper look. The course SVG is the "paper"; the page
   around it is the desk. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --desk: #ece5d3;
  --ink: #33334f;
  --accent: #2e6b3d;
  --card: #fdfcf3;
  --muted: #8a8672;
}
@media (prefers-color-scheme: dark) {
  :root { --desk: #2b2923; --ink: #e8e4d8; --muted: #a49f8c; }
}

html, body { height: 100%; }
body {
  background: var(--desk);
  color: var(--ink);
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 0 8px env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

header.top {
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 0;
}
h1 { font-size: 1.7rem; font-weight: 400; letter-spacing: 1px; }

.icon-btn {
  font-family: inherit;
  font-size: 1.05rem;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  color: #33334f;
  cursor: pointer;
  line-height: 1;
}

.hud {
  font-size: 1.12rem;
  padding: 2px 0 6px;
  color: var(--ink);
}
.hud .sep { margin: 0 8px; color: var(--muted); }

main { display: flex; flex-direction: column; align-items: center; width: 100%; }

#board-wrap { display: flex; justify-content: center; width: 100%; }
#board {
  width: 100%;
  max-width: min(94vw, 400px);
  max-height: calc(100dvh - 232px);
  height: auto;
  aspect-ratio: 468 / 684;
  filter: drop-shadow(2px 4px 8px rgba(60, 50, 20, 0.25));
  transform: rotate(0.4deg);
  touch-action: manipulation;
}
#board text { font-family: 'Patrick Hand', cursive; }
.fx-label { font-style: normal; animation: pop 0.9s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translateY(6px); }
  20% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

#hint {
  font-size: 1.02rem;
  color: var(--muted);
  min-height: 1.5em;
  padding: 6px 0 2px;
  text-align: center;
}

#clubs {
  display: flex;
  gap: 7px;
  padding: 4px 8px 10px;
  width: 100%;
  max-width: 430px;
}
.club {
  flex: 1;
  justify-content: center;
  font-family: inherit;
  font-size: clamp(0.92rem, 3.4vw, 1.08rem);
  color: #33334f;
  background: var(--card);
  border: 2px solid #33334f;
  border-radius: 12px;
  padding: 7px 4px 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 1px 2px 0 rgba(51, 51, 79, 0.35);
}
.club .dist {
  background: #33334f;
  color: var(--card);
  border-radius: 50%;
  width: 21px; height: 21px;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.club.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.club.selected .dist { background: #fff; color: var(--accent); }
.club:disabled { opacity: 0.35; cursor: default; box-shadow: none; }

footer { color: var(--muted); font-size: 0.92rem; padding-bottom: 10px; }

/* ---- modals ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(30, 26, 16, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
}
.modal.open { display: flex; }
.card {
  position: relative;
  background: var(--card);
  color: #33334f;
  border-radius: 14px;
  max-width: 400px;
  width: 100%;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 22px 22px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.card h2 { font-weight: 400; font-size: 1.55rem; margin-bottom: 8px; }
.card p { margin: 8px 0; line-height: 1.45; }
.card .close {
  position: absolute; top: 10px; right: 12px;
  border: none; background: none;
  font-size: 1.15rem; cursor: pointer; color: #33334f;
  font-family: inherit;
}
.legend { list-style: none; margin: 10px 0; }
.legend li { display: flex; gap: 9px; margin: 8px 0; line-height: 1.4; align-items: flex-start; }
.chip { flex: none; width: 15px; height: 15px; border-radius: 5px; display: inline-block; margin-top: 4px; }
.chip-tree { background: #2e6b3d; }
.chip-water { background: #b9def4; border: 1px solid #5f9fce; }
.chip-sand { background: #f2e2af; border: 1px solid #cba75c; }
.chip-hole { background: #fff; border: 2px solid #2d2d2d; border-radius: 50%; }

.muted { color: var(--muted); font-size: 0.98rem; }
.trail { font-size: 1.35rem; letter-spacing: 2px; text-align: center; margin: 10px 0; }
.big-btn {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  margin: 6px 0 4px;
}
.next { text-align: center; }
.btn-group { display: flex; gap: 6px; }

/* leaderboard */
#leaderboard h3 { font-weight: 400; font-size: 1.2rem; margin: 12px 0 4px; }
#lb-submit { display: flex; gap: 7px; margin: 6px 0 10px; }
#lb-submit[hidden] { display: none; }
#lb-name {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 1.05rem;
  color: #33334f;
  background: #fff;
  border: 2px solid #33334f;
  border-radius: 10px;
  padding: 6px 10px;
}
#lb-post {
  font-family: inherit;
  font-size: 1.02rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
#lb-post:disabled { opacity: 0.6; cursor: default; }
.lb-me { text-align: center; color: var(--muted); font-size: 0.98rem; margin: 2px 0 6px; }
.lb-list { list-style: none; max-height: 200px; overflow-y: auto; }
.lb-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 2px;
  border-bottom: 1px dashed rgba(51, 51, 79, 0.15);
}
.lb-rank { width: 22px; color: var(--muted); text-align: right; flex: none; }
.lb-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tr { font-size: 0.72rem; letter-spacing: 1px; flex: none; max-width: 40%; overflow: hidden; white-space: nowrap; }
.lb-list b { flex: none; width: 24px; text-align: right; }

/* stats */
.stat-row { display: flex; justify-content: space-around; margin: 12px 0 14px; }
.stat { text-align: center; }
.stat b { font-size: 1.7rem; display: block; line-height: 1; }
.stat span { color: var(--muted); font-size: 0.9rem; }
.bars { margin-bottom: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.bar-label { width: 90px; text-align: right; font-size: 0.95rem; }
.bar { flex: 1; background: rgba(51, 51, 79, 0.08); border-radius: 5px; height: 15px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; min-width: 2px; }
.bar-n { width: 26px; font-size: 0.95rem; }
