/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --bg-light: #F5F5F5;
  --circle-inner: #E8E8E8;
  --ring-yellow: #F4B942;
  --ring-black: #1A1A1A;
  --text-black: #1A1A1A;
  --accent-red: #E63946;
  
  /* Typography */
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --font-hand: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
  background: var(--bg-light);
  color: var(--text-black);
  font-family: var(--font-display);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

#app {
  width: 100%;
  height: 100vh;
}

.countdown-container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* 圆形计时器 */
.timer-circle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3rem;
  pointer-events: none; /* 容器不拦截事件 */
}

#timerCanvas {
  position: absolute;
  z-index: 1;
  pointer-events: none; /* canvas 不拦截点击事件 */
}

.time-display {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto; /* 时间显示区域可以点击 */
}

#timeText {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-black);
  letter-spacing: 0.05em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
  padding: 1rem 1.5rem; /* 增大点击区域 */
  border-radius: 8px;
  pointer-events: auto; /* 确保时间文字可以点击 */
  position: relative;
  z-index: 10; /* 提高层级 */
}

#timeText:hover {
  background: rgba(244, 185, 66, 0.15);
  transform: scale(1.05);
}

#timeText:active {
  transform: scale(1.02);
  background: rgba(244, 185, 66, 0.25);
}

#timeText:active {
  transform: scale(1.02);
}

/* 控制按钮 */
.controls {
  position: fixed;
  bottom: 3rem;
  display: flex;
  gap: 1rem;
  z-index: 10;
}

.btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

.btn-start {
  background: var(--ring-yellow);
  color: var(--text-black);
}

.btn-start:hover {
  background: #E5A832;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 185, 66, 0.4);
}

.btn-pause {
  background: #71717a;
  color: white;
}

.btn-pause:hover {
  background: #52525B;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(113, 113, 122, 0.4);
}

.btn-reset {
  background: var(--accent-red);
  color: white;
}

.btn-reset:hover {
  background: #D32F2F;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.4);
}

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

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

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  width: 320px;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content h3 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  color: var(--text-black);
}

.modal-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.modal-inputs input[type="number"] {
  width: 80px;
  padding: 0.75rem;
  font-size: 1.5rem;
  font-family: 'SF Mono', 'Consolas', monospace;
  text-align: center;
  border: 2px solid #D0D0D0;
  border-radius: 12px;
  background: white;
  color: var(--text-black);
  transition: all 0.3s ease;
}

.modal-inputs input[type="number"]:focus {
  outline: none;
  border-color: var(--ring-yellow);
  box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.2);
}

.separator {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-black);
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-cancel {
  background: #E8E8E8;
  color: var(--text-black);
  padding: 0.6rem 1.5rem;
}

.btn-cancel:hover {
  background: #D0D0D0;
}

.btn-confirm {
  background: var(--ring-yellow);
  color: var(--text-black);
  padding: 0.6rem 1.5rem;
}

.btn-confirm:hover {
  background: #E5A832;
  box-shadow: 0 4px 12px rgba(244, 185, 66, 0.4);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .timer-circle canvas {
    width: 300px !important;
    height: 300px !important;
  }
  
  #timeText {
    font-size: 3rem;
  }
  
  .controls {
    bottom: 2rem;
    gap: 0.8rem;
  }
  
  .btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
  }
  
  .modal-content {
    padding: 1.5rem;
  }
  
  .modal-inputs input[type="number"] {
    width: 70px;
    font-size: 1.3rem;
  }
}

/* 添加动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.countdown-container > * {
  animation: fadeIn 0.6s ease-out;
}

.timer-circle {
  animation: fadeIn 0.8s ease-out;
}

/* 时间数字切换动画 */
#timeText {
  transition: transform 0.2s ease;
}

#timeText.tick {
  transform: scale(1.05);
}

/* 主题按钮 */
.theme-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--text-black);
}

.theme-btn:hover {
  transform: rotate(45deg) scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 主题面板 */
.theme-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
  z-index: 998;
  overflow-y: auto;
  transition: right 0.3s ease;
}

.theme-panel.active {
  right: 0;
}

.theme-panel-header {
  position: sticky;
  top: 0;
  background: white;
  padding: 1.5rem;
  border-bottom: 1px solid #E8E8E8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
}

.theme-panel-header h3 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--text-black);
}

.close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 2rem;
  cursor: pointer;
  color: #71717a;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--text-black);
}

/* 主题部分 */
.theme-section {
  padding: 1.5rem;
  border-bottom: 1px solid #E8E8E8;
}

.theme-section h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-black);
}

/* 主题网格 */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 2px solid #E8E8E8;
  border-radius: 12px;
  background: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-option:hover {
  border-color: var(--ring-yellow);
  transform: translateY(-2px);
}

.theme-option.active {
  border-color: var(--ring-yellow);
  background: rgba(244, 185, 66, 0.1);
}

.theme-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid;
}

.custom-preview {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.custom-preview span {
  font-size: 1.5rem;
}

.theme-option span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-black);
}

/* 自定义颜色 */
.custom-section {
  background: #F9FAFB;
}

.color-inputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.color-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.color-input-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-black);
}

.color-input-group input[type="color"] {
  width: 100%;
  height: 48px;
  border: 2px solid #E8E8E8;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
}

