/* Trinity start screen: the hero (logo over the skyline) and the setup panel.
   Built by src/ui/StartScreen.js; the live skyline is src/render/Splash.js. */
#start-screen {
  --ss-font: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --ss-ink: #eef0fa;
  --ss-dim: rgba(214, 219, 245, 0.68);
  --ss-line: rgba(255, 255, 255, 0.13);
  --ss-glass: rgba(13, 15, 34, 0.6);
  --ss-card: rgba(255, 255, 255, 0.055);
  --ss-card-on: rgba(150, 125, 255, 0.2);
  --ss-accent: #c77dff;
  --ss-magenta: #ff4fd8;
  --ss-accent-2: #5ee0ff;
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background: #0a0b1c;
  color: var(--ss-ink);
  font-family: var(--ss-font);
  transition: opacity 0.5s ease, transform 0.5s ease, background-color 1.2s ease;
}
#start-screen.live { background: transparent; }
#start-screen.hidden { opacity: 0; transform: scale(1.04); pointer-events: none; }
#start-screen [hidden] { display: none !important; }

/* behind the page: the live city on the WebGPU canvas, and a light smog over it */
#start-screen .ss-back { position: absolute; inset: 0; pointer-events: none; }
#start-screen .ss-scrim {
  position: absolute; inset: 0;
  /* a neon night: magenta and cyan smog low over the city */
  background:
    radial-gradient(70% 55% at 8% 100%, rgba(255, 60, 200, 0.2) 0%, rgba(255, 60, 200, 0) 70%),
    radial-gradient(70% 55% at 92% 100%, rgba(40, 220, 255, 0.16) 0%, rgba(40, 220, 255, 0) 70%);
}

/* ---- two columns: the setup left, the board preview right ---- */
#start-screen .ss-layout {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: clamp(380px, 42vw, 540px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
#start-screen .ss-setup {
  min-width: 0; min-height: 0;
  overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(10px, 3vh, 30px) 16px 28px;
  /* dark behind the options, clear towards the preview */
  background: linear-gradient(90deg, rgba(8, 6, 26, 0.82) 0%, rgba(8, 6, 26, 0.6) 70%, rgba(8, 6, 26, 0) 100%);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
#start-screen .ss-setup::before, #start-screen .ss-setup::after { content: ""; flex: 1 1 0; }
/* the preview: a frame and nothing in it but the still skyline, which goes once the live city draws */
#start-screen .ss-preview {
  position: relative; min-width: 0; min-height: 0;
  margin: clamp(10px, 2vh, 22px) clamp(10px, 2vh, 22px) clamp(10px, 2vh, 22px) 6px;
  border-radius: 24px; border: 1px solid var(--ss-line);
  overflow: hidden; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 60px rgba(8, 6, 26, 0.35);
}
#skyline-still {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  background: linear-gradient(180deg, #05061a 0%, #170f45 45%, #5b1d7a 72%, #c2358f 90%, #ff5fb0 100%);
  transition: opacity 1.2s ease;
}
#start-screen.live #skyline-still { opacity: 0; }

