/* ============================================================
   The title screen
   Four layers, back to front:
     #titleFx     the backdrop: a canvas drawn by engine/title.js
     #titleGrade  the grade over it
     .hero        the lettering, the menu and the live board
     #titleFoot   the ticker and the small print
   The first two are position:fixed: .screen scrolls on short viewports, and
   the backdrop must not scroll with it.
   ============================================================ */

#titleScreen{
  /* Deeper and colder than the shared screen gradient, with the light coming
     from where the strip light on the canvas is. */
  background:
    radial-gradient(1100px 620px at 50% 8%,rgba(255,111,145,.10),transparent 62%),
    radial-gradient(900px 700px at 50% 100%,rgba(180,140,255,.06),transparent 70%),
    linear-gradient(180deg,#0f1620,var(--ink) 55%,#080b10);
  /* No justify-content here: responsive.css switches .screen to flex-start on
     short viewports, and an id selector would override it. */
}
#titleFx{position:fixed;inset:0;width:100%;height:100%;z-index:0;pointer-events:none}

/* The grade. Scanlines at 3px, a vignette, and a very slight screen-door — it
   is a monitor bolted to a ceiling, not a web page. */
#titleGrade{
  position:fixed;inset:0;z-index:1;pointer-events:none;
  background:
    repeating-linear-gradient(180deg,rgba(0,0,0,.22) 0 1px,transparent 1px 3px),
    radial-gradient(120% 90% at 50% 45%,transparent 40%,rgba(0,0,0,.55) 100%);
  mix-blend-mode:multiply;opacity:.85;
}
/* The strip light on the fourth floor has never been right. Twice in eleven
   seconds, for a frame and a half. */
#titleFlicker{
  position:fixed;inset:0;z-index:1;pointer-events:none;
  background:rgba(190,215,255,.055);opacity:0;
  animation:striplight 11s steps(1,end) infinite;
}
@keyframes striplight{
  0%,90%,100%{opacity:0}
  90.6%{opacity:1}
  91.2%{opacity:0}
  92.4%{opacity:.7}
  93%{opacity:0}
}

#titleScreen .hero{position:relative;z-index:2;max-width:min(860px,100%);width:100%}

/* ---------- the strip across the top ---------- */
.hero-strip{
  display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;justify-content:center;
  font-family:var(--mono);font-size:10px;letter-spacing:.2em;text-transform:uppercase;
  color:var(--dim);margin-bottom:20px;
}
.hero-strip b{color:var(--hold);font-weight:400}
.hero-live{display:inline-flex;align-items:center;gap:7px;color:var(--bad)}
.hero-live i{width:7px;height:7px;border-radius:50%;background:var(--bad);
  box-shadow:0 0 0 0 rgba(255,95,86,.6);animation:onair 2.2s ease-out infinite}
@keyframes onair{0%{box-shadow:0 0 0 0 rgba(255,95,86,.55)}70%,100%{box-shadow:0 0 0 9px rgba(255,95,86,0)}}


/* ---------- the lettering ----------
   Printed slightly out of register: a blue plate one way, an amber the other. */
.title-line1{
  font-family:var(--mono);font-size:clamp(30px,7.6vw,68px);font-weight:700;
  letter-spacing:.035em;line-height:.95;color:var(--text);
  text-shadow:
    2px 0 0 rgba(255,111,145,.36),
    -2px 0 0 rgba(255,179,71,.16),
    0 0 38px rgba(255,111,145,.28);
}
.title-line2{
  font-family:var(--mono);font-size:clamp(21px,5.2vw,46px);font-weight:700;
  color:var(--hold);letter-spacing:.09em;line-height:1.08;margin-top:2px;
  text-shadow:0 0 30px rgba(255,179,71,.32),-2px 0 0 rgba(255,95,86,.18);
  animation:signflicker 9s steps(1,end) infinite;
}
/* The second line is the bit of the sign that has gone. */
@keyframes signflicker{
  0%,82%,100%{opacity:1}
  83%{opacity:.42}
  83.7%{opacity:1}
  85%{opacity:.6}
  85.6%{opacity:1}
}
/* The line under it is a phone line: something goes along it every few seconds. */
.title-rule{
  position:relative;overflow:hidden;height:1px;margin:18px auto 0;width:min(540px,86%);
  background:linear-gradient(90deg,transparent,var(--line),transparent);
}
.title-rule::after{
  content:"";position:absolute;top:0;left:-34%;width:34%;height:100%;
  background:linear-gradient(90deg,transparent,var(--brand),transparent);
  animation:linesweep 5.2s ease-in-out infinite;
}
@keyframes linesweep{0%{left:-34%}58%,100%{left:100%}}

