:root {
  color-scheme: light;
  --ink: #17313c;
  --muted: #66777d;
  --teal: #0b6b63;
  --teal-dark: #07554f;
  --mint: #dff3ed;
  --lime: #d7ee72;
  --sand: #f7f4eb;
  --paper: rgba(255, 255, 255, 0.94);
  --line: #dce6e3;
  --danger: #b8463c;
  --shadow: 0 18px 50px rgba(27, 60, 62, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* Keep semantic hidden states reliable even when a component sets display. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(215, 238, 114, 0.22), transparent 34%),
    linear-gradient(160deg, #f8f6ef 0%, #edf6f2 58%, #f8f5ec 100%);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(11, 107, 99, 0.25);
  outline-offset: 2px;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
}
.page-glow-a { top: -120px; right: -80px; background: #b9e1d7; }
.page-glow-b { bottom: -130px; left: -100px; background: #e9dc9e; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(440px, 100%);
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 20px;
  background: var(--teal);
  font-size: 30px;
  box-shadow: 0 12px 28px rgba(11, 107, 99, 0.25);
}
.brand-mark.small { width: 48px; height: 48px; margin: 0; border-radius: 15px; font-size: 23px; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; }
h2 { margin-bottom: 8px; font-size: clamp(23px, 3vw, 31px); letter-spacing: -0.025em; }
h3 { margin-bottom: 6px; }
.gate-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }

label, .soft-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(11, 107, 99, 0.08); outline: none; }
textarea { resize: vertical; line-height: 1.5; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.member-form { display: grid; gap: 10px; margin-top: 20px; }
.member-form label { margin: 0; }
.member-form .primary-button { margin-top: 4px; }
.gate-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }

.primary-button, .secondary-button, .join-button {
  border: 0;
  border-radius: 13px;
  padding: 12px 18px;
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.primary-button { background: var(--teal); color: white; box-shadow: 0 8px 18px rgba(11, 107, 99, 0.2); }
.primary-button:hover, .join-button:hover { transform: translateY(-1px); background: var(--teal-dark); }
.secondary-button { background: var(--mint); color: var(--teal-dark); }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 10px 12px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger) !important; font-size: 13px; }

