/* Screen-filling presentation. The renderer keeps pixel proportions, follows
   White on phones, and fits the complete dodge arena above the thumb controls. */
.canvas-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
.battle-ui { display: contents; }
button { touch-action: manipulation; }
.touch-controls { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.joystick-zone { display: grid; justify-items: center; gap: 8px; flex-shrink: 0; }
.joystick {
  width: 132px; height: 132px; position: relative; border-radius: 50%;
  border: 2px solid #69516e; background: radial-gradient(circle, #37283f 0 43%, #201727 44%);
  box-shadow: inset 0 0 0 7px #18121f, 0 4px 0 #08060d; touch-action: none;
}
.joystick::after { content: ''; position: absolute; inset: 17%; border: 1px solid #76607c55; border-radius: 50%; pointer-events: none; }
.joystick-knob {
  position: absolute; width: 44%; height: 44%; top: 28%; left: 28%;
  display: grid; place-items: center; border-radius: 50%; border: 2px solid #b08aac;
  background: radial-gradient(circle at 35% 25%, #80566f, #462b46 75%);
  box-shadow: 0 5px 0 #0c0710, inset 0 0 0 4px #c999b21a; color: var(--pink);
  font-size: 29px; pointer-events: none; will-change: transform;
}
.joystick.held { border-color: var(--pink); }
.joystick.held .joystick-knob { border-color: #ffd1df; background: #71415f; }
.stick-direction { position: absolute; font-size: 19px; color: #ac92b2; pointer-events: none; line-height: 1; }
.north { top: 5px; left: calc(50% - 5px); }.south { bottom: 5px; left: calc(50% - 5px); }
.west { left: 7px; top: calc(50% - 9px); }.east { right: 7px; top: calc(50% - 9px); }
.touch-caption { color: #b49abc; font-size: 14px; letter-spacing: .4px; white-space: nowrap; }
.touch-actions { display: grid; gap: 9px; width: 154px; align-self: center; }
.touch-actions button {
  width: 100%; height: auto; min-height: 54px; display: flex; align-items: center;
  justify-content: center; flex-direction: column; gap: 3px; border-radius: 10px;
}
.touch-actions button:disabled { opacity: .45; }
.touch-actions #touch-action {
  width: 100%; height: 72px; background: #40263e; border: 2px solid #e5a1c1;
  border-bottom: 5px solid #8e526f; color: #ffe4ee; gap: 3px;
}
#touch-action-icon { font-size: 26px; line-height: 1; }
#touch-action-label { font-size: 23px; font-weight: normal; letter-spacing: 1px; }
.touch-actions #touch-action.held,.touch-actions #touch-action:active { background: #81506d; }
.touch-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.touch-actions #touch-back { width: 100%; height: 54px; color: #dbc8e0; }
.touch-secondary button > span:first-child { font-size: 22px; line-height: 1; }
.touch-secondary button > span:last-child { font-size: 15px; }

/* The page is the game. Native fullscreen only removes the browser chrome. */
html,body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: block; padding: 0; min-height: 0; background: #080710; }
.adventure {
  --touch-height: 0px;
  width: 100%; max-width: none; height: 100svh; height: 100dvh;
  min-height: 0; position: relative; display: grid;
  grid-template-rows: minmax(0,1fr) var(--touch-height);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.masthead,.controls,.footer-note { display: none; }
.game-window {
  --status-height: 60px;
  --stage-height: calc(100dvh - 44px - var(--status-height) - var(--touch-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  width: 100%; height: 100%; min-height: 0; border: 0; box-shadow: none;
  display: grid; grid-template-rows: 44px minmax(0,1fr) var(--status-height);
}
.game-window:is([data-view="title"],[data-view="battle"],[data-mode="panel"]) { --status-height: 0px; }
.game-window:is([data-view="title"],[data-view="battle"],[data-mode="panel"]) .game-status { display: none; }
.window-bar { height: 44px; padding: 0 8px 0 16px; }
.location { min-width: 0; }
#location-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-light,.window-actions { flex-shrink: 0; }
.window-actions { gap: 4px; }
.window-actions button { min-width: 44px; width: 44px; height: 44px; }
.scene-wrap {
  width: min(100%,calc(var(--stage-height) * 4 / 3)); aspect-ratio: 4 / 3;
  max-height: 100%; min-height: 0; justify-self: center; align-self: center;
}
#game { position: absolute; top: 0; left: 0; max-width: none; max-height: none; transform-origin: 0 0; }
.game-status { min-height: 0; height: 60px; padding: 7px 16px; }
.journal-button { min-height: 44px; }
.title-buttons button,.panel-options button { min-height: 44px; }
.panel-options { min-height: 0; max-height: 55%; overflow-y: auto; }
.panel-head button { min-width: 44px; min-height: 44px; }
.focus-hint { z-index: 3; }
.focus-hint button { min-height: 48px; }
.choice-grid,#panel-options,#panel-body,.dialog p { scrollbar-width: thin; scrollbar-color: #bb8bab #281b30; }

@media (any-pointer: coarse), (max-width: 700px), (max-height: 600px) and (max-width: 1100px) {
  .adventure { --touch-height: 156px; }
  .adventure:is([data-mode="title"],[data-mode="panel"]) { --touch-height: 0px; }
  .adventure:is([data-mode="title"],[data-mode="panel"]) .touch-controls { display: none; }
  .scene-wrap { width: 100%; height: 100%; aspect-ratio: auto; }
  .window-bar { padding: 0 4px 0 12px; }
  .location { font-size: 17px; letter-spacing: 0; gap: 6px; }
  .window-actions { gap: 0; }
  .window-actions button { font-size: 23px; }
  .touch-controls {
    display: flex; padding: 6px 18px; gap: 12px; min-height: 0;
    background: #100c17; border-top: 1px solid var(--line);
  }
  .joystick-zone { gap: 4px; }
  .joystick { width: 120px; height: 120px; }
  .touch-actions { width: 154px; gap: 6px; }
  .touch-caption { font-size: 12px; }
  .title-screen { padding: 0 12px; }
  .title-heading { padding-top: clamp(24px,8vh,72px); }
  .title-heading .eyebrow { font-size: clamp(12px,3cqw,18px); letter-spacing: 1px; }
  .title-heading h1 { font-size: clamp(56px,17cqw,96px); margin: 12px 0; letter-spacing: 6px; }
  .title-heading h2 { font-size: clamp(23px,6cqw,36px); margin: 4px 0 18px; letter-spacing: 3px; }
  .title-heading p { font-size: clamp(21px,5.5cqw,28px); line-height: 1.12; }
  .title-buttons { width: min(85%,420px); gap: 10px; margin-bottom: 24px; }
  .title-buttons button { min-height: 52px; font-size: 27px; padding: 8px; }
  .title-footnote { max-width: 290px; font-size: 13px; line-height: 1.2; margin-bottom: 18px; letter-spacing: .5px; }
  .game-status { display: grid; grid-template-columns: minmax(0,1fr) 70px; gap: 3px 8px; padding: 5px 12px; }
  .player-status { grid-column: 1; }
  #portrait { display: none; }
  .player-status strong { font-size: 21px; gap: 12px; }
  .player-status strong span { font-size: 19px; }
  .hp-track { margin-top: 3px; height: 3px; }
  .quest-status { grid-column: 1; min-width: 0; font-size: 17px; line-height: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .quest-status small { display: none; }
  .journal-button { grid-column: 2; grid-row: 1/3; width: 70px; padding: 3px; font-size: 19px; }
  .journal-button span { display: none; }
  .room-label { top: 18px; }
  .room-label span { font-size: 18px; }
  .room-label strong { font-size: clamp(26px,7cqw,36px); }
  .dialog { left: 12px; right: 12px; bottom: 12px; border-width: 2px; padding: 12px; gap: 4px; min-height: 174px; max-height: 85%; }
  .dialog-name { font-size: 21px; }
  .dialog p { font-size: 24px; line-height: 1.1; overflow-y: auto; min-height: 0; }
  .dialog button { font-size: 22px; min-height: 44px; padding: 6px 10px; flex-shrink: 0; }
  .world-prompt { font-size: 22px; bottom: 12px; left: 12px; right: 12px; background: #100a18e6; padding: 8px; border: 1px solid #65506c; }

  /* Decisions and the arena each get room without covering either thumb. */
  .scene-wrap[data-view="battle"] { display: flex; flex-direction: column; }
  .scene-wrap[data-view="battle"] .canvas-wrap { height: min(44%,74cqw); flex: 0 0 auto; }
  .battle-heading { top: 8px; left: 12px; right: 12px; }
  .battle-heading strong { font-size: 20px; }
  .battle-heading span { font-size: 14px; max-width: 45%; }
  .battle-ui { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; padding: 0 12px 12px; }
  .battle-box,.battle-box.message { position: static; height: auto; min-height: 0; flex: 1; margin: 0; padding: 10px; border-width: 2px; font-size: 24px; line-height: 1.1; }
  .battle-box p { overflow-y: auto; min-height: 0; }
  .battle-box.message p { flex: 1; }
  .battle-box.message > button.next { min-height: 44px; font-size: 22px; padding: 6px; line-height: 1; margin: 0; flex-shrink: 0; }
  .battle-box .choice-grid { gap: 7px; max-height: 100%; overscroll-behavior: contain; }
  .choice-grid button { min-height: 48px; font-size: 23px; line-height: 1.05; padding: 8px; border: 1px solid #49374c; background: #171019; }
  .choice-grid button.selected { border-color: #ac8e64; background: #30202b; }
  .choice-grid button small { font-size: 17px; padding-left: 0; margin-top: 3px; }
  .battle-hint { position: static; font-size: 20px; line-height: 1.1; padding: 4px; }
  .battle-meta { position: static; font-size: 20px; min-height: 20px; flex-shrink: 0; }
  .battle-actions { position: static; display: grid; gap: 6px; flex-shrink: 0; }
  .battle-actions button { min-height: 48px; font-size: 25px; padding: 5px 0; }
  .battle-actions button span { display: none; }
  .scene-wrap:is([data-phase="message"],[data-phase="act"],[data-phase="item"],[data-phase="mercy"],[data-phase="defend"],[data-phase="attack"]) .battle-actions { display: none; }
  .scene-wrap:is([data-phase="defend"],[data-phase="attack"]) .canvas-wrap { height: auto; flex: 1; min-height: 0; }
  .scene-wrap:is([data-phase="defend"],[data-phase="attack"]) .battle-ui { flex: 0 0 auto; }

  .scene-wrap[data-mode="panel"] { width: min(100%,900px); display: block; }
  .scene-wrap[data-mode="panel"] .canvas-wrap,.scene-wrap[data-mode="panel"] .battle-ui { display: none; }
  .panel { inset: 10px; padding: 16px; border-width: 2px; box-shadow: none; }
  .panel-head { min-height: 44px; font-size: 19px; letter-spacing: .5px; }
  .panel-head button { font-size: 30px; margin: -6px -8px 0 0; }
  .panel h2 { font-size: 34px; line-height: 1; margin: 0 0 16px; }
  .panel #panel-body { font-size: 24px; line-height: 1.15; overscroll-behavior: contain; }
  .panel-options { flex-shrink: 0; max-height: 53%; overflow-y: auto; overscroll-behavior: contain; gap: 8px; margin-top: 12px; }
  .panel-options button { min-height: 48px; font-size: 24px; padding: 10px; }
  .panel-options button small { font-size: 18px; line-height: 1.05; }
}

@media (max-width: 350px) {
  .touch-controls { padding-inline: 10px; }
  .touch-actions { width: 142px; }
  .joystick { width: 110px; height: 110px; }
  .choice-grid button { font-size: 21px; padding: 5px; }
  .choice-grid button small { font-size: 16px; }
  .battle-actions button { font-size: 22px; }
  .title-heading .eyebrow { letter-spacing: 0; }
}
@media (orientation: portrait) and (max-height: 640px) {
  .adventure { --touch-height: 140px; }
  .joystick { width: 108px; height: 108px; }
  .touch-actions #touch-action { height: 62px; }
  .touch-controls { padding-block: 4px; }
  .title-heading { padding-top: 20px; }
  .title-heading h1 { margin: 8px 0; }
  .title-heading p { font-size: 20px; }
  .title-buttons { gap: 7px; margin-bottom: 16px; }
  .title-buttons button { min-height: 44px; }
  .title-footnote { font-size: 11px; margin-bottom: 10px; }
  .battle-box,.battle-box.message { font-size: 22px; padding: 6px; }
}

/* Landscape uses the full height, with compact controls in the side margins. */
@media (orientation: landscape) and (any-pointer: coarse), (orientation: landscape) and (max-width: 700px), (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  .adventure { --touch-height: 0px; --control-rail: 136px; }
  .game-window { --status-height: 44px; }
  .scene-wrap { width: calc(100% - 2 * var(--control-rail)); }
  .game-window[data-view="title"] .scene-wrap { width: 100%; }
  .game-status { height: 44px; display: flex; padding: 0 12px; }
  .game-status .quest-status,.game-status .hp-track { display: none; }
  .journal-button { margin-left: auto; border-width: 0; }
  .touch-controls {
    position: absolute; top: calc(44px + env(safe-area-inset-top)); bottom: env(safe-area-inset-bottom);
    left: env(safe-area-inset-left); right: env(safe-area-inset-right);
    padding: 0 8px; display: flex; align-items: center; pointer-events: none; border: 0; background: none;
  }
  .joystick-zone,.touch-actions { pointer-events: auto; width: 120px; }
  .joystick { width: 112px; height: 112px; }
  .touch-actions { gap: 7px; }
  .touch-actions #touch-action { height: 70px; }
  .touch-caption { font-size: 11px; letter-spacing: 0; }
  .touch-secondary { gap: 5px; }
  .touch-secondary button > span:last-child { font-size: 13px; }
  .dialog { min-height: 150px; padding: 10px; }
  .dialog p { font-size: 22px; }
  .battle-ui { gap: 5px; padding: 0 8px 6px; }
  .battle-box,.battle-box.message { font-size: 22px; padding: 6px; }
  .choice-grid button { font-size: 21px; min-height: 44px; padding: 5px; }
  .battle-actions button { font-size: 23px; min-height: 44px; }
  .battle-meta { font-size: 18px; min-height: 18px; }
  .battle-hint { font-size: 18px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .title-heading { padding-top: 12px; }
  .title-heading .eyebrow,.title-heading p,.title-footnote { display: none; }
  .title-heading h1 { font-size: clamp(44px,10vh,68px); margin: 0; }
  .title-heading h1 span { margin-top: 7px; }
  .title-heading h2 { font-size: 24px; margin: 8px 0; }
  .title-buttons { gap: 7px; margin-bottom: 18px; }
  .title-buttons button { min-height: 44px; font-size: 24px; }
  .panel { padding: 8px 14px; }
  .panel h2 { font-size: 28px; margin-bottom: 8px; }
  .panel #panel-body { font-size: 21px; }
  .panel-options { margin-top: 7px; gap: 6px; }
  .panel-options button { font-size: 21px; min-height: 44px; padding: 6px; }
}
@media (orientation: landscape) and (max-width: 700px) {
  .adventure { --control-rail: 110px; }
  .joystick-zone,.touch-actions { width: 98px; }
  .joystick { width: 96px; height: 96px; }
  .touch-caption { font-size: 10px; }
  #touch-action-label { font-size: 20px; letter-spacing: 0; }
  .touch-secondary button > span:last-child { font-size: 12px; }
  .battle-heading span { display: none; }
  .battle-heading strong { font-size: 18px; }
  .battle-actions { gap: 4px; }
  .battle-actions button { font-size: 20px; }
  .battle-box,.battle-box.message { font-size: 20px; }
  .battle-hint { font-size: 16px; }
}
