/* Shared on-screen touch controls for 8.A.P Labs games */
.tc-root {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tc-root.tc-hidden {
  display: none;
}

.tc-dpad {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 8px;
}

.tc-btn {
  pointer-events: auto;
  touch-action: none;
  margin: 0;
  padding: 0;
  min-width: 56px;
  min-height: 56px;
  border-radius: 12px;
  border: 2px solid rgba(200, 200, 200, 0.35);
  background: rgba(8, 8, 8, 0.72);
  color: rgba(240, 240, 240, 0.92);
  font: 600 1.35rem/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.tc-btn:active,
.tc-btn.tc-pressed {
  background: rgba(40, 40, 40, 0.92);
  border-color: rgba(255, 255, 255, 0.55);
  transform: scale(0.96);
}

.tc-btn-up    { grid-column: 2; grid-row: 1; }
.tc-btn-left  { grid-column: 1; grid-row: 2; }
.tc-btn-right { grid-column: 3; grid-row: 2; }
.tc-btn-down  { grid-column: 2; grid-row: 3; }

.tc-actions {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.tc-action {
  pointer-events: auto;
  touch-action: none;
  min-width: 72px;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 12px;
  border: 2px solid rgba(200, 200, 200, 0.35);
  background: rgba(8, 8, 8, 0.72);
  color: rgba(240, 240, 240, 0.92);
  font: 700 0.82rem/1 system-ui, -apple-system, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.tc-action:active,
.tc-action.tc-pressed {
  background: rgba(40, 40, 40, 0.92);
  border-color: rgba(255, 255, 255, 0.55);
  transform: scale(0.96);
}

.tc-action--wide {
  min-width: 96px;
}

.tc-action--run {
  min-height: 72px;
  font-size: 1rem;
}

/* Game-specific accent themes */
.tc-theme-horror .tc-btn,
.tc-theme-horror .tc-action {
  border-color: rgba(180, 140, 80, 0.45);
  color: #e8c878;
  background: rgba(12, 8, 4, 0.78);
}

.tc-theme-lab .tc-btn,
.tc-theme-lab .tc-action {
  border-color: rgba(168, 200, 72, 0.45);
  color: #d4e888;
  background: rgba(4, 8, 2, 0.78);
}

.tc-theme-block .tc-btn,
.tc-theme-block .tc-action {
  border-color: rgba(120, 180, 255, 0.4);
  color: #cfe8ff;
  background: rgba(6, 10, 18, 0.78);
}

/* Hide touch UI on mouse-first desktops */
@media (hover: hover) and (pointer: fine) {
  .tc-root:not(.tc-force) {
    display: none !important;
  }
}

/* Larger tap targets for games that use native buttons / inputs */
@media (hover: none), (pointer: coarse) {
  .st-btn,
  .st-box {
    min-height: 48px;
  }

  .st-btn {
    min-width: 48px;
    padding: 14px 22px;
  }

  .st-input {
    min-height: 48px;
    font-size: 1rem;
  }

  .chatbot-touch-target,
  .new-chat-btn,
  .suggestion,
  #sendBtn,
  .upload-btn {
    min-height: 48px;
    min-width: 48px;
  }

  #sendBtn {
    padding: 0 16px;
  }

  .suggestion {
    padding: 12px 16px;
  }

  .coma-btn,
  .coma-exit {
    min-height: 48px;
    min-width: 220px;
  }

  .coma-pause-btn {
    width: 52px;
    height: 48px;
    font-size: 0.85rem;
  }

  .ds-log-btn,
  .mh-pause-btn {
    min-height: 48px;
    min-width: 48px;
  }
}
