/* ---------------------------------------------------------------------------
   Rose Noir — a romantic dark theme
   Blush #f7d4e4 · Rose #d76a93 · Mauve #c7a4b6 · Crisp White #fafafa
   over deep candlelit-plum surfaces.
--------------------------------------------------------------------------- */

:root {
  --blush: #f7d4e4;
  --rose: #a54a6f;
  --rose-bright: #d987ac;
  --mauve: #c7a4b6;
  --white: #fafafa;

  --bg: #1a0c18;
  --bg-raised: #241124;
  --panel: #2c152e;
  --border: #4d2a4c;

  --font-sans: "DejaVu Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--blush);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* --- candlelit haze backdrop ------------------------------------------------ */

.haze {
  position: fixed;
  inset: -20% -10%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 20% 10%, rgba(165, 74, 111, 0.35), transparent 70%),
    radial-gradient(50% 35% at 80% 5%, rgba(217, 135, 172, 0.2), transparent 70%),
    radial-gradient(40% 30% at 55% 20%, rgba(247, 212, 228, 0.07), transparent 70%),
    radial-gradient(45% 35% at 70% 85%, rgba(240, 180, 120, 0.06), transparent 70%);
  animation: haze-drift 26s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes haze-drift {
  from {
    transform: translateX(-3%) translateY(-1%);
  }
  to {
    transform: translateX(3%) translateY(2%);
  }
}

/* --- skip link --------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--rose);
  color: var(--white);
  border-radius: 0 0 8px 8px;
  text-decoration: none;
}

.skip-link:focus-visible {
  top: 0;
}

/* --- header / footer ----------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  padding-left: max(clamp(1rem, 4vw, 3rem), env(safe-area-inset-left));
  padding-right: max(clamp(1rem, 4vw, 3rem), env(safe-area-inset-right));
}

.wordmark {
  color: var(--white);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.header-tag {
  color: var(--mauve);
  font-size: 0.85rem;
}

.site-footer {
  padding: 2rem clamp(1rem, 4vw, 3rem);
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  color: var(--mauve);
  font-size: 0.85rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

/* --- layout --------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 980px;
  margin: 0 auto;
  padding: 0.5rem clamp(1rem, 4vw, 3rem) 2rem;
}

@media (min-width: 820px) {
  .layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: start;
  }
}

/* --- stage ------------------------------------------------------------------------ */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stage h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  color: var(--white);
  text-wrap: balance;
}

.counter {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.counter-number {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.counter-label {
  color: var(--mauve);
  font-size: 1.1rem;
}

.rates {
  margin: 0.25rem 0 1.5rem;
  color: var(--mauve);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.clicker {
  padding: 1.5rem;
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 120ms ease, border-color 150ms ease;
}

.clicker img {
  display: block;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(217, 135, 172, 0.5));
  pointer-events: none;
}

.clicker:hover {
  border-color: var(--rose-bright);
  transform: scale(1.03);
}

.clicker:active {
  transform: scale(0.96);
}

.clicker:focus-visible {
  outline: 3px solid var(--rose-bright);
  outline-offset: 4px;
}

/* --- particles ----------------------------------------------------------------------- */

.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  bottom: 35%;
  font-variant-numeric: tabular-nums;
  animation: particle-rise 1100ms ease-out forwards;
  will-change: transform, opacity;
}

.particle-amount {
  color: var(--white);
  font-weight: 700;
  font-size: 1.2rem;
  text-shadow: 0 0 8px rgba(217, 135, 172, 0.8);
}

.particle-heart {
  color: var(--rose-bright);
  font-size: 1.6rem;
  text-shadow: 0 0 10px rgba(217, 135, 172, 0.9);
}

@keyframes particle-rise {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(var(--scale, 1));
  }
  to {
    opacity: 0;
    transform: translate(var(--drift-x, 0px), calc(-1 * var(--rise, 120px))) scale(var(--scale, 1));
  }
}

/* --- milestone card ---------------------------------------------------------------------- */

.milestone-card {
  width: 100%;
  max-width: 420px;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  text-align: left;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border: 1px solid var(--rose-bright);
  border-radius: 16px;
  animation: card-in 300ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.milestone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.milestone-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.milestone-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--mauve);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 150ms ease, color 150ms ease;
}

.milestone-close:hover {
  border-color: var(--rose-bright);
  color: var(--white);
}

.milestone-close:focus-visible {
  outline: 2px solid var(--rose-bright);
  outline-offset: 2px;
}

.milestone-text {
  margin: 0.5rem 0 1rem;
  color: var(--blush);
  overflow-wrap: break-word;
}

.milestone-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mauve);
}

.milestone-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.milestone-row input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  font: inherit;
  color: var(--white);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 150ms ease;
}

.milestone-row input::placeholder {
  color: color-mix(in srgb, var(--mauve) 70%, transparent);
}

.milestone-row input:hover:not(:disabled) {
  border-color: var(--rose);
}

.milestone-row input:focus-visible {
  outline: 2px solid var(--rose-bright);
  outline-offset: 1px;
  border-color: var(--rose-bright);
}

.milestone-row input:disabled {
  opacity: 0.5;
}

.milestone-send {
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--white);
  background: var(--rose);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 150ms ease;
}

.milestone-send:hover:not(:disabled) {
  background: var(--rose-bright);
  color: var(--bg);
}

.milestone-send:focus-visible {
  outline: 2px solid var(--rose-bright);
  outline-offset: 2px;
}

.milestone-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.milestone-hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--mauve);
}

/* --- shop ------------------------------------------------------------------------------ */

.shop h2 {
  margin: 0 0 1rem;
  font-size: 1.3rem;
  color: var(--white);
  text-wrap: balance;
}

.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  padding: 0.75rem 1rem;
  font: inherit;
  text-align: left;
  color: var(--blush);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 150ms ease, transform 150ms ease;
}

.shop-item:hover:not(:disabled) {
  border-color: var(--rose-bright);
  transform: translateY(-1px);
}

.shop-item:focus-visible {
  outline: 2px solid var(--rose-bright);
  outline-offset: 2px;
}

.shop-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.shop-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shop-item-name {
  color: var(--white);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-item-desc {
  color: var(--mauve);
  font-size: 0.85rem;
}

.shop-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.shop-item-cost {
  color: var(--rose-bright);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shop-item-owned {
  color: var(--mauve);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.shop-status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--mauve);
  font-size: 0.9rem;
}

/* --- meta row ------------------------------------------------------------------------------ */

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.save-note {
  margin: 0;
  color: var(--mauve);
  font-size: 0.8rem;
}

.reset-button {
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--mauve);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 150ms ease, color 150ms ease;
}

.reset-button:hover {
  border-color: #b06a6a;
  color: #f0b3b3;
}

.reset-button:focus-visible {
  outline: 2px solid var(--rose-bright);
  outline-offset: 2px;
}

/* --- reduced motion --------------------------------------------------------------------------- */

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

  .milestone-card {
    animation: none;
  }

  .particle {
    animation: none;
    display: none;
  }

  .clicker,
  .shop-item,
  .reset-button {
    transition: none;
  }

  .clicker:hover,
  .clicker:active,
  .shop-item:hover:not(:disabled) {
    transform: none;
  }
}
