/* Cold open (lane A): js/coldopen.js. A full-viewport cinematic above everything, before the welcome gate.
   Sized from the real viewport (vmin/vw/vh), not the scaled #stage, so it frames phones in both orientations. */
.co { position: fixed; inset: 0; z-index: 5000; overflow: hidden; background: #07040f; color: #f6ecd8; user-select: none; -webkit-user-select: none;
  touch-action: none; -webkit-tap-highlight-color: transparent; font-family: "Old Standard TT", Georgia, serif; transition: opacity .4s ease; }
.co.out { opacity: 0; pointer-events: none; }
.co-stage { position: absolute; inset: 0; overflow: hidden; }
.co-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.co-vig { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, rgba(7, 4, 15, 0) 45%, rgba(7, 4, 15, .72) 100%),
    linear-gradient(180deg, rgba(4, 2, 10, .55) 0, rgba(4, 2, 10, 0) 16%, rgba(4, 2, 10, 0) 70%, rgba(4, 2, 10, .8) 100%); }
.co-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 45%, #fff 0, #d8b8ff 30%, rgba(150, 90, 255, 0) 75%); }

/* attempt counter */
.co-count { position: absolute; left: 50%; top: max(9vh, calc(env(safe-area-inset-top) + 56px)); transform: translateX(-50%); text-align: center; opacity: 0; pointer-events: none; }
.co-count small { display: block; font: 700 clamp(10px, calc(1vmin + 6px), 14px) Cinzel, Georgia, serif; letter-spacing: .35em; text-transform: uppercase; color: rgba(233, 220, 255, .7); }
.co-count b { display: block; font: 800 clamp(34px, calc(6vmin + 12px), 72px) Cinzel, Georgia, serif; font-variant-numeric: tabular-nums; color: rgba(240, 230, 255, .85); line-height: 1.05;
  text-shadow: 0 0 18px rgba(160, 100, 255, .6); transition: color .3s, text-shadow .3s; }
