/* Artwork-led challenge cards. No changes to screen scrolling or launch footers. */
:is(#menu-root#menu-root,body[data-page=community]) :is(#route-cards,#map-grid,#local-map-list){display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr));gap:16px;align-items:start}
:is(#menu-root#menu-root,body[data-page=community]) :is(#route-cards,#map-grid,#local-map-list) .mission-card{display:flex;flex-direction:column;position:relative;min-width:0;min-height:0;padding:0;margin:0;gap:0;overflow:hidden;isolation:isolate;text-align:left;border:1px solid #a6c9b333;border-radius:16px;background:#142b24;color:#f6f3e7;box-shadow:0 8px 22px #0002;transition:border-color 160ms ease,box-shadow 160ms ease;align-content:normal;grid-template-columns:none;grid-template-rows:none}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art{display:block;position:relative;isolation:isolate;width:100%;height:180px;min-height:180px;padding:0;margin:0;border:0;border-radius:0;background:linear-gradient(145deg,#395747,#162f2c);overflow:hidden;box-sizing:border-box;grid-column:auto;grid-row:auto;text-align:left}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art::after{content:'';position:absolute;inset:0;pointer-events:none;z-index:1;background:linear-gradient(180deg,#071c2320 0%,transparent 24%,#091c1c40 50%,#0d231ff5 100%)}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art .content-preview{display:block;width:100%;height:100%;max-height:none;aspect-ratio:auto;object-fit:cover;margin:0;border:0;border-radius:0;opacity:1;transition:transform 280ms ease}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art>strong,:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art>h2{position:absolute;z-index:2;bottom:15px;left:18px;right:18px;display:block;margin:0;padding:0;color:#fff8e7;font-family:'Barlow Condensed','DM Sans',sans-serif;font-size:28px!important;font-weight:750;line-height:1.07;letter-spacing:.01em;overflow-wrap:anywhere;text-shadow:0 2px 12px #0006;pointer-events:none}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art>h2{pointer-events:auto}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .map-title-button{font:inherit;color:inherit;line-height:inherit;background:none;border:0;border-radius:0;min-height:44px;padding:0;text-align:left;width:100%}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .map-cover-button{position:absolute;inset:0;display:block;width:100%;height:100%;min-height:0;margin:0;padding:0;border:0;border-radius:0;background:none;grid-column:auto;grid-row:auto}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-body{display:flex;flex-direction:column;gap:9px;min-width:0;padding:14px 18px 16px;margin:0;background:linear-gradient(135deg,#233e31,#162e28);grid-column:auto;box-sizing:border-box;width:100%}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-number{position:absolute;z-index:2;top:12px;left:16px;font-family:'Barlow Condensed',sans-serif;font-size:27px;font-weight:700;color:#fff4d4;text-shadow:0 2px 8px #0009}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-picked{display:none;position:absolute;z-index:2;top:14px;right:14px;padding:5px 9px;border-radius:5px;background:#ffd05c;color:#203325;font-size:10px;font-weight:800;letter-spacing:.05em;text-transform:uppercase}
#menu-root #route-cards .mission-card[aria-pressed=true],#menu-root #local-map-list .mission-card[data-selected=true]{border-color:#ffd05c;box-shadow:inset 0 0 0 1px #ffd05c,0 8px 24px #0003;background:#213d2d}
#menu-root #route-cards .mission-card[aria-pressed=true] .mission-picked{display:block}
#menu-root #route-cards .mission-card .route-detail{display:block;grid-column:auto;grid-row:auto;color:#ffd880;font-size:10px;font-weight:750;text-transform:uppercase;letter-spacing:.09em;margin:0}
#menu-root #route-cards .mission-card .route-assigned-car{display:flex;align-items:center;gap:10px;min-height:45px;padding:0;margin:0;background:none;border:0;grid-column:auto;grid-row:auto}
#menu-root #route-cards .mission-card .route-assigned-car img{display:block;width:82px;height:44px;object-fit:cover;border-radius:7px;margin:0;flex-shrink:0}
#menu-root #route-cards .mission-card .route-vehicle{font-size:12px;font-weight:650;color:#e8eee0;line-height:1.4}
#menu-root #route-cards .mission-card .route-history{display:block;grid-column:auto;grid-row:auto;font-size:10px;line-height:1.5;color:#b2c6b8;margin:0;padding:0}
#menu-root #route-cards .mission-card[data-completed=yes] .route-history{color:#a5e2b4}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-body>a{font-size:11px;color:#b9d8c0;text-decoration:none;align-self:flex-start;min-height:24px;display:flex;align-items:center}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card :is(.map-description,.saved-map-caption){display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:12px;line-height:1.5;color:#c1d0c4;margin:0;min-width:0;overflow-wrap:anywhere}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card :is(.map-stats,.mission-rule){margin:0;color:#b4c9b8;font-size:10px;line-height:1.5;overflow-wrap:anywhere}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .map-stats:last-of-type{color:#f2cf88}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card :is(.map-actions,.local-file-actions){display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:4px 0 0;padding:0;border:0;grid-column:auto;width:100%}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card :is(.map-actions,.local-file-actions)>:is(button,a){display:flex;align-items:center;justify-content:center;min-height:44px;min-width:0;flex:1 1 auto;padding:8px 10px;margin:0;border:1px solid #b7cdb421;border-radius:8px;background:#ffffff05;color:#d6e3d2;font:600 11px 'DM Sans',sans-serif;text-decoration:none;box-sizing:border-box;line-height:1.3}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card .map-actions>.primary,#menu-root .mission-card .local-file-actions>button:first-child{background:#ffd05c;color:#233621;border-color:transparent;font-weight:800;flex-grow:1.4}
#menu-root .mission-card .local-file-actions>button:last-child{color:#efb4a5}
:is(#menu-root#menu-root,body[data-page=community]) .mission-card:focus-visible,:is(#menu-root#menu-root,body[data-page=community]) .mission-card :is(button,a):focus-visible{outline:3px solid #ffe4a0;outline-offset:-4px}
@media(hover:hover){:is(#menu-root#menu-root,body[data-page=community]) .mission-card:hover{border-color:#d5bd7b99;box-shadow:0 10px 25px #0003}:is(#menu-root#menu-root,body[data-page=community]) .mission-card:hover .mission-art .content-preview{transform:scale(1.035)}}
@media(max-width:760px){:is(#menu-root#menu-root,body[data-page=community]) :is(#route-cards,#map-grid,#local-map-list){grid-template-columns:minmax(0,1fr);gap:13px}:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art{height:160px;min-height:160px}:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-body{padding:12px 15px 14px;gap:7px}:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art>strong,:is(#menu-root#menu-root,body[data-page=community]) .mission-card .mission-art>h2{left:15px;right:15px;font-size:26px!important}}
@media(prefers-reduced-motion:reduce){:is(#menu-root#menu-root,body[data-page=community]) .mission-card,:is(#menu-root#menu-root,body[data-page=community]) .mission-card *{transition:none!important;transform:none!important}}

/* Official levels own their card layout. Dedicated classes avoid the legacy
   .route-choice row rules in map-browser.css, which is loaded dynamically.
   The screen, scrolling viewport and departure footer keep their existing rules. */
#menu-root :is(#home-drive,#home-import) :is(#route-cards,#local-map-list) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
#menu-root :is(#home-drive,#home-import) :is(#route-cards,#local-map-list) .official-route-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  gap: 0;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid var(--cl-line);
  border-radius: 12px;
  background: var(--cl-panel);
  color: var(--cl-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}
#menu-root :is(#home-drive,#home-import) .official-route-art {
  display: grid;
  grid-template-rows: minmax(118px, 1fr) auto;
  position: relative;
  isolation: isolate;
  flex: 1;
  min-height: 204px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: var(--cl-input);
}
#menu-root :is(#home-drive,#home-import) .official-route-art::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, #07161340 0%, #07161300 36%, #07161388 66%, #071613eb 100%);
  pointer-events: none;
}
#menu-root :is(#home-drive,#home-import) .official-route-art > .content-preview {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  object-fit: cover;
}
#menu-root :is(#home-drive,#home-import) .official-route-body > strong {
  grid-column: 1 / -1;
  width: 100%;
  grid-row: 1;
  align-self: end;
  margin: 0;
  padding: 0;
  color: var(--cl-ink);
  font: 600 24px/1.12 'Barlow Condensed', sans-serif;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 8px #0008;
}
#menu-root :is(#home-drive,#home-import) .official-route-number {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 16px;
  color: var(--cl-ink);
  font: 600 24px/1 'Barlow Condensed', sans-serif;
  text-shadow: 0 2px 8px #0009;
}
#menu-root :is(#home-drive,#home-import) .official-route-body {
  position: relative;
  z-index: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 5px 12px;
  min-width: 0;
  padding: 10px 16px 13px;
}
#menu-root :is(#home-drive,#home-import) .official-route-card .route-detail,
#menu-root :is(#home-drive,#home-import) .official-route-card .route-history {
  display: block;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  color: var(--cl-muted);
  overflow-wrap: anywhere;
}
#menu-root :is(#home-drive,#home-import) .official-route-card .route-detail {
  grid-column: 1;
  grid-row: 3;
  align-self: start;
  color: var(--cl-accent);
  letter-spacing: .06em;
  text-transform: uppercase;
}
#menu-root :is(#home-drive,#home-import) .official-route-description {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  color: var(--cl-muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#menu-root :is(#home-drive,#home-import) .official-route-description[hidden] { display: none; }
/* A reserved top band keeps the vehicle clear of the full-width text below. */
#menu-root :is(#home-drive,#home-import) .official-route-car {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 2;
  isolation: isolate;
  width: min(49%, 166px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  pointer-events: none;
}
#menu-root :is(#home-drive,#home-import) .official-route-car::before {
  content: '';
  position: absolute;
  inset: -12px -22px -10px;
  z-index: -1;
  background: radial-gradient(ellipse at 58% 55%, #03100ee0 0%, #03100e90 32%, #03100e00 72%);
  pointer-events: none;
}
#menu-root :is(#home-drive,#home-import) .official-route-car > .content-preview {
  display: block;
  flex: 0 0 84px;
  width: 100%;
  height: 84px;
  margin: 0;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 5px 4px #0009);
}
#menu-root :is(#home-drive,#home-import) .official-route-car > .content-preview:not([data-preview=ready]) {
  visibility: hidden;
}
#menu-root :is(#home-drive,#home-import) .official-route-vehicle {
  min-width: 0;
  text-align: center;
  color: var(--cl-ink);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#menu-root :is(#home-drive,#home-import) .official-route-card .route-history {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 4px;
  font-size: 10px;
  opacity: .8;
}
#menu-root :is(#home-drive,#home-import) .official-route-card[data-completed=yes] .route-history {
  color: var(--cl-sage);
}
#menu-root :is(#home-drive,#home-import) :is(#route-cards,#local-map-list) .official-route-card[aria-pressed=true] {
  border-color: var(--cl-accent);
  box-shadow: 0 0 0 1px var(--cl-accent), 0 5px 20px #ffd05c20;
}
#menu-root :is(#home-drive,#home-import) :is(#route-cards,#local-map-list) .official-route-card[aria-pressed=true]::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 3px 0 var(--cl-accent), inset 0 0 24px #ffd05c0a;
  pointer-events: none;
}
#menu-root :is(#home-drive,#home-import) .official-route-card[aria-pressed=true] .official-route-number {
  color: var(--cl-accent);
}
#menu-root :is(#home-drive,#home-import) .official-route-card:focus-visible {
  outline: 3px solid var(--cl-accent);
  outline-offset: -4px;
}
@media (hover: hover) {
  #menu-root :is(#home-drive,#home-import) .official-route-card:not([aria-pressed=true]):hover {
    border-color: var(--cl-sage);
  }
}
@media (max-width: 760px) {
  #menu-root :is(#home-drive,#home-import) :is(#route-cards,#local-map-list) {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}


/* Custom map actions are siblings of the selection button: no nested buttons. */
#menu-root #home-import .custom-route-shell { position:relative;min-width:0;display:flex; }
#menu-root #home-import #local-map-list .official-route-card { height:100%; }
#menu-root #home-import .custom-route-actions { position:absolute;z-index:4;right:10px;bottom:13px;display:flex;gap:6px; }
#menu-root #home-import .custom-route-actions button { display:grid;place-items:center;width:44px;height:44px;min-height:44px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--cl-ink);cursor:pointer; }
#menu-root #home-import .custom-route-actions button:last-child { color:var(--cl-danger); }
#menu-root #home-import .custom-route-actions button:focus-visible { outline:2px solid var(--cl-accent);outline-offset:2px; }

/* Status and actions share the final row; title and description retain full width.
   Actions remain sibling buttons, preserving keyboard access and valid markup. */
#menu-root #home-import .custom-route-shell .official-route-body { padding-bottom:12px; }
#menu-root #home-import .custom-route-shell .official-route-body .route-detail {
 display:flex;align-items:center;align-self:end;box-sizing:border-box;
 min-height:44px;padding-right:94px;
}
@media(hover:hover){
 #menu-root #home-import .custom-route-actions button:hover { background:#ffffff12;color:var(--cl-accent); }
 #menu-root #home-import .custom-route-actions button:last-child:hover { background:#ffb5a515;color:var(--cl-danger); }
}


