/* =========================================================
   The Greens at Oak Openings — Mini Golf Scorecard
   Colors pulled from the website + printed scorecard
   ========================================================= */
:root {
  --forest: #2c4925;      /* deep green (site + scorecard header) */
  --forest-dk: #1e3319;
  --olive: #6b7d3a;       /* scorecard "Par" row green */
  --sage: #d3e1d0;        /* site accent */
  --cream: #efece3;       /* site header background */
  --paper: #ffffff;
  --bark: #443325;        /* site brown */
  --ink: #161616;
  --muted: #4f4f4c;
  --sun: #f7b32b;
  --flag: #e4572e;
  --sky: #3fa7d6;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(30, 51, 25, .18), 0 12px 24px rgba(30, 51, 25, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: Raleway, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.55) 0 2px, transparent 3px) 0 0 / 34px 34px,
    var(--cream);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Hero / logo ---------- */
.hero {
  position: relative;
  background:
    linear-gradient(180deg, rgba(20,35,16,.35), rgba(20,35,16,.65)),
    url("https://img1.wsimg.com/isteam/ip/20aacbba-aad6-4000-aea3-c0b7c7265d2e/website%20home%20page.png/:/rs=w:900,m") center / cover,
    var(--forest);
  color: #fff;
  text-align: center;
  padding: calc(18px + env(safe-area-inset-top)) 16px 46px;
  border-radius: 0 0 50% 50% / 0 0 28px 28px;
  overflow: hidden;
}
.hero-inner { position: relative; z-index: 1; }
.badge { width: min(210px, 62vw); filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.script {
  font-family: Yellowtail, cursive;
  font-weight: 400;
  font-size: clamp(44px, 13vw, 64px);
  margin: 2px 0 0;
  line-height: 1;
  text-shadow: 0 3px 10px rgba(0,0,0,.4);
}
.sub {
  font-family: Montserrat, sans-serif;
  letter-spacing: .22em;
  font-size: 13px;
  margin: 4px 0 0;
  opacity: .95;
}

/* ---------- Layout ---------- */
main { max-width: 520px; margin: -26px auto 0; padding: 0 16px; position: relative; z-index: 2; }
.screen { animation: pop .35s ease; }
.hidden { display: none !important; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 18px;
  border: 3px solid var(--forest);
}
h2 {
  font-family: Montserrat, sans-serif;
  font-weight: 800;
  color: var(--forest);
  margin: 0 0 4px;
  font-size: 22px;
}
.hint { color: var(--muted); margin: 0 0 14px; font-size: 15px; }
.tiny { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---------- Buttons ---------- */
.btn {
  font-family: Montserrat, sans-serif;
  font-weight: 700;
  font-size: 17px;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); }
.btn-primary {
  background: var(--forest);
  color: #fff;
  box-shadow: 0 5px 0 var(--forest-dk);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--forest-dk); }
.btn-ghost {
  background: var(--sage);
  color: var(--forest);
  box-shadow: 0 5px 0 #a9bfa4;
}
.btn-ghost:active { box-shadow: 0 2px 0 #a9bfa4; }
.btn-big { width: 100%; font-size: 21px; padding: 18px; }
#btn-add-player { width: 100%; margin-top: 6px; }

/* ---------- Player setup ---------- */
.player-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.score-list, .leaderboard { grid-template-columns: minmax(0, 1fr); }
.player-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--cream);
  border-radius: 16px;
  padding: 8px 10px;
}
.player-row input {
  flex: 1; min-width: 0; width: 100%;
  font: 600 17px Raleway, sans-serif;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.player-row input:focus { outline: none; border-color: var(--olive); }
.remove {
  border: 0; background: transparent; font-size: 22px; color: var(--muted);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
}
.remove:active { background: rgba(0,0,0,.08); }

/* golf ball avatar */
.ball {
  --c: #fff;
  flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; cursor: pointer; padding: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.9) 0 3px, transparent 4px),
    radial-gradient(circle, rgba(0,0,0,.12) 1.2px, transparent 1.6px) 0 0 / 7px 7px,
    radial-gradient(circle at 35% 35%, var(--c), color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: inset -3px -4px 6px rgba(0,0,0,.18), 0 2px 3px rgba(0,0,0,.2);
  display: grid; place-items: center;
  font: 800 15px Montserrat, sans-serif; color: rgba(0,0,0,.55);
}
.ball.sm { width: 30px; height: 30px; font-size: 12px; }

