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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f0f4f8;
  color: #333;
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* ヘッダー */
header {
  background: #2196F3;
  color: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.date-display {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* カウンターセクション */
.counter-section {
  background: white;
  border-radius: 12px;
  padding: 24px 20px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.total-count {
  margin-bottom: 24px;
}

.total-label {
  display: block;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 4px;
}

.total-number {
  font-size: 4rem;
  font-weight: 800;
  color: #2196F3;
  line-height: 1;
}

.total-unit {
  font-size: 1.5rem;
  color: #666;
  margin-left: 4px;
}

.count-btn {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  background: #2196F3;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.count-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.count-icon {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.count-label {
  font-size: 0.8rem;
  margin-top: 6px;
  opacity: 0.9;
}

.undo-btn {
  background: none;
  border: 1px solid #ccc;
  color: #666;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.undo-btn:hover {
  background: #f5f5f5;
}

/* 共通セクション */
.hourly-section,
.history-section {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
}

.reset-btn,
.clear-history-btn {
  background: none;
  border: 1px solid #f44336;
  color: #f44336;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.reset-btn:hover,
.clear-history-btn:hover {
  background: #fff5f5;
}

/* 時間帯テーブル */
.hourly-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hour-row {
  display: grid;
  grid-template-columns: 80px 1fr 48px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}

.hour-row:last-child {
  border-bottom: none;
}

.hour-row.active {
  background: #e3f2fd;
  border-radius: 6px;
  padding: 6px 8px;
  margin: 0 -8px;
}

.hour-label {
  font-size: 0.85rem;
  color: #555;
  white-space: nowrap;
}

.hour-bar-wrap {
  background: #f0f0f0;
  border-radius: 4px;
  height: 10px;
  overflow: hidden;
}

.hour-bar {
  height: 100%;
  background: #2196F3;
  border-radius: 4px;
  transition: width 0.3s;
  min-width: 0;
}

.hour-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: #2196F3;
  text-align: right;
}

.hour-count.zero {
  color: #ccc;
  font-weight: 400;
}

.no-data {
  text-align: center;
  color: #aaa;
  font-size: 0.85rem;
  padding: 12px 0;
}

/* 履歴リスト */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.history-item:last-child {
  border-bottom: none;
}

.history-date {
  font-size: 0.9rem;
  color: #555;
}

.history-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: #2196F3;
}

/* モーダル */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px 20px;
  width: 280px;
  text-align: center;
}

.modal-content p {
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

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

.modal-cancel,
.modal-ok {
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.9rem;
  cursor: pointer;
}

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

.modal-ok {
  background: #f44336;
  color: white;
}

/* スマホ対応 */
@media (max-width: 400px) {
  .count-btn {
    width: 160px;
    height: 160px;
  }

  .total-number {
    font-size: 3rem;
  }
}
