:root {
  /* Near-black, but cooled slightly so the surfaces are not dead flat */
  --bg: #08090d;
  --panel: #14161c;
  --panel-2: #1b1e26;
  --line: #262a33;
  --line-soft: #1d2028;
  --ink: #f4f5f7;
  --dim: #8b9199;
  --dimmer: #5c626b;

  /* Lime is the app's own colour and stays the primary action everywhere. */
  --lime: #ccff4d;
  --lime-ink: #08090d;

  /* Each sport gets an identity, so a glance tells you which game it is. */
  --padel: #5aa9ff;
  --padel-tint: rgba(90, 169, 255, .09);
  --padel-edge: rgba(90, 169, 255, .34);
  --pickle: #ccff4d;
  --pickle-tint: rgba(204, 255, 77, .06);
  --pickle-edge: rgba(204, 255, 77, .3);

  /* Money reads gold, availability reads teal — both distinct from actions. */
  --gold: #ffc95c;
  --gold-tint: rgba(255, 201, 92, .09);
  --teal: #4fd6c0;
  --amber: #ffc247;
  --red: #ff6f61;
  --violet: #a78bfa;

  --r: 18px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }   /* Safari inflates text in landscape otherwise */

/*
 * A carbon weave under everything, with a lime cast through it.
 *
 * On a fixed pseudo-element rather than a background on body: iOS handles
 * background-attachment: fixed badly, and this way the texture stays put while
 * the page scrolls over it. Kept deliberately faint — the diagonals are two
 * hundredths of white, which reads as grain rather than pattern and does not
 * fight anything laid on top.
 */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-color: var(--bg);
  background-image:
    /* the twill: crossed fine diagonals, one set stronger than the other */
    repeating-linear-gradient(45deg,  rgba(255,255,255,.022) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.014) 0 1px, transparent 1px 5px),
    /* a coarser lime thread every so often, so it is not merely grey */
    repeating-linear-gradient(45deg,  rgba(204,255,77,.02) 0 1px, transparent 1px 22px),
    /* and the glows that give it depth */
    radial-gradient(1100px 620px at 8% -8%, rgba(204,255,77,.07), transparent 62%),
    radial-gradient(900px 620px at 105% 4%, rgba(90,169,255,.075), transparent 60%),
    radial-gradient(760px 520px at 50% 118%, rgba(167,139,250,.055), transparent 62%);
  background-size: 7px 7px, 7px 7px, 31px 31px, cover, cover, cover;
}



/* Anything you tap: no 300ms delay, no double-tap zoom, no text selection or
   magnifier from a long press. All four are things iOS does by default that
   feel wrong in an app. */
button, .btn, .block, .spot, .pick, .ug-cell, .switch, .slot-chip, nav button {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: var(--lime); }
.hidden { display: none !important; }
.wrap {
  max-width: 620px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ---------- header ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 66%, rgba(8,9,13,.9) 86%, rgba(8,9,13,0));
  backdrop-filter: blur(10px);
  padding: calc(12px + env(safe-area-inset-top)) 0 10px;
}
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mark { font-size: 17px; font-weight: 800; letter-spacing: .28em; }
.mark span { color: var(--lime); }
h1 { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin: 14px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 0 16px; border-radius: 999px; font-size: 14px; color: var(--dim);
}
.chip b { color: var(--ink); font-weight: 600; }

.lede { color: var(--dim); font-size: 14px; line-height: 1.5; margin: 4px 0 18px; }
.lede.tight { margin: 0 0 12px; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .15em; color: var(--dimmer);
  margin: 26px 0 10px; font-weight: 700;
}

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.card.compact { padding: 14px 18px; }
.card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: transparent; }
.card.sport-padel { background: linear-gradient(var(--padel-tint), transparent 42%), var(--panel);
  border-color: var(--padel-edge); }
.card.sport-padel::before { background: var(--padel); opacity: .5; }
.card.sport-padel .venue { color: var(--padel); }
.card.sport-pickleball { background: linear-gradient(var(--pickle-tint), transparent 42%), var(--panel);
  border-color: var(--pickle-edge); }