/* ---- hero ---- */
#start-screen .hero { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 0 0 auto; }
#start-screen .logo-img {
  display: block;
  width: min(72vw, 30vh, 260px);
  min-width: 150px;
  height: auto; aspect-ratio: 1;
  margin: -2% 0 -3%;
  object-fit: contain;
  /* the art sits on a ground that was keyed out; the mask takes what is left of its square */
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, rgba(0, 0, 0, 0.5) 88%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 72%, rgba(0, 0, 0, 0.5) 88%, transparent 100%);
  filter: drop-shadow(0 0 26px rgba(150, 120, 255, 0.35)) drop-shadow(0 6px 22px rgba(0, 0, 0, 0.55));
  animation: ss-logo-in 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both, ss-logo-glow 5.5s ease-in-out 1.1s infinite alternate;
  user-select: none; -webkit-user-drag: none;
}
#start-screen .logo {
  display: none;
  margin: 0.4em 0 0.1em;
  font-size: clamp(2.4rem, 9vw, 4.6rem); font-weight: 200; letter-spacing: 0.32em; text-indent: 0.32em;
  color: #f4f4ff; text-shadow: 0 0 40px rgba(180, 140, 255, 0.55);
}
#start-screen.no-logo .logo-img { display: none; }
#start-screen.no-logo .logo { display: block; }
#start-screen .subtitle {
  margin: 0 0 clamp(12px, 2.4vh, 24px);
  font-size: clamp(0.7rem, 1.6vw, 0.86rem); letter-spacing: 0.34em; text-indent: 0.34em; text-transform: uppercase;
  color: rgba(150, 235, 255, 0.9); text-shadow: 0 0 14px rgba(40, 220, 255, 0.45), 0 1px 12px rgba(0, 0, 0, 0.8);
  animation: ss-rise 0.9s ease 0.25s both;
}
@keyframes ss-logo-in { from { opacity: 0; transform: translateY(14px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes ss-logo-glow {
  from { filter: drop-shadow(0 0 22px rgba(255, 80, 216, 0.3)) drop-shadow(0 6px 22px rgba(0, 0, 0, 0.55)); }
  to { filter: drop-shadow(0 0 40px rgba(110, 200, 255, 0.5)) drop-shadow(0 6px 22px rgba(0, 0, 0, 0.55)); }
}
@keyframes ss-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---- the panel ---- */
#start-screen .setup-panel {
  flex: 0 0 auto;
  width: min(520px, 100%);
  /* one column of options: the second column of the page is the board */
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px 26px;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--ss-line);
  background: linear-gradient(160deg, rgba(70, 30, 100, 0.5), var(--ss-glass) 45%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: ss-rise 0.8s ease 0.35s both;
}
#start-screen .setup-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
#start-screen .ss-h {
  margin: 0; display: flex; align-items: center; gap: 10px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ss-dim);
}
#start-screen .ss-h::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--ss-line), transparent); }
#start-screen .ss-h + .ss-h, #start-screen .seat-list + .ss-h { margin-top: 6px; }

/* a radio that is there for the keyboard and for readers, not for the eye */
#start-screen .ss-radio { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }

#start-screen .count-card, #start-screen .opt-card, #start-screen .seat-card {
  position: relative;
  border: 1px solid var(--ss-line); border-radius: 16px; background: var(--ss-card);
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
#start-screen .count-card, #start-screen .opt-card { cursor: pointer; }
#start-screen .count-card:hover, #start-screen .opt-card:hover { border-color: rgba(255, 255, 255, 0.32); transform: translateY(-1px); }
#start-screen .count-card.is-on, #start-screen .opt-card.is-on {
  border-color: var(--ss-accent); background: var(--ss-card-on);
  box-shadow: 0 0 0 1px var(--ss-accent), 0 10px 30px rgba(200, 90, 255, 0.28);
}
#start-screen .count-card:focus-within, #start-screen .opt-card:focus-within, #start-screen .level-pill:focus-within,
#start-screen .kind-toggle:focus-visible, #start-screen .seat-name:focus-visible,
#start-screen .start-button:focus-visible, #start-screen .watch-button:focus-visible {
  outline: 2px solid var(--ss-accent-2); outline-offset: 2px;
}

/* player count */
#start-screen .count-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#start-screen .count-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px 11px; }
#start-screen .count-num { font-size: 2.1rem; font-weight: 300; line-height: 1; }
#start-screen .count-word { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ss-dim); }
#start-screen .count-dots { display: flex; gap: 4px; margin-top: 7px; }
#start-screen .count-dots i { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px rgba(255, 255, 255, 0.2); }

