/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ─── Body ───────────────────────────────────────────────────── */
html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  /* Solid dark color fills iOS safe areas (notch top + home indicator bottom) */
  background: #0a0b0e;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #D0D0D8;
  touch-action: manipulation;
}

/* ─── Canvas ─────────────────────────────────────────────────── */
#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

/* ─── Selection ──────────────────────────────────────────────── */
::selection {
  background: transparent;
}

/* ─── Controls ───────────────────────────────────────────────── */
.controls {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  right: 24px; /* default: right-handed */
  display: flex;
  flex-direction: row;
  gap: 12px;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.2s ease, transform 0.2s ease, right 0.3s ease, left 0.3s ease;
}

.controls.left-handed {
  right: auto;
  left: 24px;
}

.controls.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.control-btn {
  pointer-events: auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.1s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.control-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

.control-btn svg {
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* ─── Handedness toggle pill ─────────────────────────────────── */
.hand-toggle {
  position: absolute;
  bottom: 50px;
  width: 18px;
  height: 56px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.35);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.2s ease;
  user-select: none;
}

.hand-toggle:active {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
}

.hand-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

/* right-hand mode: toggle pill sits on the left edge */
#hand-toggle-left  { left: 6px; }
/* left-hand mode: toggle pill sits on the right edge */
#hand-toggle-right { right: 6px; }

/* ─── Desktop Optimization ───────────────────────────────────── */
@media (pointer: fine) and (min-width: 1024px) {
  .controls, .hand-toggle {
    display: none !important;
  }

  /* --ui-scale is set by JS (renderer.js) on resize to match boardScale.
     Use zoom (not transform) to avoid conflicts with existing transforms. */
  .edgy-dropdown {
    zoom: var(--ui-scale, 1);
  }

  .icon-btn {
    zoom: 1;
  }

  #game-hud {
    zoom: var(--ui-scale, 1);
  }

  .modal-content {
    zoom: var(--ui-scale, 1);
  }
}

