/* The middle of the view remains the canvas. Only real controls own touches. */
:root {
 --touch-vv-width:100vw; --touch-vv-height:100dvh; --touch-vv-left:0px; --touch-vv-top:0px; --touch-vv-bottom:0px;
 --touch-button-size:44px; --touch-use-size:56px; --touch-stick-size:96px; --touch-controls-space:166px; --touch-controls-bottom:54px;
 --touch-stick-zone-width:112px; --touch-stick-zone-height:112px; --touch-right-width:104px; --touch-action-height:104px;
 --touch-nav-height:44px; --touch-nav-width:92px; --touch-nav-left:calc(100vw - 108px); --touch-nav-top:16px;
 --touch-flight-button-size:44px; --touch-flight-width:188px; --touch-flight-bottom:108px; --touch-control-gap:4px; --touch-tray-max-height:360px;
 --touch-hotbar-left:16px; --touch-hotbar-bottom:16px; --touch-hotbar-width:calc(100vw - 32px); --touch-hotbar-height:48px;
 --touch-hud-middle-left:136px; --touch-hud-middle-width:0px;
 --touch-edge-space:16px; --touch-control-opacity:.85;
 --touch-safe-left:calc(env(safe-area-inset-left,0px) + var(--touch-edge-space));
 --touch-safe-right:calc(env(safe-area-inset-right,0px) + var(--touch-edge-space));
 --touch-safe-top:calc(env(safe-area-inset-top,0px) + var(--touch-edge-space));
 --touch-safe-bottom:calc(env(safe-area-inset-bottom,0px) + var(--touch-edge-space));
}
html.touch-ui #game {touch-action:none;}
.touch-controls {
 position:fixed; left:var(--touch-vv-left); top:var(--touch-vv-top); width:var(--touch-vv-width); height:var(--touch-vv-height);
 z-index:44; pointer-events:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; color:#e4eee6; font:11px/1.2 system-ui,sans-serif;
}
.touch-controls[hidden],.touch-controls [hidden] {display:none!important;}
.touch-controls * {box-sizing:border-box;}
.touch-safe-probe {position:fixed;left:0;top:0;width:0;height:0;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);}
.touch-controls button {
 min-width:44px; min-height:44px; margin:0; padding:3px; border:1px solid #91b8ac80; border-radius:10px;
 background:#102b35b8; color:#edf5eb; font:600 11px/1.15 system-ui,sans-serif; text-transform:none; letter-spacing:0;
 box-shadow:0 2px 6px #0003; pointer-events:auto; touch-action:none; -webkit-tap-highlight-color:transparent;
}
.touch-controls button:focus-visible {outline:3px solid #eed392;outline-offset:2px;}
.touch-controls button:active,.touch-controls button.is-held,.touch-controls button.is-active {background:#526e61;border-color:#e5d3a0;}
.touch-controls button:disabled {opacity:.45;}
.touch-stick {
 position:absolute; left:var(--touch-safe-left); bottom:calc(var(--touch-safe-bottom) + var(--touch-controls-bottom)); width:var(--touch-stick-zone-width); height:var(--touch-stick-zone-height);
 pointer-events:auto; touch-action:none; border-radius:24px; opacity:var(--touch-control-opacity);overflow:hidden;
}
.touch-stick-base {
 position:absolute;left:calc(50% + var(--touch-stick-origin-x,0px));top:calc(50% + var(--touch-stick-origin-y,0px));transform:translate(-50%,-50%);
 width:var(--touch-stick-size);height:var(--touch-stick-size);border-radius:50%;background:#102c3542;border:1px solid #adc6ba60;pointer-events:none;
}
.touch-stick.is-held .touch-stick-base {background:#1639439e;border-color:#d9e2bdcc;}
.touch-stick-ring {position:absolute;inset:11px;border:1px solid #b8cfbf44;border-radius:50%;pointer-events:none;}
.touch-stick-thumb {
 position:absolute; width:36px; height:36px; left:calc(50% - 18px); top:calc(50% - 18px); border-radius:50%; pointer-events:none;
 background:#b9cfaba6; border:1px solid #e6e8cbb0; box-shadow:0 2px 6px #0003;
}
.touch-stick-label {position:absolute;bottom:4px;left:0;right:0;text-align:center;font:600 8px system-ui;letter-spacing:.06em;opacity:.65;pointer-events:none;}
.touch-right {position:absolute;right:var(--touch-safe-right);bottom:calc(var(--touch-safe-bottom) + var(--touch-controls-bottom));width:var(--touch-right-width);height:var(--touch-action-height);opacity:var(--touch-control-opacity);}
.touch-nav,.touch-flight {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--touch-control-gap);}
.touch-nav {position:absolute;left:var(--touch-nav-left);top:var(--touch-nav-top);width:var(--touch-nav-width);height:var(--touch-nav-height);opacity:var(--touch-control-opacity);z-index:2;}
.touch-nav .touch-button {height:var(--touch-nav-height);font-size:11px;}
.touch-flight {position:absolute;right:0;bottom:var(--touch-flight-bottom);width:var(--touch-flight-width);}
.touch-flight .touch-button {height:var(--touch-flight-button-size);font-size:11px;}
html.touch-flight-wide .touch-flight {display:flex;width:var(--touch-flight-width);}
html.touch-flight-wide .touch-flight .touch-button {flex:0 0 var(--touch-flight-button-size);width:var(--touch-flight-button-size);}
.touch-primary {position:absolute;bottom:0;left:0;display:grid;grid-template-columns:var(--touch-button-size) var(--touch-use-size);grid-template-rows:var(--touch-button-size);gap:var(--touch-control-gap);}
.touch-primary.has-use {grid-template-rows:var(--touch-button-size) var(--touch-use-size);}
.touch-primary [data-touch-control=targetNext] {grid-column:1;grid-row:1;}
.touch-primary [data-touch-control=interact] {grid-column:2;grid-row:1;}
.touch-primary [data-touch-control=aim] {grid-column:1;grid-row:2;height:var(--touch-button-size);align-self:center;}
.touch-primary [data-touch-control=use] {grid-column:2;grid-row:2;}
.touch-controls .touch-use {
 width:var(--touch-use-size);height:var(--touch-use-size);border-radius:50%;border:1px solid #dfcb92;background:#4e5434cf;color:#fff5d5;font-size:12px;
 display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;overflow-wrap:anywhere;
}
.touch-controls .touch-use[data-fire-look=true]::after {content:'Hold + drag';display:block;font:500 8px/1.15 system-ui;white-space:nowrap;color:#f5e9c5;}
.touch-controls .touch-use.is-held {background:#7e7948;}
.touch-controls .touch-use.is-aiming {background:#827037;border-color:#fff0b1;box-shadow:0 0 0 3px #ead69d44;}
.touch-controls .touch-use.is-aiming::after {content:'Aiming';}
.touch-look-hint {display:none;pointer-events:none;}
.touch-creator-zoom {position:absolute;right:var(--touch-safe-right);top:calc(var(--touch-safe-top) + 52px);display:grid;grid-template-columns:repeat(2,52px);gap:8px;}
.touch-actions {
 position:absolute;right:var(--touch-safe-right);bottom:calc(var(--touch-safe-bottom) + var(--touch-controls-space) + 8px);
 width:min(320px,calc(var(--touch-vv-width) - var(--touch-safe-left) - var(--touch-safe-right)));
 max-height:var(--touch-tray-max-height);
 overflow:auto;overscroll-behavior:contain;touch-action:pan-y;pointer-events:auto;-webkit-overflow-scrolling:touch;
 border:1px solid #8aa99d;border-radius:10px;padding:4px;background:#10252bf7;box-shadow:0 6px 18px #0005;
}
.touch-actions-heading {position:sticky;top:-4px;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:4px;margin:0 0 4px;padding:0;background:#10252b;font-size:10px;letter-spacing:.04em;}
.touch-actions-heading strong {flex:1;min-width:0;}
.touch-actions-heading .touch-button {padding:4px 10px;}
.touch-actions .touch-button {touch-action:pan-y;}
.touch-action-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;}
.touch-action-grid .touch-button {min-height:44px;}
.touch-actions-note {margin:8px 2px 0;color:#bed0c8;font-size:10px;line-height:1.4;}
.touch-fishing {
 position:absolute;left:50%;bottom:var(--touch-safe-bottom);transform:translateX(-50%);
 width:min(600px,calc(var(--touch-vv-width) - var(--touch-safe-left) - var(--touch-safe-right)));
 padding:8px;pointer-events:auto;touch-action:none;border:1px solid #8aafa2;border-radius:12px;background:#112c36f2;
}
.touch-fishing-title {font-size:10px;letter-spacing:.08em;margin:0 0 6px;color:#d9e4d4;}
.touch-fishing-inputs {display:grid;grid-template-columns:repeat(var(--touch-fishing-count,1),minmax(44px,1fr));gap:8px;}
.touch-fishing-inputs .touch-button {min-height:48px;font-size:11px;overflow-wrap:normal;}
.touch-fishing-footer {display:flex;justify-content:flex-end;gap:8px;margin-top:8px;}
.touch-fishing-footer .touch-button {padding:5px 12px;}
/* Unpaid preparation stays beside the complete movement zone and can scroll. */
html.touch-fishing-preparing .touch-fishing {
 left:auto;right:var(--touch-safe-right);transform:none;
 bottom:calc(var(--touch-safe-bottom) + var(--touch-controls-bottom));
 width:min(280px,calc(var(--touch-vv-width) - var(--touch-safe-left) - var(--touch-safe-right) - var(--touch-stick-zone-width) - 12px));
 max-height:calc(var(--touch-vv-height) - var(--touch-safe-top) - var(--touch-safe-bottom) - var(--touch-controls-bottom));overflow:auto;overscroll-behavior:contain;touch-action:pan-y;
}
html.touch-fishing-preparing .touch-fishing .touch-button {touch-action:pan-y;}
html.touch-fishing-preparing .touch-fishing-footer {flex-wrap:wrap;margin-top:0;}
html.touch-fishing-preparing .touch-fishing-footer .touch-button {flex:1 1 100px;}
html.touch-left-handed .touch-stick {left:auto;right:var(--touch-safe-right);}
html.touch-left-handed .touch-right,html.touch-left-handed .touch-look-hint,html.touch-left-handed .touch-actions,html.touch-left-handed .touch-creator-zoom {left:var(--touch-safe-left);right:auto;}
html.touch-left-handed .touch-primary {grid-template-columns:var(--touch-use-size) var(--touch-button-size);}
html.touch-left-handed .touch-primary [data-touch-control=targetNext],html.touch-left-handed .touch-primary [data-touch-control=aim] {grid-column:2;}
html.touch-left-handed .touch-primary [data-touch-control=interact],html.touch-left-handed .touch-primary [data-touch-control=use] {grid-column:1;}
html.touch-left-handed .touch-flight {left:0;right:auto;}
html.touch-left-handed.touch-fishing-preparing .touch-fishing {left:var(--touch-safe-left);right:auto;}
html.touch-short-tray .touch-actions {padding:4px;}
html.touch-short-tray .touch-actions-heading {top:-4px;margin-bottom:4px;gap:4px;}
html.touch-short-tray .touch-action-grid {gap:4px;}
html.touch-short-tray .touch-action-grid .touch-button {min-height:44px;font-size:11px;}
html.touch-short-tray .touch-actions-note {font-size:10px;}
@media (max-height:420px) {
 .touch-controls .touch-button:not(.touch-use) {border-radius:8px;}
 .touch-fishing {padding:6px;}
 .touch-fishing-title {display:none;}
 .touch-fishing-inputs .touch-button {min-height:44px;}
 .touch-fishing-footer {margin-top:6px;}
 .touch-look-hint {display:none;}
}
@media (prefers-reduced-motion:no-preference) {
 .touch-controls button {transition:background-color .08s,border-color .08s;}
}
