#game-shell.adventure-game {
  --adventure-edge: clamp(.65rem, 2vw, 1.25rem);
  --paper: #f4eadd;
  --quiet: #bdc8b9;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  background: #1a3128;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.is-playing #game-shell.adventure-game {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.is-playing #game-shell.adventure-game:has(#adventure-intro:not([hidden])) {
  grid-template-rows: minmax(0, 1fr) auto;
}

.adventure-game button {
  min-height: 44px;
  padding: .45rem .75rem;
  border: 1px solid #56695d;
  border-radius: .25rem;
  color: inherit;
  background: #263b34;
}

.adventure-game button:hover:not(:disabled) { background: #365247; }
.adventure-game button[aria-pressed="true"] { background: #425e4f; border-color: #a9bd9e; }
.adventure-game button.primary { color: #201d16; background: #ffc29b; border-color: #ffc29b; font-weight: 700; }
.adventure-game button.primary:hover:not(:disabled) { background: #ffd0af; }
.adventure-game kbd { display: inline; padding-inline: .15em; border: 0; background: transparent; font: inherit; }
.adventure-game :focus-visible { outline-color: #ffc58b; outline-offset: 3px; }
#adventure-title-status:empty { display: none; }

.adventure-operational {
  grid-column: 1 / -1;
  padding-inline: var(--adventure-edge);
}

.adventure-operational:not(:has(> :not([hidden]))) { display: none; }
.adventure-operational p { margin: .4rem 0; font-size: .85rem; }
.adventure-operational .game-update { width: fit-content; }

.adventure-hud-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem;
}

.adventure-hud {
  display: grid;
  grid-template-columns: minmax(7.25rem, 1fr) minmax(10rem, 2.3fr) auto auto;
  align-items: center;
  gap: .5rem 1.2rem;
  padding: .65rem var(--adventure-edge);
}

.adventure-hud p, .adventure-controls p { margin: 0; }
.adventure-campaign-status { display: contents; }

.adventure-label {
  color: var(--quiet);
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#adventure-location { color: #e4f3dd; font-weight: 700; }
#adventure-objective { color: #f7ebdf; }

#adventure-skip-scene {
  border-color: #8c8c6c;
  color: #f2e4c5;
  font-size: .88rem;
  white-space: nowrap;
}

.adventure-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
}

#adventure-progress {
  padding: .3rem .55rem;
  border: 1px solid #668373;
  border-radius: .25rem;
  color: #d9eed5;
  background: #233d34;
  font-size: .81rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.adventure-arena {
  position: relative;
  display: grid;
  place-items: center;
  container-type: inline-size;
  border-block: 1px solid #53695e;
  background: radial-gradient(ellipse at center, #28433c, #11241f 84%);
}

.is-playing .adventure-arena { container-type: size; }

#game-shell #game-surface {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0;
  background: #11241f;
}

/* Active play uses every horizontal pixel between the controls. The camera
   resolves the slot's aspect ratio in world units. */
.is-playing #game-shell #game-surface {
  width: 100%;
  height: min(100cqh, calc(100cqw * 9 / 16));
  aspect-ratio: auto;
}
#game-shell #game-surface #adventure-canvas { width: 100%; height: auto; aspect-ratio: 16 / 9; }
.is-playing #game-shell #game-surface #adventure-canvas { height: 100%; aspect-ratio: auto; }
.is-playing #game-shell #game-surface:has(#adventure-intro:not([hidden])) { height: 100%; }
#adventure-canvas:focus-visible { outline-offset: -4px; }

.page-original-title,
.adventure-original-title {
  font-family: 'Noto Serif TC', 'Songti TC', PMingLiU, 'Microsoft JhengHei', serif;
  font-weight: 600;
}

.page-original-title { display: inline-block; margin-inline-start: .2em; font-size: .62em; white-space: nowrap; }
.adventure-original-title { color: #ffd6a0; letter-spacing: .12em; }

.adventure-boss-title {
  position: absolute;
  inset: 13% .75rem auto;
  color: #fff1d3;
  font: 600 clamp(1.45rem, 5.6cqw, 4.75rem)/1.05 Georgia, serif;
  letter-spacing: .025em;
  text-align: center;
  text-shadow: 0 .06em .08em #100d13, 0 0 .36em #0b1821, 0 0 .55em #0b1821;
  pointer-events: none;
}

.adventure-boss-title[data-boss="eel"] { color: #ddfff3; }
.adventure-boss-title[data-boss="warden"] { color: #ffe2aa; }

@media (max-width: 36rem) {
  .adventure-boss-title {
    inset-block-start: 18%;
    font-size: clamp(1.28rem, 6cqw, 2rem);
  }
}

@media (min-width: 50rem) and (max-aspect-ratio: 4/3) {
  .is-playing #game-shell.adventure-game:has(#adventure-controls:not([hidden])) {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }
}

.adventure-encounter {
  position: absolute;
  inset: .5rem .5rem auto;
  display: flex;
  justify-content: flex-end;
  gap: .45rem;
  pointer-events: none;
}

.adventure-vitals {
  --vitals-fill: #f29a89;
  --vitals-track: #50313b;
  display: grid;
  gap: .22rem;
  width: min(8rem, 42%);
  min-width: 0;
  padding: .25rem .45rem .35rem;
  border: 1px solid #aa7969;
  border-radius: .35rem;
  color: #ffe3cc;
  background: #172722f5;
  font-weight: 700;
  font-size: clamp(.66rem, 2.8cqw, .83rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  box-shadow: 0 .14rem .42rem #08131080;
}

.adventure-vitals[hidden] { display: none; }

.adventure-vitals-player {
  --vitals-fill: #b8ebbd;
  --vitals-track: #304b42;
  width: clamp(5rem, 19cqw, 9rem);
  margin-inline-end: auto;
  border-color: #7ca68e;
  color: #daf3d5;
}

.adventure-vitals-boss { width: min(13rem, 49%); }

.adventure-vitals meter {
  appearance: none;
  display: block;
  width: 100%;
  height: .36rem;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  background: var(--vitals-track);
}

.adventure-vitals-boss meter { height: .48rem; }
.adventure-vitals meter::-webkit-meter-bar { background: var(--vitals-track); border: 0; border-radius: 1rem; }
.adventure-vitals meter::-webkit-meter-optimum-value { background: var(--vitals-fill); border-radius: 1rem; }
.adventure-vitals meter::-moz-meter-bar { background: var(--vitals-fill); border-radius: 1rem; }

@media (forced-colors: active) {
  .adventure-vitals meter { appearance: auto; }
}

.adventure-messages {
  position: absolute;
  inset: clamp(.4rem, 1.25vw, 1rem) .5rem auto;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.adventure-stage:has(.adventure-vitals:not([hidden])) .adventure-messages { inset-block-start: 3rem; }

.adventure-caption {
  max-width: min(100%, 34rem);
  margin: 0;
  font-size: clamp(.8rem, 2.5vw, 1.05rem);
  line-height: 1.35;
  color: #fff4e5;
  text-align: center;
  text-wrap: pretty;
}

.adventure-caption:not(:empty) {
  padding: .42rem .75rem;
  border: 1px solid #c3aa86;
  border-radius: .35rem;
  background: #152822f5;
  box-shadow: 0 .2rem .75rem #0b161a70;
}

.adventure-caption:is([data-combat="guard"], [data-combat="finish"]) {
  border-color: #e8bd75;
  color: #ffdfac;
}

.adventure-caption[data-combat="hit"] {
  border-color: #9cd8ca;
  color: #d7f3ea;
}

.adventure-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  max-width: 100%;
  font-size: clamp(.85rem, 2.5vw, 1rem);
  pointer-events: auto;
}

.adventure-caption:not(:empty) + .adventure-prompt { margin-block-start: .4rem; }

.adventure-game .adventure-prompt kbd {
  padding: .08em .38em;
  border: 1px solid #a87956;
  border-radius: .2rem;
  color: #4a2d1e;
  background: #fff1df;
  font-weight: 600;
  white-space: nowrap;
}

@media (pointer: coarse) {
  .adventure-game .adventure-prompt kbd { display: none; }
}

.adventure-strike-keys, .adventure-dive-keys { display: none; }
#adventure-controls[data-dive] .adventure-dive-keys { display: inline; }
#adventure-controls[data-dive] .adventure-movement-actions { flex-wrap: wrap; }
.adventure-game:has(#adventure-strike:not([hidden])) .adventure-strike-keys { display: inline; }
.adventure-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: center;
  padding: clamp(.65rem, 4vw, 3rem);
  background: linear-gradient(90deg, #112a24 1%, #112a24eb 36%, #132a2440 84%);
  overflow: auto;
}

#adventure-pause-screen {
  z-index: 1;
  place-items: center;
  padding: .65rem;
  background: #0e211dd9;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
}

#adventure-pause-title {
  max-width: none;
  font-size: clamp(1.8rem, 6vw, 3.65rem);
}

#adventure-resume {
  min-width: min(100%, 12rem);
  min-height: 3.5rem;
  margin-block-start: .65rem;
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
}

#adventure-pause-screen p:not(.adventure-kicker) {
  margin: .6rem auto 0;
  color: #d9e7de;
  font-size: .88rem;
}

#adventure-death-screen {
  z-index: 2;
  place-items: safe center;
  padding: .85rem;
  background: radial-gradient(ellipse at center, #211519df 0%, #14191af2 78%);
  text-align: center;
}

#adventure-death-title {
  max-width: none;
  color: #ffd6c4;
  font-size: clamp(2rem, 6vw, 4.5rem);
}

#adventure-death-title:focus { outline: none; }

#adventure-death-screen .adventure-end-actions {
  justify-content: center;
  margin-block-start: clamp(.8rem, 3vw, 1.6rem);
}

#adventure-intro {
  background-image:
    var(--adventure-intro-shade, linear-gradient(90deg, #122721 2%, #172e27f0 33%, #19312a52 76%)),
    url("assets/chapter/01.webp");
  background-position: center, center 53%;
  background-size: cover;
}

#adventure-sailor-illustration,
#adventure-scene-fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#adventure-sailor-illustration { background: url("assets/chapter/16.webp") center / cover; }
#adventure-caption[data-sailor-scene] { justify-self: end; max-width: min(100%, 27rem); text-align: left; }

#adventure-scene-fade { background: #0b1c17; }

:is(#adventure-grove-end, #adventure-storm-end) {
  align-items: safe center;
  background: linear-gradient(90deg, #112a24fa 3%, #112a24d9 42%, #142b2640 90%);
}

.adventure-end-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
#adventure-replay-dialog { inline-size: min(38rem, calc(100% - 1.5rem)); }
.adventure-replay-list { list-style: none; margin: .75rem 0; padding: 0; }
.adventure-replay-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center;
  gap: .5rem; padding-block: .45rem; border-block-end: 1px solid #34445d;
}
.adventure-replay-list strong, .adventure-replay-list small { display: block; overflow-wrap: anywhere; }
.adventure-replay-list button {
  min-height: 44px; padding-inline: .62rem; border: 1px solid #566477;
  border-radius: .36rem; background: #29384a; color: #fff4e5; cursor: pointer;
}
.adventure-replay-list button:not(:disabled):hover { background: #394b62; }
.adventure-replay-list button:disabled { color: #b0b8c2; opacity: .58; cursor: default; }
@media (max-width: 440px) {
  .adventure-replay-list li { grid-template-columns: 1fr 1fr; }
  .adventure-replay-list li > span { grid-column: 1 / -1; }
}
.adventure-tools button { white-space: nowrap; }

.adventure-card { max-width: 24rem; text-shadow: 0 1px #16251e; }

.adventure-kicker {
  margin: 0 0 .45rem;
  color: #ffbc9c;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.adventure-card h2 {
  max-width: 10ch;
  margin: 0;
  color: #fff4e5;
  font: 500 clamp(1.8rem, 5vw, 4.4rem)/.98 "Cormorant Garamond", Georgia, serif;
  letter-spacing: -.04em;
  text-wrap: balance;
}

.adventure-card p:not(.adventure-kicker) {
  max-width: 34ch;
  margin: .65rem 0 .9rem;
  line-height: 1.34;
}

.adventure-card button { padding-inline: 1.25rem; text-shadow: none; }

#adventure-intro .adventure-end-actions { margin-block-start: .9rem; }

.adventure-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .65rem 1rem;
  min-width: 0;
  padding: .75rem var(--adventure-edge);
}

.adventure-guidance { display: grid; gap: .25rem; min-width: 0; }
#adventure-status { min-height: 1.3em; line-height: 1.3; }
#adventure-key-help { color: var(--quiet); font-size: .8rem; line-height: 1.35; }
#adventure-key-help kbd { color: #e4efdf; white-space: nowrap; }

#adventure-prologue-keys, #adventure-rescue-keys,
#adventure-controls:is([data-prologue], [data-rescue]) #adventure-keys { display: none; }
#adventure-controls[data-prologue] #adventure-prologue-keys,
#adventure-controls[data-rescue] #adventure-rescue-keys { display: block; }
.adventure-row-help, #adventure-controls[data-rescue] .adventure-move-help { display: none; }
#adventure-controls[data-rescue] .adventure-row-help { display: inline; }
#adventure-controls[data-rescue]:not([data-paused]) .adventure-actions { display: none; }
#adventure-controls[data-scene]:not([data-paused]) { display: none; }
.is-playing #game-shell.adventure-game:has(#adventure-controls[data-scene]:not([data-paused])) {
  grid-template-columns: minmax(0, 1fr);
}

.adventure-hand-controls, .adventure-actions, .adventure-movement-actions, .adventure-utility-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.adventure-actions { justify-content: flex-end; }

#adventure-controls[data-paused] .adventure-hand-controls { display: flex; justify-content: flex-end; }
#adventure-controls[data-paused] :is(.adventure-joystick, .adventure-movement-actions, #adventure-action, #adventure-strike) { display: none; }

.adventure-utility-actions button {
  color: #e6eee4;
  font-size: .86rem;
}

#adventure-dive:not(:disabled) {
  color: #e2fcf7;
  background: #286063;
  border-color: #82b8b7;
}

#adventure-dive:hover:not(:disabled) { background: #357877; }

#adventure-gust:not(:disabled) {
  border-color: #8db79f;
  background: #345d50;
  color: #eef9e5;
}

#adventure-gust:hover:not(:disabled) { background: #417361; }

#adventure-strike {
  border-color: #bf835f;
  background: #653d2e;
  color: #ffe3ca;
  font-weight: 700;
}

