/* ===== Reset & Base ===== */
*, *::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: #f8f9fa;
}

/* ===== Header ===== */
header {
  background: #1a1a2e;
  color: white;
  padding: 1.25rem 1rem;
  text-align: center;
}

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

.subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.3rem;
}

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

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

/* ===== Tool Section ===== */
.tool-section {
  background: white;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.09);
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 0.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.6rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  background: transparent;
  color: #666;
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
}

.tab-btn.active {
  background: #1a1a2e;
  color: white;
}

.tab-btn:not(.active):hover {
  background: #f0f0f0;
  color: #333;
}

/* ===== Tab Panels ===== */
.tab-panel.hidden {
  display: none;
}

/* ===== Preset Buttons ===== */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

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

.preset-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid #1a1a2e;
  border-radius: 6px;
  background: white;
  color: #1a1a2e;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
  min-width: 56px;
}

.preset-btn:hover,
.preset-btn.selected {
  background: #1a1a2e;
  color: white;
}

/* ===== Time Input Row ===== */
.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.input-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  min-width: 20px;
}

.input-row input[type="number"] {
  width: 80px;
  padding: 0.55rem 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid #ccc;
  border-radius: 6px;
  min-height: 44px;
}

.input-row input[type="number"]:focus {
  outline: none;
  border-color: #1a1a2e;
}

.colon {
  font-size: 1.8rem;
  font-weight: 700;
  color: #333;
  line-height: 1;
}

/* ===== Message Row ===== */
.message-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.message-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.message-row input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  border: 2px solid #ccc;
  border-radius: 6px;
  min-height: 44px;
}

.message-row input[type="text"]:focus {
  outline: none;
  border-color: #1a1a2e;
}

/* ===== Button Row ===== */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-primary,
.btn-secondary,
.btn-accent {
  flex: 1 1 calc(50% - 0.5rem);
  padding: 0.7rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 44px;
}

.btn-primary {
  background: #1a1a2e;
  color: white;
}

.btn-secondary {
  background: #e5e7eb;
  color: #333;
}

.btn-accent {
  background: #e67e22;
  color: white;
}

.btn-primary:hover,
.btn-accent:hover {
  opacity: 0.88;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-primary:active,
.btn-secondary:active,
.btn-accent:active {
  transform: scale(0.97);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Timer Display (Inline) ===== */
.timer-display {
  margin-top: 1.25rem;
  padding: 1.5rem 1rem;
  background: #111;
  border-radius: 10px;
  text-align: center;
  transition: background 0.5s;
}

.timer-display.state-warning {
  background: #b7950b;
}

.timer-display.state-danger {
  background: #c0392b;
  animation: blink-bg 1s infinite;
}

.timer-display.state-done {
  background: #555;
}

@keyframes blink-bg {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

.timer-clock {
  font-size: clamp(3.5rem, 14vw, 6rem);
  font-weight: 800;
  color: white;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.timer-msg {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: rgba(255, 255, 255, 0.85);
  margin-top: 0.4rem;
  min-height: 1.6em;
  word-break: break-all;
}

.timer-status {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.session-progress {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.3rem;
}

.session-progress.hidden,
.hidden {
  display: none;
}

/* ===== Next Session Button (inline) ===== */
.btn-next-session {
  margin-top: 1rem;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.btn-next-session:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ===== Session Manager ===== */
.session-desc {
  font-size: 0.88rem;
  color: #666;
  margin-bottom: 0.75rem;
}

#session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f4f4f5;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.session-item .session-order {
  font-size: 0.8rem;
  color: #888;
  font-weight: 700;
  min-width: 1.4rem;
}

.session-item input[type="text"] {
  flex: 2;
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  min-height: 44px;
}

.session-item input[type="number"] {
  width: 64px;
  padding: 0.45rem 0.3rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 6px;
  min-height: 44px;
}

.session-item .session-min-label {
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
}

.session-item .btn-remove {
  background: none;
  border: none;
  color: #c0392b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
  min-height: 44px;
  min-width: 44px;
}

.session-item .btn-remove:hover {
  background: #fce4e4;
}

.session-item.active-session {
  border: 2px solid #e67e22;
  background: #fff8f0;
}

.btn-add {
  width: 100%;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  min-height: 44px;
}

/* ===== Howto Section ===== */
.howto-section {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
}

.howto-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.6rem;
  margin-top: 1.1rem;
}

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

.howto-section ol,
.howto-section ul {
  padding-left: 1.3rem;
  font-size: 0.9rem;
  color: #555;
}

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

.howto-section p {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.75;
}

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

footer a {
  color: #555;
  text-decoration: underline;
}

footer p + p {
  margin-top: 0.3rem;
}

/* ===== Fullscreen Overlay ===== */
.fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.5s;
  padding: 1.5rem;
}

.fs-overlay.hidden {
  display: none;
}

.fs-overlay.state-warning {
  background: #b7950b;
}

.fs-overlay.state-danger {
  background: #c0392b;
  animation: blink-bg 1s infinite;
}

.fs-overlay.state-done {
  background: #444;
}

.fs-clock {
  font-size: clamp(5rem, 22vw, 18rem);
  font-weight: 800;
  color: white;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.fs-msg {
  font-size: clamp(1.5rem, 5vw, 4rem);
  color: rgba(255, 255, 255, 0.85);
  margin-top: 0.6rem;
  text-align: center;
  word-break: break-all;
  min-height: 1.2em;
}

.fs-status {
  font-size: clamp(0.9rem, 2vw, 1.4rem);
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
}

.fs-session-progress {
  font-size: clamp(0.85rem, 1.8vw, 1.2rem);
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.4rem;
  text-align: center;
}

.fs-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.fs-btn {
  padding: 0.75rem 1.5rem;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
  min-width: 80px;
}

.fs-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.fs-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fs-btn-exit {
  border-color: rgba(255, 100, 100, 0.7);
  color: #ffaaaa;
}

.fs-btn-exit:hover {
  background: rgba(200, 50, 50, 0.3);
}

/* ===== Desktop ===== */
@media (min-width: 640px) {
  header h1 {
    font-size: 1.4rem;
  }

  main {
    padding: 1.5rem 2rem;
  }

  .btn-primary,
  .btn-secondary,
  .btn-accent {
    flex: 1 1 auto;
    max-width: 180px;
  }
}
