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

:root {
  --bg: #0a1628;
  --card: #0f2035;
  --card2: #0d1e30;
  --accent: #2ecc71;
  --accent2: #1a6b4a;
  --accent-dark: #1a9954;
  --gold: #52d68a;
  --teal: #27ae60;
  --text: #e0f0e8;
  --muted: #6b9e82;
  --radius: 18px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ========== HEADER ========== */
header {
  text-align: center;
  padding: 28px 20px 12px;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.1em;
}

/* ========== BG TOGGLE BUTTON ========== */
.btn-bg-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}
.btn-bg-toggle:active {
  background: rgba(255,255,255,0.28);
}

/* ========== STREAK CARD ========== */
.streak-card {
  margin: 12px 20px;
  background: linear-gradient(135deg, rgba(10,22,40,0.5), rgba(26,107,74,0.35)), url('./bg-hero.png') center right/cover no-repeat;
  border-radius: var(--radius);
  padding: 32px 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(46, 204, 113, 0.2);
}

.streak-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(46, 204, 113, 0.07);
}

.streak-label {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.streak-days {
  font-size: 5rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  letter-spacing: -2px;
}

.streak-unit {
  font-size: 1.3rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  margin-left: 4px;
}

.streak-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.55);
  margin-top: 6px;
}

.streak-start {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  margin-top: 10px;
}

/* ========== SAVINGS CARD ========== */
.savings-card {
  margin: 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, #0f2035, #0d2a1a);
}

.savings-card .label {
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 8px;
}

.savings-amount {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 6px;
  letter-spacing: -1px;
}

.savings-detail {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ========== MESSAGE CARD ========== */
.message-card {
  margin: 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  border-left: 3px solid var(--teal);
}

.message-card .label {
  font-size: 0.75rem;
  color: var(--teal);
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 6px;
}

.message-text {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.7;
}

/* ========== EFFECT CARD ========== */
.effect-card {
  margin: 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
}

.effect-card .label {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 4px;
}

.effect-period {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.effect-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
}

.effect-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.effect-list li {
  font-size: 0.92rem;
  color: var(--text);
  padding-left: 1.2em;
  position: relative;
}

.effect-list li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 0.6rem;
  top: 0.35em;
}

/* ========== MILESTONE / PROGRESS ========== */
.progress-section {
  margin: 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.progress-section .label {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 14px;
}

.milestones {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.milestone {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.05);
}

.milestone.done {
  background: rgba(46, 204, 113, 0.1);
  border-color: rgba(46, 204, 113, 0.25);
}

.milestone-check {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.milestone.done .milestone-check {
  filter: none;
}

.milestone:not(.done) .milestone-check {
  color: rgba(255,255,255,0.2);
  font-size: 0.9rem;
}

.milestone-name {
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
}

.milestone.done .milestone-name {
  color: var(--accent);
  font-weight: 600;
}

.milestone-days-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.milestone.done .milestone-days-label {
  color: var(--accent);
  font-weight: 700;
}

.next-milestone {
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
  background: rgba(46, 204, 113, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(46, 204, 113, 0.15);
  line-height: 1.5;
}

/* ========== RECOMMEND CARD ========== */
.recommend-card {
  margin: 12px 20px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.recommend-card .label {
  font-size: 0.75rem;
  color: var(--teal);
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 4px;
}

.recommend-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.recommend-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.07);
  transition: background 0.15s;
}

.recommend-link:active {
  background: rgba(255,255,255,0.09);
}

.recommend-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 44px;
  text-align: center;
}

.recommend-info {
  flex: 1;
}

.recommend-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.recommend-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.recommend-arrow {
  font-size: 1.3rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* ========== EMERGENCY BUTTON ========== */
.emergency-zone {
  margin: 16px 20px 4px;
}

.btn-emergency {
  width: 100%;
  background: linear-gradient(135deg, #1a3a2a, #0f2a1a);
  border: 1px solid rgba(46, 204, 113, 0.4);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: #86efac;
  box-shadow: 0 4px 20px rgba(46, 204, 113, 0.15);
  transition: transform 0.1s, box-shadow 0.2s;
  -webkit-font-smoothing: antialiased;
}

.btn-emergency:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(46, 204, 113, 0.1);
}

.emergency-icon {
  font-size: 1.3rem;
}

/* ========== EMERGENCY MODAL ========== */
.modal-emergency {
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
}

.emergency-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.emergency-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.emergency-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emergency-tip-card {
  background: linear-gradient(135deg, #0d1e30, #0a2518);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  border: 1px solid rgba(46, 204, 113, 0.2);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tip-number {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  font-weight: 600;
}

.tip-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.tip-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
}

.tip-body {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.75;
  white-space: pre-line;
}

.emergency-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 8px;
}

.btn-tip-nav {
  background: rgba(255,255,255,0.07);
  border: none;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-tip-nav:active {
  background: rgba(255,255,255,0.13);
}

.tip-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.2s, width 0.2s;
}

.tip-dot.active {
  background: var(--accent);
  width: 16px;
  border-radius: 3px;
}

.emergency-affirmation {
  margin-top: 16px;
  background: rgba(46, 204, 113, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--accent);
  text-align: center;
  line-height: 1.7;
  border: 1px solid rgba(46, 204, 113, 0.15);
}

/* ========== BUTTONS ========== */
.actions {
  margin: 20px 20px 8px;
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-font-smoothing: antialiased;
}

.btn:active {
  transform: scale(0.97);
}

.btn-reset {
  background: rgba(255, 101, 132, 0.12);
  color: #f87171;
  border: 1px solid rgba(255, 101, 132, 0.25);
}

.btn-share {
  background: rgba(46, 204, 113, 0.12);
  color: var(--accent);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

/* ========== SETUP SCREEN ========== */
.setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  padding: 40px 30px;
  text-align: center;
}

.setup-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.setup-screen h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), #1abc9c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.setup-screen p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
  line-height: 1.7;
}

.setup-screen label {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
  max-width: 320px;
}

.date-input {
  width: 100%;
  max-width: 320px;
  background: var(--card);
  border: 1px solid rgba(46,204,113,0.35);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  color: var(--text);
  font-family: inherit;
  margin-bottom: 20px;
  outline: none;
  -webkit-appearance: none;
}

.date-input:focus {
  border-color: var(--accent);
}

.cost-input {
  -moz-appearance: textfield;
}

.cost-input::-webkit-inner-spin-button,
.cost-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.btn-start {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(135deg, var(--accent-dark), #1abc9c);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 24px rgba(46,204,113,0.35);
  transition: transform 0.1s;
  margin-top: 4px;
}

.btn-start:active {
  transform: scale(0.97);
}

/* ========== MODAL ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card2);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.modal h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.btn-cancel {
  flex: 1;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-confirm {
  flex: 1;
  background: #f87171;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ========== FOOTER ========== */
footer {
  text-align: center;
  padding: 16px 20px 32px;
  color: rgba(255,255,255,0.15);
  font-size: 0.75rem;
}

/* ========== HIDDEN ========== */
.hidden { display: none !important; }
