/* 기본 리셋 및 변수 */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-game: #1a1a2e;
  --text-primary: #e8e8e8;
  --text-secondary: #888;
  --accent: #4ecdc4;
  --accent-hover: #3dbdb5;
  --danger: #ff6b6b;
  --success: #51cf66;
  --gauge-bg: #2a2a3e;
  --gauge-fill: linear-gradient(90deg, #4ecdc4, #44a08d);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: auto;
}

/* 화면 전환 */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* 버튼 */
.btn-primary, .btn-secondary, .btn-back {
  padding: 14px 28px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--text-secondary);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

/* 시작 화면 */
#start-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 20px;
}

#start-screen h1 {
  font-size: 3rem;
  margin-bottom: 10px;
}

#start-screen .subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.how-to-play {
  background: var(--bg-secondary);
  padding: 15px 25px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.how-to-play p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 5px 0;
}

 .data-note {
   width: 100%;
   max-width: 720px;
   background: var(--bg-secondary);
   border: 1px solid #2a2a3e;
   border-radius: 14px;
   padding: 12px 14px;
 }

 .data-note summary {
   cursor: pointer;
   color: var(--text-primary);
   font-weight: 700;
 }

 .data-note-body {
   margin-top: 10px;
   color: var(--text-secondary);
   font-size: 0.92rem;
   line-height: 1.6;
 }

 .data-note-body ul {
   margin: 10px 0 0 18px;
 }

 .data-note-body li {
   margin: 6px 0;
 }

 .start-links {
   margin-top: 10px;
 }

 .easycome-link {
   display: inline-block;
   color: var(--text-secondary);
   text-decoration: none;
   border: 1px solid #2a2a3e;
   padding: 10px 14px;
   border-radius: 10px;
   background: var(--bg-secondary);
 }

 .easycome-link:hover {
   color: var(--text-primary);
   border-color: #3a3a52;
 }

 .ad-slot {
   width: 100%;
   max-width: 720px;
   margin-top: 18px;
   padding: 14px 16px;
   border-radius: 14px;
   background: var(--bg-secondary);
   border: 1px solid #2a2a3e;
   overflow-x: auto;
 }

 .ad-row {
   width: 100%;
   display: flex;
   justify-content: center;
 }

 .site-footer {
   width: 100%;
   padding: 18px 14px;
   border-top: 1px solid #2a2a3e;
   background: var(--bg-primary);
   text-align: center;
 }

 .footer-links {
   display: flex;
   flex-wrap: wrap;
   justify-content: center;
   gap: 10px;
   margin-bottom: 10px;
 }

 .footer-link {
   color: var(--text-secondary);
   text-decoration: none;
   border-bottom: 1px dashed #3a3a52;
   padding-bottom: 2px;
 }

 .footer-link:hover {
   color: var(--text-primary);
   border-bottom-color: var(--text-primary);
 }

 .footer-meta {
   color: var(--text-secondary);
   font-size: 0.85rem;
 }

 .ad-slot .ad-label {
   display: block;
   font-size: 0.75rem;
   color: var(--text-secondary);
   margin-bottom: 8px;
 }

 .ad-slot .ad-title {
   font-size: 0.95rem;
   font-weight: 700;
   margin-bottom: 10px;
 }

 .ad-slot .ad-links {
   display: flex;
   flex-wrap: wrap;
   gap: 10px;
   justify-content: center;
 }

 .ad-slot .ad-link {
   display: inline-flex;
   align-items: center;
   gap: 8px;
   padding: 10px 12px;
   border-radius: 12px;
   text-decoration: none;
   background: var(--bg-primary);
   border: 1px solid #2a2a3e;
   color: var(--text-primary);
   font-size: 0.9rem;
 }

 .ad-slot .ad-link:hover {
   border-color: #3a3a52;
 }

/* 게임 화면 */
#game-screen {
  padding: 15px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

 #game-canvas {
   touch-action: none;
 }

.game-layout {
  display: flex;
  gap: 20px;
  height: 100%;
}

.game-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

/* 게임 캔버스 */
.game-canvas-container {
  width: 100%;
  height: 100%;
  max-width: 600px;
  max-height: 600px;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-game);
  border-radius: 16px;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 우측 사이드바 */
.game-sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-shrink: 0;
}

.species-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}

#species-icon-large {
  font-size: 4rem;
  margin-bottom: 10px;
}

#species-name-large {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 5px 0;
}

#species-scientific {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  margin: 0;
}

.era-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
}

.era-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

#era-name {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 600;
}

#era-time {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 진화 게이지 */
.evolution-gauge {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 15px;
}