.tagline{margin-top:16px;font-size:clamp(14px,2.4vw,19px);color:var(--text)}
.tagline small{display:block;color:var(--dim);font-size:13px;margin-top:6px;font-style:italic}

/* ---------- the menu ---------- */
.title-menu{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:26px}
.title-menu .btn{position:relative;padding:12px 20px 12px 30px;font-size:15px}
/* The marker sits in padding reserved for it, so the label does not jump
   sideways as the selection moves down the menu. */
.title-menu .btn::before{
  content:"▸";position:absolute;left:13px;top:50%;transform:translateY(-50%);
  color:var(--hold);opacity:0;transition:opacity .12s;
}
.title-menu .btn.sel::before{opacity:1}
.title-menu .btn.sel{border-color:var(--brand);
  box-shadow:0 0 0 1px rgba(255,111,145,.22),0 12px 34px -16px var(--brand)}
.title-menu .btn:disabled::before{content:"·";color:var(--dim)}
.title-menu[hidden]{display:none}
/* Multiplayer: host, or a code and Join side by side, and a line on what happens next. */
.coop-join{display:inline-flex;gap:6px;align-items:stretch}
.title-menu .coop-join .btn{width:auto;flex:1 0 auto}
#coopCode{width:8.5em;background:rgba(10,2,20,.55);border:2px solid rgba(255,255,255,.14);border-radius:var(--pill,999px);
  color:var(--text);font-family:var(--mono);font-size:16px;letter-spacing:.2em;text-align:center;text-transform:uppercase;padding:8px 12px;flex:1 1 8.5em;min-width:0}
#coopCode:focus{outline:none;border-color:var(--brand)}
.coop-note{flex-basis:100%;margin:4px 0 0;color:var(--dim);font-size:13px;text-align:center}
.coop-note.bad{color:var(--bad)}

/* ---------- the wallboard ----------
   The thing bolted above the desks. Bordered, backed, and slightly luminous,
   because on a real floor it is the only object in the room emitting light. */
.board{
  margin:26px auto 0;width:min(560px,100%);
  border:1px solid var(--line);border-radius:var(--radius);
  background:linear-gradient(180deg,rgba(27,34,48,.78),rgba(10,14,20,.78));
  box-shadow:0 30px 70px -34px #000,inset 0 1px 0 rgba(255,255,255,.05);
  overflow:hidden;
}
@supports (backdrop-filter:blur(4px)){ .board{backdrop-filter:blur(4px)} }
.board-head{
  font-family:var(--mono);font-size:10px;letter-spacing:.22em;text-transform:uppercase;
  color:var(--dim);padding:9px 14px;border-bottom:1px dashed var(--line);
  display:flex;justify-content:space-between;gap:10px;
}
.board-head b{color:var(--brand);font-weight:400}
.board-cells{display:grid;grid-template-columns:repeat(3,1fr)}
.cell{padding:12px 8px 13px;text-align:center;border-left:1px solid var(--line-soft)}
.cell:first-child{border-left:0}
.cell-n{
  display:block;font-family:var(--mono);font-size:clamp(24px,5.4vw,34px);line-height:1;
  color:var(--text);font-variant-numeric:tabular-nums;transition:color .3s;
  text-shadow:0 0 22px rgba(255,111,145,.22);
}
.cell-n.warn{color:var(--hold);text-shadow:0 0 22px rgba(255,179,71,.3)}
.cell-n.bad{color:var(--bad);text-shadow:0 0 22px rgba(255,95,86,.3)}
.cell-l{display:block;margin-top:7px;font-family:var(--mono);font-size:9px;
  letter-spacing:.16em;text-transform:uppercase;color:var(--dim)}
