:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #162033;
    --muted: #6d7890;
    --border: #dfe5ef;
    --accent: #4f63e9;
    --accent-dark: #3448c5;
    --season-a: #354bbf;
    --season-b: #6d5ce7;
    --success: #138b66;
    --warning: #c76b18;
    --danger: #c84351;
    --shadow: 0 16px 45px rgba(31, 48, 83, 0.1);
  }

  * { box-sizing: border-box; }
  [hidden] { display: none !important; }

  html {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior-y: auto;
    color: var(--text);
    background:
      radial-gradient(circle at 90% 0, rgba(79, 99, 233, 0.12), transparent 28rem),
      var(--bg);
    font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  }

  button { font: inherit; }
  .page-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 28px; }

  .hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
  }

  .hero-actions { display: flex; align-items: center; gap: 10px; }
  .copy-button { border-color: transparent; color: white; background: var(--accent); }
  .copy-button:hover:not(:disabled) { border-color: transparent; color: white; background: var(--accent-dark); }

  .eyebrow, .section-label {
    display: block;
    margin: 0 0 7px;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.16em;
  }

  h1, h2, p { margin-top: 0; }
  h1 { margin-bottom: 8px; font-size: clamp(1.85rem, 4vw, 2.75rem); }
  h2 { margin-bottom: 0; }
  .hero-copy { margin-bottom: 0; color: var(--muted); }

  button {
    height: 42px;
    padding: 0 17px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    font-weight: 750;
    box-shadow: 0 6px 18px rgba(31, 48, 83, 0.06);
  }

  button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
  button:disabled { cursor: not-allowed; opacity: 0.55; }

  .status, .warning-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.8);
  }

  .status-ready { display: none; }
  .status-error { border-color: rgba(200, 67, 81, 0.35); color: var(--danger); }
  .warning-box { border-color: rgba(199, 107, 24, 0.35); color: #8f4a0d; background: #fff8ef; }

  .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  @keyframes spin { to { transform: rotate(360deg); } }
  main { display: grid; gap: 20px; }

  .event-heading, .section-heading, .capacity-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
  }

  .event-meta {
    display: grid;
    justify-items: end;
    gap: 7px;
    font-size: 0.82rem;
  }

  .event-heading {
    padding: 22px 24px;
    border-radius: 17px;
    color: white;
    background: linear-gradient(125deg, #202f75, #5064e5 62%, #7967ed);
    box-shadow: var(--shadow);
  }

  .event-heading .section-label { color: rgba(255, 255, 255, 0.68); }
  .event-heading h2 { font-size: clamp(1.55rem, 4vw, 2.2rem); }
  .dropin-fee-pill {
    padding: 9px 13px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 11px;
    color: #202f75;
    background: #fff3b8;
    font-size: 1rem;
    font-weight: 900;
    box-shadow: 0 5px 14px rgba(25, 34, 84, 0.2);
  }
  .event-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 24px rgba(31, 48, 83, 0.05);
  }
  .event-badge {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: var(--surface);
    font-size: 0.82rem;
    font-weight: 800;
  }
  .event-badge-highlight {
    padding: 9px 13px;
    border-color: #f0d466;
    color: #202f75;
    background: #fff3b8;
    font-size: 1rem;
    font-weight: 900;
    box-shadow: 0 5px 14px rgba(25, 34, 84, 0.2);
  }
  .attendance-pill, .count-pill {
    flex-shrink: 0;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 0.77rem;
    font-weight: 800;
  }
  .attendance-pill { color: white; background: rgba(255, 255, 255, 0.16); }
  .count-pill { color: var(--accent); background: rgba(79, 99, 233, 0.09); }

  .summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
  .summary-card, .capacity-panel, .member-section {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .summary-card { padding: 19px; }
  .summary-card > span { display: block; margin-bottom: 12px; color: var(--muted); font-size: 0.8rem; font-weight: 750; }
  .summary-card strong { display: block; margin-bottom: 7px; font-size: 1.9rem; font-variant-numeric: tabular-nums; }
  .summary-card small { color: var(--muted); }
  .highlight-card strong { color: var(--accent); }
  .remaining-card strong { color: var(--success); }

  .capacity-panel { padding: 18px 20px; }
  .capacity-heading { margin-bottom: 12px; font-size: 0.85rem; }
  .capacity-heading span { color: var(--muted); font-weight: 700; }
  .progress-track { height: 13px; overflow: hidden; border-radius: 999px; background: #e8ecf5; }
  .progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #806ce9); transition: width 0.35s ease; }

  .member-section { padding: 21px; }
  .section-heading { margin-bottom: 16px; }
  .section-heading h2 { font-size: 1.15rem; }
  .member-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }

  .member-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
    padding: 13px 14px;
    border-radius: 12px;
    font-weight: 750;
  }

  .season-member {
    color: white;
    background: linear-gradient(130deg, var(--season-a), var(--season-b));
    box-shadow: 0 9px 22px rgba(75, 71, 188, 0.2);
  }

  .dropin-member { border: 1px solid var(--border); color: var(--text); background: #f8faff; }
  .badge { flex-shrink: 0; padding: 4px 8px; border-radius: 999px; font-size: 0.67rem; font-weight: 850; }
  .leave-badge { color: #8e1e2b; background: #ffdce0; }
  .waitlist-badge { color: #93470b; background: #ffe7cc; }
  .empty-message { grid-column: 1 / -1; margin: 8px 0; color: var(--muted); text-align: center; }

  footer { display: flex; justify-content: space-between; gap: 16px; padding: 5px 3px; color: var(--muted); font-size: 0.75rem; }
  .site-credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 26px;
    padding: 22px 12px 6px;
    border-top: 1px solid var(--border);
    text-align: center;
  }
  .site-credit p { margin: 0; letter-spacing: 0.04em; }
  .site-credit strong { color: var(--accent); font-weight: 850; }

  @media (max-width: 900px) {
    .summary-grid, .member-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  @media (max-width: 560px) {
    .page-shell { width: calc(100% - 24px); padding-top: 25px; padding-bottom: 36px; }
    .hero { align-items: flex-start; flex-direction: column; }
    .hero-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .hero button { width: 100%; }
    .event-heading { align-items: flex-start; flex-direction: column; }
    .event-meta { justify-items: start; }
    .event-badges { justify-content: flex-start; }
    .summary-grid, .member-grid { grid-template-columns: 1fr; }
    footer { flex-direction: column; }
  }
