*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #e8eef4;
  --surface: #f7fafc;
  --text: #1a2332;
  --muted: #5a6a7a;
  --accent: #2c5f8a;
  --accent-hover: #1e4a6e;
  --border: #b8c5d4;
  --empty: #8896a6;
  --zone-bg: #e8f5e9;
  --zone-border: #66bb6a;
  --zone-text: #1b5e20;
  --zone-muted: #2e7d32;
  --zone-count: #1b5e20;
  /* 原方案选择框高度 + 竖屏控件行上下间隔，并入点击区 */
  --former-scheme-slot: calc(2.95rem + 0.75rem);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #dfe8f0 0%, var(--bg) 45%, #f0ebe3 100%);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.click-zone {
  min-height: calc(42vh + var(--former-scheme-slot));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 1rem;
  background: var(--zone-bg);
  border: 3px dashed var(--zone-border);
  border-radius: 8px;
  color: var(--zone-text);
  cursor: pointer;
  user-select: none;
  transition:
    background 0.28s ease,
    border-color 0.28s ease,
    color 0.28s ease,
    filter 0.15s ease;
}

.click-zone:hover,
.click-zone:focus-visible {
  filter: brightness(0.96);
  outline: none;
}

.click-zone-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.click-hint {
  margin: 0;
  font-size: 0.95rem;
  color: var(--zone-muted);
}

.total-label {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--zone-muted);
}

.total-count {
  margin: 0;
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--zone-count);
  transition: color 0.28s ease;
}

.click-zone-times {
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--zone-muted);
}

.click-zone-times p {
  margin: 0;
}

.click-zone-times span {
  color: var(--zone-text);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.step-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.step-field input {
  width: 5.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  background: var(--surface);
}

.reset-btn {
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

.reset-btn:hover {
  background: var(--accent-hover);
}

.stats-columns {
  display: grid;
  gap: 1rem;
}

/* 竖屏：统计上下排列 */
@media (orientation: portrait) {
  .stats-columns {
    grid-template-columns: 1fr;
  }

  .click-zone {
    min-height: calc(36vh + var(--former-scheme-slot));
  }
}

/* 横屏：统计左右排列 */
@media (orientation: landscape) {
  .stats-columns {
    grid-template-columns: 1fr 1fr;
  }

  .click-zone {
    min-height: calc(42vh + var(--former-scheme-slot));
  }
}

.stats-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem 1rem;
  min-height: 8rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.stats-panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.view-toggle {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
}

.view-toggle:hover {
  background: #e8eef4;
}

.view-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--empty);
  font-size: 0.9rem;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.stats-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.2rem 0;
  border-bottom: 1px dotted #d0d8e0;
}

.stats-list li:last-child {
  border-bottom: none;
}

.stats-list .empty {
  justify-content: center;
  color: var(--empty);
  border-bottom: none;
}
