:root {
  color-scheme: dark;
  --bg: #090d18;
  --bg-2: #141b2e;
  --ink: #f6f3ec;
  --muted: #b7c0d4;
  --line: rgba(246, 243, 236, 0.14);
  --sand: #e4d2b0;
  --sand-ink: #24180f;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -10%, rgba(120, 146, 210, 0.18), transparent 55%),
    radial-gradient(700px 380px at 110% 0%, rgba(228, 210, 176, 0.1), transparent 46%),
    var(--bg);
  line-height: 1.55;
}

a { color: var(--sand); }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

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

.app {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 0 calc(36px + env(safe-area-inset-bottom));
}

.top { margin-bottom: 22px; }

.brand-mark {
  margin: 0 0 4px;
  color: var(--sand);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
}

.brand-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

h1, h2, h3 { font-weight: 720; letter-spacing: -0.03em; line-height: 1.25; }

h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); }

h2 { margin: 0 0 8px; font-size: 1.45rem; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  color: var(--sand-ink);
  background: var(--sand);
  border-color: var(--sand);
}

.lede, .status, .card-date, .seed-note {
  color: var(--muted);
}

.lede { margin: 0 0 8px; }

.status { min-height: 1.4em; margin: 0 0 14px; }

.seed-note {
  margin: 0 0 12px;
  font-size: 0.86rem;
}

.coin-grid, .gallery-grid, .figure-grid {
  display: grid;
  gap: 12px;
}

.coin-grid { grid-template-columns: 1fr; }

.gallery-grid, .figure-grid { grid-template-columns: 1fr 1fr; }

.coin-btn, .gallery-card, .btn-primary, .btn-ghost {
  min-height: 48px;
}

.coin-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 27, 46, 0.92);
  text-align: left;
  box-shadow: var(--shadow);
}

.coin-btn.is-recent { border-color: rgba(228, 210, 176, 0.7); }

.thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: #101628;
}

.coin-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.coin-name, .coin-symbol {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coin-name { font-weight: 700; }

.coin-symbol { color: var(--muted); font-size: 0.92rem; }

.recent-badge {
  width: fit-content;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--sand);
  color: var(--sand-ink);
  font-size: 0.75rem;
  font-weight: 700;
}

#view-card { width: min(100%, 440px); min-width: 0; }

.back-row { margin: 0 0 12px; }

.card-date { margin: 0 0 10px; }

.card-info {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0 0 12px;
}

.card-info[hidden] { display: none; }

.card-age,
.card-bloom {
  margin: 0;
  overflow-wrap: anywhere;
}

.card-age.is-birthday { color: hsl(45, 90%, 70%); }

.char-tag {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--sand);
  overflow-wrap: anywhere;
}

.char-tag[hidden] { display: none; }

.canvas-wrap { position: relative; }

.canvas-wrap canvas, .figure-grid canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  display: block;
  border-radius: 22px;
  background: #101628;
}

.draw-status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: 0;
  text-align: center;
  color: #f6f3ec;
  text-shadow: 0 1px 8px #000;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.btn-primary, .btn-ghost {
  border-radius: 999px;
  padding: 12px 16px;
}