#adventure-strike:hover:not(:disabled) { background: #804b36; }

#adventure-gust { --ability-icon: url('./assets/adventure/wind-dash-icon.webp'); }
#adventure-dive { --ability-icon: url('./assets/adventure/tide-dive-icon.webp'); }
#adventure-strike { --ability-icon: url('./assets/adventure/wing-strike-icon.webp'); }

:is(#adventure-gust, #adventure-dive, #adventure-strike) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}

:is(#adventure-gust, #adventure-dive, #adventure-strike)::before {
  content: '';
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  background: var(--ability-icon) center / contain no-repeat;
  transition: transform 140ms ease-out;
}

:is(#adventure-gust, #adventure-dive, #adventure-strike):disabled::before {
  opacity: .5;
  filter: saturate(.45);
}

@media (prefers-reduced-motion: no-preference) {
  :is(#adventure-gust, #adventure-dive, #adventure-strike):active:not(:disabled)::before {
    transform: scale(.86);
  }
}

.adventure-joystick {
  display: none;
  align-items: center;
  gap: .55rem;
}

#adventure-stick {
  position: relative;
  flex: none;
  width: 92px;
  height: 92px;
  border: 1px solid #799182;
  border-radius: 50%;
  background: #233f34;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#adventure-stick:active { cursor: grabbing; }

#adventure-stick::before, #adventure-stick::after {
  position: absolute;
  inset: 50% 15% auto;
  height: 1px;
  background: #50695e;
  content: "";
  pointer-events: none;
}