/* ---------- Hole progress dots ---------- */
.hole-dots {
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px;
  background: var(--paper); border-radius: 18px; padding: 10px;
  box-shadow: var(--shadow); margin-bottom: 14px; border: 3px solid var(--forest);
}
.dot {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--sage);
  background: #fff; font: 700 11px Montserrat, sans-serif; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.dot.done { background: var(--olive); border-color: var(--olive); color: #fff; }
.dot.current { background: var(--sun); border-color: var(--bark); color: var(--bark); transform: scale(1.15); }

/* ---------- Hole card ---------- */
.hole-card { padding-top: 14px; }
.hole-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hole-title { display: flex; flex-direction: column; align-items: center; }
.hole-label { font: 800 13px Montserrat, sans-serif; letter-spacing: .25em; color: var(--olive); }
.hole-num {
  font: 800 64px/1 Montserrat, sans-serif; color: var(--forest);
}
.hole-num.bump { animation: bump .35s ease; }
@keyframes bump { 50% { transform: scale(1.18) rotate(-4deg); } }
.par-pill {
  margin-top: 6px; background: var(--olive); color: #fff;
  font: 700 14px Montserrat, sans-serif; padding: 4px 14px; border-radius: 999px;
}
.par-pill.tricky { background: var(--flag); }
.nav-arrow {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--sage); color: var(--forest);
  font: 800 30px/1 Montserrat, sans-serif; cursor: pointer;
}
.nav-arrow:disabled { opacity: .3; }

