/* Shared baseline: scope browser-gesture ownership to the game, keep native
   editable fields and links usable, and never disable viewport scaling. */
[data-game-surface], [data-game-surface] * {
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
}
[data-game-surface] { touch-action:none; overscroll-behavior:none; }
[data-game-surface] button, [data-game-surface] canvas, [data-realtime-control] {
  touch-action:none;
  -webkit-tap-highlight-color:transparent;
}
[data-game-surface] button > *, [data-realtime-control] > * { pointer-events:none; }
[data-game-surface] input, [data-game-surface] textarea,
[data-game-surface] select, [data-game-surface] [contenteditable]:not([contenteditable="false"]),
[data-game-surface] [data-native-touch], [data-game-surface] a[href], [data-game-surface] a[href] * {
  -webkit-user-select:text;
  user-select:text;
  -webkit-touch-callout:default;
  touch-action:manipulation;
}
html,body { position:fixed; inset:0; overscroll-behavior:none; }
#game { height:100%; height:100dvh; }
.modal { 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)); }
.sheet { max-height:100%; min-height:0; overflow:hidden; }
.sheet-header { flex:none; padding:10px 16px; min-height:60px; }
.sheet-header h2 { font-size:24px; }
.sheet-body { min-height:0; overflow:hidden; overscroll-behavior:none; padding:12px 16px; }
.sheet-body p { margin:8px 0; line-height:1.45; }
.tabs { flex:none; margin:0 0 10px; gap:4px; }
.tabs button { min-height:44px; padding:8px 10px; border-radius:12px; }
.recipe-list { grid-template-columns:repeat(var(--panel-columns,1),minmax(0,1fr)); gap:6px; }
.recipe { min-height:80px; padding:8px; gap:8px; grid-template-columns:28px minmax(0,1fr) auto; }
.recipe-icon { width:28px; height:32px; font-size:17px; }
.recipe h3 { font-size:11px; }
.recipe .button { min-height:44px; padding:8px; }
.recipe p { font-size:10px; }
.costs { font-size:10px; gap:2px 7px; }
.pager { margin:10px 0 0; }
.pager .button { min-height:44px; min-width:44px; padding:8px 12px; }
.resource-grid { grid-template-columns:repeat(var(--resource-columns,4),minmax(0,1fr)); gap:6px; margin:8px 0; }
.resource { min-height:72px; padding:6px 3px; }
.resource .symbol { margin-bottom:3px; }
.survival-stats { width:auto; float:none; }
.stat { padding:5px 3px; }
.stat strong { font-size:16px; }
.pack-head { height:auto; margin:8px 0 0; }
.button-row { margin:8px 0 0; }
.button-row .button { min-height:44px; }
.pet-name { margin:10px 0; font-size:23px; }
.full { min-height:44px; margin-top:8px; }
.map-layout { display:grid; gap:10px; min-height:0; }
.map-canvas { max-width:100%; max-height:calc(100dvh - 280px); object-fit:contain; }
.map-legend { margin:8px 0; gap:8px; }
.map-info .subheading { margin:8px 0; }
.end-panel { max-height:100%; overflow:hidden; }
@media (orientation:landscape) and (max-height:560px) {
  .sheet { width:min(760px,100%); }
  .survival-stats { width:52%; float:right; }
  .pack-head { height:43px; margin:0; }
  .resource-grid { clear:both; }
  .map-layout { grid-template-columns:minmax(0,1.3fr) minmax(0,1fr); align-items:center; }
  .map-canvas { max-height:calc(100dvh - 126px); }
  .map-legend { font-size:9px; }
  .sheet-body[data-panel="help"] h3 { margin:0 0 8px; }
  .sheet-body[data-panel="help"] p { font-size:12px; }
  .end-panel { padding:12px 20px; }
  .end-panel h2 { font-size:26px; }
  .end-stats { margin:8px 0; }
  .end-panel .session-notice { margin:6px 0; }
}
@media (max-height:360px) {
  .modal { padding:8px max(8px,env(safe-area-inset-right)) 8px max(8px,env(safe-area-inset-left)); }
  .sheet-header { min-height:52px; padding:6px 12px; }
  .sheet-header h2 { font-size:21px; }
  .sheet-body { padding:8px 12px; }
  .tabs { margin-bottom:6px; }
  .recipe { min-height:72px; }
  .pager { margin-top:6px; }
  .sheet-body[data-panel="help"] p { font-size:11px; line-height:1.35; }
  .menu-buttons { grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  .menu-buttons .button { padding:8px; }
  .end-panel h2 { margin:4px 0; }
  .end-panel>p { margin:5px 0; }
}
.pack-footer,.storage-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.pack-footer>span { font-size:11px; white-space:nowrap; }
.pack-footer .pager,.storage-footer .pager { flex:1; margin:0; }
.storage-footer .button-row { margin:0; }
.storage-footer .button-row .button { min-width:52px; }
@media (orientation:landscape) and (max-height:560px) {
 .survival-stats { width:100%; float:none; }
 .stat { padding:4px 3px; }
 .stat strong,.stat span { display:inline; margin:0 4px; }
}
/* Keep thumb targets and status clear of both portrait and landscape cutouts. */
#hud { top:max(14px,env(safe-area-inset-top)); left:max(18px,env(safe-area-inset-left)); right:max(16px,env(safe-area-inset-right)); }
.vitals { top:max(15px,env(safe-area-inset-top)); left:max(16px,env(safe-area-inset-left)); }
.stick { left:max(25px,env(safe-area-inset-left)); }
.combat-controls { right:max(18px,env(safe-area-inset-right)); bottom:max(24px,env(safe-area-inset-bottom)); }
@media (max-width:560px) and (orientation:portrait) {
 .objective { top:calc(max(15px,env(safe-area-inset-top)) + 71px); }
 .clock { top:calc(max(15px,env(safe-area-inset-top)) + 49px); }
 .combat-controls { bottom:max(52px,env(safe-area-inset-bottom)); }
 .quick-actions { left:max(18px,env(safe-area-inset-left)); }
}
/* Modular camp controls stay inside the existing non-scrolling game panels. */
.recipe-actions { display:flex; gap:4px; }
.recipe-actions .button { min-width:40px; padding:7px; }
.craft-footer { display:flex; gap:10px; align-items:center; margin-top:10px; }
.craft-footer .pager { flex:1; margin:0; }
.build-bar { flex-wrap:wrap; }
.build-bar>div { flex-basis:100%; }
.build-bar>.button { flex:1; min-height:44px; }
@media (orientation:landscape) {
 .build-bar { max-width:min(560px,80vw); min-width:360px; bottom:max(118px,env(safe-area-inset-bottom)); }
 .build-bar>div { flex-basis:100%; }
}
.pet-switch { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:4px 0; }
.pet-switch .pet-name { margin:0; font-size:21px; }
.pet-switch .button { min-width:44px; min-height:44px; padding:8px; }

@media (max-height:360px) {
 .sheet-body[data-panel="pack"] .pet-switch { margin:0; }
 .sheet-body[data-panel="pack"] .pet-switch+p { margin:4px 0; }
}
/* Narrow landscape: separate the central inventory buttons from combat targets. */
@media (orientation:landscape) and (max-height:420px) and (max-width:740px) {
 .quick-actions { flex-direction:column; width:96px; gap:6px; bottom:max(20px,env(safe-area-inset-bottom)); }
 .quick-actions button { height:44px; min-height:44px; justify-content:center; padding:0 8px; }
 .quick-actions kbd,.quick-actions small { display:none; }
}
@media (orientation:landscape) and (max-height:420px) and (max-width:600px) {
 .combat-controls { display:grid; grid-template-columns:54px 76px; gap:7px; align-items:end; }
 .combat-controls .round.main { grid-column:2; grid-row:1/3; align-self:center; }
}

/* Six bounded trait cards instead of a scrollable detail sheet. */
.animal-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px 8px; }
.animal-stats .stat { padding:6px 2px; min-width:0; }
.animal-stats .stat strong { font-size:16px; text-transform:capitalize; }
.animal-stats .stat span { font-size:10px; }
@media (max-height:360px) { .animal-stats { grid-template-columns:repeat(6,minmax(0,1fr)); } .animal-stats .stat strong { font-size:14px; } }