.card.sport-pickleball::before { background: var(--pickle); opacity: .45; }
.card.sport-pickleball .venue { color: var(--pickle); opacity: .82; }
.card.confirmed::before { opacity: 1; }
.card.confirmed.sport-padel { border-color: rgba(90,169,255,.55); }
.card.confirmed.sport-pickleball { border-color: rgba(204,255,77,.5); }
.card.dead { opacity: .48; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-head { min-width: 0; }
.venue { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .11em; }
.when { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 5px 0 1px; }
.clock { font-size: 17px; font-weight: 600; margin-bottom: 5px; }
.meta { font-size: 14px; color: var(--dim); }
.meta b { color: var(--ink); font-weight: 600; }

.tag {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .11em;
  padding: 6px 11px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
}
.tag.padel { background: rgba(90,169,255,.18); color: var(--padel); }
.tag.pickleball { background: rgba(204,255,77,.14); color: var(--lime); }
.tag.locked { background: var(--lime); color: var(--lime-ink); }
.tag.booked { background: linear-gradient(135deg, var(--lime), var(--teal)); color: var(--lime-ink); }
.sport-padel .tag.locked { background: var(--padel); color: #05121f; }
.tag.dead { background: rgba(255,111,97,.16); color: var(--red); }

/* ---------- spots ---------- */
.spots { display: flex; gap: 8px; margin: 16px 0 6px; }
.spot {
  flex: 1; height: 58px; border-radius: 13px; background: var(--panel-2);
  border: 1px dashed var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; color: var(--dimmer);
}
.spot.filled { border-style: solid; color: var(--ink); }
.spot.filled.me { border-color: var(--lime); }
.spot .initials { font-weight: 700; font-size: 15px; }
.spot .initials.empty { opacity: .35; }
.spot .who { font-size: 10px; color: var(--dim); max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }

.bench { font-size: 13px; color: var(--dim); margin-top: 9px; }
.countdown { font-size: 13px; color: var(--amber); margin-top: 11px; }
.countdown.urgent { color: var(--red); }
.booker { font-size: 13px; color: var(--dim); margin-top: 10px; line-height: 1.5; }
.booker b { color: var(--lime); }

.booker-ask {
  margin-top: 14px; padding: 14px; border-radius: 14px;
  background: rgba(255,194,71,.07); border: 1px solid rgba(255,194,71,.28);
}
.booker-ask-q { font-size: 14px; font-weight: 600; color: var(--amber); margin-bottom: 10px; }
.booker-ask .row { margin-top: 0; }

/* ---------- buttons ---------- */
.row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; min-height: var(--tap); border-radius: 13px; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  transition: transform .08s ease, opacity .15s ease; padding: 0 14px;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.btn.subtle { background: transparent; color: var(--dim); }
.btn.danger { color: var(--red); }
.btn.icon { flex: 0 0 auto; width: var(--tap); padding: 0; color: var(--dim); font-size: 17px; }
.btn.small { flex: 0 0 auto; min-height: 44px; padding: 0 16px; font-size: 14px; border-radius: 11px; }
.btn.link { background: none; border: none; color: var(--dim); font-weight: 500; font-size: 14px;
  min-height: 40px; text-decoration: underline; }
.btn:disabled { opacity: .45; }
.btn.wide { width: 100%; margin-top: 4px; }

/* ---------- calendar ---------- */
.day { border-top: 1px solid var(--line-soft); padding: 16px 0 18px; }
.day:first-of-type { border-top: none; }
.day-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.day-name { font-size: 16px; font-weight: 700; }
.day-date { font-size: 13px; color: var(--dimmer); }
.day.today .day-name { color: var(--lime); }

.slot-chip {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 8px; color: var(--ink);
}
.slot-chip.sport-padel { border-color: var(--padel-edge); background: linear-gradient(var(--padel-tint), transparent), var(--panel); }
.slot-chip.sport-padel .slot-venue { color: var(--padel); }
.slot-chip.sport-pickleball { border-color: var(--pickle-edge); }
.slot-chip.confirmed { box-shadow: inset 3px 0 0 var(--lime); }
.slot-chip.sport-padel.confirmed { box-shadow: inset 3px 0 0 var(--padel); }
.slot-chip.mine { background: var(--panel-2); }
.slot-chip:active { transform: scale(.99); }
.slot-when { font-size: 14px; font-weight: 700; width: 68px; flex: 0 0 auto; }
.slot-body { flex: 1; min-width: 0; }
.slot-venue { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-meta { font-size: 12px; color: var(--dim); }
.slot-fill { flex: 0 0 auto; text-align: right; }
.fill-count { font-size: 13px; font-weight: 700; }
.pips { display: flex; gap: 3px; margin-top: 4px; justify-content: flex-end; }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.pip.on { background: var(--lime); }

.blocks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 4px; }
.block {
  height: 46px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; color: var(--dimmer);
  transition: background .12s ease;
}
.block-name { font-size: 11px; font-weight: 600; }
.block-count { font-size: 10px; opacity: .8; }
.block.on { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.block.hot { border-color: rgba(79,214,192,.5); color: var(--teal); background: rgba(79,214,192,.06); }
.block.hot.on { color: var(--lime-ink); background: var(--lime); border-color: var(--lime); }
.block-hours { font-size: 9px; opacity: .65; letter-spacing: .02em; }
.block:active { transform: scale(.96); }

/* ---------- the tab ---------- */
.balance {
  border-radius: var(--r); padding: 26px 20px; margin-bottom: 6px; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
}
.balance {
  background: linear-gradient(var(--gold-tint), transparent 55%), var(--panel);
}
.balance.up { border-color: rgba(255,201,92,.42); }
.balance.down { border-color: rgba(255,111,97,.4); }
.balance-label { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--dim); }
.balance-figure { font-size: 46px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.balance.up .balance-figure { color: var(--gold); }
.balance.down .balance-figure { color: var(--red); }
.balance.level .balance-figure { color: var(--dimmer); }

.amount { font-weight: 700; font-size: 15px; }
.amount.in { color: var(--gold); }
.amount.out { color: var(--red); }

.transfer {
  display: flex; align-items: center; gap: 8px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 15px;
}
.transfer:last-child { border-bottom: none; }
.t-from, .t-to { font-weight: 600; }
.t-arrow { color: var(--dimmer); }
.t-amount { margin-left: auto; font-weight: 700; color: var(--gold); }

.ledger-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.ledger-row:last-child { border-bottom: none; }
.ledger-what { font-size: 14px; font-weight: 600; }
.ledger-who { font-size: 12px; color: var(--dim); }
.ledger-amount { font-weight: 700; font-size: 15px; margin-left: auto; }
.ledger-amount.in { color: var(--gold); }
.ledger-amount.out { color: var(--red); }

/* ---------- people ---------- */
.person { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.person:first-child { padding-top: 2px; }
.person:last-child { border-bottom: none; padding-bottom: 2px; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  border: 1px solid var(--line); flex: 0 0 auto;
}
.grow { flex: 1; min-width: 0; }
.person .name { font-weight: 600; }
.person .name .you { color: var(--dimmer); font-weight: 400; }
.person .sub { font-size: 12px; color: var(--dim); }
.score { font-size: 13px; font-weight: 700; }
.score.good { color: var(--lime); }
.score.mid { color: var(--amber); }
.score.bad { color: var(--red); }
.score.new { color: var(--dimmer); font-weight: 500; }

/* ---------- tabs ---------- */
/* The sheet sits above the tab bar (z-index 41 against 30) and is anchored to the
   bottom, so the bar is covered whenever one is open — including when the
   keyboard pushes things about. No need to move it. */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(10,11,13,.94); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  /* one shorthand: a longhand before it was being wiped, losing the landscape
     insets. max() not addition — adding 9px to the home-indicator inset stacks
     padding on space iOS has already reserved, and the bar floats. */
  padding:
    9px
    env(safe-area-inset-right)
    max(9px, env(safe-area-inset-bottom))
    env(safe-area-inset-left);
  display: flex;
}
nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: 10px; color: var(--dimmer); letter-spacing: .02em; text-transform: uppercase;
  padding: 4px 2px; font-weight: 700; position: relative; min-height: 48px;
  white-space: nowrap;
}
nav button.on { color: var(--lime); }
nav .glyph { display: flex; align-items: center; justify-content: center; height: 22px; }
/*
 * The home-indicator inset only exists in the installed app. Safari's own
 * toolbar already occupies that space, so applying the inset there lifts the
 * bar off the bottom of the screen and leaves a gap beneath it.
 */
/* The body needs room for the bar plus whatever the device reserves below it.
   Harmless in a browser, where the inset is zero. */
body { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }

/* ---------- add to home screen ---------- */
.install {
  background: linear-gradient(rgba(204,255,77,.1), transparent 60%), var(--panel);
  border: 1px solid rgba(204,255,77,.34); border-radius: var(--r);
  padding: 15px 17px; margin-bottom: 18px; position: relative;
}
.install-title { font-size: 15px; font-weight: 700; color: var(--lime); margin-bottom: 5px; }
.install p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--dim); }
.install b { color: var(--ink); }
.install-close {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px;
  color: var(--dimmer); font-size: 15px; display: flex; align-items: center; justify-content: center;
}

