:root {
  --accent: #e63946;
  --accent-glow: rgba(230, 57, 70, .55);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: radial-gradient(ellipse at 50% 115%, #2b1c10 0%, #15100b 55%, #090705 100%);
  padding: 20px;
}

/* ============ 3D 动态背景 ============ */
.scene3d {
  position: fixed;
  inset: 0;
  z-index: 0;
  perspective: 1000px;
  perspective-origin: 50% 38%;
  overflow: hidden;
  pointer-events: none;
}

.room {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  animation: room-tilt 46s ease-in-out infinite alternate;
}

@keyframes room-tilt {
  from { transform: rotateX(9deg) rotateZ(-7deg); }
  to   { transform: rotateX(-7deg) rotateZ(9deg); }
}

.floor {
  position: absolute;
  left: -60vmax;
  top: -60vmax;
  width: 120vmax;
  height: 120vmax;
  transform: rotateX(90deg) translateZ(24vmin);
  background:
    radial-gradient(circle, transparent 0 30%, rgba(9, 7, 5, .9) 72%, #090705 92%),
    repeating-linear-gradient(0deg, rgba(255, 190, 120, .1) 0 2px, transparent 2px 9vmin),
    repeating-linear-gradient(90deg, rgba(255, 190, 120, .1) 0 2px, transparent 2px 9vmin),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3vmin),
    linear-gradient(180deg, #5a3a22, #2b1c10);
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
/* ============ 主面板（木桌风格） ============ */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 470px;
  text-align: center;
  padding: 32px 30px 26px;
  border-radius: 28px;
  border: 1px solid rgba(0, 0, 0, .45);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .28)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .1) 0 3px, transparent 3px 16px),
    linear-gradient(180deg, #7a4a28 0%, #5d3620 48%, #452715 100%);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, .65),
    inset 0 2px 2px rgba(255, 220, 170, .35),
    inset 0 -5px 12px rgba(0, 0, 0, .55);
}

.title {
  font-size: 1.55rem;
  margin-bottom: 18px;
  letter-spacing: 2px;
  color: #ffe9c9;
  text-shadow: 0 2px 5px rgba(0, 0, 0, .6);
}

.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}

.tab {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .9rem;
  color: #ffdcae;
  background: linear-gradient(180deg, #6f4223, #4a2c17);
  box-shadow: inset 0 1px 1px rgba(255, 225, 180, .25), 0 2px 4px rgba(0, 0, 0, .35);
  opacity: .85;
  transition: opacity .2s, box-shadow .2s, background .2s;
}

.tab:hover { opacity: 1; }

.tab.active {
  opacity: 1;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(180deg, #8a5a2f, #63391f);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5), 0 0 0 2px rgba(255, 210, 150, .3);
}

/* ============ 高仿真木制时钟 ============ */
.clock {
  width: min(330px, 78vw);
  margin: 0 auto 26px;
}

.clock-frame {
  position: relative;
  aspect-ratio: 1;
  padding: 24px;
  border-radius: 50%;
  background:
    repeating-conic-gradient(rgba(0, 0, 0, .16) 0deg 5deg, transparent 5deg 11deg),
    radial-gradient(circle at 32% 28%, #bd8852 0%, #8a5a2f 38%, #5d3620 68%, #3a2211 100%);
  box-shadow:
    0 24px 45px rgba(0, 0, 0, .6),
    0 0 0 6px rgba(28, 17, 9, .7),
    inset 0 3px 6px rgba(255, 225, 180, .4),
    inset 0 -7px 14px rgba(0, 0, 0, .6);
}

/* 计时运行时外圈呼吸光晕（颜色随模式变化） */
.clock-frame::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 55px 10px var(--accent-glow);
}

.app.running .clock-frame::after {
  opacity: 1;
  animation: glow-pulse 2.4s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { opacity: .35; }
  50% { opacity: .9; }
}

/* 四角金属螺丝 */
.screw {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  z-index: 3;
  background: radial-gradient(circle at 35% 30%, #f2e0c0, #9c7346 48%, #43280f 92%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .6), 0 1px 2px rgba(0, 0, 0, .6);
}

.screw::after {
  content: "";
  position: absolute;
  left: 18%;
  top: 47%;
  width: 64%;
  height: 2px;
  border-radius: 2px;
  background: rgba(28, 14, 4, .85);
  transform: rotate(var(--ang, 20deg));
}

.s1 { top: 10px; left: 10px; --ang: 24deg; }
.s2 { top: 10px; right: 10px; --ang: -40deg; }
.s3 { bottom: 10px; left: 10px; --ang: 72deg; }
.s4 { bottom: 10px; right: 10px; --ang: -12deg; }

/* 表盘：木纹 + 内阴影 */
.clock-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(38, 21, 9, .75);
  overflow: hidden;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 235, 205, .05) 0 2px, transparent 2px 9px),
    repeating-conic-gradient(rgba(58, 30, 12, .22) 0deg 2.5deg, transparent 2.5deg 8deg),
    radial-gradient(circle at 50% 42%, #cfa771 0%, #a87a45 46%, #7c5229 78%, #5b3a1c 100%);
  box-shadow: inset 0 7px 20px rgba(0, 0, 0, .55), inset 0 -4px 10px rgba(255, 220, 170, .14);
}
/* 刻度 / 数字（由 JS 生成） */
.tick { position: absolute; inset: 0; }

.tick::before {
  content: "";
  position: absolute;
  left: calc(50% - 1.5px);
  top: 3.5%;
  width: 3px;
  height: 6.5%;
  border-radius: 2px;
  background: rgba(43, 24, 12, .85);
}

.tick.major::before {
  left: calc(50% - 3px);
  top: 2.5%;
  width: 6px;
  height: 9.5%;
  background: #2b180c;
  box-shadow: 0 0 2px rgba(0, 0, 0, .4);
}

.num {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: .95rem;
  font-weight: 800;
  color: #33200f;
  text-shadow: 0 1px 0 rgba(255, 225, 180, .4);
}

/* 指针 */
.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  transition: none; /* 指针由 requestAnimationFrame 逐帧驱动，禁用过渡以免拖尾/滞后 */
  z-index: 2;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
}

