/**
 * games.css
 * Mini-Games Styling: The Style Chameleon Jukebox, Polyrhythm Tap Hero,
 * Ear Hero Quest, and World Melody Matrix.
 */

/* Chameleon Jukebox */
.styles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.style-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.style-card:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.style-card.active {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.12), rgba(139, 92, 246, 0.12));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 25px rgba(0, 242, 254, 0.2);
}

.style-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.style-info h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.style-groove {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.6rem;
}

.style-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge-sm {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
}

/* Mixer Buttons */
.mixer-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-pill.active-muted {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}

/* Polyrhythm Tap Hero */
.dual-tap-pads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.25rem 0;
}

.tap-pad {
  height: 90px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.1s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.pad-left {
  border-color: rgba(0, 242, 254, 0.3);
}

.pad-right {
  border-color: rgba(245, 158, 11, 0.3);
}

.tap-pad:active, .tap-pad.hit {
  transform: scale(0.96);
}

.pad-left.hit {
  background: var(--accent-cyan);
  box-shadow: 0 0 25px var(--accent-cyan);
}
.pad-left.hit * { color: #040812 !important; }

.pad-right.hit {
  background: var(--accent-amber);
  box-shadow: 0 0 25px var(--accent-amber);
}
.pad-right.hit * { color: #040812 !important; }

.pad-key {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.pad-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Step Progression Tabs & Controls */
.step-selector-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem 0;
  flex-wrap: wrap;
}

.step-pill {
  flex: 1;
  min-width: 105px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.step-pill:hover {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.step-pill.active {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(168, 85, 247, 0.25));
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.25);
}

.step-banner {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.step-banner-highlight {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Hand selector for Step 1 */
.step1-hand-selector {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

.step1-hand-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.step1-hand-btn.active {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--accent-amber);
  color: #ffffff;
}

.step1-hand-btn.hand-left.active {
  background: rgba(0, 242, 254, 0.25);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

/* Muted Tap Pad in Step 1 */
.tap-pad.muted {
  opacity: 0.32;
  cursor: not-allowed;
  filter: grayscale(0.6);
  border-style: dashed;
}

/* Ghost pulse visual indicator */
.ghost-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  background: rgba(168, 85, 247, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #c084fc;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  animation: ghostGlow 1.8s infinite ease-in-out;
}

@keyframes ghostGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
    opacity: 0.7;
  }
  50% {
    box-shadow: 0 0 22px rgba(168, 85, 247, 0.7);
    opacity: 1;
  }
}

/* Step 4 Tempo presets & Accelerando */
.tempo-presets {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.btn-preset {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset:hover, .btn-preset.active {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.accelerando-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.75rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.accelerando-toggle input {
  cursor: pointer;
}

.accel-active-tag {
  color: #f43f5e;
  font-weight: 700;
  animation: pulse 1s infinite alternate;
}


/* Unified Arcade Console Styles */
.arcade-cabinet {
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid rgba(0, 242, 254, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 242, 254, 0.08);
}

.arcade-hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  background: rgba(10, 15, 30, 0.75);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
  flex-wrap: wrap;
}

.arcade-hud-stats {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.hud-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.hud-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.hud-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #ffffff;
}

.combo-fire {
  color: #f59e0b !important;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.8), 0 0 25px rgba(239, 68, 68, 0.6);
  animation: fireFlicker 0.4s infinite alternate;
}

@keyframes fireFlicker {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Stage Stepper Progress Bar */
.stage-stepper-container {
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-subtle);
}

.stage-stepper-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.stage-step-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm, 6px);
  padding: 0.4rem 0.6rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.stage-step-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}

.stage-step-card.cleared {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.stage-step-card.cleared::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: 0.7rem;
  color: #10b981;
  font-weight: 900;
}

.step-card-num {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stage-step-card.active .step-card-num {
  color: var(--accent-cyan);
}

.step-card-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet, #a855f7));
  transition: width 0.2s ease;
}

.stage-objective-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  align-items: center;
}

.stage-objective-counter {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Floating screen shake */
.canvas-shake {
  animation: screenVibrate 0.15s infinite;
}

@keyframes screenVibrate {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -3px); }
  100% { transform: translate(2px, 3px); }
}

/* Polyrhythm Tap Hero Countdown & Rhythmic Example Overlay */
.countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 12, 24, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
  border-radius: inherit;
  animation: overlayFadeIn 0.2s ease-out;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.countdown-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 2rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(0, 242, 254, 0.4);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 242, 254, 0.18);
  max-width: 540px;
  width: 90%;
}

.countdown-badges {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.countdown-hint-text {
  font-size: 0.92rem;
  color: var(--text-main, #ffffff);
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 1rem;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-demo-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan, #00f2fe);
  padding: 0.35rem 0.85rem;
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.35);
  border-radius: 20px;
  margin-bottom: 0.85rem;
  transition: all 0.25s ease;
}

.countdown-demo-status.ready {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.45);
}

.countdown-big-num {
  font-size: 3.6rem;
  font-weight: 900;
  font-family: var(--font-mono, monospace);
  line-height: 1;
  color: #ffffff;
  min-height: 4.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 20px var(--accent-cyan, #00f2fe), 0 0 40px var(--accent-cyan, #00f2fe);
  animation: countdownPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.countdown-big-num.go {
  color: #10b981;
  text-shadow: 0 0 25px #10b981, 0 0 50px rgba(16, 185, 129, 0.8);
  font-size: 4rem;
}

@keyframes countdownPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.game-stats-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.judgment-banner {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.judgment-text {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* Ear Hero Quest */
.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.btn-answer {
  padding: 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-answer.btn-success {
  background: rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.btn-answer.btn-danger {
  background: rgba(244, 63, 94, 0.25);
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

/* World Melody Matrix (Step Sequencer) */
.matrix-grid-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  overflow-x: auto;
}

.matrix-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-row-label {
  width: 48px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

.matrix-cells-wrapper {
  display: flex;
  gap: 4px;
  flex: 1;
}

.matrix-cell {
  flex: 1;
  height: 28px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
  min-width: 22px;
}

.matrix-cell:hover {
  background: rgba(255, 255, 255, 0.12);
}

.matrix-cell.beat-down {
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.matrix-cell.active {
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
}

.matrix-cell.current-step {
  border-color: #ffffff;
  transform: scaleY(1.1);
}

.matrix-cell.active.current-step {
  background: #ffffff;
  box-shadow: 0 0 14px #ffffff;
}

/* Toggle Switch (Checkbox) */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-container input {
  display: none;
}

.toggle-slider {
  width: 42px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.2s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
}

.toggle-container input:checked + .toggle-slider {
  background: var(--accent-cyan);
}

.toggle-container input:checked + .toggle-slider::after {
  transform: translateX(18px);
}
