/* ── 番茄钟 · anzhi-ehzo 风格 ── */
@font-face {
  font-family: 'Fusion Pixel';
  src: url('/fonts/fusion-pixel.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #131314;
  --surface: rgba(138,219,210,0.03);
  --surface-hover: rgba(138,219,210,0.06);
  --border: rgba(138,219,210,0.12);
  --border-hover: rgba(138,219,210,0.3);
  --text: #b2dfdb;
  --text-dim: rgba(178,223,219,0.45);
  --mint: #8adbd2;
  --mint-glow: rgba(138,219,210,0.15);
  --orange: #ffb74d;
  --red: #e57373;
  --radius: 6px;
  --font: 'Fusion Pixel', 'Fira Code', Consolas, monospace;
  --font-num: 'Fusion Pixel', 'Fira Code', monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ── 网格背景 ── */
#grid-base {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    linear-gradient(rgba(138,219,210,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138,219,210,0.04) 1px, transparent 1px),
    linear-gradient(rgba(138,219,210,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138,219,210,0.015) 1px, transparent 1px);
  background-size: 72px 72px, 72px 72px, 12px 12px, 12px 12px;
}
#grid-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    linear-gradient(rgba(138,219,210,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138,219,210,0.12) 1px, transparent 1px),
    linear-gradient(rgba(138,219,210,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138,219,210,0.05) 1px, transparent 1px);
  background-size: 72px 72px, 72px 72px, 12px 12px, 12px 12px;
  -webkit-mask: radial-gradient(300px at 50% 50%, #000 0%, rgba(0,0,0,0.25) 50%, transparent 100%);
  mask: radial-gradient(300px at 50% 50%, #000 0%, rgba(0,0,0,0.25) 50%, transparent 100%);
  transition: mask 0.1s, -webkit-mask 0.1s;
}

#app {
  position: relative; z-index: 2;
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.logo {
  font-size: 18px;
  font-weight: 500;
  color: var(--mint);
  letter-spacing: 0.5px;
}
.logo span { color: var(--text-dim); font-weight: 300; }
nav { display: flex; gap: 2px; }
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border); }
.nav-btn.active { color: var(--mint); border-color: var(--border-hover); background: var(--surface); }

/* ── Views ── */
.view { display: none; flex-direction: column; align-items: center; gap: 18px; flex: 1; }
.view.active { display: flex; }

/* ── Mouse ── */
.mouse-area {
  width: 140px; height: 140px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
  transition: border-color 0.2s;
}
.mouse-area:hover { border-color: var(--border-hover); }
#mouse-canvas, #mouse-big { image-rendering: pixelated; }

/* ── Timer ── */
.timer-display {
  font-size: 42px;
  font-family: var(--font-num);
  font-weight: 400;
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--mint);
  line-height: 1;
  text-shadow: 0 0 40px rgba(138,219,210,0.08);
}
.timer-status {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: -4px;
}

/* ── Progress ── */
.progress-bar {
  width: 100%;
  max-width: 320px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--mint);
  width: 0%;
  transition: width 0.5s linear;
  border-radius: 1px;
  box-shadow: 0 0 8px var(--mint-glow);
}

/* ── Duration ── */
.duration-control {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--surface);
}
.dur-btn {
  width: 30px; height: 30px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  transition: all 0.2s;
}
.dur-btn:hover { border-color: var(--border-hover); color: var(--mint); background: var(--surface-hover); }
.dur-value {
  font-size: 24px;
  font-weight: 400;
  min-width: 36px;
  text-align: center;
  color: var(--mint);
}
.dur-unit { color: var(--text-dim); font-size: 12px; }

/* ── Task Types ── */
.task-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  max-width: 280px;
}
.task-chip {
  padding: 4px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  transition: all 0.2s;
}
.task-chip:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface-hover); }
.task-chip.active {
  border-color: var(--mint);
  color: var(--mint);
  background: var(--mint-glow);
}

