.touch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0;
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch[hidden], .touch.idle { display: none; }

.touch-pad {
  position: relative;
  flex: none;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.05) 0 38%, transparent 39%),
    rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.22);
  touch-action: none;
}

.touch-nub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

.touch-buttons {
  display: grid;
  grid-template-columns: repeat(2, 68px);
  gap: 12px;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.5);
  background: #3a3f4c;
  color: #fff;
  font: 800 13px/1.1 system-ui, sans-serif;
  letter-spacing: 0.02em;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn.down { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }

.touch-btn.pink { background: #ef4f7a; }
.touch-btn.gold { background: #f0b429; color: #1a1206; }
.touch-btn.blue { background: #3f8ef0; }
.touch-btn.cream { background: #efe7d6; color: #1a1206; }
.touch-btn.wide { grid-column: span 2; width: 100%; height: 52px; border-radius: 999px; }

.stage:fullscreen .touch,
html.is-fullscreen .touch {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  pointer-events: none;
}

.stage:fullscreen .touch-pad,
.stage:fullscreen .touch-btn,
html.is-fullscreen .touch-pad,
html.is-fullscreen .touch-btn { pointer-events: auto; }

/* Landscape phones: float the controls over the bottom corners of the game. */
@media (orientation: landscape) and (max-height: 520px) {
  .has-touch .stage { position: relative; }

  .has-touch canvas {
    width: auto;
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    margin: 0 auto;
  }

  .has-touch .topbar,
  .has-touch .site-foot,
  .has-touch .session-controls:not(#practice-controls) { display: none !important; }

  html.has-touch, html.has-touch body { overflow: hidden; height: 100%; }

  .touch {
    position: fixed;
    z-index: 5;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    margin: 0;
    pointer-events: none;
    opacity: 0.8;
  }

  .touch-pad, .touch-btn { pointer-events: auto; }
  .touch-pad { width: 116px; height: 116px; }
  .touch-buttons { grid-template-columns: repeat(2, 58px); gap: 10px; }
  .touch-btn { width: 58px; height: 58px; font-size: 11px; letter-spacing: 0; }
}

/* Repeated taps and holds belong to the game, not the browser selection UI. */
.stage,.stage *,.touch,.touch *,.session-controls button,.top-actions button{
 -webkit-user-select:none!important;user-select:none!important;
 -webkit-touch-callout:none!important;
}
.stage img,.touch img{-webkit-user-drag:none;user-drag:none}
#game,.touch-pad,.touch-btn{touch-action:none}
.stage button,.session-controls button,.top-actions button{touch-action:manipulation}
.stage :is(input,textarea,select,[contenteditable=true]){-webkit-user-select:text!important;user-select:text!important;-webkit-touch-callout:default!important}

