/* ========================================
   집중력 훈련 전용 스타일 v1.0.0
   CPT 기반 집중력 훈련 (국제표준 적용)
   화면: 2000×1200 패드 최적화
   레벨 선택: 스크롤 가능
   게임/결과: 600px 고정
   도형: 이모지 150px (반응형: 120px → 100px)
   입력: 전체 화면 클릭
   반응형: 800px, 700px 중단점
   ======================================== */

:root {
  --focus-primary: #10b981;
  --focus-secondary: #3b82f6;
  --focus-danger: #ef4444;
  --focus-warning: #f59e0b;
  --focus-success: #22c55e;
  --focus-purple: #a855f7;
  --focus-pink: #ec4899;
}

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

html {
  overflow-y: auto;
  overflow-x: hidden;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #1f2937;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========================================
   헤더
   ======================================== */

.focus-header {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 12px 30px;
}

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

.focus-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.focus-icon {
  font-size: 24px;
}

.focus-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1f2937;
}

.btn-back {
  padding: 8px 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-back:hover {
  background: #f3f4f6;
  border-color: var(--focus-primary);
  transform: translateY(-2px);
}

.level-display-large {
  padding: 10px 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  letter-spacing: 1px;
  min-width: 140px;
  text-align: center;
}

.focus-progress-info {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 10px;
  font-size: 13px;
  color: #6b7280;
}

.focus-progress-info .divider {
  color: #d1d5db;
}

#member-display {
  color: var(--focus-primary);
  font-weight: 600;
}

/* ========================================
   메인 영역
   ======================================== */

.focus-main {
  max-width: 2000px;
  margin: 10px auto;
  padding: 0 30px;
  min-height: calc(100vh - 200px);
}

.focus-screen {
  background: white;
  border-radius: 16px;
  padding: 12px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.focus-screen.hidden {
  display: none;
}

/* ========================================
   레벨 선택 화면 - 스크롤 가능
   ======================================== */

#level-select-screen {
  position: static;
  overflow-y: auto;
  max-height: none;
  height: auto;
  padding: 40px 20px;
}

.level-select-container {
  text-align: center;
}

.screen-title {
  font-size: 36px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 16px;
}

.screen-subtitle {
  font-size: 18px;
  color: #6b7280;
  margin-bottom: 40px;
}

.screen-subtitle strong {
  color: var(--focus-primary);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.level-card {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 16px;
  padding: 32px 24px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: white;
}

.level-card:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.3);
}

.level-number {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 900;
  margin: 0 auto 20px;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.level-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.level-info {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.95;
}

.level-detail {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 12px;
}

.level-target {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

/* ========================================
   모드 선택 화면 (신규)
   ======================================== */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  max-width: 1200px;
  margin: 40px auto 0;
}

.mode-card {
  background: white;
  border-radius: 20px;
  padding: 40px 32px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 3px solid transparent;
}

.mode-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.2);
  border-color: var(--focus-primary);
}

.mode-icon {
  font-size: 64px;
  margin-bottom: 20px;
  text-align: center;
}

.mode-title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 12px;
  text-align: center;
}

.mode-description {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 24px;
  text-align: center;
  line-height: 1.5;
}

.mode-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.mode-feature {
  font-size: 14px;
  color: #4b5563;
  padding: 10px 16px;
  background: #f3f4f6;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
}

.mode-duration {
  font-size: 15px;
  color: var(--focus-primary);
  font-weight: 700;
  text-align: center;
  padding-top: 16px;
  border-top: 2px solid #e5e7eb;
}

/* ========================================
   게임 화면
   ======================================== */

#game-screen {
  height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

/* 타이머 */
.timer-section {
  width: 100%;
  margin-bottom: 20px;
}

.timer-bar-container {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  transition: width 0.1s linear;
  border-radius: 10px;
}

.timer-text {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--focus-primary);
}

/* 과제 안내 */
.task-instruction {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 20px;
  padding: 16px;
  background: #f3f4f6;
  border-radius: 12px;
}

/* 도형 표시 영역 */
.shape-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.shape-display {
  font-size: 150px;
  transition: all 0.2s;
  text-align: center;
  line-height: 1;
}

/* 애니메이션 */
.shape-display.correct-pulse {
  animation: correctPulse 0.3s ease-in-out;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); filter: brightness(1.3); }
  100% { transform: scale(1); }
}

.shape-display.wrong-shake {
  animation: wrongShake 0.4s ease-in-out;
}

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

.shape-display.timeout-fade {
  animation: timeoutFade 0.3s ease-out;
}

@keyframes timeoutFade {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.3; transform: scale(0.8); }
}

/* 점수 표시 */
.score-section {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  padding-top: 20px;
  border-top: 2px solid #e5e7eb;
}

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

.score-label {
  display: block;
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 6px;
}

