/* Campaign planner popup (campaigns.html).
   Overlay + glass panel come from glass-modals.css (.modal / .modal-content);
   phone full-screen comes from mobile-optimized.css. Everything inside the
   panel resets font + button appearance so page/global button rules can't
   bleed in. */

.cp-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  padding: 16px;
  box-sizing: border-box;
  /* The panel is sized to the viewport, so the overlay itself does not
     scroll. A second scrollbar here is what made the popup feel cramped. */
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.cp-modal[hidden] { display: none !important; }

.cp-panel {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  color: #fff;
}
.cp-panel *,
.cp-panel *::before,
.cp-panel *::after { box-sizing: border-box; }
.cp-panel * { font-family: inherit !important; }
.cp-panel button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  color: #fff;
  text-transform: none;
  letter-spacing: normal;
}

/* ---------- Header ---------- */
.cp-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 12px;
  padding-right: 52px;
  min-width: 0;
  flex: 0 0 auto;
}
.cp-panel .cp-title {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  flex: 1 1 auto;
  min-width: 0;
}
.cp-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cp-month-label {
  min-width: 156px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.cp-panel .cp-btn,
.cp-panel .cp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.cp-panel .cp-icon-btn { width: 38px; padding: 0; font-size: 18px; }
.cp-panel .cp-btn:active,
.cp-panel .cp-icon-btn:active,
.cp-panel .cp-tab:active { transform: scale(0.97); }
.cp-panel .cp-btn:hover,
.cp-panel .cp-icon-btn:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); }
.cp-panel .cp-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cp-panel .cp-btn-primary {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 14px rgba(0, 0, 0, 0.25);
}
.cp-panel .cp-btn-primary:hover { background: rgba(255, 255, 255, 0.26); border-color: rgba(255, 255, 255, 0.6); }
.cp-panel .cp-btn-danger { color: #ffb4ae; }
.cp-panel .cp-btn-danger:hover { background: rgba(255, 69, 58, 0.2); border-color: rgba(255, 69, 58, 0.55); color: #fff; }
.cp-panel .cp-btn.active {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 14px rgba(255, 255, 255, 0.2);
}

.cp-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Layout ---------- */
/* Desktop: the panel has a definite height, the calendar stretches to fill
   it and the side card scrolls inside its own row. Nothing in the side card
   is allowed to size the row. */
.cp-panel {
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  min-height: 0;
}
.cp-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  /* The calendar takes most of the row. The side column stays a fixed
     readable width instead of growing with the screen. */
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}
.cp-body.is-editing { grid-template-columns: minmax(0, 1fr) 440px; }

/* ---------- Calendar ---------- */
/* The calendar and the side panel are twin glass cards. */
.cp-calendar,
.cp-side {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.cp-calendar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 12px 12px 12px;
}
.cp-weekdays,
.cp-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.cp-weekdays {
  flex: 0 0 auto;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.cp-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  min-width: 0;
}
.cp-weekday:first-child,
.cp-weekday:last-child { color: rgba(255, 255, 255, 0.38); }
.cp-grid {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  container-type: size;
  container-name: cpcal;
}
.cp-week {
  box-sizing: border-box;
  height: calc(100cqh / 6);
  min-height: 52px;
  padding-bottom: 5px;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}
@supports not (container-type: size) {
  .cp-week { height: 72px; }
}

/* Day cells are <button>s, so every visual property is set here under
   .cp-panel to stay ahead of site-wide button rules. On desktop a cell
   fills its grid row; stacked, height comes from the width (aspect-ratio,
   padding spacer where unsupported). The floor keeps a cell from ever
   collapsing into a flat bar. */
.cp-panel .cp-day {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  /* A transform of its own makes the rounded clip apply to the art and the
     zoomed portraits. Without it, WebKit paints both past the corner. */
  transform: translateZ(0);
  margin: 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid transparent;
  background-color: rgba(255, 255, 255, 0.035);
  background-image: none;
  box-shadow: none;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.cp-panel .cp-day:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}
.cp-panel .cp-day:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
}
.cp-panel .cp-day.is-outside { background-color: transparent; opacity: 0.35; }
.cp-panel .cp-day.active {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 18px rgba(255, 255, 255, 0.18);
}
.cp-day-num {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.88);
}
.cp-day.is-past:not(.has-game) .cp-day-num { color: rgba(255, 255, 255, 0.38); }
.cp-day.is-today .cp-day-num { background: #fff; color: #111; }

/* A day with a game is painted with the campaign art. */
.cp-panel .cp-day.has-game {
  border-color: rgba(255, 255, 255, 0.22);
  background-color: #11181f;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.cp-panel .cp-day.has-game.active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 18px rgba(255, 255, 255, 0.18);
}
.cp-panel .cp-day.has-game:hover { transform: translateY(-1px) translateZ(0); }
.cp-day-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.cp-day.has-game::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.72) 100%);
  pointer-events: none;
}
.cp-day.has-game .cp-day-num { background: rgba(0, 0, 0, 0.45); color: #fff; }
.cp-day.has-game.is-today .cp-day-num { background: #fff; color: #111; }
.cp-panel .cp-day.is-invite { box-shadow: inset 0 0 0 2px #ff9f0a; }
.cp-panel .cp-day.is-invite.active { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 18px rgba(255, 255, 255, 0.18), inset 0 0 0 2px #ff9f0a; }
.cp-day-party {
  position: absolute;
  left: 5px;
  bottom: 5px;
  z-index: 2;
  display: flex;
  align-items: center;
  /* Stop short of the "+N" badge so a face is never sliced by it. */
  max-width: calc(100% - 32px);
}
.cp-day-party .cp-avatar { --cp-av: 18px; margin-left: -5px; }
.cp-day-party .cp-avatar:first-child { margin-left: 0; }
/* A fourth face only fits in a wide cell. Hiding it whole beats cropping it. */
.cp-day-party .cp-avatar:nth-child(n+4) { display: none; }
@supports (container-type: inline-size) {
  .cp-panel .cp-day { container-type: inline-size; container-name: cpday; }
}
@container cpday (min-width: 108px) {
  .cp-day-party .cp-avatar:nth-child(n+4) { display: inline-flex; }
}
@container cpday (max-width: 78px) {
  .cp-day-party .cp-avatar:nth-child(n+3) { display: none; }
  .cp-day-time { display: none; }
}
.cp-day-time,
.cp-day-count {
  position: absolute;
  z-index: 2;
  max-width: calc(100% - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
}
.cp-day-time { top: 6px; right: 5px; }
.cp-day-count { bottom: 6px; right: 5px; max-width: 36px; background: #fff; color: #111; }

/* ---------- Avatars (investigator portrait of the player's latest deck) ---------- */
.cp-avatar {
  --cp-av: 40px;
  --cp-ring: rgba(255, 255, 255, 0.4);
  position: relative;
  width: var(--cp-av);
  height: var(--cp-av);
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  /* Keeps the zoomed portrait inside the circle, including on WebKit. */
  transform: translateZ(0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2a3a46, #151d24);
  box-shadow: 0 0 0 2px var(--cp-ring), 0 2px 6px rgba(0, 0, 0, 0.45);
  color: #fff;
  font-weight: 700;
  font-size: calc(var(--cp-av) * 0.4);
  line-height: 1;
}
.cp-avatar > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 23% 32%;
  transform: scale(2.4);
  transform-origin: 23% 32%;
  display: block;
}
.cp-avatar.faction-guardian { --cp-ring: #4a86b8; }
.cp-avatar.faction-seeker   { --cp-ring: #d29a2e; }
.cp-avatar.faction-rogue    { --cp-ring: #2f9b71; }
.cp-avatar.faction-mystic   { --cp-ring: #6e5cc8; }
.cp-avatar.faction-survivor { --cp-ring: #b54a4f; }
.cp-avatar.faction-neutral  { --cp-ring: rgba(255, 255, 255, 0.75); }

/* ---------- Side panel ---------- */
.cp-side {
  min-height: 0;
  min-width: 0;
  /* clip (not hidden) so a sideways overflow cannot turn into a second
     scrollbar. Hidden would be forced back to auto beside overflow-y. */
  overflow-x: hidden;
  overflow-x: clip;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  /* Right padding is the scrollbar's gutter. Bottom padding clears the
     fixed bug-report button. */
  padding: 14px 6px 56px 14px;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.42) transparent;
}
/* The side panel scrolls; nothing inside it may shrink to fit. */
.cp-side > *,
.cp-form > *,
.cp-step > *,
.cp-session > * { flex-shrink: 0; }
.cp-clip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}
.cp-clip-text { flex: 1 1 160px; min-width: 0; }
.cp-clip-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-clip-hint { font-size: 12px; color: rgba(255, 255, 255, 0.65); margin-top: 2px; }
.cp-side-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.cp-dayhead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.cp-dayhead-num {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}
.cp-dayhead-text { min-width: 0; }
.cp-dayhead-week {
  font-size: 15px;
  font-weight: 700;
}
.cp-dayhead-month {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}
.cp-side-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}
.cp-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.cp-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.cp-muted { font-size: 12px; color: rgba(255, 255, 255, 0.6); font-weight: 600; }
.cp-empty {
  padding: 22px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}
.cp-empty a { color: #fff; text-decoration: underline; }

/* ---------- Banner (session card hero + editor preview) ---------- */
/* 16:9 boxes get their height from a padding spacer: their content is all
   absolutely positioned, so aspect-ratio alone lets grid rows collapse. */
.cp-tile::before {
  content: '';
  display: block;
  padding-top: 56.25%;
}
/* A definite height, not a max-height over a padding spacer. max-height
   clipped the title and the portraits off the bottom of a wide banner. */
.cp-banner::before { content: none; display: none; }
.cp-banner {
  position: relative;
  height: clamp(132px, 18vw, 168px);
  border-radius: 14px;
  overflow: hidden;
  transform: translateZ(0);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(17, 26, 34, 0.9));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}
.cp-banner > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.cp-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.85) 100%);
}
.cp-banner-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.cp-banner-text { min-width: 0; }
.cp-banner-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: break-word;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}
.cp-banner-name.is-placeholder { color: rgba(255, 255, 255, 0.6); font-weight: 600; }
.cp-banner-when {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-stack {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 48%;
  /* Room for the faction ring so the circle isn't shaved by the clip. */
  padding: 3px;
  overflow: hidden;
}
.cp-stack .cp-avatar { --cp-av: 32px; margin-left: -8px; }
.cp-stack .cp-avatar:first-child { margin-left: 0; }
.cp-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 159, 10, 0.92);
  color: #1d1d1f;
  font-size: 11px;
  font-weight: 800;
}

/* ---------- Session card ---------- */
.cp-session {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  min-width: 0;
}
.cp-roster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.cp-roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 4px;
}
.cp-roster-row .cp-avatar { --cp-av: 34px; }
.cp-roster-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-roster-row.is-declined .cp-avatar { filter: grayscale(1); opacity: 0.5; }
.cp-roster-row.is-declined .cp-roster-name { color: rgba(255, 255, 255, 0.5); }
.cp-pill {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
}
.cp-pill.rsvp-yes { background: rgba(255, 255, 255, 0.9); color: #111; }
.cp-pill.rsvp-maybe { background: rgba(255, 159, 10, 0.18); color: #ffc15c; }
.cp-pill.rsvp-no { background: rgba(255, 69, 58, 0.16); color: #ff8a82; }
.cp-pill.rsvp-host { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45); }

.cp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cp-actions-label { font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.8); margin-right: 2px; }
.cp-spacer { flex: 1 1 auto; }

/* Coming up */
.cp-upcoming { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cp-panel .cp-up {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.cp-panel .cp-up:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.14); }
.cp-panel .cp-up-art {
  position: relative;
  display: block;
  width: 92px;
  height: 52px;
  flex: 0 0 92px;
  min-width: 92px;
  max-width: 92px;
  border-radius: 9px;
  overflow: hidden;
  /* The art is a background, not an <img>, so global img rules can't resize it. */
  background-color: #11181f;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center 30%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.cp-up-text { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.cp-up-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-up-when { font-size: 11px; color: rgba(255, 255, 255, 0.65); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-up-when.is-invite { color: #ffc15c; font-weight: 700; }
.cp-up .cp-stack .cp-avatar { --cp-av: 24px; margin-left: -7px; }
.cp-up .cp-stack .cp-avatar:first-child { margin-left: 0; }

/* ---------- Editor ---------- */
.cp-form { display: flex; flex-direction: column; align-items: stretch; gap: 16px; min-width: 0; }
.cp-step { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 0; }
.cp-fields { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; }
.cp-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 140px; min-width: 0; }
.cp-field label { font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, 0.75); }
.cp-panel .cp-field input,
.cp-panel .cp-search {
  width: 100% !important;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 14px;
  color-scheme: dark;
}
.cp-panel .cp-field input:focus,
.cp-panel .cp-search:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
}
.cp-search::placeholder { color: rgba(255, 255, 255, 0.45); }

.cp-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  overflow: visible;
  /* Room for the active ring so the scrollport doesn't shave it, or the label. */
  padding: 4px 2px;
}
.cp-tabs::-webkit-scrollbar { display: none; }
.cp-panel .cp-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 36px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: visible;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.cp-panel .cp-tab:hover { background: rgba(255, 255, 255, 0.1); }
.cp-panel .cp-tab.active {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 14px rgba(255, 255, 255, 0.2);
}