#adventure-stick::after { inset: 15% auto 15% 50%; width: 1px; height: auto; }

#adventure-stick-knob {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid #b9d9bd;
  border-radius: 50%;
  background: #8cb698;
  box-shadow: 0 .15rem .35rem #112b22;
  pointer-events: none;
}

#adventure-stick-help { color: var(--quiet); font-size: .78rem; line-height: 1.35; }
#adventure-stick-help strong { color: var(--paper); }

@media (max-width: 43rem), (any-pointer: coarse) {
  .adventure-joystick { display: flex; }
  .adventure-actions { display: grid; }
  .adventure-movement-actions { flex-wrap: nowrap; }
  .adventure-movement-actions button { min-width: 3.25rem; min-height: 52px; padding-inline: .55rem; }
  #adventure-strike { min-width: 3.25rem; min-height: 48px; }
  :is(#adventure-gust, #adventure-dive, #adventure-strike) {
    flex-direction: column;
    gap: .08rem;
    padding-block: .25rem;
    line-height: 1.05;
  }
  :is(#adventure-gust, #adventure-dive, #adventure-strike)::before {
    width: 1.3rem;
    height: 1.3rem;
  }
}

@media (max-width: 48rem) {
  .adventure-controls { grid-template-columns: 1fr; }
  .adventure-actions { justify-content: flex-start; }
}

