/* The title, event and actions form one header. Narrow screens wrap whole groups. */
.masthead { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 0 0 16px; }
.wordmark { grid-column: 1; }
#event-countdown { grid-column: 2; justify-self: end; font-size: 18px; }
#countdown-label { font-family: "Yu Gothic", "Hiragino Sans", sans-serif; font-size: 14px; }
.header-tools.participation-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 12px; margin: 0; min-width: 0; }
.header-tools .cheer-entry { flex: 0 1 auto; gap: 8px; position: relative; }
.header-tools #cheer-open { flex: none; min-width: 144px; min-height: 44px; height: 44px; padding: 8px 24px; position: relative; overflow: hidden; isolation: isolate; gap: 8px; font-size: 14px; white-space: nowrap; }
/* A soft one-second sweep, followed by seven seconds at rest. */
.header-tools #cheer-open::before { content: ""; position: absolute; inset: -25% auto -25% 0; width: 35%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .45), transparent); pointer-events: none; opacity: 0; transform: translateX(-160%) skewX(-18deg); animation: cheer-shimmer 8s linear 2s infinite; }
.header-tools #cheer-open > * { position: relative; z-index: 1; }
@keyframes cheer-shimmer {
  0% { transform: translateX(-160%) skewX(-18deg); opacity: 0; }
  2%, 10% { opacity: 1; }
  12.5%, 100% { transform: translateX(420%) skewX(-18deg); opacity: 0; }
}
.header-tools .cheer-entry.is-paused #cheer-open::before,
.cheer-hidden #cheer-open::before,
body:has(dialog[open]) #cheer-open::before,
.header-tools #cheer-open:disabled::before { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .header-tools #cheer-open::before { animation: none; } }
.header-tools #cheer-open > span:last-child { display: inline; margin: 0; }
.header-tools #cheer-open .icon { width: 16px; height: 16px; }
.header-tools #help-open { flex: 0 0 44px; width: 44px; height: 44px; padding: 8px; }
/* Occasional status (e.g. a withdrawn shared cheer) drops below the button and never widens the header.
   An unreachable API only greys the button out; it reconnects by itself. */