/* seats */
#seat-list { display: flex; flex-direction: column; gap: 10px; }
#start-screen .seat-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 12px;
  padding: 10px 12px 10px 14px;
  border-left: 3px solid var(--seat);
  background: linear-gradient(90deg, color-mix(in srgb, var(--seat) 14%, transparent), var(--ss-card) 55%);
  animation: ss-rise 0.35s ease both;
}
#start-screen .seat-badge {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.85rem; font-weight: 700; color: #0b0c1c; background: var(--seat);
  box-shadow: 0 0 14px color-mix(in srgb, var(--seat) 55%, transparent);
}
#start-screen .seat-name {
  width: 100%; min-width: 0; padding: 7px 9px;
  font: 600 0.98rem/1.2 var(--ss-font); color: var(--ss-ink);
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
#start-screen .seat-name::placeholder { color: var(--ss-ink); opacity: 0.85; }
#start-screen .seat-name:hover { border-color: var(--ss-line); }
#start-screen .seat-name:focus { background: rgba(0, 0, 0, 0.3); border-color: var(--ss-line); }
#start-screen .seat-name:focus::placeholder { opacity: 0.35; }

/* Human / CPU: one switch, the lit half slides */
#start-screen .kind-toggle {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: center;
  padding: 3px; border-radius: 999px; border: 1px solid var(--ss-line);
  background: rgba(0, 0, 0, 0.32); color: var(--ss-dim);
  font: 600 0.74rem/1 var(--ss-font); letter-spacing: 0.04em; cursor: pointer;
}
#start-screen .kind-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.1));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.26s cubic-bezier(0.3, 1.3, 0.5, 1), background 0.26s ease;
}
#start-screen .kind-toggle[aria-checked="true"] .kind-thumb {
  transform: translateX(100%);
  background: linear-gradient(135deg, var(--ss-accent), #6d5be0);
}
#start-screen .kind-side { position: relative; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 10px; transition: color 0.2s ease; }
#start-screen .kind-toggle[aria-checked="false"] .kind-human, #start-screen .kind-toggle[aria-checked="true"] .kind-cpu { color: #fff; }
#start-screen svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* CPU difficulty */
#start-screen .level-pills {
  grid-column: 2 / -1; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 3px; border-radius: 11px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--ss-line);
  animation: ss-rise 0.25s ease both;
}
#start-screen .level-pill {
  position: relative; text-align: center; padding: 6px 4px; border-radius: 8px; cursor: pointer;
  font-size: 0.76rem; font-weight: 600; letter-spacing: 0.05em; color: var(--ss-dim);
  transition: background-color 0.18s ease, color 0.18s ease;
}
#start-screen .level-pill:hover { color: #fff; }
#start-screen .level-pill.is-on { background: color-mix(in srgb, var(--seat) 30%, rgba(255, 255, 255, 0.1)); color: #fff; }

/* founding */
#start-screen .opt-cards { display: flex; flex-direction: column; gap: 10px; }
#start-screen .opt-card { display: flex; align-items: center; gap: 14px; padding: 11px 14px 11px 11px; }
#start-screen .opt-art { width: 58px; height: 58px; stroke: none; border-radius: 10px; background: rgba(0, 0, 0, 0.3); }
#start-screen .opt-art rect { fill: rgba(255, 255, 255, 0.13); }
#start-screen .opt-art .art-zone-a { fill: rgba(51, 153, 255, 0.4); }
#start-screen .opt-art .art-zone-b { fill: rgba(255, 102, 77, 0.4); }
#start-screen .opt-art .art-park { fill: #58d27c; }
#start-screen .opt-art .art-prime { fill: #ffcc4d; }
#start-screen .opt-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#start-screen .opt-name { font-size: 0.98rem; font-weight: 650; }
#start-screen .opt-line { font-size: 0.8rem; line-height: 1.38; color: var(--ss-dim); }