/* Community cards: inset preview, image captions, and compact actions. */
:is(#menu-root #home-community,body[data-page=community]) #map-grid {
 display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,300px),1fr));gap:16px;align-items:stretch;min-width:0;width:100%;box-sizing:border-box;
}
.community-route-card {
 display:flex;flex-direction:column;min-width:0;overflow:hidden;padding:8px;box-sizing:border-box;
 border:1px solid var(--cl-line,#bcd4b425);border-radius:12px;background:var(--cl-panel,#20392f);color:var(--cl-ink,#f4f3e7);
}
.community-route-card button.community-route-cover {
 display:block;flex:none;width:100%;min-height:0;margin:0;padding:0;border:0;border-radius:0;
 height:100%;background:#142832;overflow:hidden;cursor:pointer;
}
.community-route-card .community-route-cover > .content-preview {
 display:block;width:100%;height:100%;max-width:none;margin:0;border:0;border-radius:0;aspect-ratio:24/13;object-fit:contain;
}
.community-route-copy { display:flex;flex:1;flex-direction:column;gap:5px;min-width:0;margin:0;padding:10px 7px 0; }
.community-route-heading h2 { margin:0;padding:0;font:600 24px/1.15 'Barlow Condensed',sans-serif;overflow-wrap:anywhere; }
.community-route-card button.community-route-title { display:block;width:100%;margin:0;padding:0;min-height:30px;border:0;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer; }
.community-route-card .community-route-author { align-self:flex-start;color:var(--cl-sage,#afe2ba);font-size:10px;line-height:1.5;text-decoration:none; }
.community-route-card .community-route-description { margin:3px 0;color:var(--cl-muted,#b8cbbd);font-size:11px;line-height:1.5;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.community-route-card :is(.community-route-stats,.community-route-difficulty) { margin:0;color:var(--cl-ink,#f4f3e7);font-size:10px;line-height:1.5;white-space:nowrap; }
.community-route-metadata { display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:3px 10px;margin-left:auto;text-shadow:0 1px 5px #000; }
.community-route-actions { display:grid;grid-template-columns:minmax(0,1fr) 40px 40px;align-items:center;column-gap:2px;margin-top:auto;padding-top:6px;border-top:1px solid var(--cl-line,#bcd4b425); }
.community-route-vehicle { position:absolute;z-index:2;top:5px;right:7px;display:flex;flex-direction:column;align-items:center;gap:0;width:min(45%,150px);min-width:0;pointer-events:none;isolation:isolate; }
.community-route-vehicle .content-preview { flex:none;display:block;width:100%;height:74px;object-fit:contain;aspect-ratio:auto;margin:0;border-radius:0;background:none; }
.community-route-vehicle .content-preview:not([data-preview=ready]) { visibility:hidden; }
.community-route-vehicle span { min-width:0;font-size:10px;line-height:1.4;color:var(--cl-muted,#b8cbbd);overflow-wrap:anywhere; }
.community-route-card .community-route-actions :is(button,a) { display:grid;place-items:center;box-sizing:border-box;width:40px;min-height:44px;margin:0;padding:0;border:0;border-radius:7px;background:transparent;color:var(--cl-muted,#b8cbbd);cursor:pointer;text-decoration:none; }
.community-route-card .community-route-actions .community-route-play { display:flex;justify-content:center;gap:5px;width:auto;min-width:52px;padding:0 5px;background:transparent;color:var(--cl-accent,#ffd05c);font-size:11px;font-weight:650; }
.community-route-play::after { content:'→'; }
.community-route-card :is(button,a):focus-visible { outline:2px solid var(--cl-accent,#ffd05c);outline-offset:-3px; }
.community-route-card:focus-within { border-color:var(--cl-accent,#ffd05c); }
@media(hover:hover){
 .community-route-card:hover { border-color:#bcd4b45c; }
 .community-route-card .community-route-actions :is(button,a):hover { background:#ffffff0c;color:var(--cl-accent,#ffd05c); }
 .community-route-card .community-route-title:hover,.community-route-card .community-route-author:hover { color:var(--cl-accent,#ffd05c); }
}
@media(max-width:760px){ :is(#menu-root #home-community,body[data-page=community]) #map-grid { grid-template-columns:minmax(0,1fr);gap:12px; } }

.community-route-preview { position:relative;isolation:isolate;aspect-ratio:24/13;min-height:180px;overflow:hidden;border-radius:8px;background:#142832; }
.community-route-preview::after { content:'';position:absolute;inset:0;z-index:1;pointer-events:none;background:linear-gradient(180deg,transparent 40%,#07161350 60%,#071613eb 100%); }
.community-route-heading { position:absolute;z-index:2;left:12px;right:12px;bottom:10px;pointer-events:none; }
.community-route-heading :is(button,a) { pointer-events:auto; }
.community-route-heading h2 { text-shadow:0 2px 8px #0008; }
.community-route-identity { display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;min-width:0; }
.community-route-identity .community-route-author { min-width:0;overflow-wrap:anywhere; }
/* Compact activity metadata; keep the preview and map title dominant. */
.community-route-counts { display:flex;flex-wrap:wrap;align-items:center;gap:4px 16px;margin:0 0 3px;color:var(--cl-ink,#f4f3e7); }
.community-route-counts > span { display:inline-flex;align-items:center;gap:4px;min-width:0;line-height:1.5; }
.community-route-counts strong { font-size:12px;font-weight:650;font-variant-numeric:tabular-nums; }
.community-route-counts .community-route-count-label { font-size:11px;color:var(--cl-muted,#b8cbbd); }
.community-route-counts svg { flex-shrink:0;width:12px;height:12px;opacity:.65; }
.community-route-counts > [data-active=true] svg { color:var(--cl-sage,#afe2ba);opacity:1; }
.community-route-preview .community-route-vehicle span { text-align:center;color:var(--cl-ink,#f4f3e7);text-shadow:0 1px 5px #000; }
.community-route-vehicle::before { content:'';position:absolute;inset:-8px -16px;z-index:-1;background:radial-gradient(ellipse,#03100ec9,transparent 72%); }
