/* ============================================
   COLOR SORT - WordPress Ready Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #0F172A;
  color: #ffffff;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Utility Classes --- */
.hidden { display: none !important; }

/* --- Background Atmosphere --- */
.bg-atmosphere {
  position: fixed; /* 화면에 고정 */
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -1; /* 모든 요소보다 뒤로 */
  
  /* 배경 이미지 적용: 어두운 그라데이션을 겹쳐서 액체 색상이 잘 보이게 함 */
  background-image: 
    linear-gradient(rgba(15, 23, 42, 0.75), rgba(15, 23, 42, 0.85)), 
    url('https://zsz.kr/g/brain-tube-game/tube.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg-glow {
  position: absolute;
  border-radius: 9999px;
  filter: blur(120px);
  opacity: 0.4; /* 이미지가 있으므로 광원은 조금 더 투명하게 조정 */
}

.bg-glow-emerald {
  top: 25%;
  left: -80px;
  width: 384px;
  height: 384px;
  background-color: rgba(16, 185, 129, 0.1);
}

.bg-glow-blue {
  bottom: 25%;
  right: -80px;
  width: 384px;
  height: 384px;
  background-color: rgba(59, 130, 246, 0.1);
}

/* ============================================
   MENU SCREEN
   ============================================ */
#menu-screen {
  min-height: 100vh;           /* 화면 전체 높이 차지 */
  display: flex;               /* 플렉스 박스 활성화 */
  flex-direction: column;      /* 요소를 세로로 배치 */
  align-items: center;         /* 가로 중앙 정렬 */
  justify-content: center;     /* 세로 중앙 정렬 */
  padding: 24px;
  position: relative;
  background: transparent;     /* 배경 이미지 보이도록 투명 설정 */
  z-index: 10;
}

