/* ------------------------------------------------------------ phones
   js/mobile.js sets the classes on <html>:
   .is-phone    a touch phone
   .is-portrait held upright (and not flipped)
   .is-compact  a short landscape screen: the game fills the height, controls live in a slim side rail
   .is-flip     the page is turned sideways in CSS (iPhone can't lock rotation from a web page)  */

html.is-flip { --app-h: 100dvw; --app-w: 100dvh; }
html.is-flip, html.is-flip body { overflow: hidden; }
html.is-flip body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100dvh;
  height: 100dvw;
  transform-origin: 0 0;
  transform: translateX(100dvw) rotate(90deg);
}

/* ---- landscape: game edge to edge on the left, a slim rail on the right */
html.is-compact .app {
  width: var(--app-w);
  height: var(--app-h);
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "stage top" "stage dock";
  padding: 0 max(6px, env(safe-area-inset-right)) 0 env(safe-area-inset-left);
  gap: 0 6px;
}
html.is-flip.is-compact .app { padding: 0 6px 0 0; }
html.is-compact .stage-wrap { grid-area: stage; place-items: center end; }
html.is-compact .stage {
  width: min(100%, calc(var(--app-h) * 1280 / 672));
  max-width: none;
  border-radius: 0;
  box-shadow: none;
}
html.is-compact .topbar { grid-area: top; flex-direction: column; align-items: stretch; gap: 6px; padding-top: max(8px, env(safe-area-inset-top)); width: auto; }
html.is-compact .title-block { display: none; }
html.is-compact .pills { display: flex; flex-direction: column; gap: 6px; }
html.is-compact .money-chip { justify-content: center; text-align: center; padding: 4px 6px; font-size: 13px; }
html.is-compact .score-pill { justify-content: center; padding: 4px 6px; gap: 3px; }
html.is-compact .score-pill #scoreValue { font-size: 16px; }
html.is-compact .score-pill .of { font-size: 10px; }
html.is-compact .dock {
  grid-area: dock;
  align-self: end;
  justify-self: stretch;
  flex-direction: column;
  gap: 8px;
  padding: 6px;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
  border-radius: 28px;
}
html.is-compact .segmented { flex-direction: column; gap: 2px; }
html.is-compact .seg { padding: 6px 4px; font-size: 0; }
html.is-compact .seg::after { font-size: 11px; }
html.is-compact .seg[data-mode="remastered"]::after { content: 'HD'; }
html.is-compact .seg[data-mode="classic"]::after { content: '8-bit'; }
html.is-compact .dock-centre { width: 48px; height: 48px; margin: 0; }
html.is-compact .dock-centre svg { width: 26px; height: 26px; }
html.is-compact .dock-btn { width: 38px; height: 38px; }
html.is-compact .dock-btn svg { width: 24px; height: 24px; }

/* conversations float over the game, on the left so the rail stays reachable */
html.is-compact .narration-host { position: fixed; left: 0; right: 72px; bottom: 6px; padding: 0 10px; z-index: 5; }
html.is-compact .narration { max-height: calc(var(--app-h) - 12px); overflow-y: auto; padding: 12px 16px 10px; }
html.is-compact .narration.has-portrait { grid-template-columns: 48px 1fr; column-gap: 12px; }
html.is-compact .portrait { width: 48px; height: 48px; }
html.is-compact .choice-row { margin-top: 8px; gap: 6px; }
html.is-compact .choice { padding: 8px 14px; font-size: 14px; }
html.is-compact .sheet { max-height: calc(var(--app-h) - 12px); }

/* the title screen on a short screen */
html.is-compact .title-screen { overflow-y: auto; place-items: center; }
html.is-compact .title-art { width: 110px; margin-bottom: 0; }
html.is-compact .big-title { font-size: 44px; }
html.is-compact .sub-title { font-size: 16px; margin: 6px 0 14px; }
html.is-compact .primary-btn { padding: 12px 26px; font-size: 16px; }
html.is-compact .title-note { display: none; }
html.is-compact .donate-btn { margin-top: 10px; }

/* ---- upright phone: the game spans the full width, with a big invitation to turn sideways */
html.is-portrait.is-phone .app { padding-left: 0; padding-right: 0; }
html.is-portrait.is-phone .topbar { padding: 0 16px; }
html.is-portrait.is-phone .stage { width: 100%; border-radius: 0; box-shadow: none; }
html.is-portrait.is-phone .stage-wrap { align-content: center; gap: 16px; }

.flip-cta { display: none; }
html.is-portrait.is-phone .flip-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 17px;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 14px 40px rgba(255, 45, 135, 0.4);
}
.flip-cta svg { width: 26px; height: 26px; }

/* the rail's rotate button, only on phones */
#flipBtn { display: none; }
html.is-phone #flipBtn { display: grid; }

/* ---- install as an app */
.install-btn { margin-top: 10px; padding: 10px 22px; border-radius: 999px; font-weight: 700; font-size: 14px; color: #fff; background: rgba(255, 255, 255, 0.12); }
.install-btn[hidden] { display: none; }
.install-steps { display: grid; gap: 10px; margin: 4px 0 8px; padding: 0; list-style: none; counter-reset: step; }
.install-steps li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: var(--seg); font-weight: 600; counter-increment: step; }
.install-steps li::before { content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; }

/* Larry's phone on a short screen: as tall as possible, with a slimmer Ryde map so the stops fit */
html.is-compact .phone { height: calc(var(--app-h) - 56px); }
html.is-compact .ryde-map { flex: 0 0 64px; min-height: 64px; }
