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

:root {
  --bg: #0f0f1a;
  --card: #1a1a2e;
  --card2: #16213e;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --gold: #f5c842;
  --text: #e8e8f0;
  --muted: #8888aa;
  --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(30,27,75,0.45), rgba(49,46,129,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(108, 99, 255, 0.25);
}

.streak-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.08);
}

.streak-label {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.08em;
  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;
}

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

.message-card .label {
  font-size: 0.75rem;
  color: var(--accent);
  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;
}

/* ========== PROGRESS BAR ========== */
.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: 12px;
}

.milestones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.milestone-name {
  font-size: 0.8rem;
  color: var(--muted);
  width: 60px;
  flex-shrink: 0;
}

.milestone-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.milestone-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.8s ease;
}

.milestone-pct {
  font-size: 0.75rem;
  color: var(--muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.milestone.done .milestone-name {
  color: var(--gold);
}

.milestone.done .milestone-bar-fill {
  background: linear-gradient(90deg, var(--gold), #ffaa00);
}

/* ========== 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(--accent);
  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, #7f1d1d, #991b1b);
  border: 1px solid rgba(239, 68, 68, 0.5);
  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: #fca5a5;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.25);
  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(239, 68, 68, 0.2);
}

.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: #fca5a5;
}

.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, #1e1b2e, #2d1b3d);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  border: 1px solid rgba(139, 92, 246, 0.25);
  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: #c4b5fd;
}

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

.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: #a78bfa;
  width: 16px;
  border-radius: 3px;
}

.emergency-affirmation {
  margin-top: 16px;
  background: rgba(245, 200, 66, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--gold);
  text-align: center;
  line-height: 1.7;
  border: 1px solid rgba(245, 200, 66, 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.15);
  color: var(--accent2);
  border: 1px solid rgba(255, 101, 132, 0.3);
}

.btn-share {
  background: rgba(108, 99, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(108, 99, 255, 0.3);
}

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

.setup-screen h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -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(108,99,255,0.4);
  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);
}

.btn-start {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  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(108,99,255,0.4);
  transition: transform 0.1s;
}

.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: var(--accent2);
  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; }
