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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #faf8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* 导航栏 */
.nav-bar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #667eea;
  border-radius: 50px;
  text-decoration: none;
  color: #667eea;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.nav-link:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nav-icon {
  font-size: 16px;
}

.nav-text {
  white-space: nowrap;
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 20px;
  display: flex;
  gap: 40px;
}

/* ===== 响应式布局 ===== */

/* 桌面（默认横向布局）*/
@media (min-width: 1024px) {
  .container {
    flex-direction: row;
    gap: 60px;
    padding: 40px;
  }

  .timer-circle {
    width: min(50vmin, 500px);
    height: min(50vmin, 500px);
  }
}

/* 平板横屏 - 保持横向布局 */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  .container {
    flex-direction: row;
    gap: 40px;
    padding: 20px 40px;
  }

  .timer-section {
    flex: 1;
  }

  .controls-section {
    flex: 1;
  }

  .timer-circle {
    width: min(50vh, 400px);
    height: min(50vh, 400px);
  }

  .nav-link {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* 平板竖屏 - 垂直布局，时钟放大 */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: portrait) {
  .container {
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 80px 40px 40px;
  }

  .timer-circle {
    width: min(65vw, 500px);
    height: min(65vw, 500px);
  }

  .controls-section {
    width: 100%;
    max-width: 600px;
  }
}

/* 手机横屏 - 横向布局，紧凑型 */
@media (max-width: 767px) and (orientation: landscape) {
  .container {
    flex-direction: row;
    gap: 20px;
    padding: 10px 20px;
  }

  .timer-section {
    flex: 0 0 auto;
  }

  .controls-section {
    flex: 1;
    gap: 15px;
  }

  .timer-circle {
    width: min(45vh, 280px);
    height: min(45vh, 280px);
  }

  .button-group {
    gap: 10px;
  }

  .time-btn,
  .interrupt-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .nav-bar {
    top: 10px;
    right: 10px;
  }

  .nav-link {
    padding: 6px 12px;
    font-size: 12px;
  }

  .nav-icon {
    font-size: 14px;
  }

  .task-input-area {
    padding: 0 10px;
  }

  .flag-area {
    min-height: 60px;
    padding: 10px;
  }

  .flag {
    font-size: 40px;
  }
}

/* 手机竖屏 - 垂直布局，时钟最大化 */
@media (max-width: 599px) and (orientation: portrait) {
  .container {
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 80px 20px 20px;
  }

  .timer-circle {
    width: min(80vw, 400px);
    height: min(80vw, 400px);
  }

  .controls-section {
    width: 100%;
    gap: 20px;
  }

  .task-input-area {
    padding: 0 10px;
  }

  .button-group {
    gap: 12px;
  }

  .time-btn,
  .interrupt-btn {
    padding: 12px 24px;
    font-size: 16px;
  }

  .nav-link {
    padding: 8px 16px;
    font-size: 13px;
  }

  .flag {
    font-size: 50px;
  }
}

/* 极小屏幕优化 */
@media (max-width: 360px) {
  .timer-circle {
    width: min(75vw, 280px);
    height: min(75vw, 280px);
  }

  .time-btn,
  .interrupt-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .nav-text {
    display: none;
  }
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: #fff;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content h2 {
  margin-bottom: 20px;
  color: #c41e3a;
  text-align: center;
  font-size: 24px;
}

.modal-task-input {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border: 2px solid #c41e3a;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 20px;
  outline: none;
  transition: box-shadow 0.3s ease;
}

.modal-task-input:focus {
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.2);
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-btn.cancel {
  background-color: #f0f0f0;
  color: #333;
}

.modal-btn.cancel:hover {
  background-color: #e0e0e0;
}

.modal-btn.confirm {
  background-color: #c41e3a;
  color: #fff;
}

.modal-btn.confirm:hover {
  background-color: #a01830;
  transform: translateY(-2px);
}

.timer-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-width: 300px;
}

.timer-circle {
  position: relative;
  width: min(70vmin, 500px);
  height: min(70vmin, 500px);
}

.timer-circle svg {
  width: 100%;
  height: 100%;
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(32px, 10vmin, 72px);
  font-weight: bold;
  color: #c41e3a;
  transition: color 0.3s ease;
}

.phase-display {
  font-size: 14px;
  color: #c41e3a;
  font-weight: 500;
  text-align: center;
  min-height: 20px;
  opacity: 0.8;
}

#time-display.timer-red {
  color: #c41e3a !important;
}

#time-display.timer-green {
  color: #228b22 !important;
}

#time-display.timer-yellow {
  color: #daa520 !important;
}

#progress-ring.timer-green {
  stroke: #228b22;
}

#progress-ring.timer-yellow {
  stroke: #daa520;
}

.controls-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 25px;
  min-width: 300px;
}

.task-input-area {
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
  position: relative;
}

.task-display {
  display: block;
  width: 100%;
  padding: 15px 20px;
  font-size: 20px;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 8px;
  background-color: rgba(196, 30, 58, 0.05);
  color: #333;
  text-align: center;
  word-wrap: break-word;
  white-space: normal;
  line-height: 1.5;
  cursor: text;
  min-height: 50px;
}

.task-input {
  width: 100%;
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 500;
  border: 2px solid #c41e3a;
  border-radius: 8px;
  background-color: #fff;
  color: #333;
  outline: none;
  transition: all 0.3s ease;
  text-align: center;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  min-height: 50px;
}

.task-input:focus {
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.2);
}

.task-input-area.editing .task-display {
  display: none;
}

.task-input-area:not(.editing) .task-input {
  display: none;
}

.button-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.time-btn {
  padding: 15px 30px;
  font-size: 18px;
  font-weight: bold;
  border: 3px solid #c41e3a;
  background-color: #fff;
  color: #c41e3a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.time-btn:hover {
  background-color: #c41e3a;
  color: #fff;
  transform: translateY(-2px);
}

.interrupt-btn {
  padding: 15px 30px;
  font-size: 18px;
  font-weight: bold;
  border: 3px solid #c41e3a;
  background-color: #fff;
  color: #c41e3a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.interrupt-btn:hover {
  background-color: #c41e3a;
  color: #fff;
  transform: translateY(-2px);
}

.flag-area {
  min-height: 80px;
  width: 100%;
  max-width: 500px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 20px;
  background-color: rgba(196, 30, 58, 0.05);
  border-radius: 8px;
}

.flag {
  font-size: 60px;
  animation: flagIn 0.3s ease;
  margin: 0 5px;
  display: inline-block;
  flex-shrink: 0;
}

.flag-yellow {
  filter: sepia(1) saturate(5) hue-rotate(20deg);
}

.flag-red {
  filter: none;
}

@keyframes flagIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
