/* Only phones opt in. A narrow desktop window still uses the desktop game. */
#rotatePhone, #touchHint { display: none; }
.phone {
  --left: max(14px, env(safe-area-inset-left));
  --right: max(14px, env(safe-area-inset-right));
  --top: max(8px, env(safe-area-inset-top));
  --bottom: max(10px, env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
.phone #view { width: 100%; height: 100%; height: 100dvh; }
.phone #title { padding: var(--top) var(--right) var(--bottom) var(--left); overflow: auto; }
.phone .title-inner { margin: auto; padding: 8px; transform: none; }
.phone .kicker { margin-bottom: 6px; font-size: 10px; }
html.phone h1 { font-size: clamp(40px, 16vh, 74px); }
.phone #loading, .phone .language { margin-top: 14px; }
.phone #start { margin-top: 10px; min-height: 44px; padding: 10px 32px; }
.phone #start:not([hidden]) ~ #touchHint { display: block; margin: 8px auto 0; font-size: 13px; }
.phone #keys, .phone #flightHelp, .phone #trick, .phone .treasures kbd { display: none; }

@media (orientation: portrait) {
  .phone #rotatePhone {
    position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 24px; text-align: center;
    background: radial-gradient(ellipse at 50% 45%, #283951, #0b1522 72%);
  }
  .phone #rotatePhone h2 { margin: 26px 0 6px; font: 500 26px/1.35 Georgia, serif; }
  .phone #rotatePhone p { margin: 0; color: #d5d9de; font-size: 15px; }
  .rotate-device { width: 58px; height: 33px; border: 2px solid var(--gold); border-radius: 8px; position: relative; }
  .rotate-device::after { content: ''; position: absolute; left: 3px; top: 10px; height: 9px; border-left: 2px solid var(--gold); }
  .phone :is(#title, #hud, #touchControls, .journal, .treasure-card) { display: none; }
}

.phone .hud-tl { left: var(--left); top: var(--top); max-width: 34%; }
.phone .hud-tr { right: calc(var(--right) + 68px); top: var(--top); max-width: 40%; }
.phone .seeds { font-size: 22px; gap: 4px; }
.phone .seeds-of, .phone .treasures { font-size: 12px; }
.phone .treasures-n, .phone .job-name { font-size: 17px; }
.phone .treasures, .phone .place, .phone .job-meta { margin-top: 2px; }
.phone .place, .phone .job-meta, .phone .job-spot { font-size: 10px; letter-spacing: .05em; }
.phone .hud-bl { left: calc(50% - 84px); bottom: var(--bottom); width: 76px; }
.phone .gust-label { margin-top: 3px; }
.phone .hud-br { right: calc(50% - 84px); bottom: var(--bottom); font-size: 22px; }
.phone .hud-br small { margin-left: 3px; letter-spacing: normal; }
.phone .prompt { bottom: calc(var(--bottom) + 34px); max-width: 42%; }
.phone :is(.prompt, .toast, .card) { white-space: normal; text-align: center; letter-spacing: normal; }
.phone .toast { top: 26%; width: 60%; font-size: 17px; }
.phone .card { top: 35%; width: 60%; }
.phone .card-name { font-size: clamp(21px, 6vh, 32px); }
.phone .card-name::after, .phone .card-sub { margin-top: 4px; }
.phone .card-name::after { margin-bottom: 0; }
.phone .card-sub { font-size: 11px; letter-spacing: .05em; }

.phone #touchControls {
  position: fixed; inset: 0; z-index: 4; pointer-events: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
}
.phone :is(#touchControls, #touchMenu, .journal) button {
  min-height: 44px; min-width: 48px; padding: 6px 12px; border-radius: 16px;
  background: rgba(12, 25, 39, .76); border: 1px solid rgba(255, 248, 236, .58);
  color: var(--ink); font: 600 14px/1.12 "Karla", system-ui, sans-serif;
}
.phone #touchControls :is(button, #touchStick) { pointer-events: auto; touch-action: none; }
.phone #touchMenuOpen { position: absolute; right: var(--right); top: var(--top); }
.phone #touchStick {
  --stick-size: clamp(82px, 27vh, 120px);
  position: absolute; left: var(--left); bottom: var(--bottom);
  width: var(--stick-size); height: var(--stick-size); border-radius: 50%;
  background: rgba(12, 25, 39, .43); border: 1px solid rgba(255, 248, 236, .65);
  box-shadow: inset 0 0 0 6px rgba(255, 248, 236, .09);
}
.phone .stick-knob {
  position: absolute; inset: 33%; border-radius: 50%; pointer-events: none;
  background: rgba(255, 248, 236, .74); border: 1px solid white;
  transform: translate(var(--stick-x, 0px), var(--stick-y, 0px));
}
.phone #stickLabel { position: absolute; inset: auto 0 7%; text-align: center; font-size: 11px; text-shadow: 0 1px 4px #122337; }
.phone .touch-actions {
  position: absolute; right: var(--right); bottom: var(--bottom);
  display: grid; grid-template-columns: repeat(2, minmax(58px, auto)); gap: 6px;
}
.phone #touchLand { grid-area: 1 / 1; }
.phone #touchFlip { grid-area: 1 / 2; }
.phone #touchBrake { grid-area: 2 / 1; }
.phone #touchBoost { grid-area: 2 / 2; color: var(--gold); border-color: var(--gold); }
.phone #touchControls button.held { background: #ffe3be; color: #352736; }
.phone #touchControls button:disabled { opacity: .5; }
.phone #touchMenu {
  width: min(440px, calc(100% - var(--left) - var(--right)));
  max-height: calc(100% - var(--top) - var(--bottom)); overflow-y: auto;
  padding: 14px 20px; color: var(--ink); border-radius: 18px;
  border: 1px solid #796d67; background: #142331; text-align: center;
}
.phone #touchMenu::backdrop { background: rgba(6, 14, 28, .65); }
.phone #menuTitle { margin: 0; font: 500 23px Georgia, serif; }
.phone #touchMenu p { margin: 6px 0 12px; font-size: 13px; line-height: 1.35; }
.phone .menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.phone #touchResume { background: #ffe1d9; color: #382839; }
.phone .journal { padding: var(--top) var(--right) var(--bottom) var(--left); }
.phone .journal-inner { height: 100%; max-height: 100%; min-height: 0; }
.phone .journal h2 { font-size: 26px; }
.phone .j-list { min-height: 0; grid-template-columns: repeat(auto-fit, minmax(min(225px, 100%), 1fr)); overscroll-behavior: contain; }
.phone .journal footer { margin-top: 4px; opacity: 1; }
.phone .treasure-card { bottom: 19%; width: 52%; padding: 9px 14px; }
.phone .tc-name { font-size: 21px; }
.phone .tc-lore, .phone .tc-place { margin-top: 4px; }
.phone .tc-lore { font-size: 12px; }
