/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== VARIABLES ===== */
:root {
  --text-primary:  #dce8ff;
  --text-muted:    #7da8d0;
  --text-hint:     #4d6a9a;
  --card-bg:       rgba(5, 14, 50, 0.68);
  --card-border:   rgba(80, 130, 220, 0.22);
  --orange:        #E8942A;
  --orange-light:  #F5A623;
  --white:         #ffffff;
  --font:          'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
                   'Yu Gothic', sans-serif;
}

/* ===== BASE ===== */
html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  background-color: #06091e;
}

body {
  background: url('images/night-sky.jpg') center top / cover fixed;
  min-height: 100vh;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  body {
    background-attachment: scroll;
  }
}

/* ===== APP WRAPPER ===== */
#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ===== HEADER ===== */
header {
  width: 100%;
  text-align: center;
  background: rgba(5, 12, 42, .52);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: .5px solid rgba(80, 130, 220, .18);
  border-radius: 20px;
  padding: .9rem 1.5rem .75rem;
}

/* ===== CHOMA BANNER ===== */
.choma-banner {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  line-height: 0;
}

.choma-banner-img {
  width: 100%;
  height: 200px;
  display: block;
  object-fit: cover;
  object-position: 20% center;
}

.tagline {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .08em;
  margin-bottom: 5px;
}

h1 {
  font-family: 'Hachi Maru Pop', sans-serif;
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.fanmarks {
  font-size: 18px;
  color: var(--text-muted);
}

/* ===== TREE CANVAS AREA ===== */
.tree-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 520 / 360;
}

.tree-wrap canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#flower-canvas {
  touch-action: manipulation;
}

#flower-canvas.planting {
  cursor: crosshair;
}

/* ===== CTA ===== */
.cta-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.cta-text {
  font-size: 15px;
  color: var(--text-primary);
  text-shadow: 0 0 18px rgba(160, 200, 255, 0.55);
  letter-spacing: .04em;
}

.plant-btn {
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 24px;
  padding: 11px 32px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  font-family: var(--font);
}

.plant-btn:hover  { opacity: .88; }
.plant-btn:active { transform: scale(.97); }

.already-planted {
  font-size: 14px;
  color: var(--text-muted);
  background: rgba(5, 14, 50, .55);
  border: .5px solid var(--card-border);
  border-radius: 20px;
  padding: 12px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.flower-days {
  font-size: 12px;
  color: #90c0f0;
  letter-spacing: .05em;
  min-height: 0;
}

.share-btn {
  background: none;
  border: 1px solid rgba(80, 130, 220, .35);
  border-radius: 20px;
  padding: 7px 20px;
  font-size: 13px;
  color: #90c0f0;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color .15s, background .15s;
}

.share-btn:hover {
  border-color: rgba(120, 170, 255, .6);
  background: rgba(80, 130, 220, .12);
}

/* ===== SHARE MODAL ===== */
.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 28, .70);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.share-modal.hidden { display: none; }

.share-modal-box {
  background: rgba(8, 18, 58, .95);
  border: .5px solid rgba(80, 130, 220, .25);
  border-radius: 20px;
  padding: 1.25rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.share-preview {
  width: 100%;
  border-radius: 12px;
  display: block;
}

.share-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-download {
  flex: 1;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 11px 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-family: var(--font);
}

.btn-x-share {
  flex: 1;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 11px 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}

.btn-share-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  padding: 4px;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 14px;
  border: .5px solid var(--card-border);
  padding: 18px 12px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stat-num {
  display: block;
  font-size: 32px;
  font-weight: 500;
  color: #a8c8f0;
  margin-bottom: 6px;
  line-height: 1;
}

.stat-card.bibimbap .stat-num {
  color: var(--orange-light);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.65;
}

.bibi-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 0 auto 6px;
  border: 2px solid rgba(196, 124, 42, .25);
}

.dm-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  background: rgba(5, 12, 42, .50);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: .5px solid rgba(80, 130, 220, .18);
  border-radius: 12px;
  padding: 10px 16px;
}

.dm-note a {
  color: #90c0f0;
  text-decoration: none;
  font-weight: 500;
}

.dm-note a:hover {
  text-decoration: underline;
}

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

@media (min-width: 520px) {
  .modal-overlay {
    align-items: center;
    padding: 1.5rem;
  }
}

.modal-box {
  background: rgba(8, 18, 58, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: .5px solid rgba(80, 130, 220, .25);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1.25rem 2.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
}

@media (min-width: 520px) {
  .modal-box {
    border-radius: 20px;
  }
}

.modal-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.25rem;
}

.message-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.msg-btn {
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1.5px solid rgba(80, 130, 220, .28);
  background: rgba(10, 22, 68, .60);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  line-height: 1.4;
  transition: border-color .1s, background .1s;
}

.msg-btn:hover {
  border-color: rgba(120, 170, 255, .50);
  background: rgba(20, 40, 100, .60);
}

.msg-btn.selected {
  border-color: var(--orange);
  background: rgba(60, 30, 5, .55);
  color: var(--orange-light);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.btn-confirm {
  width: 100%;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 24px;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .15s, transform .1s;
}

.btn-confirm:hover  { opacity: .88; }
.btn-confirm:active { transform: scale(.97); }

.btn-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  font-family: var(--font);
}

.btn-skip:hover { color: var(--text-primary); }

/* ===== BLOOM TOAST ===== */
.bloom-toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 18, 58, .92);
  border: .5px solid rgba(80, 130, 220, .30);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 14px 26px;
  text-align: center;
  font-size: 14px;
  line-height: 1.65;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  animation: toastIn .3s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== MILESTONE TOAST ===== */
.milestone-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(8, 18, 58, .96);
  border: 1px solid rgba(255, 184, 48, .45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 28px;
  padding: 2rem 3rem 1.75rem;
  text-align: center;
  z-index: 400;
  cursor: pointer;
  box-shadow:
    0 0 48px rgba(255, 184, 48, .22),
    0 0 90px rgba(255, 184, 48, .10);
  animation: milestoneIn .45s cubic-bezier(.34, 1.56, .64, 1);
}

.milestone-toast.hidden { display: none; }

.milestone-icon { font-size: 40px; display: block; margin-bottom: .5rem; }
.milestone-num  { font-size: 52px; font-weight: 500; color: var(--orange-light); display: block; line-height: 1.1; }
.milestone-msg  { font-size: 14px; color: var(--text-primary); margin-top: .6rem; line-height: 1.9; }
.milestone-tap  { font-size: 11px; color: var(--text-hint); margin-top: 1rem; }

@keyframes milestoneIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.78); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ===== FLOWER MESSAGE POPUP ===== */
.flower-popup {
  position: fixed;
  background: rgba(8, 18, 58, .94);
  border: .5px solid rgba(120, 170, 255, .32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 10px 16px 12px;
  max-width: 220px;
  text-align: center;
  z-index: 150;
  pointer-events: none;
  animation: toastIn .2s ease-out;
}

.flower-popup-icon {
  display: block;
  font-size: 18px;
  margin-bottom: 5px;
}

.flower-popup-msg {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ===== SITE NOTE ===== */
.site-note {
  font-size: 11px;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.8;
  text-shadow: 0 0 14px rgba(80, 120, 220, 0.7);
}

.guideline-link {
  color: #90c0f0;
  text-decoration: none;
}

.guideline-link:hover {
  text-decoration: underline;
}

/* ===== SPARKLE CANVAS ===== */
#sparkle-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ===== UTILITY ===== */
#app { position: relative; z-index: 1; }
.hidden { display: none !important; }
