:root {
  --ink: #1b1f2a;
  --paper: #f7f3ea;
  --card: #ffffff;
  --night: #0d3327;
  --pine: #144a37;
  --pine-deep: #0a2a1f;
  --cranberry: #a3313c;
  --cranberry-deep: #7f2530;
  --gold: #bd9339;
  --gold-soft: #f0e1c2;
  --line: #e4dfd0;
  --muted: #6a6a63;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  line-height: 1.55;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.site-header {
  text-align: center;
  margin: 0 -20px 32px;
  padding: 52px 20px 40px;
  background: var(--pine-deep);
  background-image:
    radial-gradient(circle at 18% 30%, rgba(255,255,255,0.06) 0, transparent 55%),
    radial-gradient(circle at 82% 70%, rgba(255,255,255,0.05) 0, transparent 50%);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}

.site-header h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 2.4rem;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  position: relative;
}

.subtitle {
  margin: 0;
  color: #cfe3d8;
  font-size: 1rem;
  position: relative;
}

.snow {
  position: absolute;
  top: -10px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
  animation: snow-fall linear infinite;
  pointer-events: none;
}

@keyframes snow-fall {
  from { transform: translateY(-10px) translateX(0); opacity: 0.9; }
  to { transform: translateY(160px) translateX(12px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .snow { animation: none; display: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--cranberry);
  border-radius: 18px;
  padding: 40px;
  box-shadow: 0 1px 2px rgba(16, 24, 43, 0.04);
}

.step h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--night);
  margin: 0 0 8px;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 24px;
  max-width: 46ch;
}

.hidden { display: none; }

/* Step 1 */
#name-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

#name-input {
  flex: 1;
  min-width: 200px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
}

#name-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  background: #fff;
}

.btn-primary {
  padding: 13px 24px;
  background: var(--night);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--cranberry); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  padding: 10px 18px;
  background: transparent;
  color: var(--night);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.btn-ghost:hover { border-color: var(--gold); }

.identifier-box {
  display: inline-block;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  color: var(--night);
  background: var(--gold-soft);
  border: 1px dashed var(--gold);
  border-radius: 10px;
  padding: 12px 22px;
  margin-bottom: 24px;
}

.view-ranking-link {
  display: block;
  margin: 18px auto 0;
  border: none;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.view-ranking-link:hover { color: var(--cranberry); }

/* Step 2: Calendar */
.calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.selected-count {
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

#count-number {
  font-weight: 600;
  color: var(--night);
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 8px 0 18px;
}

.month-nav button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--night);
}

.month-nav button:hover { border-color: var(--gold); }

#month-label {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  min-width: 160px;
  text-align: center;
  color: var(--night);
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--ink);
  background: var(--paper);
  transition: background 0.12s ease, color 0.12s ease;
}

.day-cell:hover { border-color: var(--gold); }

.day-cell.outside {
  visibility: hidden;
  cursor: default;
}

.day-cell.selected {
  background: var(--cranberry);
  color: #fff;
}

.day-cell.selected:hover { border-color: var(--cranberry-deep); }

.step-actions {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.save-status {
  font-size: 0.9rem;
  color: var(--muted);
}

.save-status.error { color: #a83c3c; }

/* Step 3: Ranking */
.ranking-box {
  border: 1px solid var(--line);
  border-left: 3px solid var(--pine);
  border-radius: 14px;
  padding: 24px;
  background: var(--paper);
  margin-bottom: 20px;
}

.ranking-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ranking-title-row h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0;
  color: var(--night);
}

.participant-count {
  margin: 6px 0 16px;
  font-size: 0.88rem;
  color: var(--muted);
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}

.rank-badge {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--gold);
  min-width: 24px;
}

.rank-date {
  flex: 1;
  font-size: 0.95rem;
  color: var(--ink);
}

.rank-votes {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.empty-ranking {
  color: var(--muted);
  font-size: 0.9rem;
}

.edit-btn { display: block; margin: 0 auto; }

.site-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .card { padding: 26px; }
  .site-header h1 { font-size: 2rem; }
}
