:root {
  --bg: #f3f6f1;
  --card: #ffffff;
  --text: #1d2a1d;
  --muted: #647364;
  --line: #dfe8dc;
  --brand: #2f6b2f;
  --brand-d: #245524;
  --brand-l: #e4f0e1;
  --clay: #c8643c;
  --danger: #c0392b;
  --warn: #b7791f;
  --free: #d3ebcd;
  --free-b: #7fbd76;
  --taken: #ececec;
  --mine: #2f6b2f;
  --blocked: #f6dcd3;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a12; --card: #1b261b; --text: #e8efe6; --muted: #93a593; --line: #2c3b2c;
    --brand: #5fae5f; --brand-d: #7cc77c; --brand-l: #1f3320; --free: #2a5230; --free-b: #5fae5f;
    --taken: #2a312a; --blocked: #3e2a22; --danger: #ef7d6e; --warn: #e0b04f; --mine: #3f8a43;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: flex; justify-content: center; margin-top: 26vh; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hide { display: none !important; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; }
.top .in { max-width: 1000px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; color: #fff; text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #e9f5e7; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.18); color: #fff; }
.top .who { font-size: .85rem; opacity: .9; }
.banner { background: #fff4d6; color: #5c4400; border-bottom: 1px solid #f0dca0; padding: 8px 16px; text-align: center; font-size: .92rem; }
@media (prefers-color-scheme: dark) { .banner { background: #3a3015; color: #f1dca0; border-color: #5a4a1d; } }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.1; }
.btn:hover { background: var(--brand-d); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-l); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: .88rem; border-radius: 8px; }
.btn.block { width: 100%; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-height: 42px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
.field + .field { margin-top: 12px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.code-input { font-size: 1.8rem !important; letter-spacing: .5rem; text-align: center; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--taken); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--brand-l); color: var(--brand-d); }
.badge.warn { background: #fdebc8; color: #7a5200; }
.badge.bad { background: #f9d7d2; color: #8e2418; }
.badge.info { background: #dbeafe; color: #1e40af; }
@media (prefers-color-scheme: dark) { .badge.warn { background: #4a3a14; color: #f1dca0; } .badge.bad { background: #4d2420; color: #f4b3aa; } .badge.info { background: #1e2f4d; color: #b7cdf5; } }

/* date strip */
.dates { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.dates button { flex: 0 0 auto; min-width: 58px; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-align: center; line-height: 1.2; }
.dates button b { display: block; font-size: 1.15rem; }
.dates button span { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.dates button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.dates button.on span { color: #dcefd9; }
.dates button.today:not(.on) { border-color: var(--brand); }

/* courts & slots */
.court h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.court .num { background: var(--brand); color: #fff; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; margin-top: 10px; }
.slot { padding: 10px 4px; border-radius: 10px; border: 1px solid var(--free-b); background: var(--free); text-align: center; font-weight: 600; cursor: pointer; font-size: .95rem; line-height: 1.2; }
.slot small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); min-height: 1em; }
.slot.free:hover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-l); }
.slot.taken { background: var(--taken); border-color: var(--line); color: var(--muted); }
.slot.mine { background: var(--mine); border-color: var(--mine); color: #fff; }
.slot.mine small { color: #e0f0de; }
.slot.blocked { background: var(--blocked); border-color: #e8b9aa; color: #8a4430; }
@media (prefers-color-scheme: dark) { .slot.blocked { color: #f0b9a8; border-color: #6a3b2c; } }
.slot.past, .slot.unavailable { background: transparent; border-style: dashed; border-color: var(--line); color: var(--muted); opacity: .55; cursor: default; }
.slot.wait { box-shadow: inset 0 0 0 2px var(--warn); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin: 6px 0 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: 4px; vertical-align: -1px; border: 1px solid var(--line); }

/* lists / tables */
.list > .item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list > .item:first-child { border-top: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; font-size: .9rem; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat.alert { border-color: var(--clay); } .stat.alert b { color: var(--clay); }
table.hours { width: 100%; border-collapse: collapse; }
table.hours td { padding: 4px 4px; vertical-align: middle; }
table.hours input[type=time] { min-height: 36px; padding: 4px 8px; }
.picker { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-top: 6px; }
.picker .check { padding: 4px 0; }

/* modal & toast */
.backdrop { position: fixed; inset: 0; background: rgba(10,20,10,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.modal.wide { max-width: 760px; }
.modal .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.modal .head h2 { margin: 0; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
@media (min-width: 640px) { .backdrop { align-items: center; } .modal { border-radius: 18px; } }
#toasts { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { background: #243024; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: 480px; pointer-events: auto; }
.toast.err { background: var(--danger); }
.err-box { background: #f9d7d2; color: #8e2418; border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
@media (prefers-color-scheme: dark) { .err-box { background: #4d2420; color: #f4b3aa; } }
.hero { text-align: center; padding: 30px 0 10px; } .hero .ball { font-size: 3.5rem; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.center { text-align: center; }
.top .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); }
.top .btn.ghost:hover { background: rgba(255,255,255,.15); }
.topbtns { display: flex; gap: 6px; }
[dir="rtl"] .code-input { letter-spacing: .5rem; }
/* fields placed side by side in a row must not get the stacked-field top margin */
.row > .field + .field, .row > .field { margin-top: 0; }
.row:has(> .field) { align-items: flex-start; }
.slot.free { color: var(--text); }
.slot.past { text-decoration: line-through; }
.tip { font-size: .9rem; color: var(--muted); margin: 0 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--brand); border-radius: 99px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--brand); padding: 5px 14px; font-weight: 600; cursor: pointer; font-size: .9rem; }
.seg button.on { background: var(--brand); color: #fff; }
.top .seg { border-color: rgba(255,255,255,.6); }
.top .seg button { color: #fff; padding: 4px 10px; }
.top .seg button.on { background: rgba(255,255,255,.25); }
.adsel { margin-top: 6px; font-size: .92rem; color: var(--brand-d); font-weight: 600; word-break: break-word; }
gmp-place-autocomplete { width: 100%; color-scheme: light; }

/* gear menu */
.menuwrap { position: relative; margin-inline-start: auto; }
.gear { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; font-size: 1.25rem; cursor: pointer; line-height: 1; }
.gear:hover, .gear[aria-expanded="true"] { background: rgba(255,255,255,.2); }
.menu { position: absolute; inset-inline-end: 0; top: 46px; min-width: 230px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.25); padding: 6px; z-index: 40; }
.menu a, .menu button#logout, .menu button.mi { display: block; width: 100%; text-align: start; padding: 10px 12px; border: 0; background: none; color: var(--text); text-decoration: none; border-radius: 8px; cursor: pointer; font-size: 1rem; }
.menu a:hover, .menu button#logout:hover, .menu button.mi:hover { background: var(--brand-l); }
.menuhead { padding: 8px 12px 10px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-word; }
.menurow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; }
.menu .seg { border-color: var(--brand); }
.menu .seg button { color: var(--brand); }
.menu .seg button.on { background: var(--brand); color: #fff; }
.menuver { text-align: center; font-size: .72rem; color: var(--muted); opacity: .7; padding: 6px 0 2px; user-select: none; }

.slot small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* rush hours + rules editor */
.slot.rush { border-style: dotted; border-width: 2px; border-color: var(--clay); }
.rushkey { border: 2px dotted var(--clay) !important; background: var(--free); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); font-size: .8rem; cursor: pointer; background: var(--card); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--brand); }
.chip { position: relative; }
.rrow { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: grid; gap: 8px; }
table.limits { width: 100%; border-collapse: collapse; }
table.limits th { font-size: .8rem; color: var(--muted); text-align: start; padding: 2px 4px; }
table.limits td { padding: 3px 4px; }
table.limits td:first-child { white-space: nowrap; font-weight: 600; font-size: .9rem; }
table.limits input { min-height: 36px; padding: 4px 8px; }

.note { background: #fff4d6; color: #5c4400; border: 1px solid #f0dca0; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
@media (prefers-color-scheme: dark) { .note { background: #3a3015; color: #f1dca0; border-color: #5a4a1d; } }

.slot.offer { background: #ffd27a; border-color: #e0a030; color: #4a3000; animation: pulse 1.6s ease-in-out infinite; }
.slot.offer small { color: #4a3000; font-weight: 700; }
.slot.held { background: #ffe9c2; border: 1px dashed #e0a030; color: #7a5200; }
@media (prefers-color-scheme: dark) { .slot.held { background: #3a3015; color: #f1dca0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(224,160,48,.35); } }

/* street + house number side by side, inside the card */
.addr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, 34%); gap: 10px; }
.addr > * { min-width: 0; }
.addr .field { margin-top: 0; }
input[list] { width: 100%; }

.note.prior { border-width: 2px; margin-bottom: 14px; }

/* weather icons on the calendar */
.slot { position: relative; }
.slot .wx { position: absolute; top: 1px; inset-inline-end: 3px; font-size: .78rem; line-height: 1; }
.note.wxnote { background: #e0f0ff; color: #0b3a66; border-color: #b8d8f5; }
@media (prefers-color-scheme: dark) { .note.wxnote { background: #14304a; color: #bcdcf7; border-color: #25506f; } }

.gear.on { background: rgba(255,255,255,.22); }
.menu a.cur { background: var(--brand-l); font-weight: 700; }
@media (max-width: 560px) {
  .top .in { padding: 8px 12px; gap: 8px; flex-wrap: nowrap; }
  .brand { font-size: 1.05rem; white-space: nowrap; }
  .nav { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 6px 9px; font-size: .9rem; white-space: nowrap; }
  .menuwrap { margin-inline-start: 0; flex: 0 0 auto; }
  .menu { min-width: 220px; max-width: calc(100vw - 24px); }
}

.gear { position: relative; }
.gear .dot { position: absolute; top: 0; inset-inline-end: 0; width: 12px; height: 12px; border-radius: 50%; background: #e53935; border: 2px solid var(--brand); }
a.banner.pendingbar { display: block; background: #ffe2a8; color: #5c4400; font-weight: 700; text-decoration: none; border-bottom: 1px solid #f0c060; }

/* animated racquet + ball (loading / welcome) */
.rb { display: block; overflow: visible; }
.rb-frame { fill: none; stroke: var(--brand); stroke-width: 5; }
.rb-strings path { fill: none; stroke: var(--muted); stroke-width: 1; opacity: .55; }
.rb-handle { stroke: var(--brand-d); stroke-width: 7; stroke-linecap: round; }
.rb-shadow { fill: var(--text); opacity: .16; transform-box: fill-box; transform-origin: center; animation: rb-shadow 1.1s infinite; }
.rb-racquet { transform-box: fill-box; transform-origin: 50% 50%; animation: rb-hit 1.1s infinite; }
.rb-ball { transform-box: fill-box; transform-origin: center; animation: rb-bounce 1.1s infinite; }
.rb-ball circle { fill: #d9ea3b; stroke: #b3c421; stroke-width: 1; }
.rb-ball path { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; }
@keyframes rb-bounce {
  0%   { transform: translateY(0); animation-timing-function: cubic-bezier(.2,.75,.4,1); }
  50%  { transform: translateY(-46px) rotate(180deg); animation-timing-function: cubic-bezier(.6,0,.8,.25); }
  100% { transform: translateY(0) rotate(360deg); }
}
@keyframes rb-hit {
  0%   { transform: translateY(3px) scaleY(.9); }
  12%  { transform: translateY(0) scaleY(1); }
  100% { transform: translateY(3px) scaleY(.9); }
}
}
@keyframes rb-shadow {
  0%, 100% { transform: scaleX(1); opacity: .2; }
  50% { transform: scaleX(.6); opacity: .08; }
}
.loader { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 0; }
.hero .ball { display: flex; justify-content: center; margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { .rb-shadow, .rb-racquet, .rb-ball { animation: none; } }

textarea { font: inherit; }
.menuwrap { display: flex; align-items: center; gap: 8px; }
.gear.helpbtn { font-weight: 700; font-size: 1.05rem; }
.helpsec { border-top: 1px solid var(--line); padding: 8px 0; }
.helpsec:first-child { border-top: 0; }
.helpsec summary { cursor: pointer; }
