:root {
  --gold: #e8bc60;
  --gold-2: #ffe0a0;
  --gold-3: #fff4d6;
  --gold-dk: #b07c30;
  --cream: #fff8ec;
  --cream-2: #faf0dc;
  --ink: #2a201c;
  --ink-2: #40322a;
  --mute: #6e5a46;
  --panel: rgba(255, 250, 240, 0.92);
  --panel-stroke: rgba(220, 190, 130, 0.72);
  --shadow: 0 10px 28px rgba(30, 20, 10, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1524;
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}
button, input { font: inherit; }
input { user-select: text; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  z-index: 0;
}

.hud {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(400px, 100%);
  padding: calc(18px + var(--safe-top)) 20px 0;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
body.is-sealed .hud { opacity: 0; pointer-events: none; }

.brand-title {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 650;
  font-size: 34px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 250, 240, 0.35), 0 1px 8px rgba(255, 250, 240, 0.25);
}
.brand-year {
  margin: 4px 0 0;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--gold);
}
.brand-ornament {
  width: 148px;
  height: 1px;
  margin: 10px auto 0;
  background:
    linear-gradient(90deg, transparent 0, var(--gold) 0 42%, transparent 42%, transparent 58%, var(--gold) 58%, var(--gold) 100%);
  position: relative;
}
.brand-ornament::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--gold);
}
.brand-place {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}

body[data-lighting="night"] .brand-title {
  color: var(--cream);
  text-shadow: 0 1px 10px rgba(16, 12, 28, 0.55);
}
body[data-lighting="night"] .brand-place { color: #e6dcc8; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 6px 0;
  padding: 6px 14px;
  min-height: 26px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  box-shadow: 0 6px 16px rgba(30, 20, 10, 0.12);
  color: var(--ink);
  font-family: Nunito, Outfit, sans-serif;
  font-weight: 650;
  font-size: 12px;
  pointer-events: none;
}
.pill.meta {
  font-family: Outfit, sans-serif;
  font-weight: 500;
  font-size: 11px;
  color: var(--mute);
  margin-top: 8px;
}

.tod-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  position: relative;
  flex: 0 0 16px;
}
.tod-icon[data-icon="sun"] {
  background: radial-gradient(circle at 50% 50%, var(--gold) 0 42%, transparent 44%);
}
.tod-icon[data-icon="sun"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--gold), var(--gold)) center top / 1.5px 3px no-repeat,
    linear-gradient(var(--gold), var(--gold)) center bottom / 1.5px 3px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left center / 3px 1.5px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right center / 3px 1.5px no-repeat;
}
.tod-icon[data-icon="dusk"] {
  background:
    radial-gradient(circle at 50% 58%, var(--gold) 0 38%, transparent 40%),
    linear-gradient(var(--gold), var(--gold)) 50% 78% / 14px 1.5px no-repeat;
}
.tod-icon[data-icon="moon"] {
  background: radial-gradient(circle at 42% 50%, var(--gold) 0 46%, transparent 48%);
}
.tod-icon[data-icon="moon"]::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cream);
  top: 1px;
  left: 6px;
}

.hello {
  margin: 12px 12px 0;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  text-shadow: 0 1px 8px rgba(255, 250, 240, 0.4);
}
body[data-lighting="night"] .hello {
  color: var(--cream);
  text-shadow: 0 1px 10px rgba(16, 12, 28, 0.55);
}

.wishbox {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, calc(100% - 8px));
  margin: 14px auto 0;
  padding: 10px 16px 10px 14px;
  min-height: 52px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  box-shadow: var(--shadow);
  pointer-events: auto;
  text-align: left;
}
.wishbox.is-shake { animation: shake 0.42s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.wish-star {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.wish-prefix {
  flex: 0 0 auto;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
  white-space: nowrap;
}
#wish {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 18px;
  padding: 0;
}
#wish::placeholder { color: rgba(42, 32, 28, 0.38); }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bot));
  transform: translateX(-50%);
  width: min(360px, calc(100% - 32px));
  margin: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--cream);
  text-shadow: 0 1px 8px rgba(20, 14, 8, 0.55);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
body[data-lighting="morning"] .hint,
body[data-lighting="golden"] .hint {
  color: var(--ink-2);
  text-shadow: 0 1px 8px rgba(255, 248, 236, 0.55);
}
body.is-sealed .hint,
body.is-dragging .hint { opacity: 0; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: rgba(20, 14, 24, 0.18);
  z-index: 5;
}
.overlay[hidden] { display: none; }

.card-panel {
  width: min(300px, 100%);
  padding: 28px 22px 20px;
  border-radius: 22px;
  background: rgba(255, 250, 236, 0.96);
  border: 2px solid rgba(214, 180, 110, 0.82);
  box-shadow: 0 18px 40px rgba(20, 12, 8, 0.28);
  text-align: center;
  animation: pop 0.48s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}
@keyframes pop {
  from { transform: scale(0.86); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.card-emblem {
  width: 22px;
  height: 22px;
  margin: 0 auto 8px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 8px rgba(232, 188, 96, 0.55));
}
.card-panel h2 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 620;
  font-size: 24px;
  color: var(--ink);
}
.card-wish {
  margin: 10px 4px 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink-2);
}
.card-meta {
  margin: 8px 0 0;
  font-size: 11px;
  color: #6e5a46;
}
.card-foot {
  margin: 14px 0 0;
  font-size: 11px;
  color: #786450;
}

.btn {
  display: block;
  width: min(220px, 100%);
  margin: 12px auto 0;
  height: 36px;
  border-radius: 18px;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.btn.solid {
  background: var(--gold);
  color: var(--ink);
}
.btn.solid:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 2px solid var(--gold-dk);
}
.btn:active { transform: translateY(1px); }
.text-link {
  display: inline-block;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--mute);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.friend-panel { width: min(320px, 100%); }
.friend-lead {
  margin: 10px 6px 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--mute);
}
.friend-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--mute);
  text-align: left;
}
#friend-name {
  display: block;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-stroke);
  background: #fffdf8;
  color: var(--ink);
}
.friend-status {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--gold-dk);
}

@media (max-height: 700px) {
  .brand-title { font-size: 28px; }
  .brand-ornament { display: none; }
  .wishbox { min-height: 46px; margin-top: 10px; }
}
@media (min-width: 900px) {
  .brand-title { font-size: 38px; }
}
