/* Arcade & Canvas Styling */

.game-cabinet {
  background: #090714;
  border: 4px solid var(--retro-yellow);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.3), var(--pixel-shadow-lg);
  padding: 12px;
  margin: 16px auto;
  max-width: 540px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #17112c;
  border-bottom: 3px solid var(--retro-yellow);
  padding: 8px 12px;
  margin-bottom: 10px;
}

.game-title {
  color: var(--retro-yellow);
  font-size: 11px;
}

.game-stats {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--retro-cyan);
}

.canvas-wrapper, .game-canvas-container {
  position: relative;
  width: 100%;
  background: #000;
  border: 3px solid #334155;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  touch-action: none; /* Mencegah scroll saat bermain game di HP */
  border-radius: 4px;
}

#gameCanvas, canvas.game-canvas {
  display: block;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  max-width: 480px;
  height: auto;
  aspect-ratio: 4 / 3;
  touch-action: none;
}

/* Virtual Gamepad untuk HP Android & Layar Sentuh */
.virtual-controls, .virtual-gamepad {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: #130f24;
  border-top: 3px solid #334155;
  padding: 16px 12px;
  margin-top: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  border-radius: 4px;
  gap: 12px;
  box-sizing: border-box;
}

/* D-Pad (Arah) - Stabil & Berukuran Jelas untuk Jari */
.virtual-dpad, .d-pad {
  display: grid !important;
  grid-template-columns: 44px 44px 44px !important;
  grid-template-rows: 44px 44px 44px !important;
  gap: 4px !important;
  width: 140px !important;
  height: 140px !important;
  flex-shrink: 0 !important;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.dpad-btn, .d-btn {
  background: #251e3e;
  border: 3px solid #5a4b8c;
  box-shadow: 2px 2px 0px #000;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 4px;
  transition: all 0.08s ease;
}

.dpad-btn:active, .dpad-btn.active, .d-btn:active, .d-btn.active {
  background: var(--retro-yellow) !important;
  color: #000000 !important;
  border-color: #ca8a04 !important;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000;
}

.dpad-up, .d-up {
  grid-column: 2;
  grid-row: 1;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.dpad-left, .d-left {
  grid-column: 1;
  grid-row: 2;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

.dpad-center, .d-center {
  grid-column: 2;
  grid-row: 2;
  background: #17122b !important;
  border: 2px solid #382c59 !important;
  box-shadow: none !important;
  color: #64748b;
  font-size: 10px;
  cursor: default;
}

.dpad-right, .d-right {
  grid-column: 3;
  grid-row: 2;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

.dpad-down, .d-down {
  grid-column: 2;
  grid-row: 3;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Action Buttons (A & B) */
.virtual-action-buttons, .action-buttons {
  display: flex !important;
  gap: 16px !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  transform: rotate(-12deg);
  margin-right: 6px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.action-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid #000000;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  font-weight: bold;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 3px 3px 0px #000000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.action-btn:active, .action-btn.active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000000;
}

.btn-b {
  background: var(--retro-yellow);
  color: #000000;
}

.btn-a {
  background: var(--retro-pink);
  color: #ffffff;
}

/* Single Big Action Pad */
.virtual-single-pad, .single-action-pad {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100%;
  padding: 10px 0;
  touch-action: none;
}

.big-touch-btn {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  background: var(--retro-green);
  color: #000000;
  border: 3px solid #000000;
  box-shadow: var(--pixel-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 6px;
}

.big-touch-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000000;
}

/* Penyesuaian Responsif untuk Layar HP Android Ramping (misal Samsung Galaxy S10: 360px) */
@media (max-width: 420px) {
  .virtual-controls, .virtual-gamepad {
    padding: 12px 6px !important;
    gap: 6px !important;
  }
  .virtual-dpad, .d-pad {
    grid-template-columns: 38px 38px 38px !important;
    grid-template-rows: 38px 38px 38px !important;
    gap: 3px !important;
    width: 120px !important;
    height: 120px !important;
  }
  .dpad-btn, .d-btn {
    font-size: 13px !important;
  }
  .virtual-action-buttons, .action-buttons {
    gap: 10px !important;
    transform: rotate(-8deg);
  }
  .action-btn {
    width: 48px !important;
    height: 48px !important;
    font-size: 12px !important;
  }
}

/* Game Menu Tabs */
.game-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.game-tab-btn {
  background: #181330;
  border: 2px solid #52477a;
  color: #f8fafc;
  padding: 12px 8px 10px 8px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 96px;
  box-shadow: 3px 3px 0px #000;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.game-tab-btn .game-icon {
  font-size: 26px;
  display: block;
  line-height: 1.1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

.game-tab-btn .game-title-text {
  font-family: 'VT323', monospace;
  font-size: 19px;
  font-weight: bold;
  letter-spacing: 0.8px;
  line-height: 1.15;
  color: #facc15;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: normal;
  display: block;
  margin: 2px 0;
  text-shadow: 1px 1px 0px #000;
}

.game-tab-btn .game-status-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  border-radius: 3px;
  display: inline-block;
  letter-spacing: 0.5px;
  font-weight: bold;
  white-space: nowrap;
}

.game-tab-btn .badge-pending {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #475569;
}

.game-tab-btn .badge-done {
  background: #15803d;
  color: #ffffff;
  border: 1px solid #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.game-tab-btn:hover {
  border-color: var(--retro-yellow);
  background: #251e47;
  transform: translateY(-2px);
}

.game-tab-btn.active {
  background: #2e2654;
  color: #fff;
  border-color: var(--retro-yellow);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.6), 3px 3px 0px #000;
}

.game-tab-btn.active .game-title-text {
  color: #ffffff;
}

/* MISSION TRACKER HUD */
.mission-tracker-box {
  background: #090714;
  border: 2px solid var(--retro-yellow);
  padding: 14px;
  margin-bottom: 18px;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.2);
}

.mission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.mission-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--retro-yellow);
}

.mission-counter {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  padding: 4px 8px;
  border: 1px solid #22c55e;
  border-radius: 3px;
}

.mission-desc {
  font-size: 9px;
  color: #cbd5e1;
  line-height: 1.4;
  margin-bottom: 10px;
}

.mission-progress-bar {
  width: 100%;
  height: 14px;
  background: #1e1b4b;
  border: 2px solid var(--retro-yellow);
  border-radius: 3px;
  overflow: hidden;
}

.mission-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #facc15);
  transition: width 0.5s ease-in-out;
}