@media (max-width: 44rem), (any-pointer: coarse) {
  .adventure-hand-controls { justify-content: space-between; }
}

@media (max-width: 54rem) {
  .adventure-hud { gap: .35rem .65rem; }
  .adventure-hud-options { grid-column: 1 / -1; }
  .adventure-hud-options button { padding-inline: .55rem; }
}

@media (max-width: 38rem) {
  .adventure-hud {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .4rem .65rem;
    padding: .45rem .65rem;
  }
  .adventure-task { grid-column: 1 / -1; grid-row: 2; }
  .adventure-hud-options { justify-content: flex-start; }
  .adventure-controls { padding: .65rem; }
  .adventure-tools button { padding-inline: .55rem; }
  .adventure-hand-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .45rem; }
  .adventure-actions { justify-content: flex-end; }
  .adventure-overlay { padding: .52rem .72rem; }
  #adventure-intro { --adventure-intro-shade: linear-gradient(90deg, #102820f7, #152e27d6 65%, #152e2766); }
  .adventure-card h2 { max-width: 16ch; font-size: clamp(1.4rem, 7vw, 2.2rem); }
  #adventure-intro .adventure-end-actions { margin-block-start: .65rem; }
  :is(#adventure-grove-end, #adventure-storm-end) .adventure-card { width: min(100%, 18rem); }
  .adventure-end-actions button { padding-inline: .65rem; font-size: .86rem; }
  .adventure-kicker { margin-bottom: .25rem; }
  .adventure-card p:not(.adventure-kicker) { max-width: 42ch; margin: .35rem 0 .5rem; font-size: .875rem; }
}