.gauge-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.gauge-bar {
  height: 12px;
  background: var(--gauge-bg);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 5px;
}

#gauge-fill {
  height: 100%;
  background: var(--gauge-fill);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 6px;
}

#gauge-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  display: block;
}

/* 진화 경로 미리보기 */
.path-preview {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 15px;
  flex: 1;
  overflow: hidden;
}

.path-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

#path-icons {
  font-size: 1.5rem;
  line-height: 2;
  word-break: break-all;
}

/* 게임 컨트롤 버튼 */
.game-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.btn-small {
  padding: 10px 15px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-small.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid #333;
}

.btn-small.btn-secondary:hover {
  background: #2a2a3e;
}

.btn-small.btn-warning {
  background: #3d3d00;
  color: #ffd700;
  border: 1px solid #555500;
}

.btn-small.btn-warning:hover:not(:disabled) {
  background: #4d4d00;
}

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

/* 모바일 컨트롤 */
.mobile-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 0;
  flex-shrink: 0;
}

.ctrl-row {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 60px;
  height: 60px;
  font-size: 1.6rem;
  background: var(--bg-secondary);
  border: 2px solid #333;
  border-radius: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  background: var(--accent);
  color: var(--bg-primary);
  transform: scale(0.95);
  border-color: var(--accent);
}

/* 데스크톱: 모바일 컨트롤 숨김 */
@media (min-width: 768px) and (hover: hover) {
  .mobile-controls {
    display: none;
  }
}

/* 모바일: 세로 레이아웃 */
@media (max-width: 767px) {
  .game-layout {
    flex-direction: column;
  }
  
  .game-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .species-card {
    flex: 1;
    min-width: 120px;
    padding: 15px;
  }
  
  #species-icon-large {
    font-size: 2.5rem;
    margin-bottom: 5px;
  }
  
  #species-name-large {
    font-size: 1rem;
  }
  
  .era-card {
    flex: 1;
    min-width: 100px;
    padding: 10px;
  }
  
  .evolution-gauge {
    width: 100%;
    order: -1;
  }
  
  .path-preview {
    display: none;
  }
  
  .game-controls {
    width: 100%;
    flex-direction: row;
    justify-content: center;
  }
  
  .game-controls .btn-small {
    flex: 1;
  }
}

/* 결과 화면 */
#result-screen {
  justify-content: center;
  align-items: center;
  gap: 30px;
}

.result-card {
  text-align: center;
  padding: 30px;
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 100%;
  max-width: 350px;
}

.result-icon {
  font-size: 6rem;
  margin-bottom: 15px;
}

#result-name {
  font-size: 1.8rem;
  margin-bottom: 5px;
}

#result-scientific {
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 15px;
}

.result-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.evolution-path {
  width: 100%;
  max-width: 350px;
}

.evolution-path h3 {
  text-align: center;
  margin-bottom: 15px;
  font-size: 1rem;
  color: var(--text-secondary);
}

.path-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.path-node {
  font-size: 1.5rem;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.path-arrow {
  color: var(--text-secondary);
  align-self: center;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

/* 컬렉션 화면 */
#collection-screen {
  gap: 20px;
}

.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collection-header h2 {
  font-size: 1.2rem;
}

#collection-count {
  color: var(--text-secondary);
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 12px;
}

.collection-item {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.collection-item:hover {
  transform: scale(1.05);
}

.collection-item.locked {
  opacity: 0.3;
  cursor: default;
}

.collection-item.locked:hover {
  transform: none;
}

.collection-actions {
  margin-top: 20px;
  text-align: center;
}

.collection-item .name {
  font-size: 0.6rem;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

/* 모달 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 16px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal-content h3 {
  margin-bottom: 15px;
}

.share-summary {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.share-url-box {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.share-url-box input {
  flex: 1;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.btn-small {
  padding: 12px 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-small:hover {
  background: var(--accent-hover);
}

.share-hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* 진화 애니메이션 오버레이 */
.evolution-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

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

.evolution-popup {
  text-align: center;
  animation: popIn 0.5s ease;
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.evolution-popup .evo-icon {
  font-size: 6rem;
  margin-bottom: 20px;
  animation: bounce 0.6s ease infinite;
}

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

.evolution-popup h2 {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.evolution-popup p {
  font-size: 1.2rem;
  margin-bottom: 5px;
}

.evolution-popup small {
  color: var(--text-secondary);
  font-style: italic;
}

/* 반응형 */
@media (min-width: 768px) {
  .game-canvas-container {
    max-width: 500px;
    max-height: 500px;
  }
}