.score-value {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--focus-primary);
}

/* ========================================
   모드 2: 가로 1줄 도형 레이아웃
   ======================================== */

#game-screen-mode2 {
  height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.shape-row-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: nowrap;
  padding: 40px 20px;
  min-height: 250px;
}

.shape-item {
  font-size: 120px;
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
  -webkit-user-select: none;
  padding: 20px;
  border-radius: 16px;
  border: 4px solid transparent;
  background: rgba(255, 255, 255, 0.1);
}

.shape-item:hover {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.2);
}

.shape-item.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
  transform: scale(1.1);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.shape-item.correct-flash {
  animation: correctFlash 0.5s ease-in-out;
}

@keyframes correctFlash {
  0%, 100% { background: rgba(16, 185, 129, 0.2); }
  50% { background: rgba(16, 185, 129, 0.6); transform: scale(1.2); }
}

.shape-item.wrong-flash {
  animation: wrongFlash 0.5s ease-in-out;
}

@keyframes wrongFlash {
  0%, 100% { background: rgba(239, 68, 68, 0.2); }
  50% { background: rgba(239, 68, 68, 0.6); }
}

/* 확인 버튼 */
.confirm-section {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.confirm-button {
  padding: 16px 48px;
  font-size: 20px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.confirm-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.confirm-button:active {
  transform: translateY(0);
}

.confirm-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   결과 화면
   ======================================== */

#result-screen {
  height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow-y: auto;
}

.result-container {
  text-align: center;
  width: 100%;
  max-width: 800px;
}

.result-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: resultBounce 0.6s ease-out;
}

@keyframes resultBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: 42px;
  font-weight: 800;
  color: #1f2937;
  margin-bottom: 12px;
}

.result-subtitle {
  font-size: 20px;
  color: #6b7280;
  margin-bottom: 40px;
}

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

.result-stat {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.result-stat-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 8px;
  display: block;
}

.result-stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--focus-primary);
}

.result-details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.result-detail-item {
  background: white;
  border: 2px solid #e5e7eb;
  padding: 16px;
  border-radius: 12px;
}

.detail-label {
  display: block;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}

.detail-value {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

.detail-value.correct {
  color: var(--focus-success);
}

.detail-value.omission {
  color: var(--focus-warning);
}

.detail-value.commission {
  color: var(--focus-danger);
}

.detail-value.timeout {
  color: #9ca3af;
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn {
  padding: 16px 40px;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: white;
  color: #4b5563;
  border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
  background: #f3f4f6;
  border-color: var(--focus-primary);
}

/* ========================================
   커스텀 모달
   ======================================== */

.training-custom-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  animation: modalFadeIn 0.2s ease-out;
}

.training-custom-modal.show {
  display: flex;
}

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

.training-modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.training-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 16px 16px 0 0;
}

.training-modal-icon {
  font-size: 28px;
}

.training-modal-title {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  color: white;
}

.training-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: white;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.training-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.training-modal-body {
  padding: 24px;
}

.training-modal-message {
  font-size: 16px;
  color: #374151;
  line-height: 1.6;
  margin-bottom: 0;
}

.training-modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 30px;
}

.training-modal-btn {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.training-modal-btn-single {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.training-modal-btn-single:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.training-modal-btn-cancel {
  background: #6b7280;
  color: white;
}

.training-modal-btn-cancel:hover {
  background: #4b5563;
  transform: translateY(-2px);
}

.training-modal-btn-confirm {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.training-modal-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.training-modal-btn:active {
  transform: translateY(0);
}

/* ========================================
   반응형 (800px 미만)
   ======================================== */

@media (max-width: 800px) {
  .focus-header {
    padding: 10px 20px;
  }
  
  .focus-title h1 {
    font-size: 18px;
  }
  
  .level-display-large {
    font-size: 20px;
    min-width: 120px;
  }
  
  .level-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  
  .level-card {
    padding: 24px 16px;
  }
  
  .level-number {
    width: 60px;
    height: 60px;
    font-size: 36px;
  }
  
  .level-name {
    font-size: 18px;
  }
  
  .level-info {
    font-size: 14px;
  }
  
  #game-screen {
    height: calc(100vh - 150px);
    min-height: 500px;
  }
  
  .shape-display {
    font-size: 120px;
  }
  
  .score-value {
    font-size: 24px;
  }
  
  .result-stats {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .result-details {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   반응형 (700px 미만)
   ======================================== */

@media (max-width: 700px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  #game-screen {
    height: calc(100vh - 120px);
    min-height: 400px;
  }
  
  .shape-display {
    font-size: 100px;
  }
  
  .task-instruction {
    font-size: 16px;
    padding: 12px;
  }
  
  .result-title {
    font-size: 32px;
  }
  
  .result-stat-value {
    font-size: 28px;
  }
}
