/* Touch alternatives reuse GoM windows, artwork, tokens and action controllers. */

/* Touch tablets retain the normal layout but share mobile viewport rules. */
@media (pointer: coarse) {
  #floating-text-container {
    width: var(--canvas-visible-width, 100vw);
    overflow: clip;
  }
}
.worldmap-presentation,
.worldmap-destinations,
.pro-touch-fight-controls { display: none; }
html.gom-compact .worldmap-presentation {
  display: flex; flex: 0 0 auto; gap: 8px; padding: 8px 12px;
  background: var(--mg-surface-chrome); border-bottom: 1px solid var(--mg-border-muted);
}
html.gom-compact .worldmap-presentation button { flex: 1; min-height: 44px; }
html.gom-compact .worldmap-presentation [aria-pressed="true"] { outline: 1px solid var(--mg-brass); outline-offset: -3px; }
html.gom-compact .worldmap-window.is-destination-list .worldmap-stage,
html.gom-compact .worldmap-window.is-destination-list .worldmap-zoom-controls { display: none; }
html.gom-compact .worldmap-window.is-destination-list .worldmap-destinations {
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  gap: 8px; padding: 12px; background: var(--mg-surface-window);
}
html.gom-compact .worldmap-destination {
  display: flex; align-items: center; gap: 12px; flex: 0 0 auto; width: 100%;
  min-height: 76px; padding: 10px 12px; text-align: left;
  color: var(--mg-text-main); background: var(--mg-surface-panel);
  border: 1px solid var(--mg-border-muted); border-radius: 3px;
  font: inherit; touch-action: manipulation; cursor: pointer;
}
html.gom-compact .worldmap-destination.is-current { border-color: var(--mg-brass); }
html.gom-compact .worldmap-destination img { width: 52px; height: 52px; object-fit: contain; flex: 0 0 auto; }
html.gom-compact .worldmap-destination > span { min-width: 0; }
html.gom-compact .worldmap-destination strong,
html.gom-compact .worldmap-destination small { display: block; overflow-wrap: anywhere; }
html.gom-compact .worldmap-destination strong { color: var(--mg-parchment); }
html.gom-compact .worldmap-destination small { color: var(--mg-text-muted); padding-top: 4px; }
html.gom-compact .worldmap-stage-toolbar { max-width: 100%; overflow-x: auto; }
html.gom-compact .worldmap-node-actions {
  inset: 12px !important;
  z-index: 3100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.gom-compact .worldmap-node-actions-card {
  flex: 0 0 auto;
  width: min(100%, 420px);
  min-width: 0;
  margin-block: auto;
  box-sizing: border-box;
}
html.gom-compact .worldmap-node-action-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
html.gom-compact .worldmap-node-action-btn { min-height: 44px; }
html.gom-compact .inventory-slot { touch-action: pan-y; }

/* The compact inventory owns the touch surface outside shared workspaces. */
html.gom-compact body:not(:is(.management-workspace-open, .flea-market-store-open, .flea-market-trade-open)) #inventoryOverlay.no-blur:not(.hidden) {
  pointer-events: auto;
}

