/* =========================================================
   행운의 색깔 - 스타일
   배경색(--bg)은 app.js가 바꾸고, 배경이 어두우면
   <html data-tone="dark">로 바뀌어 글자가 흰색이 됩니다.
   ========================================================= */

:root {
  --bg: #F5F2EC;
  --fg: #1C1A21;
  --fg-soft: rgba(28, 26, 33, 0.64);
  --surface: rgba(255, 255, 255, 0.6);
  --line: rgba(28, 26, 33, 0.16);
  --shadow: 0 14px 34px rgba(28, 26, 33, 0.18);
  --accent: #26306E;
  --font: system-ui, -apple-system, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "Roboto Mono", "Droid Sans Mono", Consolas, monospace;
  --ring: conic-gradient(#E8304A, #FF9A1F, #FFE14D, #9BD34A, #3FA34D, #7FE5C8,
                         #0E9F9A, #7EC8F2, #1F6FD6, #B9A3E3, #7B3FBF, #D6247E, #E8304A);
}

:root[data-tone="dark"] {
  --fg: #FFFFFF;
  --fg-soft: rgba(255, 255, 255, 0.8);
  --surface: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.34);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html { background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

[hidden] { display: none !important; }

p { margin: 0; }

button { font: inherit; cursor: pointer; }

/* 폭죽 캔버스: 화면 전체를 덮지만 터치는 통과 */
#fireworks {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 20px calc(env(safe-area-inset-bottom) + 16px);
}

/* ---------- 생년월일 입력 화면 ---------- */

#setup {
  display: flex;
  align-items: center;
  justify-content: center;
}

.setup-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.logo {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--ring);
  box-shadow: var(--shadow);
}

.logo::after {
  content: "";
  position: absolute;
  inset: 27%;
  border-radius: 50%;
  background: var(--bg);
}

h1 {
  margin: 0 0 10px;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lead {
  margin-bottom: 32px;
  color: var(--fg-soft);
  line-height: 1.6;
}

#setup-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

label {
  font-size: 0.95rem;
  font-weight: 700;
}

input[type="date"] {
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #FFFFFF;
  color: #1C1A21;
  font: inherit;
  font-size: 1.15rem;
}

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

.tip {
  color: var(--fg-soft);
  font-size: 0.85rem;
  line-height: 1.5;
}

.btn-primary {
  min-height: 56px;
  margin-top: 10px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 1.1rem;
  font-weight: 800;
}

.btn-primary:disabled { opacity: 0.38; cursor: default; }

.btn-text {
  min-height: 48px;
  border: 0;
  background: none;
  color: var(--fg-soft);
  font-weight: 700;
}

.note {
  margin-top: 24px;
  color: var(--fg-soft);
  font-size: 0.85rem;
}

/* ---------- 메인 화면 ---------- */

#main {
  display: grid;
  grid-template-rows: auto 1fr auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.today {
  color: var(--fg-soft);
  font-size: 1rem;
  font-weight: 700;
}

.upper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 20px;
  text-align: center;
}

.hint {
  color: var(--fg-soft);
  font-size: 1.05rem;
  font-weight: 600;
  word-break: keep-all;
}

.result-line {
  font-size: clamp(1.3rem, 6vw, 1.7rem);
  font-weight: 700;
}

.result-name {
  margin: 2px 0 14px;
  font-size: clamp(2.4rem, min(14vw, 9vh), 4.5rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  word-break: keep-all;
}

.result-hex {
  display: inline-block;
  padding: 6px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.result.show { animation: pop 0.65s cubic-bezier(0.2, 1.4, 0.4, 1) both; }

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.7); }
  to   { opacity: 1; transform: none; }
}

/* 가운데 큰 버튼 + 무지개 테두리 */
.draw-wrap {
  position: relative;
  justify-self: center;
  width: min(66vw, 250px, 36vh);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.draw-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ring);
  animation: turn 16s linear infinite;
}

.draw-btn {
  position: absolute;
  inset: 8px;
  padding: 0 24px;
  border: 0;
  border-radius: 50%;
  background: #FFFFFF;
  color: #1C1A21;
  font-size: clamp(1.15rem, 5.4vw, 1.4rem);
  font-weight: 800;
  line-height: 1.4;
  white-space: pre-line;
  word-break: keep-all;
  transition: transform 0.15s;
}

.draw-btn:active { transform: scale(0.96); }
.draw-btn:disabled { cursor: default; }

.is-spinning .draw-wrap::before { animation-duration: 0.7s; }

@keyframes turn { to { transform: rotate(360deg); } }

.lower {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 20px;
  text-align: center;
}

.after-note {
  color: var(--fg-soft);
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-reenter {
  min-height: 46px;
  padding: 0 22px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 700;
}

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

@media (prefers-reduced-motion: reduce) {
  .draw-wrap::before { animation: none; }
}
