/* ==========================================================================
   MegaNumbers Quiz CSS - Dark Cyber Modern & Glassmorphism Theme
   ========================================================================== */

:root {
  --bg-dark: #0b0f19;
  --bg-card: #151c2e;
  --bg-glass: rgba(26, 34, 56, 0.75);
  --border-glass: rgba(255, 255, 255, 0.12);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --danger-red: #ef4444;
  
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-muted: #64748b;
  
  --font-main: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  margin: 0;
  padding-top: 68px;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

/* Header - Fixed Bar (Matches Trainer App) */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.6rem 1.2rem;
  box-sizing: border-box;
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
}

.logo-area h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-sub);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
}

/* Buttons */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}

.btn-header-icon:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #fff;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  background: linear-gradient(135deg, #4f46e5, #3730a3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--border-glass);
  padding: 0.75rem 1.4rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border-glass);
  padding: 0.75rem 1.4rem;
}

.btn-outline:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.btn-start {
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary));
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border-radius: 30px;
  width: 100%;
}

.btn-pulse {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-soft:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.btn-large {
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
}

/* Game Status Bar */
.game-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 0.6rem 1.2rem;
  gap: 0.8rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.status-label {
  color: var(--text-sub);
}

.status-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
}

.level-badge {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(236, 72, 153, 0.15));
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent-amber);
  font-weight: 700;
}

/* Timer Bar */
.timer-bar-container {
  position: relative;
  width: 100%;
}

.countdown-bar-wrapper {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.countdown-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--primary), var(--accent-pink));
  border-radius: 6px;
  transition: width 0.05s linear;
}

.countdown-bar.warning {
  background: linear-gradient(90deg, var(--accent-amber), var(--danger-red));
  animation: timer-flash 0.5s infinite alternate;
}

@keyframes timer-flash {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

.timer-text-overlay {
  position: absolute;
  right: 8px;
  top: -22px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Quiz Stage */
.quiz-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Overlays */
.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.overlay-card {
  text-align: center;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.overlay-icon {
  font-size: 3rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.overlay-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.overlay-card p {
  color: var(--text-sub);
  font-size: 0.95rem;
  line-height: 1.5;
}

.overlay-actions {
  margin-top: 0.5rem;
  width: 100%;
}

.overlay-actions-row {
  display: flex;
  gap: 0.8rem;
  width: 100%;
  justify-content: center;
  margin-top: 0.5rem;
}

/* Quiz Question Card */
.quiz-card-wrapper {
  width: 100%;
}

.quiz-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.5rem;
  box-shadow: var(--shadow-card);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.badge {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.question-instruction {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.question-display-area {
  text-align: center;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.question-text {
  font-family: var(--font-mono);
  font-size: 2.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  word-break: break-word;
  transition: font-size 0.3s ease, opacity 0.3s ease;
  line-height: 1.3;
  user-select: none;
}

.question-sub {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

/* 4-Choice Options Grid (2x2) */
.quiz-options-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

.btn-quiz-option {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.2rem 1rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.btn-quiz-option:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.25);
}

.btn-quiz-option:active {
  transform: translateY(0);
}

.option-key {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.option-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

/* Option Flash Animations */
.btn-quiz-option.correct-flash {
  background: rgba(16, 185, 129, 0.35) !important;
  border-color: var(--accent-green) !important;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.6) !important;
  animation: pulse-correct 0.3s ease;
}

.btn-quiz-option.wrong-flash {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: var(--danger-red) !important;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.6) !important;
  animation: shake-wrong 0.3s ease;
}

@keyframes pulse-correct {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes shake-wrong {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.modal-sm { max-width: 440px; }
.modal-gameover { max-width: 480px; }
.modal-ranking { max-width: 640px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.modal-header-center {
  justify-content: center;
  border-bottom: none;
  padding-bottom: 0.2rem;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.gameover-title {
  font-size: 1.8rem !important;
  font-weight: 900 !important;
  color: var(--danger-red);
  letter-spacing: 1px;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.2rem;
  cursor: pointer;
}

.btn-close:hover { color: #fff; }

.modal-body {
  padding: 1.5rem;
}

.text-center { text-align: center; }

/* Game Over Modal Elements */
.score-display-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-label {
  font-size: 0.85rem;
  color: var(--text-sub);
}

.score-value {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent-cyan);
  line-height: 1.1;
}

.score-unit {
  font-size: 0.85rem;
  color: var(--accent-amber);
  font-weight: 700;
}

.gameover-reason {
  color: var(--text-sub);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.ranking-register-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.input-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.6rem;
}

.nickname-input-group {
  display: flex;
  gap: 0.6rem;
}

.custom-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.custom-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* Custom Select & Radio */
.control-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.custom-select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.radio-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

.radio-toggle input { display: none; }

.radio-toggle label {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  margin: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-sub);
  transition: all 0.2s ease;
}

.radio-toggle input:checked + label {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* Ranking Table & Banners */
.tip-banner {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 1.2rem;
}

.tip-banner strong { color: var(--accent-cyan); }

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  margin-bottom: 1.5rem;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.ref-table th, .ref-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-glass);
}

.ref-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-sub);
  font-weight: 600;
}

.ranking-table td {
  font-size: 0.9rem;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #b45309, #78350f); color: #fff; }
.rank-other { background: rgba(255, 255, 255, 0.1); color: var(--text-sub); }

.modal-actions-center {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  body {
    padding-top: 60px;
  }
  .app-header {
    padding: 0.5rem 1rem;
  }
  .logo-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
  .logo-area h1 {
    font-size: 1.15rem;
  }
  .quiz-options-container {
    grid-template-columns: 1fr;
  }
  .btn-quiz-option {
    padding: 1rem;
  }
  .question-text {
    font-size: 1.8rem;
  }
  .overlay-actions-row, .modal-actions-center {
    flex-direction: column;
  }
}

/* Compact Nickname Input Styling */
.nickname-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.custom-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.nickname-input-group .btn-primary {
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  white-space: nowrap;
}


/* Compact Ad Banner Styling */
.modal-divider {
  border: none;
  border-top: 1px dashed var(--border-glass);
  margin: 1rem 0 0.8rem 0;
}

.ad-banner-wrapper {
  width: 85%;
  max-width: 360px;
  margin: 0 auto;
}

.ad-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: rgba(21, 28, 46, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s ease;
  position: relative;
}

.ad-banner:hover {
  background: rgba(26, 34, 56, 0.9);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.ad-badge {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  line-height: 1;
}

.ad-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.ad-banner-trainer .ad-icon {
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary));
}

.ad-banner-quiz .ad-icon {
  background: linear-gradient(135deg, var(--accent-pink), var(--primary));
}

.ad-body {
  flex: 1;
  text-align: left;
  overflow: hidden;
}

.ad-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-sub {
  font-size: 0.68rem;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-arrow {
  font-size: 0.75rem;
  color: var(--text-sub);
}