.cp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(168px, 100%), 1fr));
  grid-auto-rows: max-content;
  gap: 10px;
  min-width: 0;
}
.cp-panel .cp-tile {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  min-height: 84px;
  padding: 0;
  border-radius: 16px;
  transform: translateZ(0);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(17, 26, 34, 0.9));
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.cp-panel .cp-tile:hover { transform: translateY(-1px) translateZ(0); border-color: rgba(255, 255, 255, 0.3); }
.cp-tile > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.cp-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.85) 100%);
}
.cp-tile-name {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  z-index: 1;
  max-height: 2.6em;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: break-word;
}
.cp-tile-flag {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 10px;
  font-weight: 700;
}
.cp-tile-flag.is-finished {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.cp-panel .cp-tile.active {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 2px #fff, 0 0 16px rgba(255, 255, 255, 0.25);
}
.cp-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  display: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.cp-tile.active .cp-check,
.cp-person.active .cp-check { display: block; }

.cp-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px 8px;
  min-width: 0;
}
.cp-panel .cp-person {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: auto;
  min-height: 96px;
  padding: 8px 2px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease;
}
.cp-panel .cp-person:hover { background: rgba(255, 255, 255, 0.05); }
.cp-person .cp-avatar { --cp-av: 56px; transition: box-shadow 0.18s ease; }
.cp-person.active .cp-avatar {
  box-shadow: 0 0 0 2px var(--cp-ring), 0 0 0 5px #fff, 0 0 18px rgba(255, 255, 255, 0.3);
}
.cp-person .cp-check { top: 4px; right: calc(50% - 34px); }
.cp-person:disabled { cursor: not-allowed; }
.cp-person:disabled:not(.active) { opacity: 0.4; }
.cp-person.is-host { cursor: default; }
.cp-person-name {
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-person.active .cp-person-name { color: #fff; }

.cp-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* Overlay scrollbar. A wide transparent gutter with a short pill thumb,
   the way macOS draws one, instead of the site's solid gray bar. */
.cp-modal,
.cp-side,
.cp-grid {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.42) transparent;
}
@media (min-width: 933px) {
  .cp-modal::-webkit-scrollbar,
  .cp-side::-webkit-scrollbar,
  .cp-grid::-webkit-scrollbar {
    width: 16px;
    height: 16px;
    background: transparent;
  }
  .cp-modal::-webkit-scrollbar-track,
  .cp-side::-webkit-scrollbar-track,
  .cp-grid::-webkit-scrollbar-track {
    background: transparent;
    margin: 14px 0;
  }
  .cp-modal::-webkit-scrollbar-thumb,
  .cp-side::-webkit-scrollbar-thumb,
  .cp-grid::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.36);
    border: 5px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
  }
  .cp-modal::-webkit-scrollbar-thumb:hover,
  .cp-side::-webkit-scrollbar-thumb:hover,
  .cp-grid::-webkit-scrollbar-thumb:hover,
  .cp-modal::-webkit-scrollbar-thumb:active,
  .cp-side::-webkit-scrollbar-thumb:active,
  .cp-grid::-webkit-scrollbar-thumb:active {
    background-color: rgba(255, 255, 255, 0.55);
  }
  .cp-modal::-webkit-scrollbar-corner,
  .cp-side::-webkit-scrollbar-corner,
  .cp-grid::-webkit-scrollbar-corner { background: transparent; }
}
@media (prefers-contrast: high) {
  .cp-modal,
  .cp-side { scrollbar-color: #fff transparent; }
  .cp-modal::-webkit-scrollbar-thumb,
  .cp-side::-webkit-scrollbar-thumb,
  .cp-grid::-webkit-scrollbar-thumb { background-color: #fff; }
}

/* Badge on the Planner button in the hub bar */
.cp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff9f0a;
  color: #1d1d1f;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-sizing: border-box;
}
.cp-badge[hidden] { display: none; }

.cp-loading {
  padding: 28px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

/* ---------- Stacked (tablet / narrow desktop) ---------- */
@media (max-width: 1280px) {
  .cp-modal { overflow-x: hidden; overflow-y: auto; }
  .cp-panel { height: auto; max-height: none; min-height: 0; }
  .cp-body,
  .cp-body.is-editing { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .cp-calendar { width: 100%; max-width: none; margin: 0; }
  .cp-grid {
    flex: 0 0 auto;
    height: min(520px, 62vh);
    max-height: min(520px, 62vh);
  }
  .cp-panel .cp-day { height: 100%; aspect-ratio: auto; min-height: 0; }
  .cp-panel .cp-day::before { content: none; display: none; }
  /* Stacked, the panel grows with its content and the modal scrolls. A
     shrinkable body plus min-height:0 on the side card squeezed the card's
     grid row below its content, so the roster and buttons spilled out of
     the card's border. */
  .cp-body { flex: 0 0 auto; }
  .cp-side { overflow: visible; min-height: auto; padding: 14px 14px 20px; }
}

/* ---------- Phone ---------- */
@media (max-width: 932px) {
  .cp-modal { padding: 0; }
  .cp-panel {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0 !important;
    /* Room for the fixed bug-report button (52px + 20px offset) so the
       last row of buttons can scroll clear of it. */
    padding: 12px 10px calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .cp-header { padding-right: 0; margin-bottom: 12px; }
  .cp-close { top: 10px; right: 10px; width: 44px; height: 44px; }
  .cp-title { font-size: 19px; flex-basis: 100%; padding-right: 52px; min-height: 44px; display: flex; align-items: center; }
  .cp-month-nav { flex: 1 1 100%; justify-content: space-between; }
  .cp-month-label { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
  /* mobile-optimized.css floors every phone <button> at 32px with a
     (0,5,2) selector, so these sizes need !important to win. */
  .cp-panel .cp-icon-btn { width: 44px; min-height: 44px !important; }
  .cp-panel .cp-btn { min-height: 44px !important; }
  .cp-up, .cp-person, .cp-tab { min-height: 44px !important; }
  .cp-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .cp-tabs::-webkit-scrollbar { display: none; }
  .cp-weekdays, .cp-week { gap: 3px; }
  .cp-week { padding-bottom: 3px; }
  .cp-weekday { font-size: 10px; letter-spacing: 0; }
  .cp-panel .cp-day { min-height: 0 !important; border-radius: 8px; }
  .cp-calendar { padding: 8px 6px 8px; border-radius: 12px; }
  .cp-weekdays { margin-bottom: 6px; padding-bottom: 6px; }
  .cp-side { padding: 10px; }
  .cp-day-num { top: 3px; left: 3px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 4px; }
  .cp-day-party, .cp-day-time { display: none; }
  .cp-day-count { bottom: 3px; right: 3px; padding: 1px 5px; font-size: 9px; }
  .cp-tiles { max-height: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-people { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .cp-form-actions .cp-btn { flex: 1 1 0; }
  .cp-actions .cp-spacer { display: none; }
  .cp-actions .cp-btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-grid { scroll-behavior: auto; }
  .cp-panel .cp-day, .cp-panel .cp-tile, .cp-panel .cp-person, .cp-panel .cp-btn,
  .cp-panel .cp-icon-btn, .cp-panel .cp-tab, .cp-panel .cp-up { transition: none; }
  .cp-panel .cp-day.has-game:hover, .cp-panel .cp-tile:hover { transform: translateZ(0); }
}