.badge {
  position: absolute; top: 2px; right: 50%; margin-right: -20px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.badge.owe { background: var(--red); }

/* ---------- forms ---------- */
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], select {
  width: 100%; min-height: var(--tap); background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; padding: 0 15px; outline: none;
}
input:focus, select:focus { border-color: var(--lime); }
label.field { display: block; margin-bottom: 13px; }
label.field span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.toggle:last-of-type { border-bottom: none; }
.toggle .sub { font-size: 12px; color: var(--dim); font-weight: 400; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; flex: 0 0 auto; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s; }
.switch.on { background: var(--lime); border-color: var(--lime); }
.switch.on::after { transform: translateX(20px); background: var(--lime-ink); }

/* ---------- sheet, toast, empty ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.62); z-index: 40; display: none; }
.sheet-back.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88vh; max-height: 88dvh;      /* dvh accounts for Safari's toolbars */
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--panel); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line);
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .24s cubic-bezier(.32,.72,0,1);
}
.sheet.open { transform: translateY(0); }
.sheet h2 { margin: 0 0 4px; font-size: 21px; }
.sheet .hint { color: var(--dim); font-size: 14px; margin: 0 0 18px; line-height: 1.5; }
.grabber { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: -8px auto 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); z-index: 60; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 12px 20px; border-radius: 999px; transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 48px 20px 32px; }
.empty .big { font-size: 34px; margin-bottom: 12px; color: var(--dimmer); }
.empty-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty-sub { font-size: 14px; color: var(--dim); line-height: 1.5; }