.board-note{
  font-family:var(--mono);font-size:10px;letter-spacing:.14em;text-transform:uppercase;
  color:var(--dim);padding:8px 14px;border-top:1px dashed var(--line);
  background:rgba(0,0,0,.22);
}

/* ---------- the foot: ticker, then the small print ---------- */
#titleFoot{
  position:absolute;left:0;right:0;bottom:calc(12px + env(safe-area-inset-bottom));
  z-index:2;pointer-events:none;
}
.ticker{
  position:relative;overflow:hidden;border-top:1px solid var(--line-soft);
  border-bottom:1px solid var(--line-soft);background:rgba(0,0,0,.3);
  padding:7px 0;margin-bottom:10px;
  /* Feathered at both ends so lines arrive and leave rather than appearing. */
  -webkit-mask-image:linear-gradient(90deg,transparent,#000 7%,#000 93%,transparent);
  mask-image:linear-gradient(90deg,transparent,#000 7%,#000 93%,transparent);
}
.ticker-run{display:flex;width:max-content;animation:tickerrun 96s linear infinite}
.tk-item{
  font-family:var(--mono);font-size:10px;letter-spacing:.12em;color:#7d8ba6;
  white-space:nowrap;padding-right:34px;position:relative;
}
.tk-item::after{content:"▸";position:absolute;right:12px;color:var(--hold);opacity:.55}
/* The list is written into the page twice; half the width is exactly one copy. */
@keyframes tickerrun{from{transform:translateX(0)}to{transform:translateX(-50%)}}

.legal{
  font-family:var(--mono);font-size:10px;color:#5a6782;letter-spacing:.08em;
  padding:0 16px;text-align:center;
}
.legal .copyright{display:block;margin-top:5px;color:#6b7a96}
/* The block stays click-through so it cannot steal a tap from the menu; the
   licence link is the one thing in it that has to remain clickable. */
.legal a{color:inherit;pointer-events:auto;text-decoration:underline;text-underline-offset:2px}
.legal a:hover{color:var(--brand)}

/* ---------- calm ----------
   Everything that moves, stopped. The canvas stops itself (engine/title.js).
   Nothing is conveyed only by movement. */
@media (prefers-reduced-motion:reduce){
  .title-line2,.title-rule::after,.hero-live i,.ticker-run{animation:none}
  #titleFlicker{display:none}
  .ticker-run{transform:none}
}
body.calm-title .title-line2,
body.calm-title .title-rule::after,body.calm-title .hero-live i,body.calm-title .ticker-run{animation:none}
body.calm-title #titleFlicker{display:none}

/* ============================================================
   Low Tide: the sunset. The canvas is the whole backdrop, so the CRT grade
   and flicker come off and the lettering is warm.
   ============================================================ */
#titleScreen{background:#2a1446}
#titleGrade{background:radial-gradient(120% 90% at 50% 40%,transparent 45%,rgba(20,6,30,.55) 100%);mix-blend-mode:normal;opacity:1}
#titleFlicker{display:none}
.title-line1{
  font-family:"Trebuchet MS","Segoe UI",sans-serif;font-weight:800;letter-spacing:.08em;
  font-size:clamp(46px,11vw,104px);color:#fff4dc;
  text-shadow:0 3px 0 #b33a6b,0 6px 0 #6b2d63,0 0 42px rgba(255,160,90,.55);
}
.title-line2{
  font-family:var(--ui);font-weight:700;font-size:clamp(12px,2.6vw,20px);letter-spacing:.28em;
  color:#ffd08a;animation:none;text-shadow:0 2px 12px rgba(80,10,60,.8);margin-top:10px;
}
.title-rule::after{background:linear-gradient(90deg,transparent,#ffd08a,transparent)}
.tagline{text-shadow:0 2px 10px rgba(40,6,40,.9)}
.tagline small{color:#ffd9e6}
.hero-strip{color:#ffd9e6;text-shadow:0 1px 6px rgba(40,6,40,.8)}
.hero-live{color:#ffd08a}
.hero-live i{background:#ffd08a}
.board{background:linear-gradient(180deg,rgba(60,20,70,.62),rgba(26,12,40,.72));border-color:rgba(255,190,150,.35)}
.cell-n{text-shadow:0 0 22px rgba(255,160,90,.35);color:#fff1e6}
.title-menu .btn.sel{border-color:var(--hold);box-shadow:0 0 0 1px rgba(255,179,71,.3),0 12px 34px -16px var(--hold)}
@media (max-width:640px),(max-height:620px){
  #titleScreen .board{display:none}
  .title-line2{letter-spacing:.18em}
  /* On a phone the blurb under the quote was a paragraph between the name and
     the menu: the quote alone says it. */
  .tagline small{display:none}
}

/* The loading screen (engine/boot.js, Loading): the title's dusk, the name,
   a bar, and a line about what the island is doing. */
#loading{position:fixed;inset:0;z-index:9000;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(900px 520px at 50% 40%,rgba(255,111,145,.14),transparent 65%),linear-gradient(180deg,#2a1446,#120b1e 70%,#080b10);
  opacity:0;transition:opacity .3s ease}
/* On at once (the work after it holds the page); it fades only going. */
#loading.on{opacity:1;transition:none}
#loading[hidden]{display:none}
.ld-box{width:min(420px,calc(100% - 32px));text-align:center}
.ld-title{font-family:var(--display);font-weight:800;font-size:clamp(26px,6vw,40px);letter-spacing:.12em;color:#ffc46b;text-shadow:0 2px 0 #b33a6b,0 0 24px rgba(255,122,89,.35)}
.ld-bar{height:8px;margin:22px 0 12px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden;border:1px solid rgba(255,255,255,.12)}
.ld-bar{position:relative}
.ld-bar i{display:block;height:100%;width:0;border-radius:999px;background:linear-gradient(90deg,#ff7a59,#ffc46b);transition:width .25s ease}
/* A sheen sweeping the bar: always while waiting, and it is all that moves
   while the island is built (a transform, so it runs off the main thread). */
.ld-bar::after,.title-wait i::after{content:'';position:absolute;top:0;bottom:0;left:0;width:40%;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.45),transparent);animation:ldSheen 1.1s linear infinite}
@keyframes ldSheen{from{transform:translateX(-100%)}to{transform:translateX(250%)}}
/* The title's own bar, in the menu's place until the game is in (index.html). */
.title-wait{display:flex;flex-direction:column;align-items:center;gap:10px;margin:22px auto 0;font-family:var(--mono);font-size:12px;letter-spacing:.06em;color:#ffe2c4;text-shadow:0 1px 6px rgba(40,6,40,.8)}
.title-wait i{position:relative;display:block;width:min(260px,70vw);height:6px;border-radius:999px;overflow:hidden;background:rgba(255,255,255,.18);border:1px solid rgba(255,255,255,.2)}
.ld-line{font-family:var(--mono);font-size:12px;letter-spacing:.04em;color:rgba(255,255,255,.7);min-height:1.4em}
@media (prefers-reduced-motion:reduce){#loading,.ld-bar i{transition:none}.ld-bar::after,.title-wait i::after{animation-duration:2.4s}}
