:root {
  --bg: #020716;
  --glass-bg: rgba(15, 32, 64, 0.55);
  --glass-border: rgba(255, 255, 255, 0.15);
  --accent: #29b6f6;
  --accent-soft: rgba(41, 182, 246, 0.25);
  --text-main: #f5f7ff;
  --text-sub: #a9b3d1;
  --danger: #ef5350;
  --success: #66bb6a;
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.55);
  --radius-xl: 28px;
  --radius-md: 16px;
  --transition-fast: 0.18s ease-out;
  --transition-med: 0.25s ease-out;
}

/* 全体レイアウト */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top, #102a43 0, #020716 55%, #000 100%);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#app {
  position: relative;
  flex: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

/* 波背景 */
.wave-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.wave-bg svg {
  position: absolute;
  bottom: -5%;
  left: 0;
  width: 130%;
  height: 55%;
  transform: translate3d(0, 0, 0);
  transition: transform 0.4s ease-out;
  opacity: 0.9;
}

/* メインカード（ガラスモーフィズム） */
.glass-card {
  position: relative;
  z-index: 1;
  width: min(960px, 92vw);
  max-height: 92vh;
  padding: 24px 24px 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(12, 24, 48, 0.82), rgba(3, 7, 20, 0.9));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(135%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ヘッダー */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header h1 {
  font-size: clamp(1.6rem, 1.1rem + 1.4vw, 2rem);
  margin: 0;
  letter-spacing: 0.04em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-sub);
  font-size: 0.9rem;
}

.title-badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(129, 212, 250, 0.45), rgba(2, 119, 189, 0.25));
  border: 1px solid rgba(179, 229, 252, 0.8);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* タイマー */
.timer-section {
  margin-top: 6px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 20px;
  align-items: center;
}

.timer-display {
  font-size: clamp(3rem, 2.3rem + 2.2vw, 4rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 22px 10px;
  border-radius: 26px;
  background: radial-gradient(circle at top, rgba(33, 150, 243, 0.14), rgba(3, 16, 42, 0.94));
  border: 1px solid rgba(144, 202, 249, 0.4);
  box-shadow: 0 0 0 1px rgba(144, 202, 249, 0.3), 0 18px 40px rgba(2, 119, 189, 0.5);
  text-shadow: 0 0 20px rgba(129, 212, 250, 0.7);
}

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

.time-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-sub);
}

.time-label input {
  width: 90px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(129, 212, 250, 0.6);
  background: rgba(3, 10, 26, 0.9);
  color: var(--text-main);
  font-size: 0.9rem;
  text-align: center;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.time-label input:focus {
  border-color: #81d4fa;
  box-shadow: 0 0 0 1px rgba(129, 212, 250, 0.7);
  background: rgba(1, 9, 24, 0.95);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ボタン */
button {
  border-radius: 999px;
  border: none;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), opacity 0.16s linear;
  white-space: nowrap;
}

button.primary {
  background: linear-gradient(135deg, #29b6f6, #039be5);
  color: #04101f;
  box-shadow: 0 12px 28px rgba(2, 136, 209, 0.7);
}

button.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(2, 119, 189, 0.8);
}

button.secondary {
  background: rgba(7, 26, 48, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(129, 212, 250, 0.4);
}

button.secondary:hover:not(:disabled) {
  background: rgba(12, 32, 64, 0.95);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  transform: none;
}

/* サマリ */
.summary-section {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.16), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-item .label {
  font-size: 0.76rem;
  color: var(--text-sub);
}

.summary-item .value {
  font-size: 0.98rem;
}

/* グラフ */
.chart-section {
  margin-top: 6px;
  padding: 10px 12px 6px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.96), rgba(3, 7, 18, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.chart-section h2 {
  margin: 0 0 6px;
  font-size: 0.96rem;
  color: var(--text-sub);
}

.week-chart {
  width: 100%;
  height: 130px;
  overflow: visible;
}

.axis {
  stroke: rgba(148, 163, 184, 0.7);
  stroke-width: 0.6;
}

.bar {
  fill: url(#barGradient);
  rx: 2;
  ry: 2;
  transition: height 0.4s ease-out, y 0.4s ease-out;
}

.bar-bg {
  fill: rgba(30, 64, 175, 0.45);
  rx: 2;
  ry: 2;
}

.week-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-sub);
}

/* フッター */
.footer {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed rgba(88, 110, 152, 0.8);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-sub);
}

.install-hint {
  opacity: 0.8;
}

/* レスポンシブ（スマホ完全対応） */
@media (max-width: 720px) {
  .glass-card {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    padding: 16px 14px 12px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .title-badge {
    align-self: flex-start;
  }

  .timer-section {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .timer-display {
    padding: 16px 8px;
  }

  .summary-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .wave-bg svg {
    width: 180%;
    height: 60%;
  }
}

@media (max-width: 420px) {
  .summary-section {
    grid-template-columns: 1fr;
  }

  .title-badge {
    font-size: 0.7rem;
  }
}
.fail-flash {
  animation: failFlash 0.8s ease-out;
}

@keyframes failFlash {
  0% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(239, 83, 80, 0.0);
  }
  40% {
    transform: scale(1.08);
    text-shadow: 0 0 18px rgba(239, 83, 80, 0.9);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(239, 83, 80, 0.0);
  }
}

/* スマホのアドレスバーによる高さ変動を防ぐ */
:root {
  --vh: 1vh;
}

body {
  height: calc(var(--vh) * 100);
}

/* JSで実際の高さを反映 */