/* Remote client on phones and tablets: the viewer fills the screen and touch-controls.js lays Bedrock-style
   controls over the stream. Buttons are translucent grey squares with a light rim, like the game's touch UI. */

.remote-dialog.touch {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0;
  display: flex; flex-direction: column; background: #000;
}
.remote-dialog.touch::backdrop { background: #000; }
.remote-dialog.touch .remote-bar {
  flex: none; gap: 6px; flex-wrap: nowrap; overflow: hidden;
  padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
}
.remote-dialog.touch .remote-bar > * { flex: none; }
.remote-dialog.touch .remote-bar .spacer { flex: 1; min-width: 0; }
.remote-dialog.touch .remote-title { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-dialog.touch .desk-only { display: none; }
.remote-dialog.touch .remote-stage { flex: 1; min-height: 0; display: block; overflow: hidden; }
.remote-dialog.touch #remote-canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; object-fit: contain; cursor: default; }
.remote-dialog.touch { overflow: hidden; }
.remote-dialog.touch #remote-canvas:focus-visible { box-shadow: none; }
#remote-touch.on { --b-bg: var(--green); --b-ink: #fff; }
.remote-quality { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.remote-sens { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.remote-sens input { width: 96px; min-height: 0; padding: 0; border: 0; background: none; accent-color: var(--green); }

@media (max-width: 520px) {
  .remote-dialog.touch .remote-title, .remote-dialog.touch #remote-status { display: none; }
  .remote-sens input { width: 64px; }
}

/* ---------- overlay ---------- */

.tc {
  position: absolute; inset: 0; z-index: 2;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.tc-btn {
  --bevel-w: 0px;
  min-width: 48px; min-height: 48px; padding: 0 8px;
  font: 14px/1 var(--mc); color: #fff; text-shadow: 2px 2px 0 #000;
  background: rgba(40, 40, 40, .55); background-image: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45), 0 0 0 2px rgba(0, 0, 0, .55);
  touch-action: none;
}
.tc-btn:not(:disabled):hover { color: #fff; }
.tc-btn.down, .tc-btn:not(:disabled):active { background: rgba(255, 255, 255, .38); color: var(--mc-yellow); }
.tc-btn.on { background: rgba(54, 184, 54, .7); }

.tc-top {
  position: absolute; top: 8px; right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 6px;
}

.tc-right {
  position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: calc(64px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 56px 68px; grid-template-rows: 56px 68px; gap: 8px; align-items: end; justify-items: end;
}
.tc-use { grid-area: 1 / 1; width: 56px; height: 56px; }
.tc-drop { grid-area: 1 / 2; width: 56px; height: 56px; }
.tc-sneak { grid-area: 2 / 1; width: 56px; height: 56px; }
.tc-jump { grid-area: 2 / 2; width: 68px; height: 68px; }
/* Chevrons, as on the game's jump and sneak buttons. */
.tc-jump::before, .tc-sneak::before {
  content: ""; width: 60%; height: 60%; background: #fff;
  filter: drop-shadow(2px 2px 0 #000);
}
.tc-jump::before { clip-path: polygon(50% 18%, 92% 66%, 72% 66%, 50% 42%, 28% 66%, 8% 66%); }
.tc-sneak::before { clip-path: polygon(50% 82%, 92% 34%, 72% 34%, 50% 58%, 28% 34%, 8% 34%); }
.tc-sneak.on::before { background: var(--mc-yellow); }

/* Joystick: shown faintly at rest, moved under the thumb while it is held. */
.tc-stick {
  position: absolute; left: calc(max(16px, env(safe-area-inset-left)) + 70px); top: calc(100% - 96px - env(safe-area-inset-bottom));
  width: 140px; height: 140px; margin: -70px 0 0 -70px; pointer-events: none; opacity: .45;
  background: rgba(0, 0, 0, .28); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .4), 0 0 0 2px rgba(0, 0, 0, .5);
}
.tc-stick.live { opacity: .9; }
.tc-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  background: rgba(200, 200, 200, .6);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .5), inset -3px -3px 0 rgba(0, 0, 0, .35), 0 0 0 2px rgba(0, 0, 0, .6);
}
.tc.cursor .tc-stick { display: none; }

/* Hotbar strip: laid by touch-controls.js exactly over the game's own nine slots (the game draws the items and the
   selection); each slot's touch area reaches up to at least 44 px. Until laid out it sits at the bottom centre. */
.tc-hotbar {
  position: absolute; left: 50%; bottom: 0; width: 360px; height: 44px; margin-left: -180px;
  display: flex; align-items: stretch;
}
.tc-hotbar[style] { margin-left: 0; bottom: auto; }
.tc-slot { position: relative; flex: none; width: 40px; height: 44px; }
.tc-slot::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--slot-h, 40px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
}
.tc-slot.on::after { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }

.tc-dot {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; pointer-events: none;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px #000;
}
.tc.breaking::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--mc-yellow), 0 0 0 2px #000;
}

.tc-chat {
  position: absolute; z-index: 3; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); top: 8px;
  display: flex; gap: 6px; padding: 6px;
}
.tc-chat input { flex: 1; min-width: 0; font-size: 16px; }

/* Portrait: a phone turning sideways. */
.tc-rotate { display: none; }
@media (orientation: portrait) {
  .remote-dialog.touch .tc-rotate {
    display: block; position: absolute; left: max(12px, env(safe-area-inset-left)); top: 12px; width: 48px; height: 48px; pointer-events: none;
    background: rgba(0, 0, 0, .5); box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
  }
  .remote-dialog.touch .tc-rotate::before {
    content: ""; position: absolute; left: 15px; top: 9px; width: 18px; height: 30px;
    box-shadow: inset 0 0 0 3px #fff, inset 0 -7px 0 rgba(255, 255, 255, .35);
    animation: tc-rotate 2.4s steps(1) infinite;
  }
  .remote-dialog.touch .tc-top { top: 8px; }
  .remote-dialog.touch .remote-bar { flex-wrap: wrap; justify-content: flex-end; }
  .remote-dialog.touch .tc-stick { top: calc(100% - 150px - env(safe-area-inset-bottom)); }
}
@keyframes tc-rotate { 50% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .remote-dialog.touch .tc-rotate::before { animation: none; transform: rotate(-90deg); } }