.menu-content {
  text-align: center;
  max-width: 400px;
  width: 100%;
  z-index: 10;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-title {
  font-size: 3.75rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  font-style: italic;
  background: linear-gradient(to bottom right, #34D399, #3B82F6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .menu-title {
    font-size: 2.75rem;    /* 기존 3.75rem에서 모바일에 맞춰 축소 */
    line-height: 1.2;      /* 줄 간격 살짝 조정 */
    margin-bottom: 4px;    /* 하단 여백 축소 */
  }
}

/* --- 아주 작은 스마트폰 (480px 이하) 추가 조정 --- */
@media (max-width: 480px) {
  .menu-title {
    font-size: 1.85rem;    /* 더 작은 화면에서 한 줄에 잘 보이도록 추가 축소 */
  }
}

.menu-subtitle {
  color: #94A3B8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  margin-bottom: 32px;
}

.start-btn {
  position: relative;
  overflow: hidden;
  background-color: #10B981;
  color: #0F172A;
  font-weight: 700;
  font-size: 1.25rem;
  padding: 16px 32px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  transition: background-color 0.3s;
}

.start-btn:hover {
  background-color: #34D399;
}

.start-btn .btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.start-btn:hover .btn-shine {
  transform: translateX(100%);
}

.start-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.menu-divider {
  padding-top: 32px;
  margin-top: 32px;
  border-top: 1px solid #1E293B;
}

.menu-quote {
  color: #64748B;
  font-size: 0.875rem;
  font-style: italic;
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Header --- */
.game-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-info {
  display: flex;
  flex-direction: column;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-label.level { color: #34D399; }
.stat-label.score { color: #60A5FA; }
.stat-label.timer { color: #FBBF24; display: flex; align-items: center; gap: 4px; }
.stat-label.timer.danger { color: #EF4444; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.stat-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #334155;
}

.moves-display {
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  padding: 12px;
  background-color: #1E293B;
  border: none;
  border-radius: 16px;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background-color: #334155;
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Main Game Area --- */
.game-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
}

.tubes-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr); 
  gap: 20px 10px; /* 세로 간격 20px, 가로 간격 10px */
  max-width: 100%;
  margin: 0 auto;
  justify-items: center;
  padding: 10px;
}

/* 380px 이상의 일반적인 모바일 화면에서 가로 5개 배치 */
@media (min-width: 380px) {
  .tubes-container {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 640px) {
  .tubes-container { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) {
  .tubes-container {
    grid-template-columns: repeat(6, 1fr);
    gap: 32px 24px;
  }
}

@media (min-width: 1024px) {
  .tubes-container { grid-template-columns: repeat(6, 1fr); }
}

/* --- Test Tube --- */
.test-tube {
  position: relative;
  width: 48px;      /* 모바일용 너비 축소 */
  height: 160px;     /* 모바일용 높이 축소 */
  border-radius: 0 0 20px 20px;
  border: 2px solid rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  overflow: hidden;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateY(0);
}

@media (min-width: 768px) {
  .test-tube {
    width: 64px;
    height: 224px;
  }
}

@media (min-width: 640px) {
  .test-tube {
    width: 64px;
    height: 224px;
  }
}

.test-tube:hover {
  transform: scale(1.05);
}

.test-tube:active {
  transform: scale(0.95);
}

.test-tube.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.3);
  /* 모바일에서 너무 많이 올라가면 상단 UI와 겹치므로 높이 축소 */
  transform: translateY(-25px) scale(1.05); 
}

@media (min-width: 768px) {
  .test-tube.selected {
    transform: translateY(-50px) scale(1.05);
  }
}

.test-tube.targetable {
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.5);
}

.tube-highlight {
  position: absolute;
  top: 0;
  left: 8px;
  width: 4px;
  height: 100%;
  background: rgba(255,255,255,0.1);
  border-radius: 9999px;
}

.tube-empty-indicator {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.1;
}

.tube-empty-line {
  width: 4px;
  height: 50%;
  background: #ffffff;
  border-radius: 9999px;
}

/* --- Liquid Unit --- */
.liquid-unit {
  width: 100%;
  height: 25%;
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,0.2);
}

/* 액체가 차오르는 느낌을 주고 싶다면, 나타날 때만 살짝 번쩍이게 변경 (투명도/크기 조절 제거) */
@keyframes liquidAppear {
  from {
    filter: brightness(1.5);
  }
  to {
    filter: brightness(1);
  }
}

.liquid-bubble-1 {
  position: absolute;
  bottom: 4px;
  left: 8px;
  width: 4px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: bounce 2s infinite;
}

.liquid-bubble-2 {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 6px;
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* --- Footer --- */
.game-footer {
  padding: 24px;
  text-align: center;
}

.game-footer p {
  color: #64748B;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

/* ============================================
   MODAL OVERLAY (Win / Game Over)
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background-color: #0F172A;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 32px;
  border-radius: 2.5rem;
  max-width: 384px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.6);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
}

.modal-icon.win {
  background-color: rgba(16, 185, 129, 0.2);
  color: #34D399;
}

.modal-icon.lose {
  background-color: rgba(239, 68, 68, 0.2);
  color: #EF4444;
}

.modal-icon svg {
  width: 40px;
  height: 40px;
}

.modal-title {
  font-size: 1.875rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.modal-subtitle {
  color: #94A3B8;
  margin-bottom: 32px;
}

.score-box {
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid rgba(255,255,255,0.05);
}

.score-label {
  font-size: 0.75rem;
  color: #64748B;
  text-transform: uppercase;
  font-weight: 900;
  margin-bottom: 4px;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 900;
  color: #34D399;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  background-color: #10B981;
  color: #0F172A;
  font-weight: 900;
  padding: 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  font-size: 1rem;
}

.btn-primary:hover {
  background-color: #34D399;
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-primary svg {
  width: 20px;
  height: 20px;
}

.btn-secondary {
  width: 100%;
  background-color: #1E293B;
  color: #ffffff;
  font-weight: 700;
  padding: 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.btn-secondary:hover {
  background-color: #334155;
}

/* Ranking Table Styles */
.rank-table {
  width: 100%;
  border-collapse: collapse;
  color: #E2E8F0;
  font-size: 0.9rem;
}
.rank-table th {
  padding: 10px;
  border-bottom: 2px solid #334155;
  color: #94A3B8;
  text-transform: uppercase;
  font-size: 0.7rem;
}
.rank-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #1E293B;
}
.rank-row-1 { color: #FBBF24; font-weight: bold; background: rgba(251, 191, 36, 0.05); }
.rank-row-2 { color: #94A3B8; }
.rank-row-3 { color: #CD7F32; }