/* ===== 공통 스타일 ===== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
  --primary: #4A90D9;
  --primary-dark: #2E6BB0;
  --primary-light: #A8D0F5;
  --secondary: #F5A623;
  --secondary-dark: #D48B0C;
  --success: #7ED321;
  --danger: #D0021B;
  --warning: #F8E71C;
  --bg: #F7F9FC;
  --bg-card: #FFFFFF;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --border: #E1E8ED;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 헤더 ===== */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .back-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.app-header .back-btn:hover {
  background: rgba(255,255,255,0.3);
}

.app-header .title-area h1 {
  font-size: 18px;
  font-weight: 700;
}

.app-header .title-area .subtitle {
  font-size: 12px;
  opacity: 0.85;
}

/* ===== 탭 네비게이션 ===== */
.mode-tabs {
  display: flex;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.mode-tab {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  min-width: 100px;
}

.mode-tab:hover {
  color: var(--primary);
  background: rgba(74, 144, 217, 0.05);
}

.mode-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* ===== 메인 콘텐츠 ===== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== 카드 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ===== 버튼 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover { background: var(--secondary-dark); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

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

/* ===== 인스트럭션 패널 ===== */
.instruction-panel {
  background: linear-gradient(135deg, #EBF5FF 0%, #F0F7FF 100%);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.instruction-panel h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.instruction-panel p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}

/* ===== 피드백 메시지 ===== */
.feedback {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
  animation: fadeIn 0.3s ease;
}

.feedback-success {
  background: #E8F8E0;
  color: #2E7D32;
  border: 1px solid #C8E6C9;
}

.feedback-error {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #FFCDD2;
}

.feedback-hint {
  background: #FFF8E1;
  color: #F57F17;
  border: 1px solid #FFE082;
}

.feedback-info {
  background: #E3F2FD;
  color: #1565C0;
  border: 1px solid #BBDEFB;
}

/* ===== 캔버스 영역 ===== */
.canvas-container {
  position: relative;
  width: 100%;
  background: white;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  overflow: hidden;
}

.canvas-container canvas {
  display: block;
  width: 100%;
  cursor: grab;
}

.canvas-container canvas:active {
  cursor: grabbing;
}

/* ===== 툴바 ===== */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
  align-items: center;
}

.toolbar .divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
}

/* ===== 점수/진행 표시 ===== */
.score-display {
  display: flex;
  gap: 16px;
  align-items: center;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}

.score-item .label { color: var(--text-light); }
.score-item .value { color: var(--primary); font-weight: 700; }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== 애니메이션 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  .main-content { padding: 12px; }
  .card { padding: 16px; }
  .app-header h1 { font-size: 16px; }
  .toolbar { gap: 4px; padding: 8px; }
}

/* ===== 유틸리티 ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