.score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.score-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  background: var(--cream); border-radius: 16px; padding: 10px;
}
.score-name { min-width: 0; }
.score-name strong {
  display: block; font: 700 17px Montserrat, sans-serif;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.score-name .tag { font-size: 13px; font-weight: 700; color: var(--muted); min-height: 1.2em; display: block; }
.tag.ace { color: #c98a00; }
.tag.under { color: var(--olive); }
.tag.over { color: var(--bark); }

.stepper { display: flex; align-items: center; gap: 6px; }
.step {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  font: 800 24px/1 Montserrat, sans-serif;
  background: #fff; color: var(--forest); box-shadow: 0 3px 0 #b9c9b5;
}
.step:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9c9b5; }
.step.plus { background: var(--forest); color: #fff; box-shadow: 0 3px 0 var(--forest-dk); }
.strokes {
  width: 44px; text-align: center; font: 800 30px Montserrat, sans-serif; color: var(--forest);
}
.strokes.empty { color: #b8b8b2; }

/* Small phones (iPhone SE, etc.) */
@media (max-width: 370px) {
  main { padding: 0 10px; }
  .card { padding: 16px 12px; }
  .score-row { gap: 8px; padding: 8px; }
  .score-row > .ball { width: 30px; height: 30px; font-size: 12px; }
  .stepper { gap: 2px; }
  .step { width: 38px; height: 38px; font-size: 21px; }
  .strokes { width: 30px; font-size: 25px; }
  .score-name strong { font-size: 15px; }
  .score-name .tag { font-size: 12px; }
  .hole-num { font-size: 54px; }
  .nav-arrow { width: 42px; height: 42px; }
}

.play-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; margin-bottom: 18px; }

/* ---------- Scorecard table (looks like the paper card) ---------- */
/* The table stretches to fill the card. It only scrolls sideways when the
   screen is narrower than the card's minimum (about 600px), e.g. a phone held upright. */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px 6px; -webkit-overflow-scrolling: touch; }
.score-table { border-collapse: separate; border-spacing: 0; font-family: Montserrat, sans-serif; width: 100%; }
.score-table th, .score-table td {
  text-align: center; padding: 8px 2px; min-width: 26px; font-size: 14px;
  border-bottom: 1px solid #e3e3dc; border-right: 1px solid #e3e3dc;
}
.score-table td.tot { min-width: 36px; }
.rotate-tip { display: none; }
.table-wrap.scrolls + .rotate-tip { display: block; margin: 10px 0 0; text-align: center; font-size: 14px; color: var(--muted); }

/* Scorecard screen gets the full screen width (phone sideways, tablet, desktop) */
body.wide main { max-width: 1100px; }
@media (min-width: 760px) {
  .score-table th, .score-table td { font-size: 15px; padding: 10px 4px; }
}

/* Short landscape screens (phone sideways): shrink the header so the card fits */
@media (orientation: landscape) and (max-height: 520px) {
  .hero { padding: calc(8px + env(safe-area-inset-top)) 16px 34px; }
  .badge { width: 130px; }
  .script { font-size: 38px; }
  .sub { font-size: 11px; }
  main { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  #screen-card .card { padding: 14px 10px; }
  .score-table th, .score-table td { min-width: 23px; font-size: 13px; padding: 7px 1px; }
  .score-table td.tot { min-width: 32px; }
  .score-table th:first-child, .score-table td:first-child { min-width: 62px; padding-left: 6px; }
}
.score-table thead th { background: var(--forest); color: #fff; font-weight: 800; }
.score-table tr.par-row th, .score-table tr.par-row td { background: var(--olive); color: #fff; font-weight: 700; }
.score-table th:first-child, .score-table td:first-child {
  position: sticky; left: 0; z-index: 1; text-align: left; min-width: 72px; max-width: 120px; padding-left: 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-table tbody th:first-child { background: #fff; }
.score-table thead th:first-child { background: var(--forest); }
.score-table tr.par-row th:first-child { background: var(--olive); }
.score-table td.tot { font-weight: 800; background: var(--sage); color: var(--forest); }
.score-table td.cell { cursor: pointer; font-weight: 700; }
.score-table td.cell.ace { background: #fff3c4; }
.score-table td.cell.under { color: var(--olive); }
.score-table td.split, .score-table th.split { border-right: 3px solid var(--forest); }

/* ---------- Results ---------- */
.results { text-align: center; }
.trophy { font-size: 64px; animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.leaderboard { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; text-align: left; }
.leaderboard li {
  display: grid; grid-template-columns: 34px auto 1fr auto; align-items: center; gap: 10px;
  background: var(--cream); border-radius: 16px; padding: 10px 12px;
}
.leaderboard li.first { background: #fff3c4; border: 2px solid var(--sun); }
.place { font: 800 22px Montserrat, sans-serif; text-align: center; }
.lb-name { font: 700 17px Montserrat, sans-serif; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { text-align: right; font: 800 22px Montserrat, sans-serif; color: var(--forest); }
.lb-score small { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.awards { display: grid; gap: 8px; margin-top: 16px; }
.award {
  background: var(--sage); color: var(--forest); border-radius: 14px; padding: 10px 12px;
  font-weight: 700; text-align: left;
}

/* ---------- Install card ---------- */
.install-card { margin-top: 14px; border-style: dashed; }
.install-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.install-icon { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.install-row strong { display: block; font: 800 17px Montserrat, sans-serif; color: var(--forest); }
.install-row span { font-size: 14px; color: var(--muted); }
#btn-install { width: 100%; }
.ios-hint { margin: 12px 0 0; font-size: 15px; background: var(--cream); border-radius: 12px; padding: 10px 12px; }

/* When opened as an installed app, leave room for the phone's status bar */
@media (display-mode: standalone) {
  .foot { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
}

/* ---------- Footer ---------- */
.foot { text-align: center; color: var(--muted); padding: 8px 16px 28px; font-size: 14px; }
.foot strong { color: var(--forest); }
.foot a { color: var(--forest); font-weight: 700; }

/* ---------- Toast + confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  background: var(--forest); color: #fff;
  font: 800 18px Montserrat, sans-serif;
  padding: 12px 22px; border-radius: 999px; box-shadow: 0 8px 20px rgba(0,0,0,.25);
  transition: transform .3s cubic-bezier(.3,1.6,.6,1), opacity .2s; z-index: 50; white-space: nowrap;
  opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
