@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
  --primary: #2563eb;
  --secondary: #60a5fa;
  --accent: #8b5cf6;
  --bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  --card-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --text-main: #1e293b;
  --text-sub: #64748b;
  --safe-area: env(safe-area-inset-bottom, 20px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(40px + var(--safe-area));
}

header {
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Main Layout */
main {
  padding: 15px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  margin: 25px 0 12px;
  padding-left: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Bottle Shelf (ボトルの増殖) */
.bottle-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 12px;
  padding: 20px;
  background: rgba(255,255,255,0.4);
  border-radius: 24px;
  min-height: 100px;
  margin-bottom: 20px;
  border: 1px solid var(--glass-border);
}

.mini-bottle {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  mix-blend-mode: multiply;
  opacity: 0;
  transform: translateY(10px);
  animation: popIn 0.4s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.05));
}

@keyframes popIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Progress Card */
.progress-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(37, 99, 235, 0.06);
  margin-bottom: 25px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 15px;
}

.current-ml { font-size: 3.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.unit { font-size: 1rem; color: var(--text-sub); margin-left: 4px; }
.goal-info { color: var(--text-sub); font-size: 0.85rem; border-left: 2px solid var(--primary); padding-left: 10px; }

.progress-bar-bg { height: 12px; background: rgba(0,0,0,0.05); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Main Bottle Visual */
.bottle-interaction {
  padding: 10px 0 30px;
  text-align: center;
}

.bottle-wrapper {
  margin: 0 auto 15px;
  position: relative;
  width: auto;
  max-width: 280px;
  cursor: pointer;
}

.bottle-img {
  width: auto;
  max-width: 100%;
  height: 320px; /* 高さを固定 */
  object-fit: contain; /* アスペクト比を維持 */
  mix-blend-mode: multiply;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: block;
  margin: 0 auto;
}
.bottle-wrapper:active .bottle-img { transform: scale(0.92); }

/* Stats Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.card-white {
  background: white;
  padding: 20px;
  border-radius: 24px;
  margin-bottom: 15px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.02);
}

.stats-card {
  padding: 18px;
  border-radius: 20px;
}

.stats-label { font-size: 0.7rem; color: var(--text-sub); font-weight: 600; margin-bottom: 6px; }
.stats-value { font-size: 1.3rem; font-weight: 700; color: var(--text-main); }

/* Calendar & Grass */
.calendar-header { display: flex; justify-content: space-between; align-items: center; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; border-radius: 50%; color: var(--text-main); }
.calendar-day.complete { background: var(--primary); color: white; font-weight: 700; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3); }
.calendar-day.partial { background: rgba(37, 99, 235, 0.1); color: var(--primary); font-weight: 600; }

.grass-container { display: flex; gap: 4px; overflow-x: auto; padding: 10px 0; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.grass-week { display: flex; flex-direction: column; gap: 4px; }
.grass-day { width: 12px; height: 12px; border-radius: 3px; background: #f1f5f9; flex-shrink: 0; }
.grass-day.level-1 { background: #dbeafe; }
.grass-day.level-2 { background: #93c5fd; }
.grass-day.level-3 { background: #3b82f6; }
.grass-day.level-4 { background: #1e3a8a; }

/* Settings (統合スタイル) */
.settings-item-unified {
  margin-bottom: 24px;
}

.unified-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.unified-label::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

input[type="number"], 
input[type="file"] {
  width: 100%;
  padding: 14px;
  border: 2px solid #f1f5f9;
  border-radius: 14px;
  background: #f8fafc;
  font-family: inherit;
  font-weight: 600;
  transition: border-color 0.2s;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

.save-btn {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 18px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
  margin-bottom: 15px;
  transition: all 0.2s;
}

.save-btn:active { transform: scale(0.96); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2); }

.btn-secondary-group {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: white;
  color: var(--text-sub);
  font-weight: 600;
  cursor: pointer;
}

/* Animations */
.flash {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  color: var(--primary);
  animation: floatUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
  font-size: 1.2rem;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -80px) scale(1); }
}

footer {
  position: relative;
  width: 100%;
  background: #2563eb; /* 隙間が目立たないよう、完全に波のベース色に合わせる */
  min-height: 150px;
  overflow: hidden;
  margin-top: 50px;
}

.water-wrapper {
  position: relative;
  width: 100%;
}

.waves {
  display: block;
  position: relative;
  width: 100%;
  height: 60px;
  margin-bottom: -10px; /* 重なりを深くして隙間を完全に消す */
  min-height: 60px;
  max-height: 100px;
}

.parallax > use {
  animation: move-forever 25s cubic-bezier(.55,.5,.45,.5) infinite;
}
.parallax > use:nth-child(1) { animation-delay: -2s; animation-duration: 7s; }
.parallax > use:nth-child(2) { animation-delay: -3s; animation-duration: 10s; }
.parallax > use:nth-child(3) { animation-delay: -4s; animation-duration: 13s; }
.parallax > use:nth-child(4) { animation-delay: -5s; animation-duration: 20s; }

@keyframes move-forever {
  0% { transform: translate3d(-90px,0,0); }
  100% { transform: translate3d(85px,0,0); }
}

.bubble-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.bubble {
  position: absolute;
  bottom: -20px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
  animation: rise var(--duration) ease-in infinite;
  opacity: 0;
}

@keyframes rise {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-100px) scale(1.5); opacity: 0; }
}

.footer-bottom {
  background: #2563eb;
  padding: 30px 20px 40px;
  text-align: center;
  color: white;
  position: relative;
  z-index: 20;
}

.footer-bottom p {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.9;
}

.footer-links {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.footer-links a {
  color: white;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.footer-links a:hover {
  opacity: 1;
}

/* ── 履歴モーダル ── */
.history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.history-overlay.open {
  display: flex;
  animation: fadeInOverlay 0.2s ease forwards;
}
@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.history-modal {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 30px 30px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 24px 36px;
  box-shadow: 0 -10px 40px rgba(37, 99, 235, 0.12);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.history-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.history-modal-date {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}
.history-modal-goal-status {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}
.status-complete { background: rgba(37,99,235,0.1); color: var(--primary); }
.status-partial  { background: rgba(96,165,250,0.15); color: #3b82f6; }
.status-none     { background: #f1f5f9; color: var(--text-sub); }
.history-close-btn {
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.history-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  border: 1px solid rgba(37,99,235,0.1);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.history-total-label { font-size: 0.8rem; font-weight: 700; color: var(--text-sub); }
.history-total-value { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.history-logs-list {
  flex-direction: column;
  gap: 8px;
}
.history-log-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 14px;
}
.history-log-index  { font-size: 0.7rem; color: var(--text-sub); font-weight: 700; width: 18px; text-align: center; flex-shrink: 0; }
.history-log-time   { font-size: 0.85rem; font-weight: 600; color: var(--text-main); flex: 1; }
.history-log-amount { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.history-log-delete {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.history-log-delete:hover { color: #f87171; }
.history-add-form {
  background: #f8fafc;
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
}
.history-add-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.history-add-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
  outline: none;
}
.history-add-input:focus { border-color: var(--primary); }
.history-add-unit { font-size: 0.8rem; color: var(--text-sub); font-weight: 700; flex-shrink: 0; }
.history-add-confirm-btn {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.history-add-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: #f1f5f9;
  border: none;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.history-add-btn:hover { background: #e2e8f0; }
.history-empty {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.85rem;
  padding: 30px 0;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .waves { height: 40px; min-height: 40px; }
  .footer-bottom { padding: 20px 20px 30px; }
}
