*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #FFF8F0;
  font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', 'Rounded Mplus 1c',
    'Arial Rounded MT Bold', sans-serif;
}

/* ===== 画面共通 ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top, 24px) 24px env(safe-area-inset-bottom, 24px);
  position: absolute;
  inset: 0;
}

.screen.active {
  display: flex;
}

/* ===== スケール選択 ===== */
.page-title {
  font-size: 2rem;
  font-weight: 800;
  color: #444;
  text-align: center;
}

.scale-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 380px;
}

.scale-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  padding: 22px 32px;
  border: none;
  border-radius: 26px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.scale-btn:nth-child(1) { background: #BDD2EA; }
.scale-btn:nth-child(2) { background: #FFC93C; }
.scale-btn:nth-child(3) { background: #6BCB77; }

.scale-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.scale-num {
  font-size: 4rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

/* 黄色ボタンは文字を暗くして視認性UP */
.scale-btn:nth-child(1) .scale-num,
.scale-btn:nth-child(1) .scale-unit,
.scale-btn:nth-child(2) .scale-num,
.scale-btn:nth-child(2) .scale-unit {
  color: rgba(0, 0, 0, 0.65);
}

.scale-unit {
  font-size: 2.2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.settings-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 16px;
}

/* ===== ダイヤル ===== */
.time-display {
  font-size: 3.5rem;
  font-weight: 900;
  color: #333;
  text-align: center;
  min-height: 1.2em;
  letter-spacing: -0.02em;
}

#dial-svg {
  width: min(86vw, 330px);
  height: min(86vw, 330px);
  touch-action: none;
  cursor: grab;
}

#dial-svg:active {
  cursor: grabbing;
}

#timer-svg {
  width: min(86vw, 330px);
  height: min(86vw, 330px);
}

/* ===== ボタン ===== */
.action-btn {
  display: block;
  width: 100%;
  max-width: 340px;
  padding: 20px;
  font-size: 1.9rem;
  font-weight: 800;
  color: white;
  background: #4CAF50;
  border: none;
  border-radius: 60px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(76, 175, 80, 0.45);
  transition: transform 0.1s ease, opacity 0.15s ease;
  text-align: center;
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.text-btn {
  background: none;
  border: none;
  color: #bbb;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 8px 20px;
}

/* ===== タイマー終了 ===== */
.done-emoji {
  font-size: 7rem;
  animation: bounce 0.65s ease-in-out infinite alternate;
}

.done-text {
  font-size: 3.5rem;
  font-weight: 900;
  color: #333;
}

@keyframes bounce {
  from { transform: scale(0.9) translateY(4px); }
  to   { transform: scale(1.1) translateY(-14px); }
}

/* ===== 設定モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: white;
  border-radius: 28px;
  padding: 36px 28px;
  width: min(90%, 360px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.modal-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #333;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  font-size: 1rem;
  color: #777;
  font-weight: 600;
}

.sound-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-select {
  flex: 1;
  padding: 14px;
  font-size: 1.1rem;
  border: 2px solid #eee;
  border-radius: 14px;
  background: white;
  outline: none;
  color: #333;
}

.preview-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: 2px solid #BDD2EA;
  border-radius: 14px;
  background: white;
  color: #BDD2EA;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.1s;
}

.preview-btn:active {
  background: #BDD2EA;
  color: white;
}
