/* 나의 수호동물 — 밤의 숲. 짙은 남색 바탕에 별, 달을 고르면 뒤집히는 카드 */

:root {
  --bg-1: #0c1627;
  --bg-2: #16293f;
  --card: #1c3047;
  --card-2: #24405c;
  --text: #eef3f8;
  --muted: #9fb0c3;
  --amber: #ffc86b;
  --amber-2: #f4a83a;
  --mint: #8fe3c8;
  --line: rgba(255, 255, 255, 0.12);
  --flip-ms: 800ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 70%);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* 별: script.js 가 점을 찍습니다 */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.stars i {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: var(--a, 0.5);
  animation: blink var(--d, 4s) ease-in-out infinite alternate;
}

@keyframes blink {
  from {
    opacity: calc(var(--a, 0.5) * 0.3);
  }
  to {
    opacity: var(--a, 0.5);
  }
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: max(36px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom));
}

@media (min-width: 820px) {
  .wrap {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 80px;
  }
}

/* ── 머리 ──────────────────────────────── */

.top {
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--mint);
}

.top h1 {
  margin: 0;
  font-size: clamp(30px, 7vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sub {
  margin: 8px auto 0;
  max-width: 34ch;
  font-size: 14px;
  color: var(--muted);
  word-break: keep-all;
}

/* ── 달 칩 ─────────────────────────────── */

.months {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 26px 0 22px;
}

@media (max-width: 400px) {
  .months {
    grid-template-columns: repeat(4, 1fr);
  }
}

.month {
  padding: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s,
    border-color 0.2s;
}

.month:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

.month[aria-pressed='true'] {
  border-color: var(--amber);
  background: var(--amber);
  color: #1b1405;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 200, 107, 0.25);
}

/* ── 카드 ──────────────────────────────── */

.scene {
  perspective: 1400px;
}

.card {
  position: relative;
  height: 400px;
  transform-style: preserve-3d;
  transition: transform var(--flip-ms) cubic-bezier(0.3, 0.7, 0.2, 1);
}

.card.flipped {
  transform: rotateY(180deg);
}

/* 다른 달로 바꿀 때: 잠깐 작아졌다가 다시 커집니다 */
.card.swap {
  animation: swap 0.5s ease-in-out;
}

@keyframes swap {
  50% {
    transform: rotateY(180deg) scale(0.92);
  }
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(160deg, var(--card-2), var(--card));
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 30px 60px rgba(0, 0, 0, 0.4);
}

.front {
  text-align: center;
}

.moon {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6d8, #f1dca3 60%, #c9b27a);
  box-shadow:
    0 0 40px rgba(255, 240, 200, 0.35),
    inset -18px -12px 0 rgba(0, 0, 0, 0.08);
  animation: hover 4s ease-in-out infinite;
}

@keyframes hover {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.front-text {
  margin: 26px 0 0;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.7;
}

.back {
  transform: rotateY(180deg);
  text-align: center;
}

.month-tag {
  margin: 0 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--mint);
}

.ring {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 107, 0.22), transparent 70%);
  box-shadow: inset 0 0 0 2px rgba(255, 200, 107, 0.35);
}

.emoji {
  font-size: 84px;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}

.card.flipped .emoji {
  animation: pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.4) 0.5s both;
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.name {
  margin: 14px 0 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.title {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--amber);
}

.traits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.traits li {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

/* ── 오늘의 메시지 ──────────────────────── */

.today {
  margin-top: 18px;
  padding: 22px 22px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px var(--line);
  animation: rise 0.5s ease-out both;
}

.today[hidden] {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.today-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.stars-row {
  letter-spacing: 2px;
  color: var(--amber);
}

.stars-row .off {
  opacity: 0.25;
}

.message {
  margin: 12px 0 16px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.6;
  word-break: keep-all;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}

@media (max-width: 400px) {
  .facts {
    grid-template-columns: 1fr 1fr;
  }
}

.facts div {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.facts dt {
  font-size: 11px;
  color: var(--muted);
}

.facts dd {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--mint);
  word-break: keep-all;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 13px 16px;
  border: 0;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  transition:
    transform 0.15s,
    filter 0.15s;
}

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

.btn-main {
  background: linear-gradient(135deg, var(--amber), var(--amber-2));
  color: #1b1405;
}

.btn-main:hover {
  filter: brightness(1.06);
}

.btn-sub {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-sub:hover {
  background: rgba(255, 255, 255, 0.14);
}

.note {
  margin: 22px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  z-index: 3;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--mint);
  color: #0b2a22;
  font-size: 13px;
  font-weight: 700;
  transform: translate(-50%, -20px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s,
    transform 0.25s;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 480px) {
  .card {
    height: 380px;
  }

  .emoji {
    font-size: 76px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .moon,
  .stars i,
  .card.swap,
  .card.flipped .emoji,
  .today {
    animation: none;
  }

  .card {
    transition-duration: 0.01ms;
  }
}
