/* ── Hamburger menu toggle ───────────────────────────────────────────── */

.menu-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: var(--surface-panel-card);
  color: var(--color-brown-strong);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 100;
}

.menu-toggle:hover {
  background: rgba(255, 253, 246, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.menu-toggle svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Floating action buttons (reset, undo, redo, rules, nudge) ───────── */

.action-btn {
  position: fixed;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: var(--surface-panel-card);
  color: var(--color-brown-strong);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 140;
}

.action-btn:hover:not(:disabled) {
  background: rgba(255, 253, 246, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.action-btn:disabled,
.action-btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rules-btn {
  top: 20px;
  left: 20px;
}

.rules-btn--attention {
  animation: rules-btn-attention 1.8s ease-in-out infinite;
}

.rules-btn--attention:hover:not(:disabled),
.rules-btn--attention:focus-visible {
  background: var(--color-gold, #d4af37);
  color: var(--color-brown-deep);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.5);
}

.rules-btn--attention::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--color-gold, #d4af37);
  pointer-events: none;
  animation: rules-btn-halo 1.8s ease-out infinite;
}

@keyframes rules-btn-attention {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(212, 175, 55, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35), 0 0 0 6px rgba(212, 175, 55, 0.18);
    transform: scale(1.04);
  }
}

@keyframes rules-btn-halo {
  0% { opacity: 0.9; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}

@media (prefers-reduced-motion: reduce) {
  .rules-btn--attention {
    animation: none;
  }
  .rules-btn--attention::after {
    animation: none;
    opacity: 0.6;
  }
}

.rules-tooltip {
  position: fixed;
  top: 74px;
  left: 20px;
  max-width: 300px;
  padding: 12px;
  background: var(--surface-panel-card-bright);
  color: var(--color-brown-strong);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 0.85rem;
  line-height: 1.5;
  z-index: 150;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  white-space: pre-line;
}

.rules-tooltip--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.rules-modal-content,
.terms-modal-content {
  white-space: pre-line;
}

.reset-icon {
  top: 182px;
  right: 20px;
}

.reset-icon:hover:not(:disabled) {
  transform: rotate(180deg);
}

.undo-btn {
  top: 74px;
  right: 20px;
}

.redo-btn {
  top: 128px;
  right: 20px;
}

.nudge-btn {
  top: 74px;
  right: 20px;
}

@keyframes nudge-ring {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-12deg); }
  30% { transform: rotate(10deg); }
  40% { transform: rotate(-8deg); }
  50% { transform: rotate(5deg); }
  60% { transform: rotate(-3deg); }
  70% { transform: rotate(1deg); }
  80% { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

.nudge-btn--ring {
  animation: nudge-ring 0.6s ease-in-out;
}

.nudge-btn--cooldown {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Feature-flag-driven layout tweaks ───────────────────────────────── */

.ff-nudge-enabled .redo-btn {
  display: none;
}

.ff-nudge-enabled .reset-icon {
  top: 128px;
}

.ff-online-disabled #opponent-online,
.ff-online-disabled #online-invite-section,
.ff-online-disabled #online-incoming-invite-modal,
.ff-online-disabled #online-invite-panel {
  display: none !important;
}

.ff-opponent-disabled #opponent-section {
  display: none !important;
}

/* ── Feature-flags devtools button + modal ───────────────────────────── */

.feature-flags-devtools-btn {
  left: 20px;
  bottom: 20px;
  z-index: 180;
}

.feature-flags-devtools-modal {
  z-index: 4100;
}

.feature-flags-devtools-content {
  background: var(--modal-surface-light-bg);
  border: var(--modal-surface-light-border);
  box-shadow: var(--modal-surface-light-shadow);
  color: var(--color-brown-strong);
  min-width: min(420px, calc(100vw - 24px));
  max-width: min(460px, calc(100vw - 24px));
}

.feature-flags-devtools-content h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.feature-flags-devtools-help {
  margin: 0 0 12px;
  color: var(--color-brown-muted);
  font-size: 0.9rem;
}

.feature-flags-devtools-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-flags-devtools-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(101, 67, 33, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
}

.feature-flags-devtools-checkbox {
  margin-top: 2px;
}

.feature-flags-devtools-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.feature-flags-devtools-title {
  font-weight: 700;
}

.feature-flags-devtools-key {
  font-size: 0.8rem;
  color: #6b4b2a;
}

.feature-flags-devtools-state {
  font-size: 0.85rem;
  color: #7a5b3d;
}

/* ── Mobile overrides for fixed-position button stack ────────────────── */

@media (max-width: 640px) {
  .action-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
  }

  .rules-btn {
    top: 12px;
    left: 12px;
  }

  .rules-tooltip {
    top: 62px;
    left: 12px;
    max-width: calc(100vw - 80px);
  }

  .menu-toggle {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 8px;
    z-index: 160;
  }

  .reset-icon {
    top: 162px;
    right: 12px;
  }

  .undo-btn {
    top: 62px;
    right: 12px;
  }

  .redo-btn {
    top: 112px;
    right: 12px;
  }

  .nudge-btn {
    top: 62px;
    right: 12px;
  }

  .ff-nudge-enabled .reset-icon {
    top: 112px;
  }

  .feature-flags-devtools-btn {
    left: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
  }

  .feature-flags-devtools-content {
    min-width: 0;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 18px;
  }
}