/* ---------- sign in ---------- */
.signin { max-width: 380px; margin: 13vh auto 0; padding: 0 22px; text-align: center; }
.signin .mark { font-size: 23px; margin-bottom: 12px; }
.tagline { color: var(--dim); margin: 0 0 28px; }
.signin input { text-align: center; margin-bottom: 12px; }
.code-input { font-size: 30px; font-weight: 700; letter-spacing: .34em; text-indent: .34em; height: 62px; }
.note { font-size: 13px; color: var(--dim); line-height: 1.5; margin: 14px 0; }
.note.dim { color: var(--dimmer); font-size: 12px; }
.note.warn { color: var(--amber); }
.note b { color: var(--ink); }

/* ---------- waitlist ---------- */
.waitlist { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.waitlist-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--dimmer); font-weight: 700; margin-bottom: 8px;
}
.waitlist-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 14px; }
.waitlist-row.me .wl-name { color: var(--lime); font-weight: 600; }
.wl-pos {
  width: 20px; height: 20px; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--dim); flex: 0 0 auto;
}
.waitlist-row.me .wl-pos { border-color: var(--lime); color: var(--lime); }

.link-action {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; margin-top: 10px;
  font-size: 14px; font-weight: 600; color: var(--dim); text-decoration: underline;
  text-underline-offset: 3px;
}
.split-preview {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; font-size: 14px; color: var(--dim); margin: 4px 0 16px;
}
.split-preview b { color: var(--ink); font-size: 16px; }

/* ---------- narrow phones ---------- */
@media (max-width: 380px) {
  .wrap { padding: 0 13px; }
  h1 { font-size: 24px; }
  .when { font-size: 22px; }
  .balance-figure { font-size: 40px; }
  .btn { font-size: 14px; padding: 0 10px; }
  .booker-ask .row { flex-direction: column; }
  .booker-ask .btn { width: 100%; }
  .slot-when { width: 60px; font-size: 13px; }
  .block-name { font-size: 10px; }
}