.inventory-reorder-bar { display: none; }
html.gom-compact #inventoryOverlay .inventory-reorder-bar {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin-bottom: 8px;
}
.inventory-reorder-bar button {
  flex: 0 0 auto;
  min-height: 44px;
  touch-action: manipulation;
}
.inventory-reorder-bar button[aria-pressed="true"] {
  outline: 1px solid var(--mg-brass);
  outline-offset: -3px;
}
.inventory-reorder-status {
  margin: 0;
  color: var(--mg-text-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
html.gom-compact #inventoryOverlay .inventory-slot.is-reorder-source {
  outline: 2px solid var(--mg-brass);
  outline-offset: -3px;
  background-color: var(--mg-surface-recessed);
}
html.gom-compact #inventoryOverlay .is-inventory-reorder .inventory-slot.empty {
  cursor: pointer;
}
html.gom-compact .inventory-slot.filled:focus-visible,
html.gom-compact .is-inventory-reorder .inventory-slot.empty:focus-visible,
html.gom-compact .worldmap-destination:focus-visible { outline: 2px solid var(--mg-brass); outline-offset: 2px; }
html.gom-compact .inventory-action-menu {
  width: auto !important; min-width: 0 !important; max-width: none !important;
  max-height: min(64dvh, 520px); overflow-y: auto; overscroll-behavior: contain;
  box-sizing: border-box; touch-action: pan-y; padding: 12px;
  z-index: 12000;
}
html.gom-compact .inventory-action-menu button { min-height: 44px; white-space: normal; }
html.gom-compact .inventory-action-menu :is(input,select) { min-height: 44px; font-size: 16px; }
html.gom-compact .inventory-touch-details { padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid var(--mg-border-muted); }
html.gom-compact .inventory-touch-details-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
html.gom-compact .inventory-touch-details-heading strong { color: var(--mg-parchment); overflow-wrap: anywhere; }
html.gom-compact .inventory-touch-details-heading button { flex: 0 0 44px; width: 44px; }
html.gom-compact .inventory-touch-details p { margin: 8px 0; color: var(--mg-text-muted); white-space: normal; line-height: 1.5; }
html.gom-compact .inventory-touch-details > div:last-child { font-size: 12px; line-height: 1.6; }
html.gom-compact .pro-fishing-root > header { flex-wrap: wrap; padding: 8px; gap: 8px; min-height: 0; }
html.gom-compact .pro-fishing-root > header button { min-height: 44px; }
html.gom-compact .pro-title { flex: 1; display: block; }
html.gom-compact .pro-title > span { display: none; }
html.gom-compact .pro-title-icon,
html.gom-compact .pro-spacer,
html.gom-compact .pro-time-of-day { display: none; }
html.gom-compact .pro-fishing-root header strong { font-size: 18px; }
html.gom-compact .pro-body { display: block; }
html.gom-compact .pro-scene-column { position: absolute; inset: 0; }
html.gom-compact .pro-scene-column > .pro-viewport { position: relative; inset: auto; }
html.gom-compact .pro-drawer { position: absolute; top: 0; bottom: 0; width: min(340px, 88vw); box-sizing: border-box; z-index: 8; }
html.gom-compact .pro-left { left: 0; }
html.gom-compact .pro-right { right: 0; }
html.gom-compact .pro-drawer :is(select,input,button) { min-height: 44px; font-size: 16px; }
html.gom-compact .pro-scene-controls { gap: 8px; padding: 8px; }
html.gom-compact .pro-scene-controls .pro-status { flex-basis: 100%; max-width: 100%; font-size: 12px; }
html.gom-compact .pro-scene-controls [data-actions] button { min-height: 44px; }
html.gom-compact .pro-touch-fight-controls:not([hidden]) { display: flex; gap: 10px; width: 100%; }
html.gom-compact .pro-touch-fight-controls button { flex: 1; min-height: 54px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html.gom-compact .pro-touch-fight-controls [aria-pressed="true"] { filter: brightness(1.25); outline: 2px solid var(--mg-brass); outline-offset: -3px; }
html.gom-compact .pro-strike-anchor { bottom: 12px; }
html.gom-compact .pro-strike { min-height: 52px; min-width: 180px; }
html.gom-compact .pro-fight-hud { bottom: 12px; padding: 10px 12px; max-height: calc(100% - 20px); overflow-y: auto; box-sizing: border-box; }
html.gom-compact .pro-fight-hud label { margin-top: 5px; }
html.gom-compact .pro-zoom button { min-width: 44px; min-height: 44px; }
/* Stack the map header instead of squeezing its title behind layer controls. */
html.gom-compact #worldMapOverlay .worldmap-hero {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  padding: 12px 54px 12px 12px;
}
html.gom-compact #worldMapOverlay .worldmap-hero .view-hero-main { flex: 0 0 auto; }
html.gom-compact #worldMapOverlay .worldmap-hero .view-hero-copy { min-width: 0; }
html.gom-compact #worldMapOverlay .worldmap-hero h2 { font-size: 20px; line-height: 1.25; }
html.gom-compact #worldMapOverlay .worldmap-hero-badge { width: 38px; height: 38px; flex: 0 0 38px; }
html.gom-compact #worldMapOverlay .worldmap-hero-badge img { width: 100%; height: 100%; object-fit: contain; }
html.gom-compact #worldMapOverlay .worldmap-hero-actions { width: 100%; justify-content: flex-start; flex: 0 0 auto; }
html.gom-compact #worldMapOverlay .worldmap-stage-toolbar { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; }
html.gom-compact #worldMapOverlay .worldmap-layer-btn { min-height: 44px; flex: 0 0 auto; }
html.gom-compact #worldMapOverlay .worldmap-window.is-destination-list .worldmap-zoom-controls { display: none; }
html.gom-compact #worldMapOverlay .worldmap-window.is-destination-list .worldmap-footer { display: flex; padding: 8px; }
html.gom-compact #worldMapOverlay .worldmap-window.is-destination-list .worldmap-world-info { min-height: 52px; padding: 8px 12px; }
html.gom-compact #worldMapOverlay #closeWorldMapBtn { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; min-height: 44px; }

