/* Retro arcade palette, sampled from the court map. */
:root {
  --bg: #efe6cc;          /* number-tile cream */
  --surface: #fbf6e8;
  --ink: #17223d;         /* net navy */
  --muted: #5a6075;
  --line: #17223d;
  --soft-line: #d6ccb0;
  --court: #1d4fc0;       /* court blue */
  --court-ink: #ffffff;
  --turf: #2f8a3c;        /* surround green */
  --stripe: #f2c200;      /* road stripe yellow */
  --open: #dbe5fb;
  --open-hover: #b9cdf7;
  --booked: #17223d;
  --booked-ink: #fbf6e8;
  --held: #f2c200;
  --held-ink: #17223d;
  --closed: #e2d9bf;
  --error: #b3261e;
  --shadow: 4px 4px 0 var(--line);
  --pixel: "Press Start 2P", ui-monospace, "Courier New", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1530; --surface: #16204a; --ink: #f1ead4; --muted: #a7aec8;
    --line: #000814; --soft-line: #2a3767;
    --court: #3d6ff0; --turf: #3fa850;
    --open: #1c3170; --open-hover: #2a4596;
    --booked: #f1ead4; --booked-ink: #0d1530;
    --closed: #1a2348; --error: #ff8a80;
    --shadow: 4px 4px 0 #000814;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top, 0) 16px env(safe-area-inset-bottom, 0);
}
/* One column width for everything on desktop. */
main, .top { max-width: 760px; margin: 0 auto; }
.top { padding-block: 28px 4px; }
h1 {
  margin: 0 0 10px; font: 400 clamp(1rem, 3.6vw, 1.6rem)/1.35 var(--pixel); letter-spacing: 0.02em;
  text-shadow: 3px 3px 0 var(--stripe);
}
h2 { margin: 0 0 6px; font-size: 1.2rem; }
.rules, .muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }
.pixel { font-family: var(--pixel); font-weight: 400; letter-spacing: 0.03em; }