/* ---------- laptops and up: a left rail, and two columns ---------- */
@media (min-width: 900px) {
  /* The offset lives on #app, never on body. The sign-in screen sits OUTSIDE
     #app, so it is structurally impossible for the rail to shove it sideways —
     which it did, twice, when this was a body rule. Do not move it back. */
  body { padding-bottom: 0; }
  #app { padding-left: 232px; }

  nav {
    top: 0; bottom: 0; right: auto; width: 232px;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: none; border-right: 1px solid var(--line);
    padding: 90px 14px 20px; background: rgba(10,11,13,.96);
  }
  nav button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 14px;
    padding: 13px 14px; border-radius: 12px; font-size: 13px; width: 100%;
  }
  nav button.on { background: var(--panel); }
  .badge { position: static; margin: 0 0 0 auto; }

  header { padding-top: 26px; }
  .head { justify-content: flex-end; }
  .head .mark { display: none; }
  nav::before {
    content: 'FOURTH';
    position: absolute; top: 30px; left: 28px;
    font-size: 16px; font-weight: 800; letter-spacing: .28em; color: var(--ink);
  }

  /* Fluid, not capped. A fixed max-width leaves a third of a wide screen doing
     nothing; the column count is what keeps a line of text readable, so let the
     container fill and add columns as there is room for them. */
  .wrap { max-width: none; padding: 0 34px; }
  h1 { font-size: 32px; }

  /* auto-fit, not a fixed count: with a fixed grid two cards sit in two of four
     tracks and the rest of the row is dead space. auto-fit drops the empty
     tracks so whatever is there stretches to fill the width. */
  #view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 0 22px; align-items: start;
  }
  /* a section owns the full width and lays its own cards out inside it, so a
     section of two stretches to fill rather than leaving half a row empty */
  #view > .section { grid-column: 1 / -1; }
  .section-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 0 22px; align-items: start;
  }
  /* auto-fill keeps the empty tracks, so one item stays its natural size instead
     of stretching across the whole screen */
  .section-grid.tight { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  #view.view-calendar { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }
  #view.view-crew { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
  #view.view-tab { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
  #view > .section-title,
  #view > .lede,
  #view > .explainer,
  #view > .empty,
  #view > .balance,
  #view > .btn { grid-column: 1 / -1; }
  #view > .btn.wide { max-width: 340px; margin-left: auto; margin-right: auto; }

  /* the balance is the headline; everything under it flows with the columns */
  #view > .balance, #view > .strip { grid-column: 1 / -1; }

  .day { padding-top: 0; border-top: none; }
  .day + .day { border-top: none; }
  .day-head { margin-top: 6px; }

  /* a bottom sheet makes no sense with a mouse — centre it */
  .sheet {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -46%) scale(.97); opacity: 0;
    width: min(460px, 92vw); border-radius: 20px; border: 1px solid var(--line);
    max-height: 84vh; transition: opacity .18s ease, transform .18s ease;
    padding: 26px 26px 28px;
  }
  .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .grabber { display: none; }
  .toast { bottom: 32px; left: calc(50% + 116px); }
}

/* The balance figure should grow with the room it has rather than float in it. */
@media (min-width: 1240px) {
  .balance { padding: 34px 20px; }
  .balance-figure { font-size: 58px; }
  .strip { grid-template-columns: repeat(3, minmax(0, 240px)); }
}

/* ---------- explainers ---------- */
.explainer {
  background: linear-gradient(rgba(90,169,255,.08), transparent 60%), var(--panel);
  border: 1px solid rgba(90,169,255,.26);
  border-radius: var(--r); padding: 16px 18px; margin-bottom: 20px;
}
.explainer.amber {
  background: linear-gradient(rgba(255,201,92,.09), transparent 60%), var(--panel);
  border-color: rgba(255,201,92,.3);
}
.explainer-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.explainer.amber .explainer-title { color: var(--gold); }
.explainer p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.55; color: var(--dim); }
.explainer p:last-child { margin-bottom: 0; }
.explainer strong { color: var(--ink); }

/* ---------- who to split with ---------- */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pick {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 7px 14px 7px 7px;
  border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--dim); font-size: 14px;
}
.pick-av {
  width: 26px; height: 26px; border-radius: 50%; background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: 1px solid var(--line);
}
.pick.on { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); font-weight: 600; }
.pick.on .pick-av { background: rgba(0,0,0,.14); border-color: transparent; color: var(--lime-ink); }

