/* ── Button Grid Layout ── */
.btn-grid {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  padding: 8px 0;
}

/* ── Zones ── */
.btn-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
}

.zone-left  { align-items: flex-end; }
.zone-right { align-items: flex-start; }

/* ── Button Card (shared) ── */
.btn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--bg-card);
  min-width: 130px;
  min-height: 68px;
  cursor: default;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-func {
  font-size: 0.88rem;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
  max-width: 160px;
  font-weight: 500;
  word-break: keep-all;
  white-space: normal;
}

/* Active / highlight state */
.btn-card.active {
  transform: scale(1.06);
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 0 22px rgba(255,255,255,0.15);
  animation: btn-pulse 0.7s ease-in-out infinite;
  z-index: 2;
}

.btn-left.active  { border-color: var(--blue);  box-shadow: 0 0 24px rgba(77,143,220,0.35); }
.btn-right.active { border-color: var(--red);   box-shadow: 0 0 24px rgba(224,85,106,0.35); }
.btn-center.active{ border-color: var(--gold);  box-shadow: 0 0 24px rgba(201,169,78,0.35); }

@keyframes btn-pulse {
  0%, 100% { transform: scale(1.06); }
  50% { transform: scale(1.14); }
}

/* Flash feedback */
.btn-card.flash-correct {
  border-color: var(--green) !important;
  background: rgba(63,185,80,0.25) !important;
  box-shadow: 0 0 28px rgba(63,185,80,0.4);
  animation: none;
}
.btn-card.flash-wrong {
  border-color: var(--red) !important;
  background: rgba(248,81,73,0.3) !important;
  box-shadow: 0 0 28px rgba(248,81,73,0.4);
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ── D-Pad cluster ── */
.dpad-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid rgba(77,143,220,0.2);
  border-radius: var(--radius);
  padding: 12px;
}
.dpad-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.dpad-cell {
  width: 140px; height: 88px;
  border-radius: 8px;
  background: var(--blue-bg);
  border: 1px solid rgba(77,143,220,0.15);
  display: flex; align-items: center; justify-content: center;
  overflow: visible;
}
.dpad-cell .btn-card {
  width: 100%; min-width: 100%;
  height: 100%; min-height: 100%;
  background: transparent;
  border: 2px solid transparent;
  padding: 8px 10px;
}
.dpad-cell .btn-card.active {
  background: var(--blue-bg-active);
  border-color: var(--blue);
  box-shadow: 0 0 24px rgba(77,143,220,0.35);
}
.dpad-cell .btn-func {
  font-size: 0.82rem;
  max-width: 120px;
}

/* ── Face button cluster ── */
.face-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid rgba(224,85,106,0.2);
  border-radius: var(--radius);
  padding: 12px;
}
.face-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.face-cell {
  width: 140px; height: 88px;
  border-radius: 8px;
  background: var(--red-bg);
  border: 1px solid rgba(224,85,106,0.15);
  display: flex; align-items: center; justify-content: center;
  overflow: visible;
}
.face-cell .btn-card {
  width: 100%; min-width: 100%;
  height: 100%; min-height: 100%;
  background: transparent;
  border: 2px solid transparent;
  padding: 8px 10px;
}
.face-cell .btn-card.active {
  background: var(--red-bg-active);
  border-color: var(--red);
  box-shadow: 0 0 24px rgba(224,85,106,0.35);
}
.face-cell .btn-func {
  font-size: 0.82rem;
  max-width: 120px;
}

.empty { background: transparent !important; border: none !important; }

/* ── Target-Only Layout (gameplay — no buttons shown) ── */
.target-only-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 45vh;
  width: 100%;
  padding: 20px 0;
}

.target-prompt-large {
  min-width: 400px;
  min-height: 240px;
  padding: 32px 40px;
  gap: 16px;
}

.target-prompt-large .target-func-big {
  font-size: 2.4rem;
}

.target-prompt-large .target-image {
  max-width: 700px;
  max-height: 520px;
}

/* ── Center Area ── */
.center-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 520px;
  min-width: 280px;
}

/* Target prompt */
.target-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 36px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 16px;
  transition: all 0.25s;
  min-height: 140px;
  justify-content: center;
}

.target-prompt.active {
  border-color: rgba(255,255,255,0.25);
  background: #1a1f2c;
  box-shadow: 0 0 36px rgba(255,255,255,0.06);
}

.target-prompt.correct-flash {
  border-color: var(--green) !important;
  box-shadow: 0 0 40px rgba(63,185,80,0.25) !important;
}

.target-prompt.wrong-flash {
  border-color: var(--red) !important;
  box-shadow: 0 0 40px rgba(248,81,73,0.25) !important;
  animation: shake 0.4s ease;
}

.target-hint {
  color: var(--text-muted);
  font-size: 1rem;
}

.target-label-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.target-func-big {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  color: #fff;
}

.target-func {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Target prompt image (for rotary menus) */
.target-image {
  max-width: 680px;
  max-height: 500px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #000;
}

/* Fallback image placeholder if image fails to load */
.target-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 140px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.8rem;
  gap: 6px;
}

/* ── Feedback overlay (big center popup) ── */
.feedback-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 150;
  opacity: 0;
  transition: opacity 0.1s;
}
.feedback-overlay.show { opacity: 1; }

.feedback-big {
  font-size: 3.5rem;
  font-weight: 900;
  text-align: center;
  animation: feedback-pop 0.6s ease-out forwards;
}
.feedback-ok  { color: var(--green); }
.feedback-bad { color: var(--red); }

@keyframes feedback-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  25%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1.0); opacity: 0; }
}

/* ── Calibration mode ── */
.btn-card.cal-clickable {
  cursor: pointer;
  position: relative;
}
.btn-card.cal-clickable:hover {
  border-color: rgba(255,255,255,0.35);
  background: var(--bg-card-hover);
  transform: scale(1.04);
}

.btn-card.cal-unmapped {
  border-color: rgba(255,255,255,0.08);
  opacity: 0.65;
}
.btn-card.cal-mapped {
  border-color: rgba(63,185,80,0.45);
}

.btn-card.cal-selected {
  border-color: var(--gold) !important;
  box-shadow: 0 0 28px rgba(201,169,78,0.4);
  transform: scale(1.08);
  z-index: 2;
}
.btn-card.cal-listening {
  animation: cal-listen-pulse 0.8s ease-in-out infinite;
}
@keyframes cal-listen-pulse {
  0%, 100% { box-shadow: 0 0 28px rgba(201,169,78,0.4); }
  50% { box-shadow: 0 0 44px rgba(201,169,78,0.6); }
}

.btn-card.cal-mapped-flash {
  border-color: var(--green) !important;
  box-shadow: 0 0 32px rgba(63,185,80,0.5);
  animation: none;
}
.btn-card.cal-error-flash {
  border-color: var(--red) !important;
  box-shadow: 0 0 32px rgba(248,81,73,0.5);
  animation: shake 0.4s ease;
}

/* Calibration status badge */
.cal-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.cal-badge-ok {
  background: var(--green);
  color: #fff;
}
.cal-badge-pending {
  background: #5a5f6a;
  color: #fff;
}