@media (max-width: 24rem) {
  .adventure-card h2 { max-width: none; }
  .adventure-controls { gap: .45rem; padding-block: .4rem; }
  #adventure-key-help kbd { padding-inline: 0; }
  .adventure-tools { gap: .35rem; }
  .adventure-tools button { min-width: 44px; padding-inline: .45rem; font-size: .9rem; }
  #adventure-location { overflow-wrap: anywhere; }
  #adventure-progress { padding-inline: .35rem; font-size: .75rem; }
  #adventure-stick { width: 78px; height: 78px; }
  #adventure-stick-help { font-size: .72rem; }
  .adventure-joystick { width: 78px; flex-direction: column; gap: .3rem; text-align: center; }
  .adventure-actions button { padding-inline: .55rem; }
}

@media (orientation: landscape) and (max-height: 31rem) and (min-width: 35.01rem) {
  .is-playing #game-shell.adventure-game:has(#adventure-controls:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) clamp(13.5rem, 28%, 19rem);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .adventure-hud {
    grid-column: 1 / -1;
    grid-template-columns: minmax(5rem, 1fr) minmax(0, 2.3fr) auto auto;
    padding-block: .25rem;
  }
  .adventure-hud-options { grid-column: auto; }
  .adventure-task { grid-column: auto; grid-row: auto; }
  .adventure-arena { border-block-end: 0; }
  .adventure-campaign-status:has(.adventure-vitals:not([hidden])) {
    display: grid;
    gap: .08rem;
    align-content: center;
    min-inline-size: 7.25rem;
  }
  .adventure-campaign-status:has(.adventure-vitals:not([hidden])) #campaign-revives { line-height: 1.05; }
  .adventure-campaign-status .adventure-encounter {
    position: static;
    display: grid;
    gap: .1rem;
    contain: inline-size;
    text-align: start;
  }
  .adventure-campaign-status .adventure-encounter:not(:has(.adventure-vitals:not([hidden]))) { display: none; }
  .adventure-campaign-status .adventure-vitals:not([hidden]) {
    grid-template-columns: minmax(0, 1fr) 1.4rem;
    align-items: center;
    gap: .25rem;
    width: auto;
    margin: 0;
    border: 0;
    padding: 0;
    box-shadow: none;
    background: none;
    font-size: .73rem;
    line-height: 1.03;
  }
  .adventure-campaign-status .adventure-vitals meter { height: .23rem; }
  .adventure-overlay { padding: .6rem .9rem; }
  .adventure-card h2 { max-width: none; font-size: clamp(1.55rem, 4.5vh, 2.2rem); }
  .adventure-card p:not(.adventure-kicker) { margin: .45rem 0 .6rem; font-size: .86rem; }
  .adventure-controls {
    grid-template-columns: 1fr;
    align-content: start;
    align-self: stretch;
    gap: .45rem;
    padding: .55rem;
    border-block-start: 1px solid #53695e;
    border-inline-start: 1px solid #53695e;
  }
  .adventure-actions { justify-content: flex-start; }
}