/* ===================================================================
   Second design pass — structure, not just colour
   =================================================================== */

/* Where the week stands, before any of the detail */
.strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px;
}
.stat {
  background: linear-gradient(160deg, rgba(255,255,255,.035), transparent 70%), var(--panel);
  border: 1px solid var(--line); border-radius: 15px; padding: 15px 14px;
}
.stat-n { font-size: 27px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.stat-l { font-size: 11px; color: var(--dim); margin-top: 4px; letter-spacing: .02em; }
.stat.good .stat-n { color: var(--lime); }
.stat.warn .stat-n { color: var(--amber); }
.stat.money { cursor: pointer; }
.stat.money .stat-n { color: var(--gold); font-size: 23px; }
.stat.money:active { transform: scale(.98); }

/* Cards arrive rather than appear — but only when a view is first opened.
   The screen is rebuilt after every action and on a timer, and replaying this
   each time reads as a twitch rather than a flourish. */
#view.first-paint > .card,
#view.first-paint > .section > .section-grid > .card,
#view.first-paint > .panel,
#view.first-paint > .day,
#view.first-paint > .strip > .stat {
  animation: rise .26s cubic-bezier(.22,.8,.28,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #view.first-paint > * { animation: none !important; } }

/* A header band gives each card a spine, and says the sport without a word */
.card { padding-top: 0; }
.card .card-top {
  padding: 16px 18px 14px; margin: 0 -18px 0;
  border-bottom: 1px solid var(--line-soft);
}
.card.sport-padel .card-top {
  background: linear-gradient(180deg, rgba(90,169,255,.13), rgba(90,169,255,.02));
}
.card.sport-pickleball .card-top {
  background: linear-gradient(180deg, rgba(204,255,77,.1), rgba(204,255,77,.015));
}
.card > *:not(.card-top) { margin-left: 0; margin-right: 0; }
.card .spots { margin-top: 16px; }
.card.compact .card-top { border-bottom: none; }

/* The vote */
.vote {
  margin-top: 14px; padding: 14px; border-radius: 14px;
  background: rgba(167,139,250,.07); border: 1px solid rgba(167,139,250,.3);
}
.vote-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 14px; font-weight: 700; color: var(--violet); margin-bottom: 10px;
}
.vote-count { font-size: 11px; font-weight: 600; color: var(--dim); letter-spacing: .04em; }
.vote-options { display: flex; flex-direction: column; gap: 7px; }
.vote-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: 11px; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line);
}
.vote-opt.current { border-color: rgba(167,139,250,.45); }
.vote-opt.mine { background: rgba(167,139,250,.16); border-color: var(--violet); }
.vote-opt:active { transform: scale(.99); }
.vo-body { flex: 1; min-width: 0; }
.vo-name { display: block; font-size: 14px; font-weight: 600; }
.vo-meta { display: block; font-size: 12px; color: var(--dim); }
.vo-votes { color: var(--violet); font-size: 10px; letter-spacing: 2px; }

/* The standing week */
.usual-grid {
  display: grid; grid-template-columns: 46px repeat(4, 1fr); gap: 6px; margin-bottom: 18px;
}
.ug-col, .ug-row {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--dimmer); font-weight: 700; display: flex; align-items: center;
}
.ug-col { justify-content: center; }
.ug-cell {
  height: 44px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); transition: background .12s;
}
.ug-cell.on { background: var(--lime); border-color: var(--lime); }
.ug-cell:active { transform: scale(.94); }

/* A spent nudge should look spent, and stay unclickable until it is not */
.btn.spent { opacity: .4; cursor: default; }
.btn.spent:active { transform: none; }
.btn.small.spent { font-size: 12px; }
.btn:disabled { opacity: .4; }

/* The tab bar gets a proper active pill */
nav button::after {
  content: ''; position: absolute; inset: -2px -6px auto; height: 34px;
  border-radius: 11px; background: transparent; z-index: -1; transition: background .16s;
}
nav button.on::after { background: rgba(204,255,77,.1); }

@media (min-width: 900px) {
  nav button::after { display: none; }
  .strip { grid-template-columns: repeat(3, minmax(0, 180px)); }
  #view > .strip { grid-column: 1 / -1; }
}

