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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f0f4f8;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #1a2a4a 0%, #2c4a7c 100%);
  color: white;
  padding: 1.5rem 1rem;
  text-align: center;
}

header h1 {
  font-size: 1.1rem;
  line-height: 1.4;
  font-weight: 700;
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 0.4rem;
}

/* ===== Main ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== Ad unit ===== */
.ad-unit {
  margin: 1.25rem 0;
}

/* ===== Counter section ===== */
.counter-section {
  background: #1a2a4a;
  border-radius: 16px;
  padding: 1.5rem 1rem;
  margin-bottom: 1.25rem;
  text-align: center;
  box-shadow: 0 4px 16px rgba(26, 42, 74, 0.3);
}

.counter-display {
  margin-bottom: 1.25rem;
}

.counter-label {
  font-size: 0.8rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}

.counter-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: #f97316;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.counter-value.running {
  color: #fb923c;
  text-shadow: 0 0 20px rgba(249, 115, 22, 0.4);
}

.counter-time {
  font-size: 1.6rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.counter-rate {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.3rem;
}

/* ===== Counter controls ===== */
.counter-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-start,
.btn-stop,
.btn-reset {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 48px;
  min-width: 100px;
  transition: all 0.2s;
}

.btn-start {
  background: linear-gradient(135deg, #dc2626 0%, #f97316 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.btn-start:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
}

.btn-start:disabled {
  background: #475569;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-stop {
  background: #334155;
  color: #e2e8f0;
}

.btn-stop:hover:not(:disabled) {
  background: #475569;
}

.btn-stop:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-reset {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
}

.btn-reset:hover {
  background: #334155;
  color: #e2e8f0;
}

/* ===== Tool section ===== */
.tool-section {
  background: white;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a2a4a;
  margin-bottom: 0.75rem;
}

.section-desc {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 1rem;
}

/* ===== Participants list ===== */
.participants-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.participant-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.participant-row select,
.participant-row input[type="number"] {
  font-size: 1rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: white;
  color: #111827;
  padding: 0.4rem 0.5rem;
  min-height: 44px;
  transition: border-color 0.2s;
}

.participant-row select {
  flex: 1;
}

.participant-row input[type="number"] {
  width: 4.5rem;
  text-align: center;
}

.participant-row select:focus,
.participant-row input[type="number"]:focus {
  outline: none;
  border-color: #2c4a7c;
}

.participant-hourly {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
}

.btn-remove-participant {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.3rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.btn-remove-participant:hover {
  background: #fee2e2;
  color: #dc2626;
}

.btn-add {
  width: 100%;
  padding: 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2c4a7c;
  background: #eff6ff;
  border: 1.5px dashed #93c5fd;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s;
}

.btn-add:hover {
  background: #dbeafe;
  border-color: #3b82f6;
}

/* ===== Cost table ===== */
.cost-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cost-table th {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-size: 0.8rem;
}

.cost-table td {
  padding: 0.75rem;
  border-top: 1px solid #e2e8f0;
  color: #374151;
}

.cost-table tr:hover td {
  background: #f8fafc;
}

.cost-amount {
  font-weight: 700;
  color: #dc2626;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.cost-per-head {
  font-size: 0.78rem;
  color: #9ca3af;
}

/* ===== ROI section ===== */
.roi-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.form-group input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
  transition: border-color 0.2s;
  min-height: 44px;
}

.form-group input[type="number"]:focus {
  outline: none;
  border-color: #2c4a7c;
  background: white;
}

/* ===== ROI result ===== */
.roi-result {
  border-radius: 10px;
  padding: 1rem;
}

.roi-result.positive {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
}

.roi-result.negative {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
}

.roi-result.neutral {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
}

.roi-percentage {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.roi-result.positive .roi-percentage {
  color: #16a34a;
}

.roi-result.negative .roi-percentage {
  color: #dc2626;
}

.roi-result.neutral .roi-percentage {
  color: #64748b;
}

.roi-verdict {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.roi-detail {
  font-size: 0.82rem;
  color: #6b7280;
}

/* ===== How-to section ===== */
.howto-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.howto-section h2 {
  font-size: 1.05rem;
  color: #1a2a4a;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.howto-section h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.howto-section ol {
  padding-left: 1.25rem;
  color: #4b5563;
  font-size: 0.9rem;
}

.howto-section ol li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.howto-section p {
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.8;
  margin-bottom: 0.75rem;
}

.howto-section p:last-of-type {
  margin-bottom: 0;
}

/* ===== Affiliate block ===== */
.affiliate-block {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.affiliate-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #9ca3af;
  border: 1px solid #d1d5db;
  padding: 0 0.35rem;
  border-radius: 3px;
  margin-bottom: 0.5rem;
}

.affiliate-desc {
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.6rem;
}

.affiliate-link {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #2c4a7c;
  text-decoration: underline;
  min-height: 44px;
  line-height: 44px;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

footer p {
  margin-bottom: 0.4rem;
}

footer a {
  color: #6b7280;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ===== Responsive: tablet+ ===== */
@media (min-width: 480px) {
  .participant-row {
    gap: 0.75rem;
  }

  .participant-hourly {
    min-width: 5.5rem;
  }
}

@media (min-width: 640px) {
  header {
    padding: 2rem 1.5rem;
  }

  header h1 {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  main {
    padding: 1.5rem 2rem;
  }

  .counter-value {
    font-size: 4.5rem;
  }

  .counter-time {
    font-size: 2rem;
  }

  .tool-section {
    padding: 1.5rem;
  }

  .roi-form {
    flex-direction: row;
    align-items: flex-start;
  }

  .roi-form .form-group {
    flex: 1;
  }

  .roi-result {
    min-width: 200px;
  }
}