/* LOCKED INVITATION SECRET BOX */
.locked-invitation-box {
  background: rgba(220, 38, 38, 0.08);
  border: 3px dashed #ef4444;
  padding: 28px 16px;
  text-align: center;
  margin-top: 24px;
  border-radius: 6px;
}

.locked-invitation-box .lock-icon-anim {
  font-size: 38px;
  margin-bottom: 12px;
  display: inline-block;
  animation: lockPulse 1.5s infinite alternate;
}

@keyframes lockPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

.locked-invitation-box h3 {
  color: #ef4444;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  margin-bottom: 10px;
}

.locked-invitation-box p {
  color: #cbd5e1;
  font-size: 10px;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto 16px auto;
}

/* UNLOCKED CELEBRATION BANNER */
.unlocked-banner {
  animation: revealCelebration 0.8s ease forwards;
  margin-top: 24px;
  margin-bottom: 24px;
}

@keyframes revealCelebration {
  0% { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}

/* Game Over / Victory Screen inside canvas or modal */
.game-result-box {
  margin-top: 12px;
  padding: 12px;
  background: #1c1535;
  border: 3px solid var(--retro-cyan);
}

/* NEXT CHALLENGE BUTTON & PULSE ANIMATION */
.next-pulse-btn {
  animation: nextBtnPulse 1.5s infinite alternate ease-in-out;
}

@keyframes nextBtnPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
  }
  100% {
    transform: scale(1.02);
    box-shadow: 0 0 22px rgba(250, 204, 21, 0.85);
  }
}

.current-challenge-card {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.replay-section-box {
  animation: fadeInReplay 0.6s ease;
}

@keyframes fadeInReplay {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Leaderboard Responsive Table Styles */
.leaderboard-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
  background: #090714;
  border: 2px solid var(--retro-cyan);
  border-radius: 4px;
}

.leaderboard-table-wrapper .pixel-table th {
  background: #181330;
  color: var(--retro-yellow);
  font-size: 8px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.leaderboard-table-wrapper .pixel-table td {
  font-size: 8px;
  white-space: nowrap;
}