/* ── Controls ── */
.controls { display: flex; gap: 8px; }
.ctrl-btn {
  padding: 10px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 400;
}
.ctrl-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface-hover); }
.ctrl-btn.primary {
  background: var(--mint);
  color: #131314;
  border-color: var(--mint);
  font-weight: 500;
  box-shadow: 0 0 20px rgba(138,219,210,0.1);
}
.ctrl-btn.primary:hover { opacity: 0.88; box-shadow: 0 0 30px rgba(138,219,210,0.2); }
.ctrl-btn.primary:disabled { opacity: 0.3; cursor: default; box-shadow: none; }
.ctrl-btn.danger { border-color: rgba(229,115,115,0.3); color: var(--red); }
.ctrl-btn.danger:hover { background: rgba(229,115,115,0.08); border-color: var(--red); }

/* ── Today Bar ── */
.today-bar {
  width: 100%;
  display: flex;
  justify-content: space-around;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface);
}
.today-bar strong { color: var(--text); font-weight: 400; }

/* ── Stats View ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.stat-card {
  border: 1px solid var(--border);
  padding: 18px 14px;
  border-radius: var(--radius);
  text-align: center;
  background: var(--surface);
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-num { font-size: 20px; font-family: var(--font-num); font-weight: 400; color: var(--mint); }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

h3 {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  align-self: flex-start;
  margin-top: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Heatmap ── */
.heatmap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
}
.heat-day {
  width: 34px; height: 34px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  transition: all 0.2s;
}
.heat-day.has { background: rgba(138,219,210,0.08); border-color: rgba(138,219,210,0.2); color: var(--mint); }
.heat-day.more { background: rgba(138,219,210,0.18); border-color: rgba(138,219,210,0.3); }
.heat-day.most { background: rgba(138,219,210,0.3); border-color: var(--mint); color: #131314; }

/* ── Type Breakdown ── */
.type-breakdown {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.type-bar-bg {
  flex: 1;
  height: 4px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  overflow: hidden;
}
.type-bar-fill { height: 100%; border-radius: 1px; transition: width 0.5s; }
.type-count { font-size: 11px; color: var(--text-dim); min-width: 48px; text-align: right; }

/* ── History ── */
.history-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-item {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--surface);
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--border-hover); }
.history-item .hi-type { color: var(--mint); }
.history-item .hi-dur { color: var(--text-dim); }
.history-item .hi-xp { color: var(--orange); }

/* ── Mouse View ── */
.mouse-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius);
  width: 100%;
  background: var(--surface);
  transition: border-color 0.2s;
}
.mouse-profile:hover { border-color: var(--border-hover); }
.mouse-level { font-size: 16px; color: var(--mint); font-weight: 400; }
.xp-bar-bg {
  width: 100%;
  height: 4px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mint), #a8e6cf);
  border-radius: 1px;
  transition: width 0.5s;
  box-shadow: 0 0 8px var(--mint-glow);
}
.xp-text { font-size: 11px; color: var(--text-dim); }
.mouse-stats {
  width: 100%;
  display: flex;
  justify-content: space-around;
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  transition: border-color 0.2s;
}
.mouse-stats:hover { border-color: var(--border-hover); }
.mouse-stats strong { color: var(--text); font-weight: 400; }

/* ── Complete Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(19,19,20,0.85);
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 28px 24px;
  border-radius: var(--radius);
  text-align: center;
  max-width: 300px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.modal h2 { color: var(--mint); font-size: 16px; font-weight: 400; margin-bottom: 12px; }
.modal .xp-gain { font-size: 20px; color: var(--orange); font-weight: 500; }
.modal .gain-detail { color: var(--text-dim); font-size: 12px; margin: 6px 0 18px; }
.modal .modal-btn {
  padding: 8px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--mint);
  background: transparent;
  color: var(--mint);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  font-weight: 400;
  transition: all 0.2s;
}
.modal .modal-btn:hover { background: var(--mint-glow); box-shadow: 0 0 20px var(--mint-glow); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Responsive ── */
@media (max-width: 480px) {
  #app { padding: 24px 16px; }
  header { margin-bottom: 24px; }
  .logo { font-size: 16px; }
  .nav-btn { font-size: 11px; padding: 4px 10px; }
  .timer-display { font-size: 32px; }
  .mouse-area { width: 120px; height: 120px; }
  .stats-grid { gap: 6px; }
  .stat-card { padding: 14px 10px; }
  .stat-num { font-size: 22px; }
  .modal { margin: 0 16px; }
}