.co-count.hit b { color: #f5d38a; text-shadow: 0 0 26px rgba(242, 196, 106, .85), 0 0 60px rgba(160, 100, 255, .6); }

/* captions: Cinzel eyebrow, Old Standard narration */
.co-cap { position: absolute; left: 50%; bottom: max(10vh, calc(env(safe-area-inset-bottom) + 40px)); width: min(88vw, 920px); transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; }
.co-cap.on { animation: coCap .9s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes coCap { from { opacity: 0; transform: translate(-50%, 10px); filter: blur(6px); } to { opacity: 1; transform: translate(-50%, 0); filter: blur(0); } }
.co-cap small { display: block; margin-bottom: .55em; font: 700 clamp(10px, calc(1.1vmin + 7px), 16px) Cinzel, Georgia, serif; letter-spacing: .26em; text-transform: uppercase; color: #e9c46a;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
.co-cap.noeb small { display: none; }
.co-cap p { margin: 0; font: italic 400 clamp(19px, calc(2.6vmin + 9px), 38px)/1.3 "Old Standard TT", Georgia, serif; color: #f8efdc; text-wrap: balance;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .95), 0 0 2px rgba(0, 0, 0, .9); }
.co-cap.gold p { font: 700 clamp(20px, calc(2.8vmin + 10px), 42px)/1.25 Cinzel, Georgia, serif; font-style: normal; color: #f5d38a; letter-spacing: .02em;
  text-shadow: 0 0 22px rgba(242, 196, 106, .55), 0 2px 12px rgba(0, 0, 0, .95); }
.co-cap.big p { font: 900 clamp(30px, calc(5vmin + 12px), 68px)/1.1 Cinzel, Georgia, serif; font-style: normal; color: #fff4d6; letter-spacing: .03em;
  text-shadow: 0 0 30px rgba(242, 196, 106, .7), 0 3px 14px rgba(0, 0, 0, .95); }

/* end card: the logo and Begin */
.co-end { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 2vh, 22px); opacity: 0; pointer-events: none; }
.co-end.on { opacity: 1; pointer-events: auto; transition: opacity 1s ease; }
.co-logo { width: min(60vmin, 440px); aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 0 40px rgba(150, 90, 255, .45)); transform: scale(.92); transition: transform 2.4s cubic-bezier(.2, .7, .2, 1); }
.co-end.on .co-logo { transform: scale(1); }
.co-begin { appearance: none; border: 0; cursor: pointer; font: 800 clamp(16px, calc(1.6vmin + 10px), 24px) Cinzel, Georgia, serif; letter-spacing: .18em; text-transform: uppercase;
  padding: .85em 2.6em; border-radius: 999px; color: #2a1606; background: linear-gradient(180deg, #ffe7a8, #e0a93c 60%, #b77a1e);
  box-shadow: 0 0 0 2px rgba(255, 236, 190, .5) inset, 0 8px 30px rgba(242, 196, 106, .45), 0 0 60px rgba(150, 90, 255, .35); animation: coBegin 2.6s ease-in-out infinite; }
.co-begin:focus-visible { outline: 3px solid #fff4d6; outline-offset: 4px; }
@keyframes coBegin { 50% { box-shadow: 0 0 0 2px rgba(255, 236, 190, .6) inset, 0 8px 40px rgba(242, 196, 106, .7), 0 0 80px rgba(150, 90, 255, .5); } }
body.portrait .co-logo, .co-end .co-logo { max-height: 52vh; }

/* tap to begin (audio still locked) + loading */
.co-tap { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; cursor: pointer;
  background: radial-gradient(ellipse at 50% 45%, #1a0e33 0, #07040f 70%); transition: opacity .6s ease; }
.co.loading .co-tap, .co.tap .co-tap { display: flex; }
.co-tap.gone { opacity: 0; pointer-events: none; }
.co-tap b, .co-tap small { display: none; }
.co.tap .co-tap b { display: block; font: 800 clamp(20px, calc(2.4vmin + 12px), 34px) Cinzel, Georgia, serif; letter-spacing: .2em; text-transform: uppercase; color: #f5d38a;
  text-shadow: 0 0 20px rgba(242, 196, 106, .5); animation: coPulse 2.2s ease-in-out infinite; }
.co.tap .co-tap small { display: block; font: italic 400 clamp(13px, calc(1vmin + 9px), 18px) "Old Standard TT", Georgia, serif; color: rgba(240, 230, 255, .65); }
.co.tap:not(.ready) .co-tap b { opacity: .5; }
.co-tapgem { width: clamp(46px, 9vmin, 80px); aspect-ratio: .66; clip-path: polygon(50% 0, 100% 45%, 50% 100%, 0 45%);
  background: linear-gradient(160deg, #e6ccff, #9a5cff 45%, #3a0f8a); animation: coGem 2.2s ease-in-out infinite; }
@keyframes coPulse { 50% { opacity: .55; } }
@keyframes coGem { 50% { transform: scale(1.08); filter: brightness(1.35); } }

/* skip controls */
.co-skip { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); z-index: 3; appearance: none; cursor: pointer;
  font: 700 clamp(12px, calc(.8vmin + 9px), 15px) Cinzel, Georgia, serif; letter-spacing: .16em; text-transform: uppercase; color: rgba(246, 236, 216, .85);
  padding: 9px 18px; border-radius: 999px; border: 1px solid rgba(233, 196, 106, .45); background: rgba(10, 6, 20, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .4s, background .2s; }
.co-skip:hover, .co-skip:focus-visible { background: rgba(40, 24, 70, .7); color: #fff4d6; }
.co.ended .co-skip { opacity: 0; pointer-events: none; }
.co-hold { position: absolute; z-index: 4; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; opacity: 0; }
.co-hold svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.co-hold circle { fill: rgba(10, 6, 20, .35); stroke: #f5d38a; stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; }
.co-hold span { position: absolute; left: 50%; top: 100%; margin-top: 6px; transform: translateX(-50%); white-space: nowrap; font: 700 11px Cinzel, Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #f5d38a; text-shadow: 0 1px 6px #000; }
.co-hold.on { opacity: 1; transition: opacity .2s .15s; }
.co-hold.on circle { animation: coHold .75s .15s linear forwards; }
@keyframes coHold { to { stroke-dashoffset: 0; } }

/* ---------------- 2D version (Graphics: Low, reduced motion, no WebGL) ---------------- */
.c2 { position: absolute; inset: 0; overflow: hidden; }
.c2 > * { position: absolute; opacity: 0; visibility: hidden; }
.c2-bg { inset: -4%; background-size: cover; background-repeat: no-repeat; will-change: opacity, transform; }
.c2-bg[data-k="lab"], .c2-bg[data-k="archive"] { filter: saturate(.8) brightness(.8); }
.c2-crys { left: 62%; top: 47%; width: min(40vmin, 320px); aspect-ratio: 1; transform: translate(-50%, -50%); }
.c2-crys.logo { left: 50%; top: 45%; transform: translate(-50%, -50%) scale(.8); }
.c2-crys > * { position: absolute; }
.c2-halo { inset: -40%; border-radius: 50%; background: radial-gradient(circle, rgba(170, 110, 255, .75) 0, rgba(170, 110, 255, .2) 35%, rgba(170, 110, 255, 0) 65%); }
.c2-wave { inset: 0; border-radius: 50%; border: 3px solid rgba(230, 205, 255, .9); box-shadow: 0 0 24px rgba(200, 160, 255, .8); opacity: 0; }
.c2-gem { left: 32%; right: 32%; top: 6%; bottom: 30%; clip-path: polygon(50% 0, 100% 45%, 50% 100%, 0 45%);
  background: linear-gradient(150deg, #efdcff 0, #b27cff 30%, #7a3ae0 55%, #2a0a66 100%); }
.c2-coils { left: 14%; right: 14%; top: 50%; bottom: 4%; }
.c2-coils i { position: absolute; left: 0; right: 0; height: 18%; border-radius: 50%; border: 3px solid #c27a3e; box-shadow: 0 0 4px rgba(255, 170, 90, .3); }
.c2-coils i:nth-child(1) { top: 0; left: 8%; right: 8%; } .c2-coils i:nth-child(2) { top: 18%; left: 3%; right: 3%; } .c2-coils i:nth-child(3) { top: 36%; }
.c2-coils i:nth-child(4) { top: 54%; left: 3%; right: 3%; } .c2-coils i:nth-child(5) { top: 72%; left: 8%; right: 8%; background: #3a2418; border-color: #5a3620; }
.c2-coils.live i { box-shadow: 0 0 10px rgba(255, 180, 100, .7); border-color: #e09a55; }
.c2-shard { left: 50%; top: 40%; width: min(4vmin, 30px); aspect-ratio: .3; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); background: linear-gradient(160deg, #fff, #c9a0ff 40%, #7a3ae0); }
.c2-win { left: 50%; top: 44%; width: min(70vw, 118vh); aspect-ratio: 1.61; background-size: cover; background-position: 70% 42%;
  clip-path: polygon(0 45.2%, 22.5% 1.6%, 60% 0, 97.5% 29.8%, 100% 66.1%, 70% 100%, 27.5% 94.4%); }
body.portrait .c2-win, .co.portrait .c2-win { width: 94vw; }
.c2-eras { left: 50%; top: 45%; width: min(84vw, 132vh); margin-left: calc(min(84vw, 132vh) / -2); translate: 0 -50%; display: grid; grid-template-columns: 1fr 1fr; gap: 2.2vmin 3vmin; }
.c2-era { transition: none; }
.c2-art { position: relative; aspect-ratio: 16 / 9; background-size: cover; border: 2px solid #c89b3c; box-shadow: 0 6px 30px rgba(0, 0, 0, .6); }
.c2-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.c2-art line { stroke: #f0dcff; stroke-width: 1.6px; vector-effect: non-scaling-stroke; opacity: 0; filter: drop-shadow(0 0 2px #b27cff); }
.c2-era b { display: block; margin-top: .45em; text-align: center; font: 700 clamp(10px, calc(1vmin + 7px), 17px) Cinzel, Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #f5dca0; text-shadow: 0 1px 6px #000; }
.c2-falls, .c2-pages { opacity: 1; visibility: visible; }
.c2-falls { inset: 0; }
.c2-falls i { position: absolute; left: 0; top: 0; width: clamp(8px, 1.6vmin, 16px); aspect-ratio: .38; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  background: linear-gradient(160deg, #f3e6ff, #b27cff 40%, #5a1fb0); opacity: 0; visibility: hidden; }
.c2-pages { inset: 0; }
.c2-pages i { position: absolute; left: 50%; top: 46%; width: 8vmin; height: 10.6vmin; margin: -5.3vmin 0 0 -4vmin; opacity: 0; visibility: hidden; border-radius: 2px;
  background: repeating-linear-gradient(180deg, rgba(60, 40, 25, 0) 0 12%, rgba(60, 40, 25, .45) 12% 14%) 18% 16% / 64% 76% no-repeat, #efe2c2; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.c2-pages i.blank:not(.wrote) { background: linear-gradient(135deg, rgba(0, 0, 0, 0) 60%, rgba(150, 100, 255, .45) 60%), #d9cdb4; }
.c2-pages i.blank.wrote { box-shadow: 0 0 18px rgba(242, 196, 106, .8); }
.c2-card { left: 50%; top: 44%; height: min(60vh, 118vw); aspect-ratio: 2 / 3; border-radius: 3%; overflow: hidden;
  box-shadow: 0 0 0 3px #f2c46a, 0 0 60px rgba(242, 196, 106, .55), 0 20px 50px rgba(0, 0, 0, .6); }
.c2-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* portrait: one column of eras, bigger shard window */
@media (max-aspect-ratio: 9/10) {
  .c2-eras { grid-template-columns: 1fr; width: min(72vw, 30vh); margin-left: calc(min(72vw, 30vh) / -2); top: 42%; gap: 1.4vh; }
  .c2-crys { left: 50%; top: 56%; }
  .c2-win { width: 94vw; }
  .co-cap { bottom: max(9vh, calc(env(safe-area-inset-bottom) + 34px)); }
}
@media (prefers-reduced-motion: reduce) {
  .co-cap.on { animation: coCapCalm .6s ease both; }
  @keyframes coCapCalm { from { opacity: 0; } to { opacity: 1; } }
  .co-begin, .co-tapgem, .co.tap .co-tap b { animation: none; }
}
