/* CSS 변수 정의 */
.color-quiz-wrapper {
  --bg-primary: #f5f5f0;
  --bg-secondary: #fff;
  --bg-section: #fff;
  --border-color: #333;
  --text-primary: #222;
  --text-secondary: #555;
  --text-light: #666;
  --color-accent: #3498db;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-danger: #e74c3c;
  --color-purple: #9b59b6;
  --shadow-sm: 2px 2px 0 rgba(0,0,0,0.1);
  --shadow-md: 4px 4px 0 rgba(0,0,0,0.15);
  --shadow-lg: 8px 8px 0 rgba(0,0,0,0.15);
}

/* 전역 box-sizing */
.color-quiz-wrapper,
.color-quiz-wrapper *,
.color-quiz-wrapper *::before,
.color-quiz-wrapper *::after {
  box-sizing: border-box;
}

/* 메인 컨테이너 */
.color-quiz-container {
  max-width: 900px;
  width: 100%;
  margin: 10px auto;
  padding: 12px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  font-family: 'Noto Sans KR', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  line-height: 1.4;
}

/* 헤더 */
.quiz-header {
  text-align: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 3px double var(--border-color);
}

.quiz-header h2 {
  margin: 0 0 5px 0;
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
  text-shadow: 2px 2px 0 rgba(255,255,255,0.5);
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* 게임 설정 섹션 */
.game-settings {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

.setting-group {
  margin-bottom: 10px;
}

.setting-group:last-of-type {
  margin-bottom: 12px;
}

.setting-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-buttons,
.difficulty-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-mode,
.btn-difficulty {
  flex: 1;
  min-width: 80px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-mode:hover,
.btn-difficulty:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-mode:active,
.btn-difficulty:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.btn-mode.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--border-color);
}

.btn-difficulty.active {
  background: var(--color-success);
  color: #fff;
  border-color: var(--border-color);
}

.btn-start {
  width: 100%;
  padding: 12px;
  background: var(--color-warning);
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-start:hover {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.btn-start:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* 광고 섹션 */
.ad-section {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 10px;
  text-align: center;
  background: #fff;
  border: 1px solid #ddd;
  overflow: visible;
  margin-bottom: 10px;
}

.ad-label {
  display: block;
  font-size: 10px;
  color: #999;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ad-section .adsbygoogle {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 70px;
  text-align: center;
}

/* 게임 화면 */
.game-screen {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

/* 게임 상태 */
.game-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.status-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.status-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}

.status-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

.status-value.streak {
  color: var(--color-warning);
}

/* 색상 표시 영역 */
.color-display {
  margin-bottom: 12px;
  text-align: center;
}

.color-box {
  width: 100%;
  height: 150px;
  border: 3px solid var(--border-color);
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease;
}

.color-question {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* 선택지 (4열로 배치) */
.choices-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

/* 피드백 섹션 */
.feedback-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.choice-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
  font-family: inherit;
  text-align: left;
}

.choice-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.choice-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.choice-btn.correct {
  background: var(--color-success);
  color: #fff;
  border-color: #1e7e34;
  animation: correctPulse 0.5s ease;
}

.choice-btn.wrong {
  background: var(--color-danger);
  color: #fff;
  border-color: #c0392b;
  animation: wrongShake 0.5s ease;
}

.choice-btn.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.choice-label {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  margin-bottom: 6px;
}

.choice-btn.correct .choice-label,
.choice-btn.wrong .choice-label {
  background: rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.5);
}

.choice-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.choice-btn.correct .choice-value,
.choice-btn.wrong .choice-value {
  color: #fff;
}

/* 애니메이션 */
@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* 피드백 */
.feedback {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 20px 12px;
  text-align: center;
  box-shadow: var(--shadow-md);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.feedback-icon {
  font-size: 48px;
}

.feedback-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.feedback-correct {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'Courier New', monospace;
}

/* 다음 문제 버튼 */
.btn-next {
  width: 100%;
  padding: 14px;
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-next:hover {
  background: #2980b9;
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
}

.btn-next:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* 게임 액션 버튼 */
.game-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-restart-game,
.btn-quit-game {
  flex: 1;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-family: inherit;
  color: var(--text-primary);
}

.btn-restart-game {
  background: var(--color-warning);
  color: #fff;
}

.btn-quit-game {
  background: #f0f0f0;
}

.btn-restart-game:hover,
.btn-quit-game:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-restart-game:active,
.btn-quit-game:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* 결과 화면 */
.result-screen {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.result-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 15px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 15px;
}

.result-stat-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 12px 10px;
  box-shadow: var(--shadow-sm);
}

.result-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}

.result-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

.result-grade {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 1px solid var(--border-color);
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: var(--shadow-md);
  color: #fff;
}

.grade-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.grade-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.grade-message {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.9;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.btn-retry,
.btn-change-settings {
  flex: 1;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-retry {
  background: var(--color-success);
  color: #fff;
}

.btn-retry:hover,
.btn-change-settings:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.btn-retry:active,
.btn-change-settings:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

/* 통계 섹션 */
.stats-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-md);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

.btn-reset-stats {
  width: 100%;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-danger);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-family: inherit;
}

.btn-reset-stats:hover {
  background: #ffe6e6;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.btn-reset-stats:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* 정보 섹션 */
.info-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.info-content {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
}

.info-item {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #ddd;
}

.info-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.info-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-primary);
}

.info-item p {
  margin: 0;
  color: var(--text-secondary);
}

.info-item ul {
  margin: 6px 0 0 0;
  padding-left: 20px;
  list-style-type: disc;
}

.info-item li {
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.info-item li:last-child {
  margin-bottom: 0;
}

/* 반응형: 태블릿 */
@media (max-width: 768px) {
  .color-quiz-container {
    margin: 10px 5px;
    padding: 10px;
    width: calc(100% - 10px);
    max-width: 100%;
  }

  .quiz-header h2 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
  }

  .game-status {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .status-value {
    font-size: 18px;
  }

  .color-box {
    height: 120px;
  }

  .choices-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-actions {
    flex-direction: column;
  }
}

/* 반응형: 모바일 */
@media (max-width: 480px) {
  .color-quiz-container {
    margin: 10px 5px;
    padding: 8px;
    width: calc(100% - 10px);
    max-width: 100%;
    border-width: 1px;
  }

  .quiz-header h2 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 11px;
  }

  .game-settings {
    padding: 10px;
  }

  .setting-group label {
    font-size: 13px;
  }

  .btn-mode,
  .btn-difficulty {
    min-width: 70px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .btn-start {
    padding: 10px;
    font-size: 14px;
  }

  .game-screen {
    padding: 10px;
  }

  .game-status {
    gap: 5px;
  }

  .status-label {
    font-size: 10px;
  }

  .status-value {
    font-size: 16px;
  }

  .color-box {
    height: 100px;
  }

  .color-question {
    font-size: 14px;
  }

  .choices-grid {
    gap: 8px;
    grid-template-columns: repeat(2, 1fr);
  }

  .choice-btn {
    padding: 10px 8px;
  }

  .choice-label {
    width: 24px;
    height: 24px;
    font-size: 12px;
    line-height: 24px;
  }

  .choice-value {
    font-size: 13px;
  }

  .feedback {
    padding: 15px 10px;
  }

  .feedback-icon {
    font-size: 36px;
  }

  .feedback-text {
    font-size: 16px;
  }

  .feedback-correct {
    font-size: 12px;
  }

  .btn-next {
    padding: 10px;
    font-size: 14px;
  }

  .game-actions {
    flex-direction: column;
    gap: 6px;
  }

  .btn-restart-game,
  .btn-quit-game {
    padding: 8px;
    font-size: 12px;
  }

  .result-screen {
    padding: 12px;
  }

  .result-title {
    font-size: 20px;
  }

  .result-stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .result-stat-value {
    font-size: 20px;
  }

  .grade-icon {
    font-size: 40px;
  }

  .grade-text {
    font-size: 18px;
  }

  .grade-message {
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 8px;
  }

  .stat-icon {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 16px;
  }

  .section-title {
    font-size: 14px;
  }

  .info-content {
    font-size: 12px;
  }

  .info-item strong {
    font-size: 13px;
  }
}