/**
 * CogniTest Retro Arcade Styling
 * Authentic Neo-Retro Cabinet, CRT Scanlines, Responsive 12-Game Hub, Virtual Touch D-Pad & HUD
 */

:root {
  --arcade-bg: #060a12;
  --arcade-cabinet-bg: #0c1222;
  --arcade-bezel: #1e293b;
  --arcade-neon-cyan: #38bdf8;
  --arcade-neon-amber: #f59e0b;
  --arcade-neon-green: #34d399;
  --arcade-neon-pink: #ec4899;
  --arcade-text-dim: #94a3b8;
  --arcade-text-bright: #f8fafc;
}

.arcade-page-container {
  width: 100%;
  min-width: 0;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Header & Intro */
.arcade-header-box {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.8) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.arcade-header-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--arcade-text-bright);
  margin: 8px 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.arcade-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--arcade-neon-cyan);
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* Main Cabinet Layout: 2 Columns on Desktop */
.arcade-main-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  margin-bottom: 32px;
}

@media (max-width: 900px) {
  .arcade-main-stage {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Arcade Cabinet Frame */
.arcade-cabinet {
  min-width: 0;
  width: 100%;
  background: var(--arcade-cabinet-bg);
  border: 2px solid #1e293b;
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.1);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Cabinet Top HUD */
.arcade-hud {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  margin-bottom: 12px;
  font-family: 'Courier New', Courier, monospace;
}

.arcade-hud-game-info {
  display: flex;
  flex-direction: column;
}

.arcade-hud-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--arcade-neon-cyan);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.arcade-hud-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--arcade-neon-amber);
}

.arcade-hud-scores {
  display: flex;
  gap: 18px;
  align-items: center;
}

.arcade-score-item {
  text-align: right;
}

.arcade-score-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--arcade-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.arcade-score-number {
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.arcade-score-number.high {
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* Screen Wrapper */
.arcade-screen-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1;
  background: #060a12;
  border: 3px solid #334155;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 4px 20px rgba(0, 0, 0, 0.5);
}

#arcadeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

/* CRT Scanlines and Glass Overlay */
.arcade-crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 4px, 6px 100%;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
}

/* Cabinet Controls Bar */
.arcade-cabinet-actions {
  width: 100%;
  max-width: 600px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.arcade-btn-start {
  flex: 1;
  background: linear-gradient(135deg, #0369a1 0%, #0369a1 100%);
  color: #ffffff;
  border: 1px solid #38bdf8;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
}

.arcade-btn-start:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.5);
}

.arcade-btn-sound {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.arcade-btn-sound:hover {
  background: #334155;
  color: #f8fafc;
}

/* Virtual Touch D-Pad for Mobile */
.arcade-vpad-container {
  display: none;
  width: 100%;
  max-width: 600px;
  margin-top: 16px;
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 14px;
}

@media (max-width: 900px) {
  .arcade-vpad-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
  }
}

.vpad-dpad-cross {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
}

.vpad-btn {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
  cursor: pointer;
  transition: background 0.1s;
}

.vpad-btn:active {
  background: #38bdf8;
  color: #060a12;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.vpad-up { grid-column: 2; grid-row: 1; }
.vpad-left { grid-column: 1; grid-row: 2; }
.vpad-center { grid-column: 2; grid-row: 2; background: transparent; border: none; pointer-events: none; }
.vpad-right { grid-column: 3; grid-row: 2; }
.vpad-down { grid-column: 2; grid-row: 3; }

.vpad-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.vpad-btn-round {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  user-select: none;
  touch-action: manipulation;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.vpad-btn-round.action-a {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
  border: 2px solid #f87171;
}

.vpad-btn-round.action-a:active {
  background: #dc2626;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.8);
}

.vpad-btn-round.action-b {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  border: 2px solid #60a5fa;
}

.vpad-btn-round.action-b:active {
  background: #2563eb;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.8);
}

/* Sidebar: Game Selector */
.arcade-sidebar {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  max-height: 720px;
}

.arcade-sidebar-header {
  font-size: 1.1rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #1e293b;
}

.arcade-game-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar */
.arcade-game-list::-webkit-scrollbar {
  width: 6px;
}
.arcade-game-list::-webkit-scrollbar-track {
  background: #090d16;
}
.arcade-game-list::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

.arcade-game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.arcade-game-card:hover {
  background: #334155;
  border-color: #475569;
  transform: translateX(3px);
}

.arcade-game-card.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.3) 0%, rgba(30, 41, 59, 0.9) 100%);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.arcade-card-icon {
  font-size: 1.5rem;
  min-width: 32px;
  text-align: center;
}

.arcade-card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.arcade-card-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
}

.arcade-card-genre {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
}

.arcade-card-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 12-Games Grid Showcase Below Stage */
.arcade-showcase-section {
  margin-top: 32px;
}

.arcade-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.arcade-grid-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.arcade-grid-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.arcade-grid-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.arcade-grid-card-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.45;
  margin-bottom: 12px;
}

.arcade-grid-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #38bdf8;
}

/* Scientific Article & FAQ Section */
.arcade-article-section {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 32px 28px;
  margin-top: 40px;
  line-height: 1.7;
}

.arcade-article-section h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: #f8fafc;
  margin: 28px 0 14px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 8px;
}

.arcade-article-section h2:first-of-type {
  margin-top: 0;
}

.arcade-article-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #38bdf8;
  margin: 20px 0 10px;
}

.arcade-article-section p {
  color: #cbd5e1;
  margin-bottom: 16px;
}

.arcade-article-section ul {
  color: #cbd5e1;
  padding-left: 20px;
  margin-bottom: 16px;
}

.arcade-article-section li {
  margin-bottom: 8px;
}

