/* Shared safeguards for mobile Safari, Chromium and tablet browsers. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: #0c100f; }
body { isolation: isolate; }
main, section, .world-copy, .world-challenge, .mechanics-list, .baseline, .competition-flow article, .play-inner { min-width: 0; }
h2, h3 { overflow-wrap: break-word; }
.river-map svg { max-width: 100%; height: auto; }
.opening-actions a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.opening-rule-link { padding: 12px 4px; }
.wordmark { display: inline-flex; align-items: center; min-height: 44px; }
.footer-links a, .text-link { display: inline-flex; align-items: center; min-height: 44px; }
a { -webkit-tap-highlight-color: rgba(225,214,181,.18); touch-action: manipulation; }
.mist-veil.is-cleared .mist-bank, .mist-veil.is-cleared .mist-bank::before { will-change: auto; }

@media (max-width: 1100px) {
  section:not(#opening) { padding: 72px clamp(24px, 5vw, 48px); }
  .baseline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .baseline { padding: 28px; border: 0; }
  .baseline:first-child { padding-left: 28px; }
  .baseline:nth-child(odd) { border-right: 1px solid var(--color-border); }
  .baseline:nth-child(-n+2) { border-bottom: 1px solid var(--color-border); }
  .baseline h3 { min-height: 0; font-size: 26px; }
  .bot-index { margin-bottom: 22px; }
  .bot-title { margin: 10px 0 18px; }
  .baseline p:not(.bot-title) { font-size: 14px; line-height: 1.75; }
  .competition-flow { gap: 28px; }
  .ranking-order { gap: 18px; }
  .match-strip span { padding-inline: 12px; gap: 12px; line-height: 1.5; }
}

@media (max-width: 900px) {
  .world-section, .mechanics-layout { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .world-copy, .section-heading { max-width: 650px; }
  .world-challenge { max-width: 650px; padding: 8px 0 8px 24px; }
  .world-copy > p:not(.section-kicker) { font-size: 19px; line-height: 1.75; }
  .river-map { position: static; width: 100%; max-width: 480px; justify-self: center; }
  .competition-flow { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .competition-flow article { padding: 28px 0; border-bottom: 1px solid var(--color-border); }
  .competition-flow article:first-child { padding-top: 0; }
  .competition-flow article:last-child { border-bottom: 0; padding-bottom: 0; }
  .competition-flow h3 { margin: 12px 0; }
  .competition-flow p { max-width: 650px; }
  .ranking-order { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .match-strip { padding: 24px; }
  .match-strip span { flex-direction: column; gap: 6px; text-align: center; font-size: 9px; }
  .section-heading { margin-bottom: 36px; }
  .prologue-full-text { grid-template-columns: 1fr; gap: 24px; padding: 20px; }
  .footer-inner { align-items: flex-start; }
}

@media (max-width: 600px) {
  .site-header { padding: 12px 24px; }
  .wordmark { font-size: 24px; }
  #opening { min-height: 100vh; min-height: 100svh; padding: 100px 24px 76px; }
  .opening-label { max-width: 280px; font-size: 10px; line-height: 1.7; letter-spacing: .15em; margin-bottom: 26px; }
  .opening-title { font-size: clamp(38px, 12vw, 72px); gap: 10px; margin-bottom: 24px; }
  .opening-pretitle { font-size: .3em; letter-spacing: .25em; }
  .opening-subtitle { max-width: 320px; font-size: 20px; line-height: 1.5; margin-bottom: 22px; }
  .opening-actions { width: 100%; max-width: 360px; justify-content: center; flex-wrap: wrap; gap: 10px 20px; }
  .opening-actions .btn-cta { font-size: 11px; padding: 14px 20px; }
  .opening-rule-link { font-size: 10px; }
  #opening .scroll-prompt { bottom: 20px; font-size: 9px; min-height: 44px; display: inline-flex; align-items: center; }
  section:not(#opening) { padding: 56px 24px; }
  h2 { font-size: clamp(28px, 7vw, 36px); line-height: 1.25; letter-spacing: 0; margin-bottom: 22px; }
  h3 { font-size: 23px; }
  .section-kicker { font-size: 10px; letter-spacing: .14em; margin-bottom: 18px; }
  .world-copy > p:not(.section-kicker) { font-size: 18px; line-height: 1.7; margin-bottom: 20px; }
  .world-challenge h3 { font-size: 29px; }
  .match-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 10px 24px; }
  .match-strip span { flex-direction: row; text-align: left; justify-content: flex-start; min-height: 76px; padding: 12px; font-size: 10px; gap: 12px; border-bottom: 1px solid var(--color-border); }
  .match-strip span:nth-child(even) { border-right: 0; }
  .match-strip span:last-child { grid-column: 1 / -1; border: 0; justify-content: center; }
  .match-strip strong { font-size: 27px; flex-shrink: 0; }
  .mechanics-list li { gap: 16px; padding-bottom: 24px; margin-bottom: 24px; }
  .mechanics-list p, .competition-flow p, .ready-list { font-size: 15px; line-height: 1.75; }
  .mechanic-number { flex-shrink: 0; }
  .ranking-panel { margin-top: 28px; padding: 24px 20px; }
  .ranking-order li { font-size: 14px; }
  .ranking-panel > p, .section-note { font-size: 13px; line-height: 1.8; }
  .play-intro { font-size: 20px; line-height: 1.5; }
  .ready-list { margin-block: 28px; padding-left: 20px; }
  .ready-list li { padding-left: 6px; }
  .ready-list a, .starter-kit-note a { display: inline-block; padding-block: 8px; }
  .state-active-content { flex-direction: column; gap: 12px; }
  .state-active-content .btn-cta { width: 100%; max-width: 320px; }
  .footer-inner { gap: 18px; }
  footer { padding: 32px 24px; }
  .footer-links { column-gap: 24px; row-gap: 4px; }
  .footer-title, .footer-subtitle, .footer-links a { font-size: 11px; }
  .leaderboard-table th, .leaderboard-table td { padding: 12px 10px; white-space: nowrap; }
}

@media (max-width: 520px) {
  .baseline-grid { grid-template-columns: minmax(0, 1fr); }
  .baseline, .baseline:first-child { padding: 26px 0; border: 0; border-bottom: 1px solid var(--color-border); }
  .baseline:nth-child(odd) { border-right: 0; }
  .baseline:last-child { border-bottom: 0; }
  .baseline h3 { font-size: 27px; }
  .baseline p:not(.bot-title) { font-size: 15px; line-height: 1.75; }
  .baseline .bot-tradeoff { margin-top: 16px; }
  .bot-index { margin-bottom: 16px; }
}

@media (max-width: 360px) {
  .opening-actions { flex-direction: column; gap: 6px; }
  #opening { padding-inline: 18px; }
  .opening-label { margin-bottom: 18px; }
  .opening-title { margin-bottom: 18px; }
  .opening-subtitle { font-size: 18px; margin-bottom: 14px; }
}

/* A stable large viewport prevents toolbar show/hide from resizing painted layers. */
@media (pointer: coarse), (max-width: 1100px) {
  body::before { filter: none; background-image: linear-gradient(180deg,rgba(8,13,11,.78),rgba(8,13,11,.94)), url('../assets/images/underworld_cavern.webp'); }
  .river-canvas, .mist-veil, body::before { height: 100vh; height: 100lvh; bottom: auto; }
  #play { background: linear-gradient(135deg,#101a14,#080d0b); }
  .btn-cta:hover { transform: none; }
  .opening-title { text-shadow: none; }
}

@media (max-height: 500px) and (orientation: landscape) and (max-width: 1100px) {
  #opening { padding: 70px 24px 52px; min-height: 100svh; }
  .site-header { padding-block: 6px; }
  .opening-label { max-width: none; font-size: 9px; line-height: 1.5; margin-bottom: 12px; }
  .opening-title { font-size: min(10vw, 18svh); gap: 8px; margin-bottom: 12px; }
  .opening-pretitle { font-size: .28em; }
  .opening-subtitle { font-size: 18px; line-height: 1.4; margin-bottom: 10px; }
  .opening-actions { flex-direction: row; max-width: none; gap: 20px; }
  #opening .scroll-prompt { bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .mist-veil { position: absolute; height: 100vh; height: 100svh; }
  *, *::before, *::after { scroll-behavior: auto !important; }
  .opening-title, .opening-label, .opening-subtitle, .opening-rule-link, .site-header { transition: none; }
}

.page-hidden .mist-bank::before, .page-hidden .scroll-prompt { animation-play-state: paused; }


/* Keep the full image width on tall screens. A viewport-width bank cropped the
   transparent inner silhouette, exposing a rectangular edge while parting. */
.mist-bank {
  width: max(180vw, 180vh);
  width: max(180vw, 180lvh);
}
