/* Input UI stays above the world, below modal screens. */
.faunara-input-dialog {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  background: #0b1c16dc;
  padding: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  font-family: inherit;
  color: #fff1cf;
}
.faunara-input-dialog.hidden {
  display: none;
}
.faunara-input-card {
  width: min(640px, 100%);
  max-height: 90dvh;
  overflow: auto;
  background: #193b2e;
  border: 1px solid #cdb983;
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.faunara-input-card h2,
.faunara-input-card p {
  width: 100%;
  margin: 4px 0 10px;
}
.faunara-input-card button,
.faunara-input-card select,
.faunara-input-card input,
.faunara-binding-row button,
.faunara-input-options select {
  font: inherit;
  color: #fff3d0;
  background: #294b39;
  border: 1px solid #9b986f;
  border-radius: 8px;
  padding: 10px;
  min-height: 44px;
}
.faunara-input-card button:disabled {
  opacity: 0.45;
}
.faunara-binding-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #567354;
}
.faunara-binding-row button {
  text-align: left;
  font-size: 12px;
}
.faunara-input-options {
  display: grid;
  gap: 10px;
}
.faunara-input-options label {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.faunara-input-status {
  font-size: 13px;
}
.faunara-letter-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  width: 100%;
}
body[data-input-device="gamepad"] button:focus,
body[data-input-device="gamepad"] input:focus,
body[data-input-device="gamepad"] select:focus {
  outline: 3px solid #ffdf77 !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #183d30 !important;
}
.faunara-touch {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.faunara-touch[hidden],
.faunara-touch button[hidden] {
  display: none !important;
}
.faunara-touch-stick {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  border: 2px solid #e2d3a484;
  border-radius: 50%;
  background: #142e258c;
  color: #fff3c9;
  font-size: 12px;
  pointer-events: auto;
  touch-action: none;
}
.faunara-touch-stick i {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f7e0a54f;
  border: 1px solid #fff0bf;
}
.faunara-touch-actions {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(48px, 72px));
  gap: 6px;
  pointer-events: none;
}
.faunara-touch button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid #e1d4aa95;
  background: #163b2ade;
  color: #fff1c9;
  font: 600 11px/1.2 system-ui;
  padding: 7px 4px;
  pointer-events: auto;
  touch-action: none;
}
.faunara-touch button:active {
  background: #648456;
}
.faunara-touch button[data-action="pause"],
.faunara-touch button[data-action="map"] {
  background: #655632dc;
}
body[data-input-device="touch"] #scene {
  touch-action: none;
}
body[data-input-device="touch"] #walkInfo,
body[data-input-device="touch"] .controls-hint {
  display: none !important;
}
@media (max-width: 600px) {
  .faunara-binding-row {
    grid-template-columns: 1fr 1fr;
  }
  .faunara-binding-row > span {
    grid-column: 1/-1;
  }
  .faunara-touch-actions {
    grid-template-columns: repeat(3, 54px);
    gap: 4px;
  }
  .faunara-touch button {
    min-height: 42px;
    font-size: 10px;
  }
  .faunara-touch-stick {
    width: 104px;
    height: 104px;
    left: 12px;
  }
  .faunara-input-card {
    padding: 14px;
  }
  .faunara-input-options label {
    flex-wrap: wrap;
  }
}
@media (max-height: 500px) {
  .faunara-touch-actions {
    grid-template-columns: repeat(5, 58px);
  }
  .faunara-touch button {
    min-height: 40px;
  }
  .faunara-touch-stick {
    width: 100px;
    height: 100px;
  }
}
button.intro-continue {
  color: inherit;
  width: 100%;
  text-align: right;
  cursor: pointer;
  pointer-events: auto;
}
/* Single dialogue confirmations should not look like selected menu rows. */
body.faunara-game button.intro-continue:focus,
#faunaraConversation[data-phase="acknowledge"] button:focus {
  outline: none !important;
}
button.intro-arrow {
  pointer-events: auto;
  color: inherit;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
}
.intro-choose {
  pointer-events: auto;
  min-height: 44px;
  padding: 10px 24px;
  border-radius: 10px;
  border: 1px solid #dcc68c;
  background: #244936;
  color: #ffefc3;
  display: block;
  margin: 12px auto;
  font-weight: 700;
}
/* Reserve separate space for touch HUD information and the thumb controls. */
body[data-input-device="touch"] .faunara-hud-actions {
  display: none !important;
}
body[data-input-device="touch"] .area-chip {
  left: 12px !important;
  top: 12px !important;
  max-width: calc(50vw - 24px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
body[data-input-device="touch"] .player-vitals {
  top: 12px !important;
  right: 12px !important;
  max-width: calc(50vw - 24px);
  flex-wrap: wrap;
}
body[data-input-device="touch"] #faunaraFieldAction {
  left: 12px !important;
  top: 66px !important;
  max-width: calc(50vw - 24px);
  font-size: 11px;
}
body[data-input-device="touch"] #faunaraWorldAction {
  left: 12px;
  top: 112px;
  bottom: auto;
  max-width: calc(50vw - 24px);
  padding: 8px 12px;
  font-size: 11px;
}
body[data-input-device="touch"] #faunaraFieldResult {
  left: 12px !important;
  top: 157px !important;
  max-width: calc(50vw - 24px) !important;
  font-size: 10px;
}
#faunaraFieldResult:empty {
  display: none;
}
body[data-input-device="touch"] .player-guard {
  left: 12px;
  bottom: 145px;
  padding: 3px 7px;
}
body[data-input-device="touch"] .player-guard progress {
  width: 65px;
}
body[data-input-device="touch"] #toast {
  bottom: auto;
  top: 45%;
  max-width: 80vw;
  pointer-events: none;
}
@media (max-width: 600px) and (orientation: portrait) {
  body[data-input-device="touch"] .area-chip {
    max-width: calc(100vw - 24px);
  }
  body[data-input-device="touch"] .player-vitals {
    left: 12px !important;
    right: auto !important;
    top: 64px !important;
    max-width: calc(100vw - 24px);
  }
  body[data-input-device="touch"] #faunaraFieldAction {
    top: 112px !important;
    max-width: calc(100vw - 24px);
  }
  body[data-input-device="touch"] #faunaraWorldAction {
    top: 157px;
    max-width: calc(100vw - 24px);
  }
  body[data-input-device="touch"] #faunaraFieldResult {
    top: 202px !important;
    max-width: calc(100vw - 24px) !important;
  }
}
body[data-input-device="touch"] .berry-slots {
  display: none !important;
}
body[data-input-device="touch"].faunara-battle #faunaraFieldAction,
body[data-input-device="touch"].faunara-battle #faunaraFieldResult {
  display: none !important;
}
.faunara-action-hints {
  position: absolute;
  right: 24px;
  bottom: 86px;
  max-width: min(660px, calc(100vw - 350px));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 12px;
  padding: 10px 12px;
  border: 1px solid #c9d5a46e;
  border-radius: 10px;
  background: #102c22e6;
  color: #f8edcb;
  font: 11px/1.4 system-ui;
  pointer-events: none;
}
.faunara-action-hints[hidden] {
  display: none !important;
}
.faunara-action-hints > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.faunara-action-hints kbd {
  display: inline-block;
  min-width: 24px;
  padding: 3px 6px;
  border: 1px solid #bdcea1;
  border-radius: 5px;
  background: #385540;
  color: #fff6d4;
  text-align: center;
  font: 700 12px/1.2 system-ui;
}
@media (max-width: 700px) {
  .faunara-action-hints {
    left: 12px;
    right: 12px;
    bottom: 76px;
    max-width: none;
    justify-content: center;
    font-size: 10px;
  }
  body:not([data-input-device="touch"]) #faunaraWorldAction {
    top: 132px;
    bottom: auto;
    max-width: calc(100vw - 24px);
  }
}
.faunara-binding-row {
  grid-template-columns: minmax(130px, 1.2fr) minmax(130px, 1fr);
}