/* actions */
#start-screen .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 6px; }
#start-screen .start-button, #start-screen .watch-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 14px; cursor: pointer; font-family: var(--ss-font); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease, border-color 0.16s ease;
}
#start-screen .start-button {
  flex: 1 1 220px; padding: 16px 22px; font-size: 1rem; color: #fff; border: 1px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(135deg, #ff4fd8 0%, #8f6bff 50%, #39d8ff 100%);
  box-shadow: 0 12px 34px rgba(190, 80, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
#start-screen .start-button svg { fill: currentColor; stroke: none; }
#start-screen .start-button.is-watch svg { fill: none; stroke: currentColor; }
#start-screen .start-button:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 16px 42px rgba(100, 120, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
#start-screen .start-button:active, #start-screen .watch-button:active { transform: translateY(0); }
#start-screen .watch-button {
  flex: 0 1 auto; padding: 16px 18px; font-size: 0.78rem; color: var(--ss-ink);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--ss-line);
}
#start-screen .watch-button:hover { border-color: rgba(255, 255, 255, 0.4); transform: translateY(-2px); }
#start-screen .instructions { margin: 2px 0 0; font-size: 0.74rem; line-height: 1.7; color: rgba(214, 219, 245, 0.5); }
#start-screen .instructions span {
  display: inline-block; padding: 0 6px; margin-right: 2px; border-radius: 5px; border: 1px solid var(--ss-line);
  color: rgba(225, 215, 255, 0.85); background: rgba(255, 255, 255, 0.05); font-size: 0.7rem;
}

/* ---- board style (the render theme): three cards side by side, a row each on a phone ---- */
#start-screen .opt-cards + .ss-h, #start-screen .theme-cards + .ss-h, #start-screen .ss-note + .ss-h { margin-top: 6px; }
#start-screen .theme-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
#start-screen .theme-card { flex-direction: column; align-items: stretch; gap: 8px; padding: 9px 9px 11px; }
#start-screen .theme-card .opt-art { width: 100%; height: 52px; }
#start-screen .theme-card .opt-body { padding: 0 3px; }
#start-screen .theme-card .opt-line { font-size: 0.74rem; }
#start-screen .theme-cards.is-off .theme-card { cursor: not-allowed; opacity: 0.45; transform: none; border-color: var(--ss-line); background: var(--ss-card); box-shadow: none; }
#start-screen .ss-note { margin: 0; font-size: 0.78rem; line-height: 1.4; color: var(--ss-dim); }
#start-screen .ss-note[hidden] { display: none; }

/* ---- narrow (under 800 px, STACK_WIDTH in preview-frame.js): the setup on top, the preview under it ---- */
@media (max-width: 800px) {
  #start-screen .ss-layout { display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; }
  #start-screen .ss-setup { flex: 0 0 auto; width: 100%; overflow: visible; padding-bottom: 14px; background: rgba(8, 6, 26, 0.6); }
  #start-screen .ss-setup::before, #start-screen .ss-setup::after { content: none; }
  #start-screen .ss-preview { flex: 0 0 auto; height: 320px; margin: 0 12px 16px; border-radius: 20px; }
  #start-screen .setup-panel { padding: 18px; border-radius: 20px; }
  #start-screen .logo-img { width: min(64vw, 30vh, 260px); }
}
@media (max-width: 420px) {
  #start-screen .ss-setup { padding: 8px 10px 12px; }
  #start-screen .setup-panel { padding: 14px 12px; gap: 16px; border-radius: 18px; }
  #start-screen .seat-card { gap: 8px; padding: 9px 9px 9px 10px; }
  #start-screen .kind-side { padding: 6px 7px; }
  #start-screen .kind-side span { display: none; }
  #start-screen .opt-art { width: 46px; height: 46px; }
  #start-screen .theme-cards { grid-template-columns: minmax(0, 1fr); }
  #start-screen .theme-card { flex-direction: row; align-items: center; gap: 12px; padding: 9px 12px 9px 9px; }
  #start-screen .theme-card .opt-art { width: 64px; height: 46px; flex: 0 0 auto; }
  #start-screen .watch-button, #start-screen .start-button { flex: 1 1 100%; }
  #start-screen .instructions { display: none; }
}
@media (max-height: 560px) and (min-width: 801px) {
  #start-screen .logo-img { width: min(26vh, 180px); min-width: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  #start-screen, #start-screen * { animation: none !important; transition: none !important; }
}
