/** The title screen and chooser. Drawn first: a dusk sky with twinkling
   pixel stars and a low stepped sun over drifting pixel wave bands, a warm
   glint on the water, the voxel boat bobbing; letterbox bars slide in, a
   vignette frames it, the heart-cube mark rises with a slow glow and a beating heart.
   `.sp-live` fades the live 3D hero in over the drawn scene and shows its
   caption; `.sp-choosing` lowers the cards to the bottom so the hero stays
   in view; `.sp-leave` fades to black before the game loads. Cards stack on
   phones and sit side by side on wide screens; every target is at least
   44 px; reduced motion stills everything. `.sp-opening` is the intro's
   black layer (`introview.mjs`) over everything until it has faded. */
body.splash > :not(#splash) { display: none !important; }
#splash {
  position: fixed; inset: 0; overflow: hidden; user-select: none; background: #0b0e1a;
  --bar: clamp(16px, 7vh, 64px);
}
#splash::after {
  content: ''; position: absolute; inset: 0; z-index: 9; background: #000; opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease-in;
}
#splash.sp-leave::after { opacity: 1; }

.sp-backdrop {
  position: absolute; inset: 0; z-index: 0; transition: opacity 1.6s ease;
  background: linear-gradient(#070912 0%, #121633 30%, #3a2a55 44%, #8a4560 51%, #e0875e 55%);
}
.sp-live .sp-backdrop { opacity: 0; }
.sp-stars { position: absolute; left: 0; right: 0; top: 0; height: 50%; -webkit-mask-image: linear-gradient(#000 40%, transparent); mask-image: linear-gradient(#000 40%, transparent); }
.sp-stars svg { display: block; width: 100%; height: 100%; }
.sp-stars .tw0 { animation: sp-twinkle 3.1s ease-in-out infinite; }
.sp-stars .tw1 { animation: sp-twinkle 4.3s ease-in-out -1.4s infinite; }
.sp-stars .tw2 { animation: sp-twinkle 5.7s ease-in-out -2.9s infinite; }
.sp-sun {
  position: absolute; left: 28%; top: calc(55% - min(9vw, 70px)); width: min(18vw, 140px); aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(circle, #fff1c9 0 26%, #ffc27a 27% 38%, rgba(255, 140, 90, 0.55) 39% 52%, rgba(255, 110, 90, 0.18) 53% 70%, transparent 71%);
  filter: drop-shadow(0 0 30px rgba(255, 150, 90, 0.6));
}
.sp-sea { position: absolute; left: 0; right: 0; top: 55%; bottom: 0; display: flex; flex-direction: column; background: #121c30; }
.sp-glint {
  position: absolute; z-index: 2; left: 28%; top: 0; width: min(14vw, 110px); height: 46%; transform: translateX(-50%); pointer-events: none;
  background: repeating-linear-gradient(transparent 0 5px, rgba(255, 190, 120, 0.55) 5px 7px);
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent);
  animation: sp-shimmer 2.4s steps(4) infinite;
}
.sp-boat {
  position: absolute; left: 62%; top: -24px; z-index: 0; line-height: 0;
  transform-origin: 50% 85%; animation: sp-bob 3.8s ease-in-out infinite;
}
.sp-boat svg { display: block; }
.sp-band {
  position: relative; z-index: 1; flex: none; height: 40px; margin-top: -4px;
  background-repeat: repeat-x; background-position: 0 0; background-size: var(--tile) auto; image-rendering: pixelated;
  animation: sp-drift var(--secs) linear infinite;
}
.sp-far { margin-top: 0; height: 18px; }
.sp-near { flex: 1 0 40px; }

.sp-hero { position: absolute; inset: 0; z-index: 1; }
.sp-hero-canvas {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block;
  opacity: 0; transition: opacity 1.4s ease, transform 0.6s ease-in;
}
.sp-hero-canvas.on { opacity: 1; }
.sp-leave .sp-hero-canvas { transform: scale(1.06); }
.sp-vignette {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(4, 5, 10, 0.75) 100%), linear-gradient(rgba(4, 5, 10, 0.55), transparent 32%, transparent 70%, rgba(4, 5, 10, 0.6));
}
.sp-bar { position: absolute; left: 0; right: 0; z-index: 3; height: var(--bar); background: #000; pointer-events: none; transition: transform 0.6s ease; }
.sp-bar-top { top: 0; animation: sp-bar-top 1.1s ease-out backwards; }
.sp-bar-bottom { bottom: 0; animation: sp-bar-bottom 1.1s ease-out backwards; }
.sp-choosing .sp-bar-top { transform: translateY(-100%); }
.sp-choosing .sp-bar-bottom { transform: translateY(100%); }

.sp-intro { position: absolute; inset: 0; z-index: 4; transition: opacity 0.4s ease; }
.sp-choosing .sp-intro { opacity: 0; pointer-events: none; }
.sp-intro { --mark: clamp(150px, 34vh, 320px); }
.sp-title {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + var(--bar) + 7vh); margin: 0; height: var(--mark); text-align: center;
  animation: sp-rise 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both, sp-glow 6s ease-in-out 1.6s infinite;
}
.sp-title svg { display: inline-block; height: 100%; width: auto; max-width: calc(100vw - 32px); filter: drop-shadow(0 0 22px rgba(255, 179, 71, 0.4)) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.75)); }
.sp-title .vl-heart { transform-box: fill-box; transform-origin: 50% 60%; animation: sp-beat 2.4s ease-in-out 1.8s infinite; }
.sp-tagline {
  position: absolute; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + var(--bar) + 7vh + var(--mark) + 14px); margin: 0; text-align: center;
  font: 600 clamp(13px, 3.4vw, 19px)/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.32em; text-transform: uppercase; color: #e9dcc8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8); animation: sp-fade 1.2s ease 1.1s both;
}
.sp-enter {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--bar) + 5vh); transform: translateX(-50%); z-index: 2;
  min-height: 56px; padding: 0 48px; font-size: 20px; font-weight: 800; letter-spacing: 0.3em; color: #fff;
  background: rgba(12, 16, 28, 0.55); border: 2px solid rgba(127, 214, 228, 0.8); border-radius: 4px;
  box-shadow: 0 0 24px rgba(31, 179, 204, 0.35), inset 0 0 18px rgba(31, 179, 204, 0.15);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: sp-fade 1s ease 1.5s both, sp-pulse 2.8s ease-in-out 2.5s infinite;
}
.sp-enter:hover { background: rgba(31, 179, 204, 0.25); }
.sp-enter:focus-visible, .sp-card:focus-visible, .sp-back:focus-visible { outline: 3px solid #7fd6e4; outline-offset: 3px; }
.sp-opening-run .sp-title, .sp-opening-run .sp-title .vl-heart { animation: none; }
.sp-opened .sp-title { animation: sp-glow 6s ease-in-out infinite; }
.sp-opening { position: absolute; inset: 0; z-index: 10; background: #000; cursor: pointer; touch-action: manipulation; }
.sp-opening svg { position: absolute; left: 20vw; top: 10vh; width: 60vw; height: 40vh; display: block; overflow: visible; }
.sp-caption {
  position: absolute; z-index: 4; left: calc(env(safe-area-inset-left) + 18px); bottom: calc(env(safe-area-inset-bottom) + var(--bar) + 12px); margin: 0;
  font: 700 12px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.22em; text-transform: uppercase; color: #e9dcc8;
  text-shadow: 0 1px 6px #000; opacity: 0; transition: opacity 0.8s ease, bottom 0.6s ease;
}
.sp-caption::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 10px; background: #e5484d; box-shadow: 0 0 8px #e5484d; animation: sp-twinkle 1.6s steps(2) infinite; }
.sp-live .sp-caption:not(:empty) { opacity: 0.9; }
.sp-choosing .sp-caption { bottom: auto; top: calc(env(safe-area-inset-top) + 16px); }

.sp-choose {
  position: absolute; inset: 0; z-index: 5; overflow-y: auto; overflow-x: hidden; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 44px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + 16px);
  background: linear-gradient(transparent 20%, rgba(6, 8, 14, 0.55) 55%, rgba(6, 8, 14, 0.92));
  animation: sp-fade 0.35s ease both;
}
.sp-choose h2 { margin: auto 0 0; font: 800 clamp(18px, 4vw, 26px)/1 ui-monospace, Menlo, Consolas, monospace; color: #fff; letter-spacing: 0.3em; text-transform: uppercase; text-shadow: 0 2px 12px #000; }
.sp-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: 100%; max-width: 1560px; }
.sp-card {
  --accent: #6b9be0;
  display: flex; flex-direction: row; align-items: stretch; gap: 14px; text-align: left; box-sizing: border-box;
  width: min(360px, 100%); min-height: 132px; padding: 14px 16px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.12); border-top: 3px solid var(--accent);
  background: linear-gradient(160deg, rgba(30, 36, 52, 0.88), rgba(12, 14, 22, 0.92)); color: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: sp-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.sp-card:nth-child(2) { animation-delay: 0.06s; }
.sp-card:nth-child(3) { animation-delay: 0.12s; }
.sp-card:nth-child(4) { animation-delay: 0.18s; }
.sp-card:hover, .sp-card:focus-visible { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 22px color-mix(in srgb, var(--accent) 45%, transparent); }
.sp-art-boat { --accent: #1fb3cc; }
.sp-art-tower { --accent: #ffd27a; }
.sp-art-house { --accent: #c46a4e; }
.sp-art-freighter { --accent: #a78bfa; }
.sp-card-art {
  flex: none; width: 84px; display: flex; align-items: center; justify-content: center; border-radius: 6px;
  background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%), rgba(0, 0, 0, 0.3);
}
.sp-card-art svg { max-width: 76px; height: auto; }
.sp-card-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sp-card-tag { font: 700 11px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
.sp-card-title { font-size: 22px; font-weight: 800; color: #fff; }
.sp-card-text { font-size: 13.5px; color: #cfd3dc; line-height: 1.45; }
.sp-card-go { margin-top: auto; font: 700 12px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); opacity: 0.8; }
.sp-back { min-height: 44px; padding: 0 28px; }

@keyframes sp-bob {
  0%, 100% { transform: translateY(0) rotate(-2.5deg); }
  50% { transform: translateY(3px) rotate(2.5deg); }
}
@keyframes sp-drift { from { background-position: 0 0; } to { background-position: var(--drift) 0; } }
@keyframes sp-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes sp-shimmer { 0% { transform: translateX(-50%) scaleX(1); } 50% { transform: translateX(-50%) scaleX(0.7); } 100% { transform: translateX(-50%) scaleX(1); } }
@keyframes sp-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes sp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sp-beat { 0%, 30%, 100% { transform: scale(1); } 10% { transform: scale(1.07); } 20% { transform: scale(1.02); } }
@keyframes sp-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
@keyframes sp-pulse { 0%, 100% { box-shadow: 0 0 24px rgba(31, 179, 204, 0.35), inset 0 0 18px rgba(31, 179, 204, 0.15); } 50% { box-shadow: 0 0 40px rgba(31, 179, 204, 0.6), inset 0 0 22px rgba(31, 179, 204, 0.3); } }
@keyframes sp-bar-top { from { transform: translateY(-100%); } }
@keyframes sp-bar-bottom { from { transform: translateY(100%); } }
@media (max-width: 560px) {
  .sp-card { min-height: 0; }
  .sp-card-art { width: 64px; }
  .sp-card-art svg { max-width: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  #splash *, #splash *::before, #splash::after { animation: none !important; transition: none !important; }
}