/* The title menu selection follows focus instead of a fixed primary button. */
#faunaraTitle .faunara-actions button:focus,
body:not([data-input-device="gamepad"]) #faunaraTitle .faunara-actions button:hover {
  background: #fff;
  color: #17211f;
  border-color: #fff;
  font-weight: 700;
  outline: none !important;
  box-shadow: none !important;
  transform: none;
}
body[data-input-device="gamepad"] #faunaraTitle .faunara-actions button:not(:focus) {
  background: #16261ed9;
  color: #fff8e9;
  border-color: #d6bc79aa;
  transform: none;
}
/* Keep settings, including audio sliders, inside narrow touch screens. */
#faunaraSettings .settings-content {
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
#faunaraSettings .settings-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Companion status stays in the HUD; control instructions live in Settings. */
.faunara-contextual-hud {
  position: fixed;
  z-index: 52;
  left: max(16px, env(safe-area-inset-left));
  bottom: calc(64px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: min(440px, 46vw);
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #b0d8c099;
  border-radius: 12px;
  background: #152b2bea;
  color: #fff6d9;
  font: 12px/1.45 system-ui;
  pointer-events: none;
  overflow-wrap: anywhere;
}
.faunara-contextual-hud[hidden] { display: none !important; }
.faunara-contextual-hud .fa-command-hud,
.faunara-contextual-hud .fa-ability-hud {
  position: static !important;
  transform: none !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  text-align: left !important;
  font: 600 12px/1.45 system-ui !important;
}
.faunara-controls-guide h3 { margin-bottom: 6px; }
.faunara-controls-guide p { margin-top: 0; line-height: 1.5; }
@media (max-width: 700px) {
  .faunara-contextual-hud { left: max(12px, env(safe-area-inset-left)); max-width: min(440px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); font-size: 11px; }
}
.faunara-contextual-source { display: none !important; }
@media (min-width: 701px) {
  body:not([data-input-device="touch"]):has(.faunara-contextual-hud:not([hidden])) #faunaraWorldAction {
    bottom: var(--faunara-contextual-top-offset, 240px);
  }
}
@media (orientation: landscape) and (min-width: 701px) and (max-height: 500px) {
  body[data-input-device="touch"] #faunaraWorldAction {
    left: auto;
    right: 12px;
    top: 66px;
    max-width: calc(45vw - 24px);
  }
}

