/* Crew drawing: one stylesheet for Wobble and Waddle. It leans on each game's own variables, with fallbacks,
   so the cards, buttons and fields match whichever game loads it. No fonts or images of its own. */
.crew-mount:empty, #crew-start:empty, #crew-over:empty, #crew-start[hidden], #crew-over[hidden] { display: none; }

/* ---------- entry point on the start card: a compact pill row */
.crew-tag {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 4px 14px 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px rgba(94, 242, 255, 0.55);
  color: var(--cream, #f6efe0);
  font-family: var(--font-body, system-ui, sans-serif);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms, transform 120ms;
}
.crew-tag:hover { background: var(--panel-3, #2c2660); }
.crew-tag:active { transform: translateY(1px); }
.crew-tag:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 3px; }
.crew-tag-icon { flex: none; width: 34px; height: 21px; color: var(--glow, #5ef2ff); }
.crew-tag-text { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.crew-tag-title { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 17px; line-height: 1.1; white-space: nowrap; }
.crew-tag-short, .crew-tag-mini { display: none; }
.crew-tag-sub { font-size: 13px; font-weight: 800; line-height: 1.2; color: var(--gold, #ffd75e); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums lining-nums; }
.crew-tag::after {
  content: ''; flex: none; width: 7px; height: 7px; margin-left: 2px;
  border: solid var(--muted, #b9b3d9); border-width: 2px 2px 0 0; transform: rotate(45deg);
}

/* ---------- one short line on the game over card */
.crew-line {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 30px;
  margin: 6px 0 0;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--cream, #f6efe0);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 14px; font-weight: 800; line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* Waddle: the game over line wears the same pill as the start card row */
[data-crew-game="waddle"] .crew-line {
  width: auto; max-width: 100%;
  min-height: 34px;
  margin: 6px auto 0;
  padding: 4px 14px 4px 10px;
  border-radius: 999px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px rgba(94, 242, 255, 0.45);
}
[data-crew-game="waddle"] .crew-line::before { inset: -5px 0; }
/* a 44px tap area without a 44px row */
.crew-line::before { content: ''; position: absolute; inset: -7px 0; }
.crew-line:hover .crew-line-text { text-decoration: underline; text-underline-offset: 3px; }
.crew-line:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 2px; border-radius: 10px; }
.crew-line-icon { flex: none; width: 26px; height: 16px; color: var(--glow, #5ef2ff); }
.crew-line-text { min-width: 0; text-wrap: balance; }
.crew-line-arrow { flex: none; width: 14px; height: 14px; color: var(--muted, #b9b3d9); }

/* ---------- the dialog */
.crew {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  padding: calc(env(safe-area-inset-top, 0px) + 34px) calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 16px) calc(env(safe-area-inset-left, 0px) + 16px);
  background: rgba(7, 6, 26, 0.74);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: crewIn 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.crew[hidden] { display: none; }
@keyframes crewIn { from { opacity: 0; } to { opacity: 1; } }
/* the screens behind the dialog step aside, so no card edges peek out around it */
.screen[data-crew-inert] > * { visibility: hidden; }

.crew .crew-card {
  width: min(100%, 368px);
  max-height: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}
.crew-card > * { position: relative; }
.crew-card:focus { outline: none; }
.crew-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px 24px 22px;
  border-radius: inherit;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-3, #2c2660) transparent;
  /* soft edge where the inside scrolls under the top and bottom of the card; the fade sits inside the padding */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 12px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 12px), transparent 100%);
}
.crew-stamp {
  position: absolute !important;
  top: -22px; left: -12px;
  width: 80px; height: 80px;
  display: grid; place-items: center;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><polygon points='96.0,50.0 90.7,54.6 94.8,60.2 88.7,63.5 91.4,70.0 84.7,71.8 86.0,78.7 79.0,79.0 78.7,86.0 71.8,84.7 70.0,91.4 63.5,88.7 60.2,94.8 54.6,90.7 50.0,96.0 45.4,90.7 39.8,94.8 36.5,88.7 30.0,91.4 28.2,84.7 21.3,86.0 21.0,79.0 14.0,78.7 15.3,71.8 8.6,70.0 11.3,63.5 5.2,60.2 9.3,54.6 4.0,50.0 9.3,45.4 5.2,39.8 11.3,36.5 8.6,30.0 15.3,28.2 14.0,21.3 21.0,21.0 21.3,14.0 28.2,15.3 30.0,8.6 36.5,11.3 39.8,5.2 45.4,9.3 50.0,4.0 54.6,9.3 60.2,5.2 63.5,11.3 70.0,8.6 71.8,15.3 78.7,14.0 79.0,21.0 86.0,21.3 84.7,28.2 91.4,30.0 88.7,36.5 94.8,39.8 90.7,45.4' fill='%235ef2ff' stroke='%230d0b1f' stroke-width='3' stroke-linejoin='round'/><circle cx='50' cy='50' r='34' fill='none' stroke='%230d0b1f' stroke-width='1.6' stroke-dasharray='3.2 3.2' opacity='.45'/></svg>") center / contain no-repeat;
  filter: drop-shadow(0 4px 0 var(--ink-deep, #07061a));
  transform: rotate(-12deg);
  z-index: 4;
  pointer-events: none;
}
.crew-stamp span { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 23px; line-height: 1; color: var(--space-bg, #0d0b1f); }
.crew-card[data-screen="ended"] .crew-stamp { filter: drop-shadow(0 4px 0 var(--ink-deep, #07061a)) saturate(0.35) brightness(0.85); }
.crew-close { position: absolute !important; top: 14px; right: 14px; z-index: 4; }

.crew-kicker {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 40px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--glow, #5ef2ff);
}
.crew-kicker-icon { width: 24px; height: 15px; }
.crew-title {
  margin: 6px 36px 0;
  font-family: var(--font-display, system-ui, sans-serif);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.02;
  color: var(--cream, #f6efe0);
  text-shadow: 0 3px 0 var(--coral-deep, #c9443a);
  text-wrap: balance;
}
.crew-lead { margin: 10px 0 0; font-size: 16px; font-weight: 700; line-height: 1.38; color: var(--cream, #f6efe0); text-wrap: pretty; }
.crew-body > * { margin-top: 12px; }
.crew-body > :first-child { margin-top: 14px; }
.crew-body p { margin-bottom: 0; }

.crew-quiet { font-size: 14px; font-weight: 600; color: var(--muted, #b9b3d9); }
.crew-more { font-size: 15px; font-weight: 700; color: var(--gold, #ffd75e); }

/* countdown, one row */
.crew-clock {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; column-gap: 10px; row-gap: 0;
  padding: 8px 12px 9px;
  border-radius: 18px;
  background: var(--space-bg, #0d0b1f);
  box-shadow: inset 0 0 0 2px var(--panel-3, #2c2660);
}
.crew-clock-label { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted, #b9b3d9); }
.crew-left { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 24px; line-height: 1.1; color: var(--gold, #ffd75e); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.crew-when { flex-basis: 100%; font-size: 13px; font-weight: 600; color: var(--muted, #b9b3d9); }
.crew-when:empty { display: none; }

/* entries and the clock side by side */
.crew-stats { display: flex; gap: 10px; align-items: stretch; }
.crew-stats > * { margin: 0; }
.crew-stats .crew-clock { flex: 1 1 auto; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.crew-stats .crew-when { display: none; }
.crew-entries {
  flex: 0 0 auto; min-width: 104px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px rgba(255, 215, 94, 0.55);
}
.crew-entries-label { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted, #b9b3d9); white-space: nowrap; }
.crew-entries-num { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 30px; line-height: 1; color: var(--gold, #ffd75e); font-variant-numeric: tabular-nums lining-nums; }

/* Venmo box: the same treatment as the giveaway's */
.crew-venmo {
  padding: 12px;
  border-radius: 20px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px rgba(255, 215, 94, 0.55);
  text-align: left;
}
.crew-venmo p { margin: 0; }
.crew-venmo-text, .crew-venmo-note { font-size: 14px; font-weight: 700; line-height: 1.35; color: var(--cream, #f6efe0); text-wrap: pretty; padding-left: 20px; text-indent: -20px; }
.crew-venmo.is-done .crew-venmo-note { padding-left: 0; text-indent: 0; }
.crew-venmo-text::before, .crew-venmo-note::before {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  margin: 0 6px -2px 0;
  background: var(--gold, #ffd75e);
  -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8l2.9 6.6 7.2.7-5.4 4.8 1.6 7.1L12 17.3 5.7 21l1.6-7.1L1.9 9.1l7.2-.7z'/></svg>") center / contain no-repeat;
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 1.8l2.9 6.6 7.2.7-5.4 4.8 1.6 7.1L12 17.3 5.7 21l1.6-7.1L1.9 9.1l7.2-.7z'/></svg>") center / contain no-repeat;
}
.crew-venmo.is-done { padding: 10px 12px; text-align: center; }
.crew-venmo-form { margin-top: 8px; }
.crew-venmo-form label { display: block; margin: 0 0 6px 4px; font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted, #b9b3d9); }
.crew-venmo .name-row { display: flex; gap: 8px; align-items: center; }
.crew-venmo .name-row input {
  flex: 1; min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 2px solid var(--muted, #b9b3d9);
  border-radius: 999px;
  background: var(--space-bg, #0d0b1f);
  color: var(--cream, #f6efe0);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 17px; font-weight: 700; letter-spacing: 0.01em;
  text-transform: none;
}
.crew-venmo .name-row input::placeholder { color: var(--faint, #8f89b8); font-weight: 600; }
.crew-venmo .name-row input:focus { border-color: var(--cream, #f6efe0); outline: none; }
.crew-venmo .name-row input:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 3px; }
.crew-venmo .btn-dark { flex: none; min-width: 72px; min-height: 48px; font-size: 18px; }
.crew-venmo .crew-get { margin-top: 10px; min-height: 52px; font-size: 21px; }
.crew-venmo-msg { margin-top: 6px !important; font-size: 14px; font-weight: 700; line-height: 1.35; color: var(--muted, #b9b3d9); }
.crew-venmo-msg:empty { display: none; }
.crew-venmo-msg.is-error { color: var(--danger, #ff5a6e); }

/* share rows */
.crew-share { display: flex; flex-direction: column; gap: 8px; }
.crew-share-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px;
  border-radius: 18px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px var(--rule, rgba(185, 179, 217, 0.22));
  text-align: left;
}
.crew-share-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.crew-share-name { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 18px; line-height: 1.1; color: var(--cream, #f6efe0); }
.crew-share-url { font-size: 12px; font-weight: 700; color: var(--muted, #b9b3d9); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; -webkit-user-select: all; }
.crew-share-btns { flex: none; display: flex; gap: 6px; }
.crew-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 64px; min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--gold, #ffd75e);
  color: var(--space-bg, #0d0b1f);
  box-shadow: 0 3px 0 var(--gold-deep, #c99a1e), 0 3px 0 2px var(--ink-deep, #07061a);
  font-family: var(--font-display, system-ui, sans-serif);
  font-weight: 700; font-size: 16px; line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, background-color 120ms;
}
.crew-btn:hover { background: #ffe07e; }
.crew-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gold-deep, #c99a1e), 0 1px 0 2px var(--ink-deep, #07061a); }
.crew-btn:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 3px; }
.crew-btn.is-done { background: var(--glow, #5ef2ff); box-shadow: 0 3px 0 #2fb9cc, 0 3px 0 2px var(--ink-deep, #07061a); }
.crew-btn-share { background: transparent; color: var(--cream, #f6efe0); box-shadow: inset 0 0 0 2px var(--keyline, rgba(246, 239, 224, 0.9)); }
.crew-btn-share:hover { background: var(--panel-3, #2c2660); }
.crew-btn-share:active { box-shadow: inset 0 0 0 2px var(--keyline, rgba(246, 239, 224, 0.9)); }
.crew-copy-tmp { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* friend progress */
.crew-progress { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.crew-pips { display: flex; gap: 10px; justify-content: center; }
.crew-pip {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--space-bg, #0d0b1f);
  box-shadow: inset 0 0 0 2px var(--panel-3, #2c2660);
}
.crew-pip.is-on { background: var(--glow, #5ef2ff); box-shadow: inset 0 0 0 2px var(--ink-deep, #07061a), 0 0 0 2px var(--glow, #5ef2ff); }
.crew-progress-text { margin: 0; font-size: 14px; font-weight: 800; color: var(--muted, #b9b3d9); }
.crew-play { margin-top: 14px !important; }
.crew-skip {
  display: block;
  min-height: 44px;
  margin: 4px auto 0 !important;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--muted, #b9b3d9);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 14px; font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  cursor: pointer;
}
.crew-skip:hover { color: var(--cream, #f6efe0); }
/* "Just play" on the Waddle share screens: slim line, full size tap area */
.crew-just { position: relative; min-height: 30px; margin: 0 auto -4px !important; }
.crew-just::before { content: ''; position: absolute; inset: -7px -10px; }
.crew-skip:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 2px; border-radius: 8px; }

/* ended */
.crew-winner {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--space-bg, #0d0b1f);
  box-shadow: inset 0 0 0 2px var(--panel-3, #2c2660);
}
.crew-winner-label { font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted, #b9b3d9); }
.crew-winner-name { font-family: var(--font-display, system-ui, sans-serif); font-weight: 700; font-size: 24px; line-height: 1.15; color: var(--gold, #ffd75e); overflow-wrap: anywhere; }

/* Waddle: a pointer at Wobble's top score giveaway */
.crew-also {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px;
  border-radius: 18px;
  background: var(--panel-2, #211c4d);
  box-shadow: inset 0 0 0 1.5px var(--rule, rgba(185, 179, 217, 0.22));
  text-align: left;
}
.crew-also-text { flex: 1; min-width: 0; margin: 0; font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--cream, #f6efe0); }
.crew-also-label { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted, #b9b3d9); }
.crew-also-go { flex: none; min-width: 0; padding: 0 14px; font-size: 15px; }

/* rules */
.crew-rules { margin-top: 4px !important; text-align: left; }
.crew-rules summary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  font-size: 14px; font-weight: 700;
  color: var(--muted, #b9b3d9);
  cursor: pointer;
  list-style: none;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  user-select: none; -webkit-user-select: none;
}
.crew-rules summary::-webkit-details-marker { display: none; }
.crew-rules summary::after { content: ''; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.crew-rules[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.crew-rules summary:hover { color: var(--cream, #f6efe0); }
.crew-rules summary:focus-visible { outline: 3px solid var(--glow, #5ef2ff); outline-offset: 2px; border-radius: 8px; }
.crew-rules[open] summary { color: var(--cream, #f6efe0); }
/* one rule per line in the same dark inset box as the clock, so it reads as part of the card */
.crew-rules-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 12px 14px 13px;
  display: grid; row-gap: 7px;
  border-radius: 18px;
  background: var(--space-bg, #0d0b1f);
  box-shadow: inset 0 0 0 2px var(--panel-3, #2c2660);
  font-size: 13px; line-height: 1.45; font-weight: 500;
  color: var(--muted, #b9b3d9);
  text-align: left;
}
.crew-rules-list li { position: relative; margin: 0; padding: 0 0 0 16px; }
.crew-rules-list li::before {
  content: '';
  position: absolute; left: 2px; top: 0.72em;
  width: 5px; height: 5px; margin-top: -2.5px;
  border-radius: 50%;
  background: var(--glow, #5ef2ff);
}

/* shorter phones */
@media (max-height: 760px) {
  .crew { padding-top: calc(env(safe-area-inset-top, 0px) + 30px); }
  .crew-scroll { padding: 24px 20px 18px; }
  .crew-title { font-size: 30px; }
  .crew-lead { font-size: 15px; }
}
@media (max-width: 360px) {
  .crew-scroll { padding-left: 16px; padding-right: 16px; }
  .crew-share-row { padding-left: 12px; }
  .crew-btn { min-width: 56px; padding: 0 11px; font-size: 15px; }
}

/* landscape phones: two columns, the words on the left and the action on the right */
@media (max-height: 460px) and (orientation: landscape) {
  .crew { padding-top: calc(env(safe-area-inset-top, 0px) + 22px); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
  .crew .crew-card { width: min(100%, 690px); }
  /* the right gutter keeps the close button clear of the second column */
  .crew-scroll { padding: 18px 62px 12px 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); column-gap: 20px; align-items: start; }
  /* the words stay put while the right column scrolls, so the left half is never empty */
  .crew-head { grid-column: 1; padding-top: 8px; position: sticky; top: 18px; }
  .crew-body { grid-column: 2; }
  .crew-line { justify-content: flex-start; padding: 0 2px; text-align: left; }
  .crew-line-text { text-wrap: pretty; }
  [data-crew-game="waddle"] .crew-line { margin-left: 0; }
  .crew-body > :first-child { margin-top: 0; }
  .crew-body > * { margin-top: 10px; }
  .crew-kicker { margin: 0 0 0 52px; justify-content: flex-start; }
  .crew-title { margin: 6px 0 0; font-size: 28px; text-align: left; }
  .crew-lead { font-size: 15px; text-align: left; }
  .crew-close { top: 10px; right: 10px; }
  .crew-stamp { width: 66px; height: 66px; top: -16px; left: -10px; }
  .crew-stamp span { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .crew { animation: none; }
}