.hand-hour {
  width: 11px;
  height: 26%;
  margin-left: -5.5px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a2211, #5d3620);
}

.hand-minute {
  width: 7px;
  height: 37%;
  margin-left: -3.5px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2b180c, #4a2d15);
}

.center-cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  z-index: 3;
  background: radial-gradient(circle at 35% 30%, #f2d9ad, #8a5a2f 58%, #3a2211);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .65);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s, filter .2s, box-shadow .3s, background .3s;
}

/* 彩蛋：圆心小球 = 音乐开关。按下（播放中）高亮下陷，按起（停止）低亮复位 */
.center-cap:hover { filter: brightness(1.3); }
.center-cap.lit {
  transform: translateY(3px); /* 按下下陷 */
  background: radial-gradient(circle at 35% 30%, #fff4dd, var(--accent) 55%, #2b180c);
  box-shadow: 0 0 24px 7px var(--accent-glow), inset 0 3px 6px rgba(0, 0, 0, .55);
}

.dial-info {
  position: absolute;
  left: 0;
  right: 0;
  top: 60%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mode-label {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: #4a2d15;
}

/* 玻璃反光 */
.glass {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, .26) 0%, rgba(255, 255, 255, .07) 24%, transparent 46%);
}

/* ============ 按钮与统计 ============ */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: center;
  margin-top: 24px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 16px;
  width: 60px;
  height: 60px;
  padding: 0;
  cursor: pointer;
  color: #fff6e6;
  background: linear-gradient(160deg, #93612f 0%, #6f4523 55%, #59341a 100%);
  box-shadow:
    0 3px 0 #38220f,
    0 12px 20px rgba(0, 0, 0, .5),
    inset 0 2px 2px rgba(255, 232, 195, .45),
    inset 0 -4px 6px rgba(0, 0, 0, .35);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease, background .25s ease;
}

.btn .btn-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

.btn:hover { filter: brightness(1.15); }

.btn:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #38220f,
    0 5px 9px rgba(0, 0, 0, .45),
    inset 0 2px 3px rgba(0, 0, 0, .3);
}

.btn.primary {
  width: 60px;
  height: 60px;
}

.btn.primary .btn-icon {
  width: 28px;
  height: 28px;
}

/* 主按钮：按状态着色（不使用红色），与木质时钟协调 */
.btn.primary[data-state="idle"] {       /* 开始：琥珀金 */
  background: linear-gradient(160deg, #f2bd54 0%, #d99e2c 55%, #b9801a 100%);
  box-shadow:
    0 3px 0 #7a5410,
    0 12px 22px rgba(0, 0, 0, .5),
    inset 0 2px 2px rgba(255, 240, 200, .6),
    inset 0 -4px 6px rgba(0, 0, 0, .3);
}

.btn.primary[data-state="running"] {    /* 暂停：陶土橙（进行中）*/
  background: linear-gradient(160deg, #e08a50 0%, #c56a32 55%, #a04e20 100%);
  box-shadow:
    0 3px 0 #6e3a16,
    0 12px 22px rgba(0, 0, 0, .5),
    inset 0 2px 2px rgba(255, 236, 215, .55),
    inset 0 -4px 6px rgba(0, 0, 0, .3);
}

.btn.primary[data-state="paused"] {     /* 继续：鼠尾草绿（待继续）*/
  background: linear-gradient(160deg, #a3b969 0%, #83994b 55%, #637a33 100%);
  box-shadow:
    0 3px 0 #48591f,
    0 12px 22px rgba(0, 0, 0, .5),
    inset 0 2px 2px rgba(240, 250, 215, .55),
    inset 0 -4px 6px rgba(0, 0, 0, .3);
}

/* 已完成番茄指示 */
.tomatoes {
  min-height: 1.7em;
  font-size: 1.3rem;
  letter-spacing: 3px;
  line-height: 1.7em;
}
