/* ====================
   Reset & Base Styles
   ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  margin: 0;
  padding: 15px 15px 20px;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: "Arial", sans-serif;
}

/* ====================
   Layout Components
   ==================== */
.header {
  text-align: center;
  margin-bottom: 10px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wake-lock-indicator {
  display: flex;
  align-items: center;
}

.wake-lock-status-indicator {
  font-size: 10px;
  color: #999;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.wake-lock-status-indicator.active {
  color: #4caf50;
  border-color: rgba(76, 175, 80, 0.3);
  background: rgba(76, 175, 80, 0.1);
}

.lang-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  font-weight: bold;
  min-width: 40px;
  margin-left: 10px;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

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

.main-content {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 15px 0;
}

/* ====================
   Typography
   ==================== */
.title {
  font-size: 20px;
  color: #fff;
  font-weight: bold;
}

.clickable-title {
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}

.clickable-title:hover {
  color: #4facfe;
  transform: scale(1.02);
}

.clickable-title:active {
  transform: scale(0.98);
}

.instructions {
  color: #ccc;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  margin-bottom: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.wake-lock-info {
  color: #ffeb3b;
  font-size: 11px;
  background: rgba(255, 235, 59, 0.1);
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 235, 59, 0.3);
  display: none;
}

.wake-lock-info.show {
  display: block;
}

/* ====================
   Wake Lock Dialog
   ==================== */
.wake-lock-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wake-lock-dialog.show {
  opacity: 1;
  visibility: visible;
}

.dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.dialog-content {
  position: relative;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}

.dialog-header h3 {
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  margin: 0 0 16px 0;
  text-align: center;
}

.dialog-body p {
  color: #ccc;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 24px 0;
  text-align: center;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.dialog-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  min-width: 100px;
}

.dialog-btn.primary {
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  color: #fff;
}

.dialog-btn.primary:hover {
  background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);
  transform: translateY(-1px);
}

.dialog-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dialog-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.refresh-btn {
  background: rgba(255, 235, 59, 0.2);
  border: 1px solid rgba(255, 235, 59, 0.5);
  color: #ffeb3b;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
  margin-left: 8px;
  display: inline-block;
}

.refresh-btn:hover {
  background: rgba(255, 235, 59, 0.3);
  border-color: rgba(255, 235, 59, 0.7);
  transform: translateY(-1px);
}

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

/* ====================
   WebGL Container
   ==================== */
#webgl-container {
  width: 280px;
  height: 280px;
  border: 2px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background: #fff;
  position: relative;
}

/* ====================
   Controls
   ==================== */
.controls-progress {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.progress-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 150px;
}

.control-section {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

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

.control-label {
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 45px;
  text-align: left;
}

.radio-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 4px 8px;
  transition: all 0.3s ease;
  font-size: 11px;
}

.radio-option:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.radio-option input[type="radio"] {
  margin: 0 6px 0 0;
  accent-color: #4facfe;
}

.radio-option input[type="radio"]:checked + .radio-text {
  color: #4facfe;
  font-weight: bold;
}

.radio-text {
  color: #fff;
  font-size: 12px;
}

.select-container {
  position: relative;
}

select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
}

select:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

select:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: #4facfe;
  box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.2);
}

option {
  background: #333;
  color: #fff;
}

/* ====================
   Progress Bar
   ==================== */

.progress-bar {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  min-width: 120px;
  flex: 1;
}

.progress-zones {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.activity-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(76, 172, 254, 0.3);
  border: 1px solid rgba(76, 172, 254, 0.6);
}

.time-marker {
  position: absolute;
  top: -18px;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  transform: translateX(-50%);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 7px;
  width: 0%;
  transition: width 0.1s ease;
  position: relative;
  z-index: 2;
}

.progress-fill.active {
  background: linear-gradient(90deg, #00ff88 0%, #00cc66 100%);
  animation: progressGlowActive 2s ease-in-out infinite;
}

.progress-fill.waiting {
  background: linear-gradient(90deg, #888888 0%, #666666 100%);
  animation: progressGlowWaiting 2s ease-in-out infinite;
}

#progressTime {
  font-size: 11px;
  color: #ccc;
  min-width: 30px;
  text-align: right;
  white-space: nowrap;
}


/* ====================
   Animations
   ==================== */
@keyframes progressGlowActive {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.5);
  }
  50% {
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
  }
}