.color-input-group input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-group input[type="color"]::-webkit-color-swatch {
  border-radius: 4px;
  border: none;
}

.custom-buttons {
  display: flex;
  gap: 0.75rem;
}

.btn-apply {
  flex: 1;
  background: var(--ring-yellow);
  color: var(--text-black);
}

.btn-reset-custom {
  flex: 1;
  background: #E8E8E8;
  color: var(--text-black);
}

/* 样式切换 */
.style-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.style-option {
  display: flex;
  align-items: center;
  padding: 1rem;
  border: 2px solid #E8E8E8;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.style-option:hover {
  border-color: var(--ring-yellow);
}

.style-option input[type="radio"] {
  margin-right: 1rem;
  cursor: pointer;
}

.style-option input[type="radio"]:checked + .style-label {
  color: var(--ring-yellow);
}

.style-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  color: var(--text-black);
}

.style-icon {
  font-size: 1.5rem;
}

/* 数字时钟样式 */
.digital-display {
  display: none;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 8rem;
  font-weight: 700;
  color: var(--text-black);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  letter-spacing: 0.05em;
}

.digital-display.active {
  display: block;
}

.timer-circle.digital-style {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 3rem 4rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.timer-circle.digital-style canvas {
  display: none;
}

.timer-circle.digital-style .time-display {
  display: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .theme-panel {
    width: 100vw;
    right: -100vw;
  }
  
  .theme-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
  
  .theme-preview {
    width: 40px;
    height: 40px;
  }
  
  .preview-ring {
    width: 30px;
    height: 30px;
  }
  
  .theme-option span {
    font-size: 0.7rem;
  }
  
  .color-inputs {
    grid-template-columns: 1fr;
  }
  
  .digital-display {
    font-size: 5rem;
  }
}

/* 仪表盘样式 */
.timer-gauge {
  position: relative;
  width: 400px;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-gauge canvas {
  pointer-events: none;
}

.gauge-time-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin-top: 40px;
}

.gauge-time-display span {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-black);
  cursor: pointer;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.gauge-time-display span:hover {
  background: rgba(244, 185, 66, 0.2);
  transform: scale(1.05);
}

/* 卡片式样式 */
.timer-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.card-container {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.time-card {
  background: white;
  border-radius: 16px;
  padding: 1.25rem 1.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  transition: transform 0.3s ease;
}

.time-card:hover {
  transform: translateY(-4px);
}

.card-value {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-black);
  line-height: 1;
}

.card-label {
  font-size: 0.875rem;
  color: #999;
  margin-top: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.card-separator {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-black);
  opacity: 0.5;
}

/* 极简进度条样式 */
.timer-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  width: 100%;
  max-width: 600px;
}

.progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.progress-bar {
  width: 100%;
  height: 40px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ring-yellow) 0%, #FFD54F 100%);
  border-radius: 20px;
  transition: width 0.3s ease;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-time {
  text-align: center;
}

.progress-time span {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 5rem;
  font-weight: 700;
  color: var(--text-black);
  cursor: pointer;
  padding: 1rem 2rem;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.progress-time span:hover {
  background: rgba(244, 185, 66, 0.2);
  transform: scale(1.05);
}

/* 沙漏样式 */
.timer-hourglass {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.hourglass-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.hourglass {
  width: 150px;
  height: 250px;
  position: relative;
}

.hourglass-top,
.hourglass-bottom {
  position: absolute;
  width: 100%;
  height: 50%;
  overflow: hidden;
}

.hourglass-top {
  top: 0;
  clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
  border: 3px solid var(--text-black);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
}

.hourglass-bottom {
  bottom: 0;
  clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0.1) 100%);
  border: 3px solid var(--text-black);
  border-top: none;
  border-radius: 0 0 10px 10px;
}

.hourglass-sand-top {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(180deg, var(--ring-yellow) 0%, #FFD54F 100%);
  transition: height 0.5s ease;
}

.hourglass-sand-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #FFD54F 0%, var(--ring-yellow) 100%);
  transition: height 0.5s ease;
}

.hourglass-time {
  text-align: center;
}

.hourglass-time span {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-black);
  cursor: pointer;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.hourglass-time span:hover {
  background: rgba(244, 185, 66, 0.2);
  transform: scale(1.05);
}

/* 移动端适配 - 新样式 */
@media (max-width: 768px) {
  .flip-card {
    width: 80px;
    height: 110px;
  }
  
  .flip-card-inner {
    font-size: 3rem;
  }
  
  .flip-separator {
    font-size: 3rem;
  }
  
  .gauge-time-display span {
    font-size: 2rem;
  }
  
  .time-card {
    padding: 1rem 1.25rem;
    min-width: 70px;
  }
  
  .card-value {
    font-size: 2.5rem;
  }
  
  .card-label {
    font-size: 0.75rem;
  }
  
  .card-separator {
    font-size: 2.5rem;
  }
  
  .progress-bar {
    height: 30px;
  }
  
  .progress-time span {
    font-size: 3rem;
  }
  
  .hourglass {
    width: 100px;
    height: 180px;
  }
  
  .hourglass-time span {
    font-size: 3rem;
  }
}