/* FAQ Accordion */
.arcade-faq-accordion {
  margin-top: 24px;
}

.arcade-faq-item {
  border: 1px solid #1e293b;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #131d33;
}

.arcade-faq-q {
  padding: 16px 20px;
  font-weight: 700;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.arcade-faq-q:hover {
  color: #38bdf8;
}

.arcade-faq-a {
  padding: 0 20px 16px;
  color: #94a3b8;
  font-size: 0.92rem;
  line-height: 1.6;
  display: block;
}

/* ==========================================================================
   Screen & Cabinet Lockdown: Anti-Scroll, Anti-Zoom, Anti-Select (Fase 3)
   ========================================================================== */
body.game-active-lock {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none;
}

body.game-active-lock .arcade-cabinet,
body.game-active-lock .arcade-cabinet * {
  user-select: none;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  touch-action: none;
  touch-action: none !important;
  overscroll-behavior: contain;
}

body.game-active-lock .arcade-cabinet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 6px;
}

body.game-active-lock .arcade-hud { margin-bottom: 0; padding: 5px 10px; }
body.game-active-lock .arcade-screen-wrapper {
  width: min(88vw, calc(100dvh - 270px), 600px);
  min-width: 100px;
  align-self: center;
}
body.game-active-lock .arcade-cabinet-actions { margin: 0; flex-wrap: wrap; gap: 6px; }
body.game-active-lock .arcade-vpad-container { margin: 0; padding: 0; }
.instructions-steps { padding-left: 24px; margin: 8px 0; line-height: 1.5; }
.instructions-steps li { margin: 6px 0; }
.arcade-instructions-overlay.active { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.arcade-instructions-overlay.active * { touch-action: pan-y; }

/* Help / Instructions Button in Cabinet Controls */
.arcade-btn-help {
  background: rgba(30, 41, 59, 0.85);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.arcade-btn-help:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

/* Instructions & Controls Overlay (Inside Screen Wrapper) */
.arcade-instructions-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 10, 18, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 18px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: scale(0.97);
  box-sizing: border-box;
}

.arcade-instructions-overlay.active {
  position: fixed;
  inset: 0;
  width: min(94vw, 640px);
  height: 92vh;
  height: 92dvh;
  margin: auto;
  z-index: 10020;
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.instructions-card {
  width: 100%;
  max-width: 500px;
  background: #0d1527;
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(56, 189, 248, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 94%;
  overflow-y: auto;
}

.instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.instructions-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.instructions-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.instructions-close-btn:hover {
  color: #f8fafc;
}

.instructions-goal-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
}

.instructions-goal-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #f59e0b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.instructions-goal-text {
  font-size: 0.92rem;
  color: #f1f5f9;
  line-height: 1.45;
  margin: 0;
}

.instructions-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
}

@media (max-width: 520px) {
  .instructions-controls-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.instructions-control-col {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
}

.instructions-col-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.instructions-key-item {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.key-badge {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.76rem;
  font-family: monospace;
  font-weight: 800;
  color: #38bdf8;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.instructions-play-btn {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  border: 1px solid #34d399;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  margin-top: 4px;
}
.instructions-play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.65);
}

.arcade-page-container > *,
.arcade-header-box > *,
.arcade-hud-game-info { min-width: 0; }
.arcade-badge-tag { max-width: 100%; overflow-wrap: anywhere; }
.arcade-header-title { flex-wrap: wrap; overflow-wrap: anywhere; }

@media (max-width: 520px) {
  .arcade-cabinet { padding: 8px; }
  .arcade-hud { padding: 8px; gap: 8px; }
  .arcade-hud-title { font-size: 0.9rem; overflow-wrap: anywhere; }
  .arcade-hud-scores { gap: 10px; flex-shrink: 0; }
  .arcade-cabinet-actions,
  body.game-active-lock .arcade-cabinet-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .arcade-cabinet-actions button { min-width: 0; min-height: 44px; padding: 8px; font-size: 0.82rem; }
  body.game-active-lock .arcade-screen-wrapper { width: min(88vw, calc(100dvh - 350px), 600px); }
  .arcade-vpad-container { padding: 8px; gap: 8px; }
  .vpad-dpad-cross { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .vpad-btn { width: 44px; height: 44px; }
  .vpad-actions { gap: 8px; }
  .vpad-btn-round { width: 44px; height: 44px; }
  .instructions-card { padding: 14px; }
  .instructions-title { font-size: 1.1rem; }
}

@media (max-height: 520px) and (min-width: 600px) {
  body.game-active-lock .arcade-cabinet {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 38vw);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  body.game-active-lock .arcade-hud { grid-column: 1 / 3; max-width: none; }
  body.game-active-lock .arcade-screen-wrapper {
    grid-column: 1;
    grid-row: 2 / 4;
    width: min(45vw, calc(100dvh - 90px));
  }
  body.game-active-lock .arcade-cabinet-actions {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-self: center;
  }
  body.game-active-lock .arcade-cabinet-actions button { min-height: 44px; padding: 6px; font-size: 0.78rem; }
  body.game-active-lock .arcade-vpad-container { grid-column: 2; grid-row: 3; }
  .arcade-vpad-container { gap: 8px; }
  .vpad-dpad-cross { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .vpad-btn { width: 44px; height: 44px; }
  .vpad-actions { gap: 8px; }
  .vpad-btn-round { width: 44px; height: 44px; }
}


.arcade-badge-tag, .arcade-card-genre, .arcade-card-badge,
.arcade-info-section span[style*="font-size"] { font-size: 0.75rem !important; }

.arcade-grid-card span[style*="font-size: 0.72"], .vpad-btn-round span[style*="font-size"] { font-size: 0.75rem !important; line-height: 1.1; }
