/* ============================================================================
 * Matte Tactile Multi-Touch Virtual Controls (Zero Blur, Brass & Stone)
 * ========================================================================== */
.touch-controls {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  touch-action: none;
}

body.touch-mode .touch-controls {
  display: block;
}

@media (pointer: coarse) {
  body:not(.touch-disabled) .touch-controls {
    display: block;
  }
}

.touch-stick-zone {
  position: fixed;
  left: 0;
  bottom: var(--tb, 0px);   /* 下のツールバーに隠れる分（src/ui/viewport.js） */
  width: 44vw;
  max-width: 240px;
  height: 42vh;
  max-height: 240px;
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-base {
  position: absolute;
  left: calc(18px + env(safe-area-inset-left, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(16, 19, 26, 0.78);
  border: 2px solid var(--brass-dim);
  box-shadow: 0 4px 0 var(--stone-ledge), inset 0 2px 6px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  transition: opacity 120ms var(--ease-ui), border-color 120ms var(--ease-ui), background-color 120ms var(--ease-ui);
}

.touch-stick-base.is-active {
  bottom: auto;
  transform: translate(-50%, -50%);
  opacity: 1;
  background: rgba(16, 19, 26, 0.90);
  border-color: var(--brass);
}

.touch-stick-ring {
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  border: 1px dashed rgba(214, 166, 70, 0.28);
  pointer-events: none;
}

.touch-stick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--stone-raised);
  border: 2px solid var(--brass);
  box-shadow: 0 3px 0 var(--stone-ledge);
  pointer-events: none;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.touch-action-pad {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px) + var(--tb, 0px));
  width: 192px;
  height: 176px;
  pointer-events: none;
  touch-action: none;
}

.touch-btn {
  position: absolute;
  appearance: none;
  border-radius: 50%;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--stone-base);
  color: var(--ink-main);
  border: 1.5px solid #394054;
  border-bottom: 3px solid var(--stone-ledge);
  box-shadow: 0 3px 0 var(--stone-ledge);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: transform 110ms var(--ease-ui), border-color 140ms var(--ease-ui), box-shadow 140ms var(--ease-ui), background-color 140ms var(--ease-ui), opacity 140ms var(--ease-ui);
}

.touch-btn:active,
.touch-btn.is-pressed {
  transform: scale(0.94);
}

.touch-btn-kanji {
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.touch-btn-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
  line-height: 1;
}

/* Primary Attack (68px Forged Brass Rim + Hold Charge Fill) */
.touch-btn-attack {
  width: 68px;
  height: 68px;
  right: 4px;
  bottom: 8px;
  overflow: hidden;
  background: #231e16;
  border: 2px solid var(--brass);
  border-bottom: 3px solid var(--brass-dark);
}

.touch-charge-fill {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transform-origin: bottom;
  transform: scaleY(var(--charge-frac, 0));
  background: linear-gradient(
    180deg,
    rgba(255, 238, 164, 0.82) 0px,
    rgba(214, 166, 70, 0.38) 2px,
    rgba(214, 166, 70, 0.22) 100%
  );
  opacity: 0;
  transition: opacity 80ms linear;
}

.touch-btn-attack .touch-btn-kanji,
.touch-btn-attack .touch-btn-sub {
  position: relative;
  z-index: 1;
}

.touch-btn-attack.is-charging .touch-charge-fill {
  opacity: 1;
}

.touch-btn-attack.is-charge-ready {
  border-color: #ffe89e;
  box-shadow: 0 3px 0 var(--brass-dark), 0 0 18px rgba(231, 190, 106, 0.72);
}

.touch-btn-attack.is-charge-ready .touch-btn-kanji {
  color: #fff6cf;
}

.touch-btn-attack .touch-btn-kanji {
  font-size: 22px;
  color: var(--brass-bright);
}

.touch-btn-attack .touch-btn-sub {
  color: var(--brass);
}

/* Dash / Roll (54px) */
.touch-btn-dash {
  width: 54px;
  height: 54px;
  right: 84px;
  bottom: 6px;
}

.touch-btn-dash .touch-btn-kanji {
  font-size: 13px;
}

/* Guard / Parry (54px — glows Shadow-Core Cyan ONLY when active) */
.touch-btn-guard {
  width: 54px;
  height: 54px;
  right: 78px;
  bottom: 72px;
  border-color: #345663;
}

.touch-btn-guard .touch-btn-kanji {
  font-size: 17px;
  color: #bceef7;
}

.touch-btn-guard.is-active {
  background: #14323e;
  border-color: var(--soul-cyan);
  box-shadow: 0 3px 0 var(--stone-ledge), 0 0 16px rgba(59, 216, 236, 0.55);
}

/* Interact / Morph / Chest (52px — softened & tucked when idle; full Brass glow when in range) */
.touch-btn-interact {
  width: 52px;
  height: 52px;
  right: 12px;
  bottom: 88px;
  opacity: 0.22;
  transform: scale(0.84);
  pointer-events: none;
}

.touch-btn-interact .touch-btn-kanji {
  font-size: 12px;
}

.touch-btn-interact.is-ready,
.touch-btn-interact.is-available {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  background: #262216;
  border-color: var(--brass-bright);
  box-shadow: 0 3px 0 var(--stone-ledge), 0 0 16px rgba(214, 166, 70, 0.55);
}

.touch-btn-interact.is-ready:active,
.touch-btn-interact.is-available:active,
.touch-btn-interact.is-ready.is-pressed,
.touch-btn-interact.is-available.is-pressed {
  transform: scale(0.94);
}

.touch-btn-interact.is-ready .touch-btn-kanji,
.touch-btn-interact.is-available .touch-btn-kanji {
  color: var(--brass-bright);
}

/* Lock-On (48px — lights up ONLY when locked) */
.touch-btn-lock {
  width: 48px;
  height: 48px;
  right: 136px;
  bottom: 112px;
}

.touch-btn-lock .touch-btn-kanji {
  font-size: 15px;
}

.touch-btn-lock.is-active {
  background: #142a34;
  border-color: var(--soul-cyan);
  box-shadow: 0 3px 0 var(--stone-ledge), 0 0 12px rgba(59, 216, 236, 0.45);
}

.touch-btn-lock.is-active .touch-btn-kanji {
  color: var(--soul-cyan);
}

.touch-btn-lock.is-staggered {
  border-color: var(--brass-bright);
  box-shadow: 0 3px 0 var(--stone-ledge), 0 0 14px rgba(214, 166, 70, 0.6);
}

.touch-btn-lock.is-staggered .touch-btn-kanji {
  color: var(--brass-bright);
}

/* Head-Slot Active Magic (50px — hidden when pure-physical Top equipped) */
.touch-btn-magic {
  width: 50px;
  height: 50px;
  right: 144px;
  bottom: 44px;
  border-color: #355873;
  background: #151e2a;
  opacity: 0.62;
}

.touch-btn-magic .touch-btn-kanji {
  font-size: 16px;
  color: #9edcf7;
}

.touch-btn-magic .touch-btn-sub {
  color: #7eb8d6;
}

.touch-btn-magic.is-ready {
  opacity: 1;
  background: #132c3b;
  border-color: var(--soul-cyan);
  box-shadow: 0 3px 0 var(--stone-ledge), 0 0 14px rgba(59, 216, 236, 0.5);
}

.touch-btn-magic.is-ready .touch-btn-kanji {
  color: #e6fbff;
}

.touch-btn-magic.on-cooldown {
  opacity: 0.45;
  border-color: #263140;
}