.header-tools .cheer-notice { position: absolute; left: 0; top: 100%; z-index: 4; width: max-content; max-width: min(320px, calc(100vw - 24px)); margin-top: 4px; background: var(--black); }
.header-tools .cheer-notice:has(#cheer-status:empty) { display: none; }
.header-tools #cheer-status { margin: 0; }
.mounting #cheer-list-open { position: absolute; bottom: 24px; left: 24px; z-index: 4; background: var(--black); font-size: 12px; }
.cheer-editor #cheer-list-open { display: none; }
.share-compact { display: flex; gap: 0; position: relative; min-width: 0; }
.share-compact .share-destinations, .share-compact .share-tools { display: flex; gap: 0; margin: 0; }
.share-compact .share-destinations a, .share-compact .share-tools button { flex: none; width: 44px; height: 44px; min-height: 44px; min-width: 44px; padding: 12px; border: 0; color: var(--quiet); }
.share-compact svg { display: block; width: 20px; height: 20px; }
/* Names the icon group; narrow headers keep only the divider. */
.share-compact .share-label { align-self: center; margin-left: 4px; padding: 2px 6px 2px 12px; border-left: 1px solid var(--border); color: var(--quiet); font-size: 11px; line-height: 1.4; white-space: nowrap; }
.share-compact a:hover, .share-compact button:hover { color: var(--gold); }
.share-compact .share-status { position: absolute; z-index: 4; top: 100%; right: 0; width: max-content; max-width: min(280px, calc(100vw - 24px)); padding: 8px; background: var(--black); border: 1px solid var(--border); }
.share-compact .share-url { position: absolute; z-index: 4; top: calc(100% + 54px); right: 0; width: min(280px, calc(100vw - 24px)); }
.footer-links { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; }
.footer-links a { display: inline-flex; align-items: center; gap: 6px; }
.footer-links .icon { width: 14px; height: 14px; }
#help-dialog { width: min(640px, calc(100vw - 24px)); padding: 24px; overscroll-behavior: contain; }
#help-dialog h2 { margin: 0; font-size: 24px; text-wrap: balance; }
#help-dialog .share-heading { margin-bottom: 8px; }
#help-dialog p { font-size: 14px; line-height: 1.7; text-wrap: pretty; }
#welcome-shared { margin-left: auto; color: var(--quiet); font-size: 11px; }
.runner-editor { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: center; border-block: 1px solid var(--border); padding: 20px 0; }
.runner-preview { position: relative; margin: 0; min-width: 0; }
.runner-bib-label { position: absolute; transform: translate(-50%, -100%); padding: 1px 4px; border-radius: 2px; background: var(--paper); color: #292d29; font: 500 11px/1.3 sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
#runner-bib-label { z-index: 3; }
.cheer-editor #runner-bib-label { display: none; }
#runner-preview { display: block; width: 100%; height: auto; background: var(--paper); border-radius: 2px; }
.runner-preview figcaption { font-size: 12px; }
.runner-fields { min-width: 0; display: grid; gap: 16px; }
.runner-fields label { display: grid; gap: 6px; font-size: 12px; color: var(--quiet); min-width: 0; }
.runner-fields select, .runner-fields input[type="text"] { width: 100%; min-width: 0; height: 44px; padding: 8px 10px; color: var(--paper); background: var(--black); border: 1px solid var(--border); border-radius: 2px; font-size: 16px; font-variant-numeric: tabular-nums; }
.runner-colors { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.runner-colors input { width: 100%; height: 44px; padding: 4px; background: transparent; border: 1px solid var(--border); border-radius: 2px; cursor: pointer; }
.runner-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.runner-numbers small { font-size: 11px; }
.welcome-guide { margin-top: 24px; font-size: 13px; }
.welcome-guide h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.welcome-guide .help-items { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 12px; line-height: 1.6; }
.welcome-guide .help-items dt, .welcome-guide .help-items dd { margin: 0; }
.welcome-guide .help-items dt { color: var(--paper); font-weight: 600; }
.welcome-guide .help-items dd { color: var(--quiet); }
.welcome-guide .help-items .hint-cheer { color: var(--gold); font-weight: 600; }
body:not(.cheer-enabled) .hint-cheer { display: none; }
#runner-form-error:empty { display: none; }
#runner-form-error { color: #f3ba9b; }
#welcome-start { width: 100%; margin-top: 12px; background: var(--gold); color: var(--black); font-size: 16px; font-weight: bold; border-radius: 2px; min-height: 48px; }
#welcome-start:hover:not(:disabled) { background: var(--paper); color: var(--black); }
@media (min-width: 1200px) {
  .masthead { grid-template-columns: minmax(0, 1fr) auto auto; }
  .header-tools.participation-actions { grid-column: 3; }
}
@media (max-width: 640px) {
  .masthead { gap: 8px; }
  .wordmark { grid-column: 1 / -1; }
  #event-countdown { grid-column: 1 / -1; justify-self: start; font-size: 14px; }
  #countdown-days { font-size: 18px; }
  .header-tools.participation-actions { justify-content: flex-end; gap: 8px; }
  .header-tools .cheer-entry { margin-right: auto; }
  .header-tools #cheer-open { min-width: 120px; padding: 8px 18px; font-size: 13px; }
  .share-compact .share-destinations a, .share-compact .share-tools button { width: 36px; min-width: 36px; padding: 10px 8px; }
  #help-dialog { padding: 16px; }
  #help-dialog h2 { font-size: 20px; }
  #help-dialog p { font-size: 13px; }
  .runner-editor { grid-template-columns: 108px minmax(0, 1fr); gap: 12px; padding: 16px 0; align-items: start; }
  .runner-preview { padding-top: 18px; }
  .runner-fields { gap: 12px; }
  .runner-colors { gap: 6px; }
  .runner-numbers { grid-template-columns: 1fr; gap: 8px; }
  .welcome-guide .help-items { gap: 8px 12px; }
  #help-dialog .share-heading { flex-wrap: wrap; gap: 4px 8px; }
  #help-dialog .share-heading form { margin-left: auto; }
  #welcome-shared { order: 3; width: 100%; margin: 0 0 8px; }
}
@media (max-width: 420px) {
  .share-compact .share-label { margin-left: 0; padding: 0; height: 24px; font-size: 0; }
}
@media (max-width: 360px) {
  .header-tools.participation-actions { gap: 4px; }
  .header-tools #cheer-open { min-width: 104px; padding-inline: 12px; gap: 4px; }
  .share-compact .share-destinations a, .share-compact .share-tools button { width: 32px; min-width: 32px; padding-inline: 6px; }
  .runner-editor { grid-template-columns: 88px minmax(0, 1fr); }
  .runner-colors { gap: 4px; }
  .runner-fields label { font-size: 11px; }
}
