:root {
  color-scheme: light;
  --paper: #f3eedf;
  --card: #fbf8ee;
  --ink: #1c2b23;
  --muted: #5f6a60;
  --line: #d8d0ba;
  --club: #1f5a3d;
  --club-ink: #f6f1e1;
  --green: #a9dd8f;
  --fairway: #6fb86b;
  --rough: #3c7a4b;
  --sand: #e7d199;
  --flag: #c93a2f;
  --gold: #e2b33c;
  --serif: Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 30rem;
  margin: 0 auto;
  padding: 0 16px 40px;
}

h1, h2, h3 { font-family: var(--serif); margin: 0; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
p { margin: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.small { font-size: 0.85rem; color: var(--muted); }

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Buttons */
.btn {
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--club);
  color: var(--club-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s;
}
.btn:hover { background: #17482f; }
.btn:active { transform: translateY(2px); }
.btn:focus-visible, .icon-btn:focus-visible, .item:focus-visible, .tab:focus-visible, .purse:focus-visible, input:focus-visible {
  outline: 3px solid var(--flag);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-wide { width: 100%; }
.btn-small { min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }
.btn-ghost { background: transparent; color: var(--club); box-shadow: inset 0 0 0 2px var(--club); }
.btn-ghost:hover { background: rgba(31, 90, 61, 0.08); }

/* The line across the top: menus on one side, coins on the other */
.topline { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; }
.rail { display: flex; gap: 8px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s;
}
.icon-btn:hover { background: #fff; }
.icon-btn:active { transform: translateY(2px); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.purse {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.coin {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  border: 2px solid #8a6a12;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe9a0, var(--gold));
  vertical-align: -0.15em;
}
/* On a wide screen the menus sit to the side of the page */
@media (min-width: 46rem) {
  .rail { position: fixed; top: 16px; left: calc(50% - 15rem - 68px); flex-direction: column; }
}

/* Clubhouse */
.start { padding-top: 2vh; text-align: center; }
.logo { font-size: clamp(3rem, 16vw, 4.5rem); font-style: italic; line-height: 1; margin: 0 0 4px; }
.tagline { font-family: var(--serif); font-size: 1.2rem; color: var(--club); }
.today { margin-top: 18px; padding: 12px 0 0; border-top: 2px solid var(--ink); }
.today-course { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; line-height: 1.2; text-wrap: balance; }
.hero { margin-top: 12px; }
.today-result { margin-top: 12px; font-weight: 700; }
.start .btn-wide { margin-top: 14px; }

/* Your best round, in red letters like a leaderboard by the first tee */
.sign {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fffdf4;
  color: var(--flag);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}
.sign strong { font-size: 1.25rem; letter-spacing: 0.04em; }
@media (min-width: 62rem) {
  .sign {
    position: fixed;
    top: 16px;
    left: calc(50% + 15rem + 24px);
    width: 11rem;
    flex-direction: column;
    align-items: center;
    padding: 14px 12px;
    box-shadow: 4px 4px 0 var(--ink);
  }
  .sign strong { font-size: 1.6rem; text-align: center; line-height: 1.15; margin: 4px 0; }
}

.rules {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rule;
  text-align: left;
  border-top: 2px solid var(--ink);
}
.rules li {
  counter-increment: rule;
  position: relative;
  padding: 12px 0 12px 2rem;
  border-bottom: 1px solid var(--line);
}
.rules li::before {
  content: counter(rule);
  position: absolute;
  left: 0;
  top: 8px;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--club);
}

/* Top bar */
.bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 12px 0 10px;
  border-bottom: 2px solid var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}
.bar-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 700;
}
.bar-score {
  justify-self: end;
  min-width: 2.6rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Prompt */
.prompt { padding: 14px 0 10px; }
.prompt h1 { font-size: clamp(1.35rem, 5.8vw, 1.85rem); line-height: 1.15; margin: 4px 0 8px; text-wrap: balance; }
.pin-line { font-size: 1.2rem; }
.pin-tag, .caddie span {
  display: inline-block;
  padding: 1px 9px;
  margin-right: 4px;
  border-radius: 4px;
  background: var(--flag);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 2px;
}
.caddie { margin-top: 6px; font-size: 0.95rem; color: var(--muted); }
.caddie span { background: var(--club); color: var(--club-ink); vertical-align: 1px; }
.caddie em { font-family: var(--serif); }

/* Clock */
.clock { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.clock-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
#clock-fill { height: 100%; width: 100%; background: var(--club); border-radius: inherit; }
#clock-num { width: 2ch; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock.low #clock-fill { background: var(--flag); }
.clock.low #clock-num { color: var(--flag); }
.clock.stopped { opacity: 0.35; }

/* The hole: a picture drawn by art.js, with the two direction labels on top. */
.course {
  position: relative;
  aspect-ratio: 360 / 190;
  border: 2px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  background: #cfe6ee;
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.course-side {
  position: absolute;
  z-index: 1;
  top: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(251, 248, 238, 0.88);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.course-side.left { left: 6px; }
.course-side.right { right: 6px; }

.cloud { animation: drift linear infinite; }
@keyframes drift {
  from { transform: translateX(-60px); }
  to { transform: translateX(400px); }
}
.pennant {
  transform-box: fill-box;
  transform-origin: left center;
  animation: wave 1.6s ease-in-out infinite;
}
.pennant.windy { animation-duration: 0.55s; }
@keyframes wave {
  0%, 100% { transform: skewY(-5deg) scaleX(1); }
  50% { transform: skewY(6deg) scaleX(0.88); }
}
.scene.cheer .pennant { animation-duration: 0.3s; }
.fall.rain { animation: fall 0.7s linear infinite; }
.fall.snow { animation: fall 8s linear infinite; }
@keyframes fall {
  to { transform: translateY(190px); }
}
.sway { animation: sway 3.5s ease-in-out infinite alternate; }
@keyframes sway {
  from { transform: translateX(-7px); }
  to { transform: translateX(7px); }
}

.mark .ball { stroke: var(--ink); stroke-width: 1.4; transition: opacity 0.2s; }
.mark .tag { opacity: 0; transition: opacity 0.25s; }
.mark.landed .tag { opacity: 1; }
.mark .tag line { stroke: var(--ink); stroke-width: 1.1; }
.mark .tag circle { fill: #fff; stroke: var(--ink); stroke-width: 1.4; }
.mark .tag text { font: 700 9.5px system-ui, -apple-system, 'Segoe UI', sans-serif; fill: var(--ink); }
.mark.lie-pin .tag circle { fill: var(--flag); }
.mark.lie-pin .tag text { fill: #fff; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}
.legend li::before {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 5px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--dot);
}

/* Shots */
.shots { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.shot {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 2px 8px;
  align-items: center;
  min-height: 3.5rem;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  animation: rise 0.3s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}
.shot.empty { border-style: dashed; background: transparent; color: var(--muted); font-size: 0.9rem; animation: none; }
.shot-n {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}
.shot-name { font-weight: 700; overflow-wrap: anywhere; }
.shot-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.shot-miss { font-size: 0.85rem; color: var(--muted); }
.chip {
  justify-self: end;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip.lie-pin { background: var(--flag); color: #fff; }
.chip.lie-green { background: var(--green); }
.chip.lie-fairway { background: var(--fairway); }
.chip.lie-rough { background: var(--rough); color: #fff; }
.chip.lie-bunker { background: var(--sand); }
.chip.lie-none { background: var(--line); }

/* Answer box */
.swing { display: flex; gap: 8px; }
.swing input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
}
.swing.shake { animation: shake 0.3s; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}
.msg { min-height: 1.6em; margin-top: 6px; font-size: 0.95rem; }
.msg[data-lie] { font-weight: 600; }
.msg[data-lie='pin'] { color: var(--club); }
.msg.warn { color: #9a2c22; font-weight: 600; }
.msg button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--club);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* End of a hole */
.holed {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  padding: 16px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
}
.holed-score {
  font-family: var(--serif);
  font-size: 2.2rem;
  font-style: italic;
  line-height: 1.1;
  transform-origin: left center;
  animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.6); }
}
.holed.great { border-color: var(--flag); box-shadow: 0 0 0 3px rgba(201, 58, 47, 0.18); }
.holed.great .holed-score { color: var(--flag); }
.holed.good .holed-score { color: var(--club); }
.holed-lie { color: var(--muted); margin-top: 2px; }
.holed h2 { margin-top: 14px; }
.confetti {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  animation: tumble 1.6s ease-in forwards;
}
@keyframes tumble {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--sway), 260px) rotate(var(--spin)); }
}
.toplist { margin: 0 0 14px; padding: 0; list-style: none; counter-reset: top; }
.toplist li {
  counter-increment: top;
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.toplist li::before { content: counter(top); color: var(--muted); font-variant-numeric: tabular-nums; }
.toplist li span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }
.toplist li.yours { font-weight: 700; }
.toplist li.yours span:first-of-type::after { content: '  (you)'; font-weight: 400; color: var(--muted); }

/* Scorecard */
.card-total { margin-top: 22px; font-family: var(--serif); font-size: 2.3rem; font-style: italic; text-align: center; line-height: 1.1; }
.card-icons { margin: 8px 0 6px; font-size: 1.7rem; letter-spacing: 0.18em; text-align: center; }
.card-coins { margin-bottom: 16px; text-align: center; font-weight: 600; color: #7a5a08; }
.scorecard { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.scorecard th {
  padding: 6px 4px;
  border-bottom: 2px solid var(--ink);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: left;
}
.scorecard th.num { text-align: right; }
.scorecard td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scorecard td small { display: block; color: var(--muted); }
.scorecard tfoot th { border-bottom: 0; border-top: 2px solid var(--ink); font-size: 0.9rem; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.share-text {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 2px dashed var(--ink);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  white-space: pre-wrap;
  user-select: all;
}
.share-text::before { content: 'Your browser would not copy it. Select this instead:'; display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--muted); }

/* Ranking */
.rank-line { font-family: var(--serif); font-size: 1.35rem; font-style: italic; margin-bottom: 8px; }
.rank-bars { display: grid; gap: 4px; margin-bottom: 6px; }
.rank-row { display: grid; grid-template-columns: 9.5rem 1fr 2.6rem; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); }
.rank-row i { display: block; height: 12px; border-radius: 3px; background: var(--line); }
.rank-row b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-row.you { color: var(--ink); font-weight: 700; }
.rank-row.you i { background: var(--flag); }

details { border-bottom: 1px solid var(--line); }
summary { padding: 10px 0; font-weight: 600; cursor: pointer; }
details ol { margin: 0 0 8px; padding: 0; list-style: none; }
details li {
  display: grid;
  grid-template-columns: 1fr auto 1.6rem;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.9rem;
}
details li span:nth-child(2) { font-variant-numeric: tabular-nums; color: var(--muted); }
details li.yours { font-weight: 700; }
details .small { padding-bottom: 12px; }

/* The panel that slides in from the left */
.backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(28, 43, 35, 0.45); }
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  width: min(24rem, 92vw);
  border-right: 2px solid var(--ink);
  background: var(--paper);
  transform: translateX(-102%);
  visibility: hidden;
  transition: transform 0.25s ease-out, visibility 0s 0.25s;
}
.drawer.open { transform: none; visibility: visible; transition: transform 0.25s ease-out; }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 2px solid var(--ink);
}
.drawer-head h2 { margin: 0; font-size: 1.4rem; font-style: italic; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 16px 32px; }
.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.block h3 { font-size: 1.05rem; margin-bottom: 8px; }
.block > * + * { margin-top: 8px; }

.slider { display: grid; grid-template-columns: 7rem 1fr 3rem; align-items: center; gap: 8px; }
.slider input { width: 100%; accent-color: var(--club); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.toggle { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; cursor: pointer; }
.toggle input { width: 1.3rem; height: 1.3rem; margin: 2px 0 0; accent-color: var(--club); }
.toggle small { display: block; color: var(--muted); }

.archive { margin: 0; padding: 0; list-style: none; }
.archive li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.archive small { display: block; color: var(--muted); }
.archive-score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.85rem; white-space: nowrap; }

.balance { font-size: 1.2rem; }
.balance b { margin: 0 4px; font-variant-numeric: tabular-nums; }
.packs { display: grid; gap: 6px; }

.lineup { display: flex; justify-content: center; align-items: flex-end; gap: 4px; padding: 14px 0 6px; border-bottom: 1px solid var(--line); }
.lineup figure { margin: 0; text-align: center; font-size: 0.8rem; color: var(--muted); }
.lineup .preview { width: 5.2rem; height: 7.4rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 8px; }
.tab {
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.tab.on { background: var(--ink); color: var(--paper); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr)); gap: 8px; margin-bottom: 12px; }
.item {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
}
.item .preview { width: 3.6rem; height: 4.4rem; }
.item b { text-wrap: balance; }
.item-blurb { color: var(--muted); font-size: 0.72rem; text-wrap: balance; }
.item-tag { color: var(--club); font-weight: 700; font-variant-numeric: tabular-nums; }
.item.using { border-color: var(--club); background: #eef6e6; cursor: default; }
.item.locked .item-tag { color: #7a5a08; }
.item.locked:disabled { opacity: 0.55; cursor: default; }
.item:disabled { color: var(--ink); }

/* Animations off: game.js puts .still on <html> when the device asks for less
   motion or the player switches them off. */
.still .cloud, .still .pennant, .still .fall, .still .sway, .still .shot, .still .holed-score, .still .swing.shake { animation: none; }
.still .drawer { transition: none; }

/* A short message at the bottom of the screen: payments, adverts */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.links a { color: var(--club); font-weight: 600; }
.footer-links { justify-content: center; margin-top: 18px; }
