body.title-mode {
  overflow: hidden;
  background: #132831;
}
body.title-mode .app { visibility: hidden; }

/* Route focus stays on the main landmark; actionable controls keep their own focus rings. */
#home-screen:focus { outline: none; }

.title-screen {
  --title-ink: #132831;
  --title-paper: #fff5de;
  --title-gold: #ffbd54;
  --title-side: clamp(18px, 6vw, 144px);
  position: fixed;
  inset: 0;
  z-index: 100;
  isolation: isolate;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--title-ink);
  color: var(--title-paper);
  font-family: var(--font-ui);
}
.title-screen[hidden],
.title-actions [hidden] { display: none !important; }

/* The picture covers the whole screen, centred: the painted wordmark sits on the vertical axis of the buttons.
   Portrait sources are cropped so the wordmark is centred (wide ones already are); cover only trims the edges. */
.title-scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.title-scene picture { position: absolute; inset: 0; }
.title-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Wider screens than the picture lose the bottom first: the wordmark stays whole. */
  object-position: 50% 20%;
}
.title-art:not([src]) { visibility: hidden; }
.title-scene picture::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--title-ink), #13283166 12%, transparent 32%);
}
@media (orientation: portrait) {
  .title-art { object-position: 50% 0%; }
}

.title-layout {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: 100svh;
  padding: max(24px, env(safe-area-inset-top)) max(var(--title-side), env(safe-area-inset-right))
           max(5svh, 24px, env(safe-area-inset-bottom)) max(var(--title-side), env(safe-area-inset-left));
  text-align: center;
}

.title-actions {
  display: grid;
  gap: 12px;
  width: min(100%, 17rem);
}
.title-actions button {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 9px;
  font: 800 clamp(20px, 1.6vw, 25px)/1.05 var(--font-heading);
  letter-spacing: .035em;
  text-transform: uppercase;
}
.title-actions .primary {
  border: 1px solid #ffd189;
  background: linear-gradient(#ffbf70, #ee9448);
  color: #32190f;
  box-shadow: 0 3px 0 var(--hub-orange-edge);
}
.title-actions .secondary {
  border: 1px solid #fff5de83;
  background: #142935ed;
  color: var(--title-paper);
  box-shadow: 0 3px 0 #081820;
}
.title-actions button:disabled { opacity: .65; }
.title-actions button:focus-visible {
  outline: 3px solid var(--title-gold);
  outline-offset: 3px;
}
/* Focus is placed at startup. The ring returns on keyboard navigation (title.js). */
#title-screen .title-actions button.quiet-focus:focus-visible { outline: none; }

.title-actions .title-continue {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.title-continue-save {
  max-width: 100%;
  overflow: hidden;
  font: 600 12px/1.25 var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title-continue-save:empty { display: none; }
.title-save,
.title-noscript {
  max-width: 100%;
  margin: 0;
  color: var(--title-paper);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 4px #081a23;
}

@media (max-height: 540px) and (orientation: landscape) {
  .title-layout {
    padding-block: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-bottom));
  }
  .title-actions { gap: 9px; width: min(100%, 14rem); }
  .title-actions button { min-height: 44px; }
}

body.title-entered .app { animation: title-enter .2s ease-out; }
@keyframes title-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion:reduce) {
  body.title-entered .app { animation: none; }
}