.app-shell { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 24px; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup h1 { margin: 0; font-size: 27px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.8);
  color: var(--ink);
  font-size: 19px;
}
.icon-button:hover { background: white; border-color: #bacdc8; }

.welcome-strip {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 38px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  background: rgba(255,255,255,0.68);
  box-shadow: 0 12px 30px rgba(32, 70, 68, 0.07);
}
.name-control { display: flex; align-items: center; gap: 10px; }
.name-control input { width: min(320px, 58vw); padding: 9px 11px; }
.save-state { color: var(--muted); font-size: 12px; white-space: nowrap; }
.member-identity { display: flex; align-items: center; gap: 12px; }
.member-identity strong { font-size: 20px; }
.live-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #28a36a; box-shadow: 0 0 0 5px rgba(40,163,106,0.1); }

.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.section-heading > p { max-width: 300px; margin-bottom: 6px; color: var(--muted); font-size: 13px; line-height: 1.55; text-align: right; }

.schedule { display: grid; gap: 26px; }
.day-group { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: start; }
.day-label { position: sticky; top: 18px; padding: 14px 10px; }
.day-label strong { display: block; font-size: 19px; }
.day-label span { color: var(--muted); font-size: 13px; }
.slot-list { display: grid; gap: 12px; }
.slot-card {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 19px 20px;
  border: 1px solid rgba(255,255,255,0.88);
  border-radius: 21px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(25, 65, 62, 0.065);
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.slot-card:hover { transform: translateY(-2px); border-color: #c2d9d3; }
.slot-time { font-size: 20px; font-weight: 850; letter-spacing: -0.02em; }
.venue-line { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.venue-pill { padding: 4px 8px; border-radius: 999px; background: var(--mint); color: var(--teal-dark); font-size: 11px; font-weight: 900; letter-spacing: 0.06em; }
.court-name { font-weight: 750; }
.slot-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.attendees { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.attendee-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px 5px 6px; border-radius: 999px; background: #f1f5f2; color: #3c555a; font-size: 12px; }
.attendee-chip.mine { background: #e4f3b2; color: #3f560e; }
.child-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 1px; border-radius: 999px; background: #fff1c7; font-size: 13px; }
.avatar { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--teal); color: white; font-size: 10px; font-weight: 800; }
.no-attendees { color: #8a989c; font-size: 12px; }
.join-area { min-width: 150px; text-align: right; }
.attendance-actions { display: grid; gap: 7px; }
.join-button { min-width: 112px; background: var(--teal); color: white; }
.join-button.joined { background: var(--lime); color: #304508; box-shadow: none; }
.join-button.joined:hover { background: #cae457; }
.join-button:disabled { cursor: not-allowed; background: #cbd6d2; transform: none; }
.child-button { min-width: 112px; border: 1px solid #d8c98c; border-radius: 11px; padding: 8px 10px; background: #fffaf0; color: #765f13; font-weight: 750; }
.child-button:hover { background: #fff1c7; }
.child-button.selected { border-color: #e4b84f; background: #ffe59b; color: #684d06; }
.child-button:disabled { cursor: not-allowed; border-color: var(--line); background: #eef2f0; color: #9aa6a3; }
.slot-count { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }

.empty-state { padding: 54px 20px; text-align: center; border: 1px dashed #b9cdc7; border-radius: 24px; background: rgba(255,255,255,0.58); }
.empty-state span { font-size: 38px; }
.empty-state h3 { margin-top: 13px; }
.empty-state p { color: var(--muted); }
.admin-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: 90vh;
  overflow: auto;
  border: 0;
  border-radius: 26px;
  padding: 26px;
  color: var(--ink);
  background: #fbfcf9;
  box-shadow: 0 25px 80px rgba(15, 49, 49, 0.28);
}
.admin-dialog::backdrop { background: rgba(13, 35, 39, 0.48); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 22px; }
.dialog-header-actions { display: flex; align-items: center; gap: 10px; }
.admin-auth-row, .inline-admin-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.admin-auth-row { margin-bottom: 22px; }
.section-note { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.admin-members { display: grid; gap: 8px; margin-top: 12px; }
.admin-member { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.admin-member strong { display: block; font-size: 14px; }
.member-status { display: inline-flex; margin-top: 4px; padding: 3px 7px; border-radius: 999px; background: #edf2ef; color: var(--muted); font-size: 11px; }
.member-status.claimed { background: var(--mint); color: var(--teal-dark); }
.slot-form { margin: 20px 0 28px; padding: 19px; border-radius: 18px; background: #f0f6f2; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slot-form label { margin-bottom: 12px; }
.field-help { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-section { margin-top: 8px; }
.admin-slots { display: grid; gap: 8px; }
.admin-slot { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.admin-slot strong { display: block; font-size: 14px; }
.admin-slot span { color: var(--muted); font-size: 12px; }
.admin-slot-actions { display: flex; gap: 6px; }
.mini-button { border: 1px solid var(--line); border-radius: 9px; background: white; padding: 6px 9px; font-size: 12px; }
.mini-button.danger { color: var(--danger); }
.import-panel { margin-top: 22px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.import-panel summary { cursor: pointer; font-weight: 800; }
.import-panel p { margin: 10px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.import-panel textarea { margin-bottom: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 16px; border-radius: 12px; background: #17313c; color: white; box-shadow: var(--shadow); font-size: 13px; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 22px, 620px); padding-top: 16px; }
  .welcome-strip, .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .day-group { grid-template-columns: 1fr; gap: 7px; }
  .day-label { position: static; padding: 4px 6px; }
  .day-label strong, .day-label span { display: inline; margin-right: 6px; }
  .slot-card { grid-template-columns: 1fr auto; gap: 13px; padding: 16px; }
  .slot-time { grid-column: 1 / -1; padding-bottom: 11px; border-bottom: 1px solid #edf1ef; }
  .join-area { min-width: 130px; }
  .join-button { min-width: 102px; padding-inline: 12px; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 460px) {
  .gate-card { padding: 28px 22px; border-radius: 24px; }
  .input-row { grid-template-columns: 1fr; }
  .welcome-strip { margin-bottom: 28px; }
  .name-control { align-items: stretch; flex-direction: column; gap: 5px; }
  .name-control input { width: 100%; }
  .slot-card { grid-template-columns: 1fr; }
  .join-area { display: flex; align-items: center; gap: 9px; text-align: left; }
  .attendance-actions { display: flex; flex-wrap: wrap; gap: 7px; }
  .slot-count { margin: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-auth-row, .inline-admin-form { grid-template-columns: 1fr; }
  .admin-member { grid-template-columns: 1fr; }
}