/* The confirmation overlay scrolls the entire framed card on short screens. */
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay, #guildFreightCrateOverlay) {
  top: var(--compact-viewport-top, 0px);
  bottom: auto;
  width: 100%;
  height: var(--compact-viewport-height, 100dvh);
  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));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(min-content, 1fr);
  place-items: start center;
  align-items: safe center;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay, #guildFreightCrateOverlay) > .game-confirm-dialog {
  width: min(100%, 420px);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: none;
  box-sizing: border-box;
  padding: 22px 18px;
  overflow: visible;
  overflow-wrap: anywhere;
}
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay, #guildFreightCrateOverlay) :is(h3, p) { overflow-wrap: anywhere; }
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay, #guildFreightCrateOverlay) p { line-height: 1.45; }
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay) .game-confirm-actions {
  display: flex;
  flex-wrap: wrap;
}
html.gom-compact :is(#gameConfirmOverlay, #quantityActionOverlay) .game-confirm-actions button {
  flex: 1 1 max-content;
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Local drawers share the app grid's available place area. Anchored desktop
   offsets and a scrolled place list must never move their header offscreen. */
html.gom-compact #main:has(.location-scene-drawer:not(.processing-workbench-window)) {
  contain: layout;
  overflow: clip;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) {
  position: fixed !important;
  inset: 6px max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left)) !important;
  display: flex;
  flex-direction: column;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  box-sizing: border-box;
  transform: none !important;
  zoom: 1 !important;
  pointer-events: auto;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) > .location-scene-drawer-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100% !important;
  box-sizing: border-box;
  overflow: hidden;
  zoom: 1;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) :is(.location-scene-drawer-head, .farming-window-header) {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 60px;
  padding: 8px 12px;
  gap: 8px;
  align-items: center;
  box-sizing: border-box;
  cursor: default;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) :is(.location-scene-drawer-head-copy, .farming-window-header > div) {
  flex: 1 1 auto;
  min-width: 0;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) :is(.location-scene-drawer-head-copy h3, .farming-window-header h3) {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) :is(.location-scene-drawer-head, .farming-window-header) > .gom-close-icon {
  position: static !important;
  inset: auto !important;
  flex: 0 0 44px;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  margin: 0;
  padding: 0;
  transform: none !important;
}
html.gom-compact .location-scene-drawer:not(.processing-workbench-window) :is(.location-scene-drawer-body, .farming-window-body) {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Overstrike uses the same meter and equipped pickaxe on touch screens. Stack
   its desktop row so the title, pressure zones and hold action all fit. */
html.gom-compact .skill-event-box:is(.overstrike-interaction-box, .overstrike-countdown-box) {
  display:grid;
  grid-template-columns:minmax(0,1fr);
  justify-content:stretch;
  align-items:center;
  gap:8px;
  width:min(520px,calc(var(--canvas-visible-width,100vw) - 24px)) !important;
  min-width:0;
  max-width:calc(100% - 24px) !important;
  max-height:calc(var(--compact-viewport-height,100dvh) - var(--compact-nav-height,52px) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  top:calc((var(--compact-viewport-height,100dvh) - var(--compact-nav-height,52px) - env(safe-area-inset-bottom)) / 2) !important;
  box-sizing:border-box;
  margin:0;
  padding:14px;
  overflow-x:hidden;
  overflow-y:auto;
}
html.gom-compact :is(.overstrike-interaction-box, .overstrike-countdown-box) > .overstrike-interaction-title {
  min-width:0;
  font-size:17px;
  line-height:1.25;
  overflow-wrap:anywhere;
}
html.gom-compact :is(.overstrike-interaction-box, .overstrike-countdown-box) > .overstrike-instruction {
  min-width:0;
  min-height:2.8em;
  font-size:14px;
  line-height:1.4;
  overflow-wrap:anywhere;
}
html.gom-compact :is(.overstrike-interaction-box, .overstrike-countdown-box) > .overstrike-meter {
  width:calc(100% - 46px) !important;
  min-width:0;
  max-width:none;
  box-sizing:border-box;
  margin:10px 23px !important;
}
html.gom-compact .overstrike-interaction-box > .overstrike-hold-btn {
  width:100%;
  min-width:0 !important;
  min-height:48px !important;
  height:48px !important;
  box-sizing:border-box;
  margin:0 !important;
}
html.gom-compact .overstrike-countdown-box > .interaction-countdown-info {
  display:grid;
  place-items:center;
  min-height:48px;
}

/* Quantity controls keep their tap targets at narrow widths. */
html.gom-compact #quantityActionOverlay { z-index: 20000; }
html.gom-compact #quantityActionOverlay .quality-amounts { overflow: visible; }
html.gom-compact #quantityActionOverlay :is(.quantity-action-item, .quantity-action-item > div, .quality-amounts) { min-width: 0; }
html.gom-compact #quantityActionOverlay .quantity-action-stepper { min-width: 0; grid-template-columns: 44px minmax(0, 1fr) 44px; }
html.gom-compact #quantityActionOverlay .quantity-action-stepper :is(button, input) { min-width: 0; min-height: 44px; box-sizing: border-box; }
html.gom-compact #quantityActionOverlay .quantity-action-stepper input { width: 100%; font-size: 16px; }
html.gom-compact #quantityActionOverlay .quantity-action-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.gom-compact #quantityActionOverlay .quantity-action-presets button { min-width: 0; max-width: 100%; min-height: 44px; width: 100%; margin: 0; box-sizing: border-box; white-space: normal; overflow-wrap: anywhere; }
html.gom-compact #quantityActionOverlay .quality-amount-row input { min-height: 44px; font-size: 16px; }


/* Skill minigames keep their own input surface visible on phones and touch tablets. */
@media (max-width: 1024px), (pointer: coarse) {
  html .skill-event-box {
    box-sizing: border-box;
    max-width: calc(var(--canvas-visible-width, 100vw) - 24px) !important;
    max-height: calc(var(--compact-viewport-height, 100dvh) - var(--compact-nav-height, 52px) - 24px);
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  html .skill-event-box:is(.interaction-countdown-box, .timing-interaction-box, .overstrike-interaction-box, .forager-eye-box, .skill-spot-interaction-box) {
    width: min(760px, calc(var(--canvas-visible-width, 100vw) - 24px)) !important;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    justify-content: stretch;
    align-items: center;
    gap: 10px;
    padding: 14px;
    top: calc(var(--compact-viewport-top, 0px) + (var(--compact-viewport-height, 100dvh) - var(--compact-nav-height, 52px)) / 2) !important;
  }
  html .skill-event-box > :is(.timing-interaction-title, .overstrike-interaction-title, .interaction-info) {
    flex: initial;
    min-width: 0;
    width: auto;
    margin: 0 !important;
    overflow-wrap: anywhere;
  }
  html .skill-event-box .interaction-preview-shell { min-height: 0; min-width: 0; }
  html .skill-event-box .interaction-area { width: 100% !important; max-width: 300px; margin: 0 auto !important; }
  html .skill-event-box .timing-bar-shell { width: calc(100% - 42px) !important; min-width: 0; max-width: none; margin: 17px 21px !important; box-sizing: border-box; }
  html .skill-event-box > :is(.timing-stop-btn, .overstrike-hold-btn) { width: 100%; min-width: 0 !important; min-height: 48px; margin: 0 !important; touch-action: manipulation; }
  html .skill-event-box > .overstrike-hold-btn { touch-action: none; }
  html .skill-event-box .skill-interaction-spot { min-width: 48px; min-height: 48px; }
  html .skill-event-box.forager-eye-box .forager-eye-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 8px;
    width: 100% !important;
    height: auto !important;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px;
  }
  html .skill-event-box.forager-eye-box .forager-eye-item { position: relative !important; left: auto !important; top: auto !important; width: 100% !important; height: 74px !important; min-width: 0; padding: 4px; box-sizing: border-box; touch-action: manipulation; }
  html .skill-event-box.forager-eye-box .forager-eye-copy { gap: 4px !important; }
  html .skill-event-box.skill-click-event-box { width: max-content; flex-wrap: wrap; justify-content: center; }
  html .skill-event-box.skill-click-event-box > button { min-height: 44px; touch-action: manipulation; }
}
@media (max-height: 500px) and (min-width: 600px) {
  html .skill-event-box.forager-eye-box { grid-template-columns: 140px minmax(0, 1fr) !important; }
}

@media (pointer: coarse) {
  .skill-event-box :is(button, .interaction-area, .forager-eye-grid) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
