:root {
  --olive: #8b8b1e;
  --olive-dark: #6c6c12;
  --green: #3f8a3a;
  --beer: #f2b531;
  --bg: #ffffff;
  --panel: #eeede8;
  --text: #151515;
  --muted: #6b6b63;
  --line: #d9d7cf;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121210;
    --panel: #1e1e1a;
    --text: #f1f0ea;
    --muted: #a3a296;
    --line: #34332c;
    --olive: #b5b53a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* Header */
.top { padding: max(16px, env(safe-area-inset-top)) 16px 0; max-width: 1100px; width: 100%; margin: 0 auto; }
.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 0; margin: 8px 0 18px;
  -webkit-tap-highlight-color: transparent;
}
.brand span { font-size: 2.6rem; font-weight: 800; color: var(--olive); letter-spacing: -0.02em; }
.brand img { display: block; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > * {
  flex: 0 0 auto;
  border: 0; background: none;
  padding: 14px 18px;
  font-weight: 800; font-size: 1.05rem;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}
.tabs > [aria-selected="true"] { background: var(--panel); }
@media (max-width: 480px) {
  .tabs { gap: 0; }
  .tabs > * { padding: 12px 9px; font-size: .85rem; }
  .brand span { font-size: 2.2rem; }
}
.tab-select { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.tab-select::after { content: "▾"; margin-left: 6px; font-size: .8em; }
.tab-select select { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 16px; }

/* Panels */
main { flex: 1; width: 100%; }
.panel { background: var(--panel); }
.panel[hidden] { display: none; }

#panel-year { display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  #panel-year { grid-template-columns: 1fr 320px; }
}
.map-wrap { position: relative; }
#map { height: min(70vh, 640px); min-height: 360px; background: #e5e3df; }
.map-badge {
  position: absolute; top: 12px; left: 12px; z-index: 500;
  width: 110px; pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}
@media (min-width: 700px) { .map-badge { width: 170px; } }

.hole-marker {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--olive); color: #fff; border: 3px solid #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.hole-marker.active { background: var(--beer); color: #111; transform: scale(1.15); }

.course-info { padding: 20px 16px 28px; }
.course-info h2 { margin: 0 0 6px; }
.winner-line { margin: 0 0 12px; font-weight: 700; color: var(--olive); }
.hole-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.hole-list button {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-weight: 600;
}
.hole-list button:hover, .hole-list button.active { border-color: var(--olive); }
.hole-list .num {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--olive); color: #fff; display: grid; place-items: center; font-weight: 800;
}
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Scorekort */
#panel-score { padding: 20px 16px 28px; }
.score-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.score-head h2 { margin: 0; }
.add-player { display: flex; gap: 8px; }
.add-player input {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 150px;
}
.add-player button, #eddi-next {
  border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700;
  background: var(--olive); color: #fff;
}
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 10px 16px; margin-top: 16px; }
.table-scroll { overflow-x: auto; margin-top: 12px; }
.score-table { border-collapse: collapse; min-width: 100%; background: var(--bg); border-radius: 10px; overflow: hidden; }
.score-table th, .score-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.score-table th:first-child, .score-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg); }
.score-table tfoot td { font-weight: 800; }
.score-table .leader { color: var(--olive); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-weight: 800;
}
.stepper span { min-width: 1.5em; font-variant-numeric: tabular-nums; font-weight: 700; }
.remove { border: 0; background: none; color: var(--muted); padding: 0 4px; }

/* Hall of Fame */
#panel-hof { padding: 28px 16px 36px; text-align: center; }
.hof-list { list-style: none; padding: 0; margin: 0 auto; font-weight: 800; font-size: 1.35rem; line-height: 1.6; }
.hof-list .yr { font-variant-numeric: tabular-nums; margin-right: .3em; }
.hof-list li.latest::after { content: " 🏆"; }
.hof-sub { margin: 28px 0 8px; color: var(--olive); }
.hof-tally { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.hof-tally li { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; }
.shame { margin: 28px auto 0; max-width: 420px; border: 2px dashed #c0392b; border-radius: 12px; padding: 12px 16px; }
.shame h3 { color: #c0392b; margin: 0 0 6px; }
.shame p { margin: 0; }

.foot { padding: 20px 16px max(20px, env(safe-area-inset-bottom)); text-align: center; color: var(--muted); font-size: .85rem; }

/* Easter egg */
.eddi {
  position: fixed; inset: 0; z-index: 2000;
  display: grid; place-items: center; padding: 16px;
  background: rgba(120, 0, 0, .55);
  animation: flash .5s steps(2) 4;
}
.eddi[hidden] { display: none; }
@keyframes flash { 50% { background: rgba(255, 180, 0, .55); } }
.eddi-card {
  background: var(--bg); color: var(--text);
  max-width: 440px; width: 100%; border-radius: 16px; padding: 24px 20px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: shake .4s ease-in-out 2;
}
@keyframes shake { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.siren { font-size: 3rem; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.eddi-card h2 { margin: 6px 0 12px; color: #c0392b; letter-spacing: .02em; }
.eddi-roast { font-size: 1.15rem; font-weight: 600; min-height: 4.5em; }
.eddi-stats { display: flex; justify-content: center; gap: 18px; margin: 12px 0 18px; }
.eddi-stats dt { font-size: .8rem; color: var(--muted); }
.eddi-stats dd { margin: 0; font-size: 1.6rem; font-weight: 800; }
.eddi-actions { display: flex; flex-direction: column; gap: 8px; }
.eddi-actions .ghost { margin-top: 0; }
.beer-rain { position: fixed; top: -40px; z-index: 2001; font-size: 28px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  .eddi, .eddi-card, .siren { animation: none; }
}