@media (orientation: landscape) and (max-height: 26rem) and (min-width: 35.01rem) and (any-pointer: coarse) {
  #adventure-key-help { display: none; }
  #adventure-status { font-size: .9rem; }
  #adventure-stick { width: 78px; height: 78px; }
  #adventure-stick-help { font-size: .72rem; }
  .adventure-hand-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .adventure-joystick { width: 78px; flex-direction: column; gap: .3rem; text-align: center; }
  .adventure-actions button { padding-inline: .45rem; }
  .adventure-movement-actions button { min-height: 48px; }
  .adventure-utility-actions { align-content: start; gap: .25rem; }
  #adventure-action { padding-inline: .28rem; font-size: .82rem; }
}

@media (orientation: portrait) and (max-width: 38rem) {
  .is-playing #game-shell.adventure-game:has(#adventure-hud:not([hidden])) {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    align-content: stretch;
    overflow: auto;
  }
  .is-playing .adventure-arena:has(#adventure-intro[hidden]) { container-type: size; }
  .is-playing #game-shell .adventure-arena:has(#adventure-intro[hidden]) #game-surface { width: 100%; }
  .is-playing #game-shell #game-surface[data-portrait-camera] { height: 100%; }

  .adventure-hud {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0 .4rem;
    padding: .35rem .65rem .45rem;
  }
  .adventure-place { grid-area: 1 / 1; }
  .adventure-tools { grid-area: 1 / 3; gap: .35rem; }
  .adventure-task { padding-block-start: .1rem; font-size: .87rem; }
  #adventure-location { line-height: 1.2; overflow-wrap: normal; }
  .adventure-hud-options { grid-row: 3; margin-block-start: .35rem; }
  #adventure-skip-scene { grid-area: 1 / 2; padding-inline: .45rem; }

  .adventure-controls { padding: .5rem .65rem .6rem; gap: .4rem; }
  #adventure-status { font-size: .87rem; }
  .adventure-hand-controls { align-items: center; }
  .adventure-joystick { width: 78px; flex-direction: column; gap: .2rem; text-align: center; }
  #adventure-stick { width: 78px; height: 78px; }
  #adventure-stick-help { font-size: .69rem; }
  .adventure-vitals-player { width: min(30%, 7rem); }
  .adventure-game .adventure-prompt kbd { display: none; }
}