.btn-primary {
  border: 0;
  background: var(--sand);
  color: var(--sand-ink);
  font-weight: 760;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

button:disabled { opacity: 0.45; cursor: default; }

.ad-slot[hidden] { display: none !important; }

.ad-slot.is-on {
  margin-top: 24px;
  margin-bottom: 24px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

#view-card .ad-slot.is-on { margin-top: 48px; margin-bottom: 24px; }

#flower-talk { scroll-margin-top: 16px; }

#flower-talk[hidden] { display: none; }

#flower-talk:not([hidden]) {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  margin-top: 24px;
  padding: 18px;
  border: 1px solid rgba(228, 210, 176, 0.3);
  border-top: 3px solid var(--sand);
  border-radius: 16px;
  background: #101628;
}

.flower-jump[hidden] { display: none; }

.flower-jump {
  margin: 14px 0 0;
  min-width: 0;
  max-width: 100%;
  text-align: center;
}

.flower-jump a {
  display: inline-block;
  max-width: 100%;
  color: var(--sand);
  font-size: 0.86rem;
  font-weight: 680;
  line-height: 1.45;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.flower-head {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.flower-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.flower-heading {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.flower-sub {
  margin: 4px 0 0;
  color: #d5dbe8;
  font-size: 0.84rem;
  line-height: 1.45;
}

.flower-badge {
  flex: 0 1 auto;
  max-width: 100%;
  margin: 0 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--sand);
  color: var(--sand-ink);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.35;
  text-align: center;
}

.flower-reactions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.flower-chip, .flower-like, .flower-report, .flower-submit {
  border-radius: 999px;
  max-width: 100%;
}

.flower-chip {
  min-height: 44px;
  padding: 8px 6px;
  border: 1px solid rgba(228, 210, 176, 0.55);
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
}

.flower-chip.is-on, .flower-like.is-on {
  border-color: var(--sand);
  background: var(--sand);
  color: var(--sand-ink);
  font-weight: 760;
}

.flower-done, .flower-hint, .flower-legal, .flower-error, .flower-name {
  margin: 0;
  overflow-wrap: anywhere;
}

.flower-done { color: var(--ink); font-size: 0.92rem; }

.flower-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 14px;
  border: 1px solid rgba(228, 210, 176, 0.28);
  border-radius: 14px;
  background: #1b2642;
}

.flower-form input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  border: 1px solid rgba(228, 210, 176, 0.35);
  border-radius: 12px;
  padding: 8px 10px;
  background: #101628;
  color: var(--ink);
  font-size: 0.88rem;
}

.flower-form input::placeholder { color: #d5dbe8; opacity: 1; }

.flower-submit {
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  background: var(--sand);
  color: var(--sand-ink);
  font-size: 0.95rem;
  font-weight: 760;
}

.flower-names {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.flower-bubble {
  position: relative;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid rgba(228, 210, 176, 0.28);
  border-radius: 16px 16px 16px 6px;
  background: #1b2642;
}

.flower-bubble::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -6px;
  width: 12px;
  height: 7px;
  background: #1b2642;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.flower-name {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 720;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.flower-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  max-width: 100%;
  margin-top: 6px;
}

.flower-nick, .flower-likes {
  color: #d5dbe8;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.flower-like, .flower-report {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid rgba(228, 210, 176, 0.45);
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
}

.flower-foot {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(228, 210, 176, 0.22);
}

.flower-hint, .flower-legal, .flower-error {
  color: #d5dbe8;
  font-size: 0.78rem;
  line-height: 1.45;
}

.flower-error { color: #f6d2cb; }

@media (min-width: 640px) {
  .flower-form {
    grid-template-columns: minmax(9.5rem, 1.7fr) minmax(5rem, 0.85fr) auto;
    align-items: center;
  }

  .flower-submit {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

@media (min-width: 840px) {
  .flower-reactions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.gallery-flower {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.ad-frame {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.ad-frame .adsbygoogle {
  display: block;
  width: 100%;
  max-width: 100%;
}

.site-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer p { margin: 6px 0; }

.visitor-count {
  font-size: 0.72rem;
  opacity: 0.72;
}

.prose {
  display: grid;
  gap: 12px;
  color: var(--muted);
  max-width: 72ch;
}

.prose h2 { color: var(--ink); margin-top: 12px; }

.prose ul { margin: 0; padding-left: 1.2em; }

.prose li { margin: 4px 0; }

.prose strong { color: var(--ink); font-weight: 680; }

figure { margin: 0; }

figcaption { margin-top: 8px; color: var(--muted); font-size: 0.92rem; }

.date-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 14px;
  padding: 2px 2px 6px;
}

.date-chip {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
}

.date-chip.is-on {
  border-color: transparent;
  background: var(--sand);
  color: var(--sand-ink);
  font-weight: 760;
}

.date-chip:disabled { opacity: 0.35; }

.gallery-card {
  display: grid;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.gallery-frame {
  position: relative;
  display: block;
  min-width: 0;
}

.gallery-card canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  border-radius: 18px;
  background: #101628;
}

.bday-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.95rem;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.65));
}

.gallery-name { font-weight: 700; }

.gallery-symbol { color: var(--muted); font-size: 0.92rem; font-weight: 600; }

.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(5, 8, 16, 0.92);
}

.save-overlay p {
  margin: 0;
  width: 100%;
  max-width: 100%;
  color: #f6f3ec;
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.save-overlay img {
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  max-width: 100%;
  max-height: 80vh;
  max-height: 80dvh;
  object-fit: contain;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

.save-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(246, 243, 236, 0.14);
  color: #f6f3ec;
  font-size: 1.6rem;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  z-index: 5;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--sand);
  color: var(--sand-ink);
  text-align: center;
  box-shadow: var(--shadow);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.test-list { display: grid; gap: 8px; padding: 0; list-style: none; }

.test-list li {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-2);
}

.test-list .ok { color: var(--sand); }

.test-list .bad { color: #f0c9c2; }

.blank-email { display: inline-block; min-width: 8em; border-bottom: 1px solid var(--line); }

@media (min-width: 720px) {
  .coin-grid { grid-template-columns: 1fr 1fr; }
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
  .figure-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1040px) {
  .coin-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.guide {
  display: grid;
  gap: 28px;
  min-width: 0;
}

.guide-block { display: grid; gap: 12px; min-width: 0; }

.guide h2 { margin: 0; }

.guide h3 { margin: 0 0 4px; font-size: 1.05rem; }

.guide p { margin: 0; }

.legend-layout {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.legend-stage { min-width: 0; }

.legend-frame {
  position: relative;
  width: min(100%, 320px);
  margin: 0 auto;
}

.legend-frame canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: #101628;
}

.pins { position: absolute; inset: 0; pointer-events: none; }

.pin {
  position: absolute;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sand);
  color: var(--sand-ink);
  font-size: 0.85rem;
  font-weight: 760;
  transform: translate(-50%, -50%);
}

.pin-1 { top: 14%; left: 28%; }
.pin-2 { top: 79%; left: 16%; }
.pin-3 { top: 83%; left: 16%; }
.pin-4 { top: 86%; left: 16%; }
.pin-5 { top: 42%; left: 50%; }
.pin-6 { top: 90%; left: 16%; }
.pin-7 { top: 93%; left: 16%; }

.legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.legend-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 27, 46, 0.72);
}

.read-table, .read-row, .thumb-pair, .energy-row { min-width: 0; }

.read-row {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.thumb-pair, .energy-row {
  display: grid;
  gap: 8px;
}

.thumb-pair { grid-template-columns: repeat(2, minmax(0, 160px)); }

.energy-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.thumb-pair canvas,
.energy-row canvas,
.today-figure canvas {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  aspect-ratio: 160 / 284;
  border-radius: 16px;
  background: #101628;
}

.guide figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.guide select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  padding: 8px 12px;
}

.pick-label { font-weight: 700; }

.today-figure { width: min(100%, 160px); margin: 0; }

.tag-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(20, 27, 46, 0.72);
}

a.guide-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.qa { display: grid; gap: 12px; margin: 0; }

.qa dt { font-weight: 760; color: var(--ink); }

.qa dd { margin: 4px 0 0; }

@media (min-width: 720px) {
  .legend-layout { grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
  .read-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}