/* --- Court map --- */
.map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 18px 0 8px; }
.map-head .pixel { font-size: 0.7rem; }
.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.map {
  margin: 0; border: 4px solid var(--line); box-shadow: var(--shadow);
  aspect-ratio: 3 / 2; container-type: inline-size; overflow: hidden; background: var(--turf);
}
.map-inner { position: relative; width: 100%; aspect-ratio: 3 / 2; }
.map picture, .map img { display: block; width: 100%; height: 100%; }
/* Phones: zoom in on the fenced courts (x 17–82%, y 3–92% of the image). */
@media (max-width: 640px) {
  .map { aspect-ratio: 998 / 911; }
  .map-inner { width: 153.8%; margin: -3.1% 0 0 -26.2%; }
}
.spot {
  position: absolute; border: 0; padding: 0; background: transparent; cursor: pointer;
  outline: 3px solid transparent; outline-offset: 2px;
}
.spot::after {   /* status overlay */
  content: ""; position: absolute; inset: 0; transition: background .15s;
}
.spot.full::after { background: rgba(23, 34, 61, .45); }
.spot.shut::after { background: repeating-linear-gradient(135deg, rgba(23,34,61,.6) 0 6px, rgba(23,34,61,.35) 6px 12px); }
.spot:hover, .spot:focus-visible { outline-color: #fff; }
.tag {
  position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); z-index: 1; white-space: nowrap;
  font: 400 clamp(7px, 1.4cqw, 11px)/1 var(--pixel); padding: 0.6em 0.7em;
  background: #fbf6e8; color: #17223d; border: 2px solid #17223d; box-shadow: 2px 2px 0 #17223d;
}
.spot.has-open .tag { background: var(--stripe); }
.spot.shut .tag, .spot.full .tag { background: #d9d2bd; }

/* --- Day picker --- */
.days { display: flex; gap: 10px; overflow-x: auto; padding: 22px 6px 14px 0; scrollbar-width: thin; }
.days button {
  flex: 1 0 auto; border: 3px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 0; padding: 8px 12px; text-align: center; cursor: pointer; font: inherit; min-width: 66px;
  box-shadow: 3px 3px 0 var(--line);
}
.days button:active { transform: translate(3px, 3px); box-shadow: none; }
.days button b { display: block; font: 400 1rem/1.6 var(--pixel); }
.days button span { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.days button[aria-pressed="true"] { background: var(--court); color: var(--court-ink); }
.days button[aria-pressed="true"] span { color: inherit; }

.hours { margin: 10px 0 0; }

.tile {
  display: inline-grid; place-items: center; min-width: 2.1em; height: 2.1em; padding: 0 .4em;
  font: 400 0.8rem/1 var(--pixel); color: #17223d; background: #fbf6e8; border: 2px solid #17223d; box-shadow: 2px 2px 0 #17223d;
}
.tile.word { font-size: 0.55rem; }

/* --- Dialog, forms, cards --- */
dialog {
  border: 4px solid var(--line); border-radius: 0; padding: 22px; width: min(430px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 6px 6px 0 var(--line);
}
dialog::backdrop { background: rgba(13, 21, 48, .55); }
.dlg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.dlg-head h2 { margin: 0; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-top: 12px; }
input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 0;
}
input:focus-visible { outline: 3px solid var(--court); outline-offset: 1px; }
.durations { border: 0; padding: 0; margin: 14px 0 0; }
.durations legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; font-weight: 500; }
.chips input { position: absolute; opacity: 0; width: 0; }
.chips span { display: inline-block; padding: 7px 11px; border: 2px solid var(--line); cursor: pointer; background: var(--surface); }
.chips input:checked + span { background: var(--court); color: var(--court-ink); box-shadow: 2px 2px 0 var(--line); }
.chips input:checked + span .muted { color: inherit; opacity: .8; }
.chips input:focus-visible + span { outline: 3px solid var(--stripe); outline-offset: 2px; }
.dlg-status { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.st { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; border: 2px solid var(--line); }
.st b { min-width: 5.2em; font-variant-numeric: tabular-nums; }
.st.open { background: var(--open); }
.st.open span { color: var(--turf); font-weight: 700; }
.st.taken { background: var(--booked); color: var(--booked-ink); }
.st.soon, .st.out { background: var(--closed); color: var(--muted); border-style: dashed; border-color: var(--soft-line); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
button { font: inherit; }
.actions button, .card button {
  border: 3px solid var(--line); border-radius: 0; padding: 10px 16px; cursor: pointer;
  font: 400 0.68rem/1.4 var(--pixel); letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--court); color: var(--court-ink); box-shadow: 3px 3px 0 var(--line);
}
.actions button:active, .card button:active { transform: translate(3px, 3px); box-shadow: none; }
.actions button.ghost, .card button.ghost { background: var(--surface); color: var(--ink); }
.actions button.danger, .card button.danger { background: var(--error); color: #fff; }
button:disabled { opacity: .6; cursor: default; }
.error { color: var(--error); margin: 10px 0 0; }
a { color: var(--court); word-break: break-all; }
.card { background: var(--surface); border: 4px solid var(--line); box-shadow: var(--shadow); padding: 22px; margin-block: 18px; }
.card .actions { justify-content: flex-start; }
.done-title { font: 400 1rem/1.5 var(--pixel); color: var(--turf); margin: 0 0 8px; }

/* --- Header + the court sign --- */
.tagline { margin: 0 0 6px; font-style: italic; }
.rules a { white-space: nowrap; }
.sign {
  margin: 0 0 48px; padding: 26px clamp(18px, 4vw, 34px);
  background: #17223d; color: #f1ead4; border: 4px solid #000814;
  box-shadow: inset 0 0 0 4px #f1ead4, inset 0 0 0 8px #17223d, 6px 6px 0 var(--turf);
}
.sign .pixel { color: #f1ead4; }
.sign-top { text-align: center; margin: 0 0 10px; font-size: clamp(0.8rem, 2.6vw, 1.05rem); line-height: 1.6; color: var(--stripe) !important; }
.sign-sub { text-align: center; margin: 0 0 18px; opacity: 0.9; }
.sign h2 { font-size: 0.75rem; margin: 0 0 12px; border-top: 3px dashed rgba(241, 234, 212, .35); padding-top: 18px; text-transform: uppercase; }
.sign ol { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.sign li::marker { font-family: var(--pixel); font-size: 0.7em; color: var(--stripe); }
.sign-end { text-align: center; margin: 22px 0 6px; font-size: 0.68rem; line-height: 1.7; }
.sign-credit { text-align: center; margin: 0; font-size: 0.8rem; opacity: 0.75; letter-spacing: 0.04em; }
label.agree { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin-top: 14px; }
label.agree input { width: 20px; height: 20px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--court); }

/* --- Day at a glance --- */
:root { --ball-line: #17223d; --tennis: #cfe33a; --pickle: #ffd21f; --ball-seam: #fbf6e8; --pickle-hole: #b38600; }
.glance { margin: 6px 0 30px; scroll-margin-top: 12px; }
.glance .map-head { margin-top: 0; }
.glance-wrap { background: var(--surface); border: 4px solid var(--line); box-shadow: var(--shadow); padding: 8px 8px 6px 0; }
.glance-grid { display: grid; grid-template-columns: 54px repeat(5, 1fr); grid-auto-rows: minmax(38px, auto); align-items: center; }
.gh { display: grid; place-items: center; padding: 2px 0 8px; }
.gh .tile.word { font-size: 0.5rem; }
.gt.dim { opacity: .45; }
.gt { font-size: 0.78rem; color: var(--muted); text-align: right; padding-right: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gc {
  height: 100%; min-height: 38px; display: grid; place-items: center; border: 0; padding: 0; background: none; cursor: pointer;
  border-top: 1px dashed var(--soft-line);
}
.gc:hover, .gc:focus-visible { background: var(--open); outline: none; }
.ball { width: 30px; height: 30px; display: block; }
/* Colors go on the <symbol> originals; every <use> copy inherits them. */
symbol .bo { fill: var(--ball-line); }
symbol .bs { fill: var(--ball-seam); }
symbol .bl { fill: #fffbe6; }
#ball-tennis .bb { fill: var(--tennis); }
#ball-pickleball .bb { fill: var(--pickle); }
symbol .bh { fill: var(--pickle-hole); }
.gclosed {
  align-self: stretch; display: flex; justify-content: center; padding-top: 10px; text-align: center; font-size: 0.75rem; color: var(--muted);
  background: repeating-linear-gradient(135deg, var(--closed) 0 8px, transparent 8px 16px);
}
.gclosed small { display: block; }
.glance-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.glance-key > span { display: inline-flex; align-items: center; gap: 6px; }
.gk .ball { width: 20px; height: 20px; }
/* Map tap: blink the court's column a few times. */
.flash { animation: flash 0.35s steps(1) 4; }
@keyframes flash { 50% { background: var(--stripe); } }
.map { margin-bottom: 36px; }
@media (prefers-color-scheme: dark) { :root { --ball-line: #000814; } }

@media (prefers-reduced-motion: reduce) {
  .blink, .flash { animation: none; }
}