.code-inline {
  display: inline-block; margin-left: 6px; padding: 2px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 17px; letter-spacing: .12em; color: var(--lime);
}

/* ---------- crew, one card each ---------- */
.person-card { padding: 0 18px 14px; }
.person-card .card-top { display: none; }
.person-card .person { border-bottom: none; padding: 16px 0 10px; }
.person-card.quiet { border-color: rgba(255,201,92,.3); }
.person-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line-soft); padding-top: 12px;
}
.person-foot .marked { font-size: 12px; color: var(--dim); }
.person-foot .marked.none { color: var(--gold); }
.person-foot .btn.small:disabled { opacity: .4; }

/* A section and its card as one unit, so wide screens lay them out side by side */
.panel > .section-title { margin-top: 0; }
@media (min-width: 900px) { #view > .panel { display: block; } }

/* When few cards share a wide row they stretch, so the contents must too. */
@media (min-width: 900px) {
  .card .spots { max-width: 100%; }
  .spot { min-width: 0; }
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 760px; }
}

/* ===================================================================
   Phones. A card that fills the whole screen tells you there is one
   game on; a card and a half tells you to keep scrolling. Tighten the
   vertical rhythm so the second one peeks.
   =================================================================== */
@media (max-width: 899px) {
  header { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 8px; }
  h1 { font-size: 25px; margin: 10px 0 2px; }
  .mark { font-size: 16px; letter-spacing: .24em; }

  .strip { gap: 8px; margin-bottom: 18px; }
  .stat { padding: 13px 12px; border-radius: 14px; }
  .stat-n { font-size: 24px; }
  .stat.money .stat-n { font-size: 21px; }
  .stat-l { font-size: 10.5px; }

  .section-title { margin: 20px 0 8px; }
  .card { padding: 0 16px 16px; margin-bottom: 12px; }
  .card .card-top { padding: 14px 16px 12px; margin: 0 -16px; }
  .when { font-size: 23px; margin: 4px 0 1px; }
  .clock { font-size: 16px; margin-bottom: 4px; }
  .meta { font-size: 13.5px; }
  .venue { font-size: 11.5px; }

  .spots { gap: 7px; margin: 12px 0 4px; }
  .spot { height: 52px; border-radius: 12px; }
  .waitlist { margin-top: 10px; padding-top: 10px; }
  .waitlist-row { padding: 3px 0; }
  .booker, .bench { margin-top: 8px; }
  .countdown { margin-top: 9px; font-size: 12.5px; }
  .row { gap: 8px; margin-top: 12px; }
  .booker-ask, .vote { margin-top: 12px; padding: 12px; }
  .vote-opt { padding: 10px 12px; }

  .day { padding: 14px 0 16px; }
  .lede { margin: 4px 0 14px; }
  .explainer { padding: 14px 16px; margin-bottom: 16px; }

  /* The bottom bar should feel like part of the phone, not a strip of website */
  nav { padding-top: 7px; }
  nav button { font-size: 9.5px; gap: 4px; }
  nav .glyph { height: 21px; }
}

/* The very small ones — SE and mini */
@media (max-width: 380px) {
  .stat-n { font-size: 22px; }
  .stat.money .stat-n { font-size: 18px; }
  .spot .who { font-size: 9.5px; }
  .tag { padding: 5px 9px; font-size: 9.5px; }
}

/* ---------- the invite link ---------- */
.invite {
  background: linear-gradient(rgba(204,255,77,.07), transparent 60%), var(--panel-2);
  border: 1px solid rgba(204,255,77,.3); border-radius: 14px;
  padding: 14px; margin-bottom: 18px;
}
.invite-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--lime); font-weight: 700; margin-bottom: 8px;
}
.invite-url {
  font-size: 13px; color: var(--ink); word-break: break-all; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  -webkit-user-select: all; user-select: all;
}
.invite .row { margin-top: 0; }
#signin input + input { margin-top: 0; }

.share-text {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 16px; white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.55; color: var(--ink);
  -webkit-user-select: text; user-select: text;
}

/* Dragged sheets follow the finger without the CSS transition fighting it */
.sheet.dragging { transition: none; }
.grabber { cursor: grab; }
.sheet::before {
  /* a taller invisible grab area than the little bar suggests */
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 44px;
}