/* Trait values and labels must not inherit the compact survival HUD's inline flow. */
.animal-stats .stat strong,.animal-stats .stat span { display:block; margin:0; max-width:100%; overflow-wrap:anywhere; line-height:1.2; }
.animal-stats .stat span { margin-top:3px; }
#close-modal { width:44px; height:44px; min-width:44px; min-height:44px; flex:0 0 44px; }

/* One bounded pack panel. Only explicit search opens a native text field. */
.sheet-actions { display:flex; gap:8px; }
#pack-more { width:44px; height:44px; min-width:44px; min-height:44px; }
.modal[data-book="true"] .sheet { width:min(920px,100%); height:min(700px,100%); }
.modal[data-book="true"] .sheet-body { flex:1; padding:8px; }
.modal[data-book="true"][data-compact="true"] .sheet-header { min-height:52px; padding:4px 12px; }
.recipe-book { height:100%; min-height:0; display:grid; grid-template-rows:44px minmax(0,1fr); gap:8px; }
.book-sections { display:flex; justify-content:center; align-items:center; gap:16px; }
.book-sections .icon-button { width:56px; height:44px; border-radius:10px; background:#213f33; }
.book-sections [aria-pressed="true"] { color:#f4cc7a; background:#496044; border-color:#d0b877; }
.recipe-book section { min-height:0; min-width:0; }
.recipe-book[data-section="inventory"] .recipe-pane,.recipe-book[data-section="inventory"] .recipe-detail,.recipe-book[data-section="inventory"] .equipment-pane,
.recipe-book[data-section="equipment"] .inventory-pane,.recipe-book[data-section="equipment"] .recipe-pane,.recipe-book[data-section="equipment"] .recipe-detail,
.recipe-book[data-section="craft"] .inventory-pane,.recipe-book[data-section="craft"] .equipment-pane { display:none; }
.inventory-pane { display:grid; grid-template-rows:28px minmax(0,1fr) 44px; gap:8px; }
.inventory-heading { display:flex; justify-content:space-between; align-items:center; color:#c4c9aa; font-size:12px; }
.inventory-slots { display:grid; grid-template-columns:repeat(var(--inventory-columns),minmax(0,1fr)); grid-auto-rows:54px; align-content:start; gap:6px; }
.inventory-slot,.empty-slot { position:relative; border:1px solid #79907870; background:#234638; border-radius:7px; min-width:44px; min-height:54px; padding:4px; }
.inventory-slot>span { display:block; font-size:20px; color:#e8c47b; line-height:24px; }
.inventory-slot>b { position:absolute; top:4px; right:5px; font-size:11px; font-weight:600; }
.inventory-slot>small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:9px; }
.empty-slot { display:grid; place-items:center; color:#a5b59a; border-style:dashed; }
.book-pager { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.book-pager>span { font-size:11px; color:#c4c9aa; }
.book-pager>.button { width:44px; min-width:44px; height:44px; padding:6px; }
.recipe-book[data-section="craft"] { grid-template-rows:44px minmax(0,1fr) 140px; }
.recipe-pane { display:grid; min-height:0; grid-template-rows:44px minmax(0,1fr) 44px; gap:6px; }
.recipe-toolbar { display:flex; align-items:center; gap:6px; }
.recipe-toolbar>.button { min-width:85px; height:44px; padding:8px; }
#craftable-filter[aria-pressed="true"] { background:#52694b; border-color:#d0b877; color:#fff0bf; }
.recipe-toolbar .icon-button { width:44px; height:44px; min-width:44px; min-height:44px; border-radius:8px; }
.recipe-search-box { display:flex; gap:6px; flex:1; min-width:0; }
.recipe-search-box input { width:100%; min-width:0; height:44px; padding:8px; font:16px system-ui; color:var(--ink); background:#102e23; border:1px solid #799078; border-radius:7px; touch-action:manipulation; }
.book-recipe-grid { display:grid; grid-template-columns:repeat(var(--recipe-columns),minmax(0,1fr)); grid-auto-rows:54px; gap:6px; align-content:start; min-height:0; }
.book-recipe { position:relative; min-width:44px; min-height:54px; border:1px solid #75917a60; border-radius:7px; padding:4px; background:#254a39; }
.book-recipe>span { display:block; color:#ddc594; font-size:21px; height:26px; }
.book-recipe>small { display:block; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.book-recipe>b { position:absolute; right:5px; top:3px; color:#c5dfa1; font-size:14px; }
.book-recipe.selected { border-color:#efce80; background:#4c6245; box-shadow:inset 0 0 0 1px #efce8060; }
.book-recipe.ready>span { color:#f4dba1; }
.no-recipes { font-size:12px; color:#c4c9aa; padding:10px 0; grid-column:1/-1; }
.recipe-detail { display:grid; grid-template-rows:24px minmax(0,1fr) 16px 44px; gap:4px; border-top:1px solid #d8dfb330; padding-top:6px; }
.recipe-detail h3 { display:flex; gap:8px; align-items:center; margin:0; font:17px Georgia,serif; }
.recipe-detail h3>span { font:21px system-ui; color:#f4cc7a; }
.book-ingredients { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px 8px; align-content:center; }
.ingredient { display:flex; gap:4px; align-items:center; justify-content:space-between; font-size:11px; min-width:0; }
.ingredient>span { flex:1; }
.ingredient>b { font-weight:500; white-space:nowrap; }
.ingredient>small { width:18px; text-align:right; font-size:10px; color:#c8deac; }
.ingredient.missing>small { color:#edac95; }
.recipe-condition { font-size:10px; color:#cfcca7; }
.book-craft-actions { display:flex; gap:6px; }
.book-craft-actions>.button { flex:1; min-width:44px; height:44px; padding:8px; }
.recipe-book.book-wide[data-section="craft"] { grid-template-columns:minmax(0,1fr) 188px; grid-template-rows:44px minmax(0,1fr); gap:8px 16px; }
.book-wide .book-sections { grid-column:1/-1; }
.book-wide .recipe-detail { border-top:0; border-left:1px solid #d8dfb330; padding:0 0 0 12px; grid-template-rows:32px minmax(0,1fr) 24px 44px; }
.book-wide .book-ingredients { grid-template-columns:1fr; }
.book-wide .recipe-detail h3 { font-size:15px; }
.book-keyboard[data-section="craft"] .recipe-detail { display:none; }
.recipe-book.book-keyboard[data-section="craft"] { grid-template-columns:1fr; grid-template-rows:44px minmax(0,1fr); }
.equipment-pane { display:grid; grid-template-rows:minmax(0,1fr) 54px; gap:8px; }
.equipment-stage { display:grid; grid-template-columns:minmax(54px,1fr) minmax(80px,1.7fr) minmax(54px,1fr); grid-template-rows:minmax(0,1fr) 54px; align-items:center; justify-items:center; gap:6px; max-width:440px; width:100%; margin:auto; height:100%; }
.character-preview { grid-column:2; grid-row:1/3; width:100%; height:100%; max-height:240px; image-rendering:pixelated; background:radial-gradient(ellipse,#49624950,transparent 70%); }
.equipment-tool { grid-column:1; grid-row:1; width:100%; }
.equipment-hand { grid-column:3; grid-row:1; width:100%; }
.equipment-flask { grid-column:3; grid-row:2; width:100%; }
.equipment-slot { width:100%; min-height:54px; border:1px solid #79907870; border-radius:7px; background:#234638; padding:4px; }
.equipment-slot>small,.equipment-slot>b { display:block; font-size:10px; font-weight:400; }
.equipment-slot>span { color:#e8c47b; font-size:20px; line-height:24px; }
.equipment-slot:disabled { opacity:.75; }
.equipment-owned { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:4px; }
.equipment-owned .button { min-width:44px; height:54px; padding:4px; overflow:hidden; }
.equipment-owned .button>span { display:block; font-size:18px; }
.equipment-owned .button>small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:9px; }
.pack-menu { margin-top:10px; grid-template-columns:repeat(2,minmax(0,1fr)); }
@media(max-width:380px) { .equipment-owned { grid-template-columns:repeat(3,minmax(0,1fr)); grid-auto-rows:44px; } .equipment-pane { grid-template-rows:minmax(0,1fr) auto; } .equipment-owned .button { height:44px; } .equipment-owned .button>small { display:none; } }
@media(orientation:landscape) and (max-height:420px) { .equipment-stage { grid-template-rows:1fr; grid-template-columns:1fr 90px 1fr 1fr; max-width:600px; } .character-preview { grid-column:2; grid-row:1; max-height:120px; } .equipment-flask { grid-column:4; grid-row:1; } .equipment-slot>small,.equipment-slot>b { display:inline; margin:0 3px; } .equipment-owned .button>small { display:none; } }

.quick-actions { width:auto; flex-direction:row; }
.quick-actions #pack-button { min-width:48px; width:48px; height:48px; min-height:48px; justify-content:center; padding:0; font-size:20px; border-radius:10px; }
.combat-controls { display:flex; align-items:flex-end; gap:8px; }
.stick-run-ring { position:absolute; inset:-5px; border:2px solid #d9c07840; border-radius:50%; pointer-events:none; }
.stick.sprinting .stick-run-ring { border-color:#f0c878; box-shadow:0 0 8px #f0c87830; }
.item-quantity { display:flex; align-items:center; gap:8px; }
.item-quantity>.button { min-width:44px; height:44px; padding:6px; }
.item-quantity>span { flex:1; text-align:center; }
.item-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-top:10px; }
.craft-quantity { display:flex; align-items:center; gap:3px; }
.craft-quantity>.button { width:44px; min-width:44px; height:44px; padding:5px; }
.craft-quantity>span { min-width:15px; text-align:center; font-size:11px; }
.book-wide .book-craft-actions { flex-wrap:wrap; }
.book-wide .book-craft-actions .craft-quantity { justify-content:center; }
.book-wide .recipe-detail:has(.craft-quantity) { grid-template-rows:26px minmax(0,1fr) 16px 92px; }
@media(max-width:380px) { .book-craft-actions:has([data-place]) .craft-quantity { gap:0; } .book-craft-actions:has([data-place])>.button { font-size:11px; padding:5px; } }

.recipe-book:not(.book-wide):not(.book-keyboard) .recipe-pane { grid-template-columns:minmax(0,1fr) 120px; grid-template-rows:44px minmax(0,1fr); gap:6px; }
.recipe-book:not(.book-wide):not(.book-keyboard) .book-recipe-grid { grid-column:1/-1; grid-row:2; }
.recipe-book:not(.book-wide):not(.book-keyboard) .recipe-pages { grid-column:2; grid-row:1; }
.recipe-book:not(.book-wide):not(.book-keyboard) .recipe-pages .book-pager { gap:4px; }
.book-keyboard .book-sections { display:none; }
.recipe-book.book-keyboard[data-section="craft"] { grid-template-rows:minmax(0,1fr); }
.book-tiny .book-recipe-grid,.book-tiny .recipe-pages { display:none; }
.book-tiny .recipe-pane { grid-template-rows:44px; }
.account-menu-link { display:grid; place-items:center; text-align:center; text-decoration:none; }
.sheet-body[data-panel="pause"] .menu-buttons { grid-template-columns:repeat(2,minmax(0,1fr)); }
.vitals { min-width:124px; padding:7px 9px; }
.vital-units { display:flex; align-items:center; gap:2px; height:18px; }
.vital-unit { width:18px; height:18px; flex:0 0 18px; stroke-width:1; }
.vital-unit .unit-empty { fill:#263f31; stroke:#748571; }
.vital-unit .unit-fill { stroke:none; fill:#df9688; }
.vital-unit.food .unit-fill { fill:#e4bd76; }
.vital-unit.water .unit-fill { fill:#89c2c5; }
.vital-unit.armor .unit-fill { fill:#b6c8bb; }
.exertion-meter { display:flex; align-items:center; gap:5px; height:17px; }
.exertion-meter svg { width:16px; height:16px; stroke:#e6bd78; stroke-width:1.7; }
.exertion-meter i { display:block; width:80px; height:5px; border-radius:5px; background:linear-gradient(90deg,#dfb56c,#e89c76 65%,#dc716a) left/var(--exertion,0%) 100% no-repeat,#ffffff1a; }
.equipment-armor { grid-column:1; grid-row:2; width:100%; }
.equipment-owned { grid-template-columns:repeat(7,minmax(0,1fr)); }
@media(max-width:380px) { .equipment-owned { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(orientation:landscape) and (max-height:420px) { .equipment-stage { grid-template-rows:repeat(2,minmax(54px,1fr)); } .character-preview,.equipment-hand,.equipment-flask { grid-row:1/3; } .equipment-armor { grid-column:1; grid-row:2; } }
#profile-button { width:44px; height:44px; min-width:44px; min-height:44px; }
@media(max-width:560px) and (orientation:portrait) { .quick-actions { bottom:184px; } }

/* Additional earned tools share one bounded equipment row, never page scroll. */
.equipment-owned { grid-template-columns:repeat(5,minmax(0,1fr)); }
.equipment-next { grid-column:5; }
@media(max-width:380px) { .equipment-owned { grid-template-columns:repeat(5,minmax(0,1fr)); } }

/* Right-side inventory remains above the action cluster and inside the safe edge. */
.quick-actions { left:auto; right:max(18px,env(safe-area-inset-right)); transform:none; bottom:calc(max(24px,env(safe-area-inset-bottom)) + 104px); }
@media(max-width:560px) and (orientation:portrait) { .quick-actions { bottom:calc(max(52px,env(safe-area-inset-bottom)) + 132px); } }
