:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, light-dark(#f0f5fa, #182432));
  --surface: var(--tg-theme-secondary-bg-color, light-dark(#fff, #223244));
  --text: var(--tg-theme-text-color, light-dark(#182f49, #e8f0f8));
  --muted: var(--tg-theme-hint-color, light-dark(#61758a, #a4b5c6));
  --accent: var(--tg-theme-button-color, light-dark(#287bbd, #4299db));
  --button-text: var(--tg-theme-button-text-color, #fff);
  --link: var(--tg-theme-link-color, light-dark(#176fae, #75baf0));
  --line: color-mix(in srgb, var(--text) 13%, transparent);
  --selected: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --yes: light-dark(#267558, #7bd2af);
  --maybe: light-dark(#90611e, #edc376);
  --danger: var(--tg-theme-destructive-text-color, light-dark(#a33e43, #f59ba3));
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-inset: 8px;
  --utility: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select { font: inherit; color: inherit; }
button, summary, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled, fieldset:disabled button { cursor: default; opacity: .48; }
button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }
button { min-height: 44px; border: 0; transition: transform .12s cubic-bezier(.23, 1, .32, 1), opacity .12s; }
button:active:not(:disabled) { transform: scale(.97); }
.text-button:active:not(:disabled) { transform: none; opacity: .6; }
a { color: var(--link); }
p, h1, h2, h3 { margin: 0; }
h1, h2, h3, .brand { font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
h1 { font-size: clamp(27px, 7vw, 34px); font-weight: 750; line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 19px; font-weight: 700; line-height: 1.25; letter-spacing: -.018em; }
h3 { font-size: 15px; font-weight: 650; }
.app { max-width: 640px; margin: auto; padding: max(12px, env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px)); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; }
.brand { display: inline-flex; gap: 9px; align-items: center; font-size: 17px; font-weight: 750; letter-spacing: -.025em; color: var(--text); text-decoration: none; }
.stack-mark { display: flex; align-items: end; height: 19px; gap: 2px; }
.stack-mark i { display: block; width: 3px; height: 13px; border-radius: 2px; background: var(--accent); }
.stack-mark i:nth-child(2), .stack-mark i:nth-child(4) { height: 16px; }
.stack-mark i:nth-child(3) { height: 19px; }
.connection { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.connection::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.connection[data-state="live"] { color: var(--yes); }
.connection[data-state="offline"], .connection[data-state="connecting"] { color: var(--maybe); }
.caption, .muted { color: var(--muted); }
.caption { font-size: 12px; line-height: 1.5; }
.eyebrow { font-size: 11px; font-weight: 650; letter-spacing: .055em; text-transform: uppercase; color: var(--muted); }
.session-heading { padding: 15px 0 12px; }
.session-heading h1 { margin: 6px 0 8px; font-size: clamp(25px, 7vw, 31px); }
.session-heading > .muted { font-size: 12px; }
.section-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-top .caption { flex-shrink: 0; }
.group-section { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 15px 14px 10px; overflow: hidden; }
.group-section h2 { font-size: 16px; }
.overlap { font-size: 14px; margin: 8px 0 0; }
.overlap strong { font-variant-numeric: tabular-nums; }
.party { padding: 10px 0 0; font-size: 13px; color: var(--yes); }
.time-rail { display: flex; gap: 7px; overflow-x: auto; margin: 15px -16px 0; padding: 3px 16px 12px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.time-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 65px; min-height: 93px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--bg); scroll-snap-align: center; padding: 8px; }
.time-slot[aria-pressed="true"] { border-color: var(--accent); background: var(--selected); box-shadow: 0 0 0 1px var(--accent); }
.time-slot.is-past { opacity: .55; }
.slot-time { font: 12px var(--utility); letter-spacing: -.045em; }
.slot-in { font-size: 15px; font-weight: 650; color: var(--yes); }
.slot-maybe { font-size: 10px; color: var(--maybe); min-height: 15px; white-space: nowrap; }
.slot-filler { font-size: 10px; color: var(--muted); }
.slot-detail { border-bottom: 1px solid var(--line); padding: 0 0 13px; font-size: 12px; }
.slot-detail p + p { margin-top: 4px; }
.slot-detail strong { font-weight: 650; }
.slot-detail .slot-heading { font-size: 13px; margin-bottom: 7px; }
.slot-detail .yes { color: var(--yes); }
.slot-detail .maybe { color: var(--maybe); }
.group-details summary { cursor: pointer; font-weight: 650; font-size: 13px; padding: 13px 0 7px; }
.group-details summary span { font-weight: 400; }
.players { list-style: none; margin: 0; padding: 0; }
.player { display: flex; gap: 10px; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.player:last-child { border-bottom: 0; }
.player-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; flex: 1 1 36%; }
.player-answer { flex: 1 1 64%; text-align: right; font-size: 12px; }
.player-answer p + p { margin-top: 2px; }
.player-answer .yes { color: var(--yes); }
.player-answer .maybe { color: var(--maybe); }
.you { font-size: 11px; font-weight: 400; color: var(--muted); }
.group-footnote { margin-top: 8px; font-size: 11px; }
.editor { margin: 0; }
.saved-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.saved-status-row .text-button { min-height: 30px; flex-shrink: 0; }
.saved-status-row p { font-size: 11px; }
fieldset { padding: 0; border: 0; margin: 0; min-width: 0; }
.response-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 9px; }
.response-grid button { border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); padding: 11px 12px; font-size: 14px; font-weight: 600; text-align: center; }
.response-grid button[aria-pressed="true"] { border-color: var(--accent); background: var(--selected); box-shadow: 0 0 0 1px var(--accent); }
.time-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 41px; }
.time-toolbar > p { font-size: 12px; }
.time-toolbar > div { display: flex; gap: 14px; flex-shrink: 0; }
.text-button { background: transparent; color: var(--link); font-size: 12px; font-weight: 600; padding: 7px 0; }
.time-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.choice-time { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 58px; padding: 8px 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control); }
.choice-time[aria-pressed="true"] { background: var(--accent); color: var(--button-text); border-color: var(--accent); }
.choice-label { font: 600 15px var(--utility); letter-spacing: -.045em; }
.choice-count { font-size: 10px; color: var(--muted); line-height: 1.15; }
.choice-time[aria-pressed="true"] .choice-count { color: inherit; opacity: .85; }
.choice-mark { position: absolute; top: 2px; right: 4px; font-size: 10px; font-weight: 750; line-height: 1; }
.choice-time.is-maybe { background: color-mix(in srgb, var(--maybe) 14%, var(--surface)); border-color: var(--maybe); color: var(--text); }
.choice-time.is-maybe .choice-mark { color: var(--maybe); }
.choice-time.is-anchor { outline: 2px dashed var(--link); outline-offset: 2px; }
.choice-time.is-anchor .choice-mark { top: 2px; right: 3px; font-size: 11px; }
.choice-time.is-past { opacity: .5; }
.grid-note { margin: 8px 0 2px; font-size: 11px; }
.range-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.range-toolbar .text-button { flex-shrink: 0; font-size: 11px; min-height: 36px; }
.more-options { margin: 0; }
.more-options summary { min-height: 38px; display: list-item; cursor: pointer; padding: 9px 0; font-size: 12px; color: var(--link); }
.more-options summary span { font-size: 11px; }
.more-options[open] { padding-bottom: 9px; }
.response-label { display: block; font-size: 12px; margin-bottom: 6px; }
select { appearance: auto; border: 1px solid var(--line); border-radius: var(--radius-control); width: 100%; min-width: 0; min-height: 44px; padding: 9px 5px 9px 10px; background: var(--surface); color: var(--text); }
#response-note { margin-top: 8px; }
.answer-review { border-top: 1px solid var(--line); margin-top: 5px; padding-top: 12px; }
.answer-review > p + p { margin-top: 5px; }
.answer-review #draft-summary { font-size: 14px; font-weight: 550; }
.primary, .secondary { padding: 12px 16px; border-radius: var(--radius-control); font-weight: 650; text-align: center; }
.primary { color: var(--button-text); background: var(--accent); }
.secondary { background: var(--surface); color: var(--link); border: 1px solid var(--line); font-size: 13px; }
.save-dock { position: sticky; bottom: 0; z-index: 2; background: var(--bg); margin: 9px -2px -10px; padding: 9px 2px max(10px, env(safe-area-inset-bottom)); }
.save-dock .primary { display: block; width: 100%; }
.save-dock p { text-align: center; margin-top: 8px; font-size: 11px; }
.native-button .save-dock { position: static; padding-top: 0; }
.native-button #save { display: none; }
.notice { border: 1px solid var(--line); border-radius: var(--radius-control); padding: 12px; font-size: 13px; margin: 12px 0; background: var(--surface); }
#connection-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conflict { border-color: var(--maybe); }
.conflict p { margin-top: 6px; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.saved-view { margin-top: 2px; padding: 10px 13px; border-radius: var(--radius-control); background: var(--surface); border: 1px solid var(--line); }
.saved-top, .saved-bottom { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.saved-top h2 { font: 600 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; color: var(--yes); }
.saved-top .text-button, .saved-bottom .text-button { flex-shrink: 0; font-size: 11px; min-height: 36px; }
.saved-view > p { margin: 1px 0 6px; font-size: 13px; }
.saved-bottom .caption { font-size: 11px; }
.showing-results .group-section { margin-top: 16px; }
.waiting-summary { margin: 12px 0 4px; padding: 9px 10px; background: var(--bg); border-radius: var(--radius-inset); font-size: 12px; color: var(--muted); }
.reminder-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0; }
#reminder-status { margin: 8px 0; }
.start-lineups { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 12px; }
.start-lineups > h3 { margin-bottom: 4px; }
.start-lineups > .caption { font-size: 11px; margin-bottom: 10px; }
.lineup { padding: 12px 0; border-bottom: 1px solid var(--line); }
.lineup:last-child { border-bottom: 0; }
.lineup-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.lineup-time { margin: 0; font: 600 13px var(--utility); letter-spacing: -.04em; }
.lineup-heading .caption { font-size: 11px; }
.lineup-answer { display: grid; grid-template-columns: 61px minmax(0, 1fr); gap: 8px; margin-top: 5px; font-size: 12px; overflow-wrap: anywhere; }
.lineup-label { font-weight: 600; }
.lineup .yes { color: var(--yes); }
.lineup .maybe { color: var(--maybe); }
.lineup-unavailable { font-size: 11px; margin-top: 7px; }
.loading, .empty-state { padding: 65px 8px; text-align: center; }
.loading h1, .empty-state h1 { font-size: 25px; }
.loading p, .empty-state p { color: var(--muted); margin-top: 12px; }
.empty-state button { margin-top: 20px; }
.loading-mark { display: block; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; width: 30px; height: 30px; margin: 0 auto 20px; animation: spin 1s linear infinite; }
.demo-banner { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); font-size: 11px; margin-top: 7px; background: var(--surface); }
.demo-controls { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; }
.demo-controls button { width: 100%; margin: 10px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 360px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .time-toolbar > p { font-size: 11px; }
  .time-toolbar > div { gap: 10px; }
  .choice-label { font-size: 14px; }
  .choice-count { font-size: 9px; }
  .time-grid { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } button:active:not(:disabled) { transform: none; } }

.party-windows { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.party-windows h3 { font-size: 13px; }
.party-window { padding: 9px 0; border-bottom: 1px solid var(--line); }
.party-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.party-window strong { font: 600 13px var(--utility); letter-spacing: -.04em; }
.party-locked { flex-shrink: 0; font-size: 11px; font-weight: 600; color: var(--yes); }
.party-window p { margin-top: 3px; }
.party-windows > .caption { margin-top: 9px; font-size: 11px; }