/* Controller/keyboard selection is immediate, including summaries and custom controls. */
body[data-input-device="gamepad"] :is(button,input,select,textarea,summary,[tabindex="0"]):focus,
body :is(button,input,select,textarea,summary,[tabindex="0"]):focus-visible {
  transition: none !important;
}
body[data-input-device="gamepad"] :is(textarea,summary,[tabindex="0"]):focus {
  outline: 3px solid #ffdf77 !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px #183d30 !important;
}
:where(.fa-pause-view,.pedia-grid,.pedia-sidebar,.pedia-detail,.fs-grid,.fs-detail,.settings-content,.faunara-input-card) {
  scroll-padding: 24px;
  overscroll-behavior: contain;
}
@media (max-width:650px), (max-height:500px) {
  :where(.fa-pause-view,.pedia-grid,.pedia-sidebar,.pedia-detail,.fs-grid,.fs-detail,.settings-content,.faunara-input-card) { scroll-padding: 12px; }
}
/* Keep the label visible and highlight the whole setting, not just its checkbox. */
body[data-input-device="gamepad"] label:has(:focus) {
  outline: 3px solid #ffdf77;
  outline-offset: 3px;
  transition: none !important;
}

/* Named control sections stay readable in both the title options and pause menu. */
#settingsControlView { scroll-padding-top: 96px; }
.faunara-control-jump { gap: 8px; font-weight: 700; }
.faunara-control-section { min-width: 0; scroll-margin-top: 0; }
.faunara-control-section-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  padding: 10px 12px;
  background: #244c43;
  color: #fff1cf;
  border-radius: 6px;
  box-shadow: 0 2px 5px #132d2526;
}
.faunara-control-section-head h3 { margin: 0; font-size: 16px; line-height: 1.3; text-wrap: balance; }
.faunara-control-section-back {
  flex-shrink: 0;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid #c9d7ad80;
  border-radius: 4px;
  background: #ffffff12;
  color: #fff1cf;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}
.faunara-control-section-back:hover { background: #ffffff25; }
.faunara-control-section > .faunara-input-options { padding: 2px 0 8px; }
.faunara-control-section .faunara-binding-row:last-child { border-bottom: 0; }
.faunara-control-jump select, .faunara-control-section select { max-width: 100%; min-width: 0; }
@media (max-width:650px), (max-height:500px) {
  .faunara-control-section-head { gap: 8px; padding: 8px; }
  .faunara-control-section-head h3 { font-size: 14px; }
  .faunara-control-section-back { padding: 6px 8px; }
}

/* One compact contextual prompt. Status widgets retain their live information. */
body.faunara-compact-controls #faunaraRecommendedControls,
body.faunara-compact-controls #faunaraWorldAction,
body.faunara-compact-controls .story-interact,
body.faunara-compact-controls .faunara-lift-hint,
body.faunara-compact-controls .faunara-crate-hint,
body.faunara-compact-controls .faunara-controls,
body.faunara-compact-controls .faunara-recommended-controls,
body.faunara-compact-controls .fa-race-entry,
body.faunara-compact-controls #faunaraHud kbd,
body.faunara-compact-controls #controlsHint,
body.faunara-compact-controls #walkInfo { display:none !important; }
.fa-context-prompt {
  position:fixed; left:50%; bottom:max(42px,env(safe-area-inset-bottom));
  transform:translateX(-50%); width:min(420px,calc(100vw - 32px)); height:152px;
  z-index:125; color:#fffbed; pointer-events:none; font-family:system-ui,sans-serif;
  -webkit-font-smoothing:antialiased; isolation:isolate;
}
.fa-context-prompt[hidden],.fa-context-wheel[hidden] { display:none !important; }
.fa-context-diamond { position:absolute; bottom:0; left:50%; transform:translateX(-50%); width:126px; height:126px; }
.fa-context-button {
  position:absolute; width:44px; height:44px; border:0; padding:0; margin:0;
  border-radius:50%; color:#fffbed; background:none; overflow:visible;
  pointer-events:auto; cursor:pointer; touch-action:none; opacity:1;
  transition:opacity .15s ease-out,transform .1s ease-out;
}
.fa-context-button:active { transform:scale(.96); }
.fa-context-button:focus-visible { outline:2px solid #fffbed; outline-offset:3px; }
.fa-context-button:disabled { cursor:default; opacity:.24; pointer-events:none; }
.fa-context-button[data-position="north"] { left:41px; top:0; }
.fa-context-button[data-position="west"] { left:0; top:41px; }
.fa-context-button[data-position="east"] { left:82px; top:41px; }
.fa-context-button[data-position="south"] { left:41px; top:82px; }
.fa-context-glyph {
  position:absolute; inset:5px; display:grid; place-items:center; border-radius:50%;
  background:#10171380; font-size:18px; font-weight:700; line-height:1;
  box-shadow:0 1px 3px #0004; text-shadow:0 1px 2px #0008;
}
.fa-context-button[data-highlight="true"]:not(:disabled) .fa-context-glyph {
  color:#182219; background:#fffbed; text-shadow:none; box-shadow:0 0 0 3px #0d181160,0 1px 4px #0008;
}
.fa-context-label {
  position:absolute; left:42px; top:10px; width:max-content; max-width:145px;
  padding:3px 8px; color:#fffbed; background:linear-gradient(90deg,#101713b0 65%,#10171300);
  font-size:12px; font-style:italic; font-weight:600; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 2px #000a; pointer-events:none;
}
.fa-context-label:empty { display:none; }
.fa-context-button[data-role="primary"] .fa-context-label { font-size:16px; top:8px; }
.fa-context-button[data-position="west"] .fa-context-label { left:auto; right:42px; background:linear-gradient(270deg,#101713b0 65%,#10171300); }
.fa-context-button[data-position="north"] .fa-context-label { top:-18px; left:50%; transform:translateX(-50%); }
.fa-context-shoulders { position:absolute; top:0; left:50%; transform:translateX(-50%); width:190px; }
.fa-context-shoulders .fa-context-button { width:44px; height:40px; }
.fa-context-shoulders .fa-context-glyph { inset:8px 0; border-radius:5px; font-size:11px; }
.fa-context-shoulders .fa-context-label { top:40px; left:50%; transform:translateX(-50%); font-size:10px; padding:2px 5px; }
.fa-context-button[data-position="shoulder-left"] { left:0; }
.fa-context-button[data-position="shoulder-right"] { right:0; }
.fa-context-prompt[data-device="keyboard"] .fa-context-glyph { font-size:12px; }
.fa-context-prompt[data-dialogue="true"] { bottom:max(18px,env(safe-area-inset-bottom)); height:110px; }
.fa-context-prompt[data-dialogue="true"] .fa-context-diamond { width:126px; height:100px; }
.fa-context-prompt[data-dialogue="true"] .fa-context-button[data-position="south"] { top:56px; }
.fa-context-prompt[data-dialogue="true"] .fa-context-button[data-position="east"] { top:15px; }
.fa-context-wheel { z-index:123; max-height:min(65vh,560px); overflow:auto; }
.fa-context-wheel .selected { outline:2px solid #fffbed; outline-offset:2px; background:#356963; }
.fa-context-wheel-nav { display:flex; align-items:center; justify-content:center; gap:16px; margin-top:12px; }
.fa-context-wheel-nav button { min-width:44px; min-height:44px; }
body.faunara-compact-controls .faunara-touch-actions.fa-context-prompt {
  left:auto; right:max(12px,env(safe-area-inset-right)); bottom:max(18px,env(safe-area-inset-bottom));
  transform:none; display:block; width:188px; height:214px; padding:0; background:none; border:0;
}
#faunaraActionPrompt[data-device="touch"] .fa-context-diamond { width:156px; height:170px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button { width:56px; height:56px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-glyph { inset:6px; font-size:22px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button[data-position="north"] { left:50px; top:0; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button[data-position="west"] { left:0; top:56px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button[data-position="east"] { left:100px; top:56px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button[data-position="south"] { left:50px; top:112px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-label {
  left:50%; right:auto; top:50px; transform:translateX(-50%); max-width:86px;
  padding:2px 5px; font-size:11px; background:#101713a0;
}
#faunaraActionPrompt[data-device="touch"] .fa-context-shoulders { width:176px; top:0; }
#faunaraActionPrompt[data-device="touch"] .fa-context-shoulders .fa-context-button { width:52px; height:44px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-shoulders .fa-context-glyph { font-size:17px; inset:0 4px 12px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-shoulders .fa-context-label { top:31px; }
.fa-context-prompt[data-device="touch"][data-dialogue="true"] { bottom:12px; height:188px; }
@media(max-width:600px) {
  .fa-context-prompt:not([data-device="touch"]) { bottom:max(28px,env(safe-area-inset-bottom)); width:calc(100vw - 24px); }
  .fa-context-label { max-width:96px; font-size:11px; padding:3px 5px; }
  .fa-context-button[data-role="primary"] .fa-context-label { font-size:14px; max-width:110px; }
}
@media(prefers-reduced-motion:reduce) { .fa-context-button { transition:none; } }

/* Target selection joins the shared context tools rather than a separate button bar. */
body.faunara-compact-controls .fa-target-controls { display:none !important; }
body.faunara-compact-controls #faunaraActionPrompt[data-dialogue="true"] { z-index:160; }
body.faunara-compact-controls #faunaraActionPrompt[data-dialogue="true"] .fa-context-label { background:#101713d9; }

body.faunara-compact-controls #faunaraTrainerOffer { display:none !important; }
/* Dialogue's general button skin must not restyle the compact circles. */
#faunaraActionPrompt .fa-context-button { background:none; border:0; box-shadow:none; padding:0; min-width:0; min-height:0; font-family:system-ui,sans-serif; }

body.faunara-compact-controls #faunaraConversation[data-phase="acknowledge"] .fa-conversation-choices { visibility:hidden !important; pointer-events:none; }

#faunaraActionPrompt .fa-context-button { position:absolute; width:44px; height:44px; color:#fffbed; text-align:center; }
#faunaraActionPrompt[data-device="touch"] .fa-context-button { width:56px; height:56px; }
#faunaraActionPrompt[data-device="touch"] .fa-context-shoulders .fa-context-button { width:52px; height:44px; }

body.faunara-compact-controls .faunara-action-hints { display:none !important; }

body.faunara-compact-controls #faunaraColdOpen .cold-next,
body.faunara-compact-controls #faunaraColdOpen [data-action="jump"],
body.faunara-compact-controls #faunaraColdOpen [data-action="drift"],
body.faunara-compact-controls #faunaraColdOpen [data-action="run"] { display:none !important; }

body.faunara-compact-controls #faunaraColdOpen .cold-touch [data-steer],
body.faunara-compact-controls #faunaraColdOpen .cold-touch [data-action="forward"],
body.faunara-compact-controls #faunaraColdOpen .cold-touch [data-action="backward"] { display:none !important; }
body.faunara-compact-controls #faunaraColdOpen .cold-pause { position:fixed;top:max(14px,env(safe-area-inset-top));right:max(14px,env(safe-area-inset-right));min-height:44px; }