@media (orientation: portrait) and (max-width: 38rem),
       (orientation: landscape) and (max-height: 26rem) and (max-width: 58rem) {
  .adventure-label, #adventure-key-help {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #adventure-progress { display: none; }
  .adventure-hud:has(#adventure-pause[aria-pressed="false"]:not(:disabled)) .adventure-hud-options { display: contents; }
  .adventure-hud:has(#adventure-pause[aria-pressed="false"]:not(:disabled))
    :is(#game-settings-button, #fullscreen, #exit-game) { display: none; }
}

@media (orientation: landscape) and (max-height: 26rem) and (max-width: 58rem) {
  .adventure-hud {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: .25rem .65rem;
    padding: .25rem .65rem;
  }
  .adventure-place { grid-area: 1 / 1; }
  .adventure-task { grid-area: 1 / 2; font-size: .87rem; }
  .adventure-tools { grid-area: 1 / 4; gap: .35rem; }
  .adventure-hud-options { grid-column: 1 / -1; }
  #adventure-skip-scene { grid-area: 1 / 3; padding-inline: .45rem; }
  .adventure-controls { align-content: center; }
  .adventure-movement-actions button, #adventure-strike { min-height: 44px; }
  .adventure-hud:has(#adventure-next-scene:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
  .adventure-hud:has(#adventure-next-scene:not([hidden])) #adventure-next-scene { grid-area: 1 / 3; }
  .adventure-hud:has(#adventure-next-scene:not([hidden])) #adventure-skip-scene { grid-area: 1 / 4; }
  .adventure-hud:has(#adventure-next-scene:not([hidden])) .adventure-tools { grid-area: 1 / 5; }
}

@media (orientation: portrait) and (max-width: 38rem) {
  .adventure-hud { grid-template-columns: minmax(0, 1fr) auto; }
  .adventure-place { grid-area: 1 / 1; }
  .adventure-task { grid-area: 2 / 1 / auto / -1; }
  .adventure-tools { grid-area: 3 / 1 / auto / -1; justify-content: space-between; font-size: .8rem; }
  .adventure-hud-options { grid-area: 4 / 1 / auto / -1; }
  #adventure-skip-scene { grid-area: 1 / 2; justify-self: end; }
  .adventure-hud:has(#adventure-next-scene:not([hidden])) #adventure-skip-scene { grid-area: 4 / 1; justify-self: start; }
  #adventure-next-scene { grid-area: 4 / 2; justify-self: end; min-width: 44px; }
}

@media (orientation: landscape) and (max-height: 31rem) {
  .is-playing.touch-device #game-shell.adventure-game:has(#adventure-controls:not([hidden], [data-scene], [data-paused])) {
    grid-template-columns: var(--play-side-width, 60px) minmax(0, 1fr) var(--play-side-width, 60px);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 0;
    padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
  }
  .is-playing.touch-device #game-shell.adventure-game:has(#adventure-controls[data-scene]:not([data-paused])) {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom);
  }
  .is-playing.touch-device #adventure-hud { grid-column: 1 / -1; padding-block: .125rem; }
  .is-playing.touch-device #game-shell:has(#adventure-controls:not([hidden], [data-scene], [data-paused])) .adventure-arena {
    grid-area: 2 / 2;
    margin-inline-start: min(0px, calc((60px - var(--play-side-width, 60px)) / 2));
    margin-inline-end: min(0px, calc((var(--play-actions-width, 50px) - var(--play-side-width, 60px)) / 2));
    border: 0;
    background: transparent;
  }
  .is-playing.touch-device #game-shell:has(#adventure-controls[data-rescue]:not([hidden], [data-paused])) .adventure-arena {
    margin-inline-end: calc(0px - var(--play-side-width, 60px));
  }
  .is-playing.touch-device #adventure-controls:not([hidden], [data-scene], [data-paused]),
  .is-playing.touch-device #adventure-controls:not([hidden], [data-scene], [data-paused]) .adventure-hand-controls { display: contents; }
  .is-playing.touch-device .adventure-guidance { grid-area: 3 / 1 / auto / -1; text-align: center; padding: 0 .5rem .125rem; }
  .is-playing.touch-device .adventure-guidance:has(#adventure-status:empty) { display: none; }
  .is-playing.touch-device #adventure-key-help { display: none; }
  .is-playing.touch-device #adventure-status { min-height: 0; font-size: .75rem; line-height: 1.15; }
  .is-playing.touch-device .adventure-joystick {
    grid-area: 2 / 1;
    place-self: end center;
    width: 60px;
    margin-block-end: .35rem;
    flex-direction: column;
    gap: .15rem;
    text-align: center;
  }
  .is-playing.touch-device #adventure-stick { width: 60px; height: 44px; border-radius: 1.5rem; }
  .is-playing.touch-device #adventure-stick::after { display: none; }
  .is-playing.touch-device #adventure-stick-knob { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
  .is-playing.touch-device #adventure-stick-help { font-size: .625rem; line-height: 1.1; }
  .is-playing.touch-device #adventure-controls:not([data-rescue], [data-scene], [data-paused]) .adventure-actions {
    display: grid;
    grid-area: 2 / 3;
    place-self: end center;
    grid-template-columns: var(--action-columns, 50px);
    gap: 1px;
    margin-block-end: .35rem;
  }
  .is-playing.touch-device #adventure-controls:not([data-paused]) :is(.adventure-movement-actions, .adventure-utility-actions) { display: contents; }
  .is-playing.touch-device #adventure-controls:not([data-paused]) .adventure-actions button {
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    padding: 1px 2px;
    border: 3px solid transparent;
    border-radius: .45rem;
    background-clip: padding-box;
    gap: .1rem;
    font-size: .74rem;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }
  .is-playing.touch-device #adventure-gust[data-locked] { display: none; }
  .is-playing.touch-device :is(#adventure-gust, #adventure-dive, #adventure-strike)::before { width: .9rem; height: .9rem; }
}

@media (orientation: landscape) and (max-height: 18rem) {
  .is-playing.touch-device:has(#adventure-controls[data-dive]) {
    --play-side-width: 94px;
    --action-columns: repeat(2, 44px);
    --play-actions-width: 89px;
  }
}