@keyframes progressGlowWaiting {
  0%, 100% {
    box-shadow: 0 0 5px rgba(136, 136, 136, 0.5);
  }
  50% {
    box-shadow: 0 0 15px rgba(136, 136, 136, 0.8);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ====================
   AdSense 광고 영역
   ==================== */
.ad-container {
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ad-top {
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 15px;
}

.ad-bottom {
  margin-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
}

/* 광고 로딩 중 플레이스홀더 */
.adsbygoogle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.adsbygoogle:empty::before {
  content: "Advertisement";
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-family: Arial, sans-serif;
}

/* ====================
   Footer
   ==================== */
.footer {
  margin-top: 30px;
  padding: 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

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

.footer-links a {
  color: #ccc;
  text-decoration: none;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 3px;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.footer-links a:hover {
  color: #4facfe;
  background: rgba(79, 172, 254, 0.1);
  border-color: rgba(79, 172, 254, 0.3);
}

.footer-copyright {
  color: #999;
  font-size: 10px;
  margin-top: 10px;
}

/* ====================
   Responsive Design
   ==================== */
@media screen and (max-width: 768px) {
  body {
    padding: 10px 10px 10px;
    padding-top: 5px;
    justify-content: flex-start;
  }
  
  .header {
    margin-top: 20px;
    margin-bottom: 10px;
  }
  
  .main-content {
    margin: 10px 0;
  }
  
  .progress-container {
    margin: 10px auto 0;
  }
}

@media screen and (max-width: 390px) {
  body {
    padding: 8px 8px 8px;
    padding-top: 5px;
  }

  .title {
    font-size: 16px;
  }

  .instructions {
    font-size: 11px;
    padding: 6px 10px;
  }

  #webgl-container {
    width: 250px;
    height: 250px;
  }

  .progress-container {
    max-width: 250px;
    margin: 10px auto 0;
  }
  
  .progress-row {
    gap: 6px;
    font-size: 11px;
  }
  
  .status-indicator {
    font-size: 10px;
    min-width: 70px;
    gap: 4px;
  }
  
  #progressTime {
    font-size: 10px;
    min-width: 25px;
  }
  
  .header {
    margin-top: 10px;
    margin-bottom: 5px;
  }
  
  .header-top {
    margin-bottom: 8px;
  }
  
  .instructions {
    margin-bottom: 8px;
  }
  
  .wake-lock-info {
    margin-bottom: 6px;
  }
  
  .controls-progress {
    gap: 8px;
    margin-bottom: 8px;
  }
  
  .progress-section {
    gap: 6px;
    min-width: 100px;
  }
  
  .progress-bar {
    min-width: 80px;
  }
  
  #progressTime {
    font-size: 10px;
    min-width: 25px;
  }
  
  .footer-links {
    gap: 15px;
  }
  
  .footer-links a {
    font-size: 11px;
    padding: 4px 8px;
  }
  
  .header-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  
  .header-controls {
    gap: 6px;
  }
  
  .wake-lock-status-indicator {
    font-size: 9px;
    padding: 2px 4px;
  }
  
  .lang-btn {
    font-size: 11px;
    padding: 5px 10px;
    min-width: 35px;
  }
  
  /* 모바일 컨트롤 조정 */
  .control-row {
    gap: 12px;
  }
  
  .control-section {
    gap: 4px;
    flex-direction: row;
  }
  
  .control-label {
    font-size: 10px;
    min-width: 35px;
  }
  
  select {
    padding: 2px 4px;
    font-size: 11px;
    min-width: 40px;
  }
  
  /* 모바일 광고 조정 */
  .ad-container {
    max-width: 320px;
    padding: 8px 0;
  }
  
  .ad-top {
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
  
  .ad-bottom {
    margin-top: 15px;
    padding-top: 15px;
  }
  
  .adsbygoogle {
    min-height: 50px;
  }
}

/* ====================
   Black Screen Overlay
   ==================== */
.black-screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  border-radius: 6px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  pointer-events: none;
}

.black-screen-overlay.active {
  opacity: 1;
  visibility: visible;
}