:root {
  --ink: #2b2236;
  --paper: #f6f0de;
  --card: #fffaf0;
  --green: #2f7d4a;
  --green-2: #5d9d4f;
  --gold: #f2b33d;
  --red: #d9483b;
  --muted: #6e6578;
  --radius: 12px;
  --shadow: 4px 4px 0 var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47,125,74,0.05) 50%, transparent 50%) 0 0 / 24px 24px,
    var(--paper);
  display: flex;
  flex-direction: column;
}
main { width: min(960px, 100% - 24px); margin: 0 auto; flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  width: min(960px, 100% - 24px); margin: 14px auto 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  background: none; border: 0; padding: 0;
  font-weight: 900; font-size: 1.5rem; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 10px;
}
.flag { width: 18px; height: 26px; position: relative; display: inline-block; }
.flag::before { content: ""; position: absolute; left: 2px; top: 0; width: 3px; height: 26px; background: var(--ink); }
.flag::after { content: ""; position: absolute; left: 5px; top: 1px; border-left: 13px solid var(--red); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.link { background: none; border: 0; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* shared pieces */
.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 16px 0;
}
.stage { position: relative; width: min(100%, calc(52vh * 192 / 108)); margin: 0 auto; }
.stage canvas {
  display: block; width: 100%; aspect-ratio: 192 / 108;
  image-rendering: pixelated; image-rendering: crisp-edges;
  border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #aedbee;
}
h1 { font-size: 1.7rem; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { margin: 0 0 12px; }
p { line-height: 1.5; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.label { font-weight: 700; min-width: 90px; }
.note { color: var(--muted); font-size: 0.9rem; margin: 10px 0 0; }

.btn {
  border: 3px solid var(--ink); border-radius: 10px; background: #fff;
  padding: 10px 18px; font-weight: 800; box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 14px; font-weight: 700; border-right: 2px solid var(--ink); display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.seg button:last-child { border-right: 0; }
.seg button small { font-weight: 500; font-size: 0.72rem; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--gold); }
.seg button[aria-checked="true"] small { color: var(--ink); }
.seg.small button { padding: 6px 12px; }

.how summary { cursor: pointer; font-weight: 700; margin-top: 16px; }
.bands { border-collapse: collapse; margin: 10px 0; }
.bands td { padding: 4px 12px 4px 0; }

/* locker room */
.locker { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 24px; }
.portrait canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border: 3px solid var(--ink); border-radius: var(--radius); }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 800; margin-bottom: 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
  width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 8px; padding: 0; overflow: hidden;
  display: grid; grid-template-rows: 2fr 1fr;
}
.preset span { display: block; }
.preset[aria-pressed="true"], .swatch[aria-pressed="true"] { outline: 3px solid var(--gold); outline-offset: 2px; }
.pickers { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.pickers label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.pickers input { width: 44px; height: 30px; border: 2px solid var(--ink); border-radius: 6px; padding: 0; background: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); padding: 0; }

/* play */
.status { display: flex; gap: 18px; font-weight: 800; margin: 4px 0 10px; align-items: baseline; }
.status .total { margin-left: auto; font-size: 1.3rem; }
.pop {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%);
  font-weight: 900; font-size: clamp(1.6rem, 5vw, 3rem); letter-spacing: -0.02em;
  color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  animation: pop 0.5s cubic-bezier(.2,1.6,.4,1) both;
  pointer-events: none; white-space: nowrap;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.skip { position: absolute; right: 12px; bottom: 12px; border: 2px solid var(--ink); border-radius: 8px; background: #fffaf0; font-weight: 700; padding: 4px 10px; }
.q { font-size: 1.3rem; margin: 0 0 14px; line-height: 1.4; }
.q .pos { background: var(--gold); border: 2px solid var(--ink); border-radius: 8px; padding: 0 8px; font-weight: 900; white-space: nowrap; }
.q .period { display: block; color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
/* scope: what counts for this hole. One colour per kind, used on the chip, the phrase and the course sign */
.alltime { --sc: #f2b33d; } .since { --sc: #6fb6e0; } .active { --sc: #7fd07a; }
.decade { --sc: #b99cf0; } .record { --sc: #f08fb8; }
.chip {
  display: inline-block; background: var(--sc); border: 2px solid var(--ink); border-radius: 999px;
  padding: 1px 12px; font-size: 0.95rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0 0 8px; vertical-align: middle;
}
.q .chip { display: table; }
.chip.mini { font-size: 0.68rem; padding: 0 7px; margin: 0 4px 0 0; }
.q .scope { font-weight: 800; box-shadow: inset 0 -0.45em 0 color-mix(in srgb, var(--sc) 70%, transparent); }
.sign {
  position: absolute; left: 14px; top: 12px; background: var(--sc); border: 3px solid var(--ink);
  border-radius: 8px; box-shadow: 3px 3px 0 var(--ink); padding: 4px 12px;
  font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em; font-size: clamp(0.8rem, 2vw, 1.1rem);
}
.sign:empty { display: none; }
#guessForm { display: flex; gap: 10px; flex-wrap: wrap; }
.ac { position: relative; flex: 1 1 260px; }
.ac input { width: 100%; font: inherit; font-size: 1.1rem; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; }
.ac ul {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; background: #fff; border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow);
}
.ac li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.ac li[aria-selected="true"], .ac li:hover { background: #e6f2dc; }
.ac li b { font-weight: 800; }

.result-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 1.1rem; }
.badge { font-weight: 900; padding: 4px 12px; border: 3px solid var(--ink); border-radius: 999px; background: var(--gold); }
.badge.s1 { background: #f2b33d; } .badge.s2 { background: #8fd06f; } .badge.s3 { background: #b6e39c; }
.badge.s4 { background: #fff; } .badge.s5 { background: #ffd6a5; } .badge.s6 { background: #ffb38a; } .badge.s7 { background: #f28b82; }
.snippet { width: 100%; border-collapse: collapse; margin-top: 14px; font-variant-numeric: tabular-nums; }
.snippet td { padding: 5px 8px; border-bottom: 1px dashed #d8cfbd; }
.snippet td.n { text-align: right; color: var(--muted); width: 4.5em; white-space: nowrap; }
.snippet td.v { text-align: right; }
.snippet tr.target td { background: #fdf0c8; font-weight: 800; }
.snippet tr.guess td { background: #e1efff; font-weight: 700; }
.snippet tr.target.guess td { background: #c9efb4; }
.snippet tr.gap td { text-align: center; color: var(--muted); border: 0; }
.tag { font-size: 0.75rem; font-weight: 800; border: 2px solid var(--ink); border-radius: 6px; padding: 0 5px; margin-left: 6px; background: #fff; }

/* scorecard */
.scorecard .big { font-size: 2.2rem; font-weight: 900; margin: 0 0 10px; }
#cardTable { width: 100%; border-collapse: collapse; }
#cardTable th, #cardTable td { padding: 8px; border-bottom: 2px solid #e8dfcc; text-align: left; vertical-align: top; }
#cardTable td.s { text-align: center; width: 3em; }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; font-weight: 900; }
.mark.under { border: 2px solid var(--ink); border-radius: 50%; }
.mark.ace { border: 2px solid var(--ink); border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); background: var(--gold); }
.mark.eagle { border: 2px solid var(--ink); border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.mark.over { border: 2px solid var(--ink); }
.mark.over2 { border: 2px solid var(--ink); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.mark.max { border: 2px solid var(--ink); background: #f28b82; }
.sub { color: var(--muted); font-size: 0.85rem; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 18px; }

@media (max-width: 640px) {
  .locker { grid-template-columns: 1fr; }
  .portrait { max-width: 220px; margin: 0 auto; }
  .q { font-size: 1.1rem; }
  .seg button { padding: 6px 8px; }
  .pop { top: 52%; }
  .sign { left: 8px; top: 8px; padding: 2px 8px; border-width: 2px; }
}
