:root {
  --bg: #0d0e10;
  --bg-2: #15171a;
  --stone: #2a2d31;
  --stone-hi: #3a3e44;
  --stone-lo: #17191c;
  --text: #d9d6cf;
  --muted: #8b8a86;
  --accent: #9bb7a0;
  --candle: #e8b65b;
  --rose: #b35a6b;
  --danger: #c0505e;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #1a1c20 0%, var(--bg) 60%, #070708 100%);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}
.fog, .ground { position: fixed; pointer-events: none; z-index: 0; }
.fog {
  inset: -20%;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(155,183,160,0.06), transparent 50%),
    radial-gradient(ellipse at 80% 60%, rgba(180,180,200,0.05), transparent 50%);
  animation: drift 40s ease-in-out infinite alternate;
}
.ground {
  left: 0; right: 0; bottom: 0; height: 22vh;
  background: linear-gradient(to top, #050506, transparent);
}
@keyframes drift {
  from { transform: translate3d(-3%, 0, 0); }
  to { transform: translate3d(3%, -2%, 0); }
}

body > *:not(.fog):not(.ground):not(.toast):not(.modal) { position: relative; z-index: 1; }

.hero { text-align: center; padding: 64px 20px 28px; }
.kicker { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 8px; letter-spacing: 0.04em; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.2rem, 6vw, 3.8rem); margin: 0; letter-spacing: 0.02em; text-shadow: 0 2px 20px rgba(0,0,0,0.6); }
.lede { max-width: 620px; margin: 14px auto 0; color: var(--muted); line-height: 1.6; }
.stats { display: flex; gap: 22px; justify-content: center; margin-top: 22px; color: var(--muted); font-size: 0.9rem; flex-wrap: wrap; }
.stats strong { color: var(--text); font-family: var(--serif); font-size: 1.15rem; margin-right: 4px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 0.95rem; padding: 11px 18px; border-radius: 999px;
  border: 1px solid #4a4e55; background: transparent; color: var(--text);
  cursor: pointer; transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: linear-gradient(180deg, #4a4e55, #2f3237); border-color: #5a5f67; }
.btn.ghost { background: rgba(255,255,255,0.02); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.toolbar { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; padding: 8px 20px 24px; }
.toolbar label { display: flex; flex-direction: column; gap: 6px; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
select, input, textarea {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg-2);
  border: 1px solid #2c3036; border-radius: 10px; padding: 9px 12px; min-width: 180px; text-transform: none; letter-spacing: normal;
}
textarea { min-width: 0; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px; padding: 12px clamp(16px, 4vw, 56px) 120px; max-width: 1280px; margin: 0 auto;
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-family: var(--serif); font-style: italic; }

.tomb {
  position: relative;
  background: linear-gradient(170deg, var(--stone-hi) 0%, var(--stone) 40%, var(--stone-lo) 100%);
  border-radius: 140px 140px 14px 14px / 90px 90px 14px 14px;
  padding: 44px 22px 20px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.06), inset 0 -10px 24px rgba(0,0,0,0.35), 0 18px 30px -18px rgba(0,0,0,0.9);
  display: flex; flex-direction: column; gap: 10px;
  border: 1px solid #111316;
  transition: transform .25s ease, box-shadow .25s ease;
  animation: rise .6s ease both;
  outline: none;
}
.tomb:hover, .tomb:focus-visible { transform: translateY(-4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.08), inset 0 -10px 24px rgba(0,0,0,0.35), 0 26px 40px -18px rgba(0,0,0,0.95), 0 0 0 1px rgba(155,183,160,0.25); }
.tomb.focused { box-shadow: 0 0 0 2px rgba(232,182,91,0.45), 0 26px 40px -18px rgba(0,0,0,0.95); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.tomb h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.35rem; text-align: center; color: #efece6; text-shadow: 0 1px 0 rgba(0,0,0,0.6); word-break: break-word; }
.dates { text-align: center; font-family: var(--serif); font-size: 0.85rem; color: #aaa69d; letter-spacing: 0.03em; }
.lifespan { text-align: center; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.epitaph { font-family: var(--serif); font-style: italic; text-align: center; color: #c9c5bc; line-height: 1.5; margin: 4px 0; font-size: 0.95rem; }
.cause { align-self: center; font-size: 0.75rem; padding: 4px 10px; border-radius: 999px; background: rgba(192,80,94,0.14); border: 1px solid rgba(192,80,94,0.45); color: #e59aa5; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.stack span { font-size: 0.7rem; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,0.3); color: #a6a39b; border: 1px solid #23262a; }
.final { font-size: 0.85rem; color: #9f9c95; line-height: 1.5; border-top: 1px dashed #3d4147; padding-top: 10px; }
.final b { color: #bdb9b0; font-weight: 600; }
.final-link { font-size: 0.8rem; color: var(--accent); text-decoration: none; align-self: center; }
.final-link:hover { text-decoration: underline; }

.respects { margin-top: auto; display: flex; gap: 10px; justify-content: center; padding-top: 6px; position: relative; }
.respect-btn {
  font: inherit; font-size: 0.9rem; color: var(--text); background: rgba(0,0,0,0.3);
  border: 1px solid #2d3136; border-radius: 999px; padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: transform .12s ease, border-color .2s ease;
}
.respect-btn:hover { border-color: var(--candle); }
.respect-btn:active { transform: scale(0.92); }
.respect-btn .count { font-variant-numeric: tabular-nums; min-width: 1.5ch; text-align: left; }
.respect-btn.bump .count { animation: bump .35s ease; }
@keyframes bump { 50% { transform: scale(1.35); color: var(--candle); } }

.float {
  position: absolute; pointer-events: none; font-size: 1.3rem;
  animation: floatUp 1.1s ease-out forwards; left: 50%; top: 0; transform: translateX(-50%);
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -90px) scale(1.1); }
}

.footer { position: relative; z-index: 1; text-align: center; color: #5f5e5a; font-family: var(--serif); font-style: italic; padding: 0 20px 40px; }

.modal { position: fixed; inset: 0; background: rgba(4,5,6,0.78); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade .2s ease; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(600px, 100%); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #1b1d21, #121316); border: 1px solid #2c3036; border-radius: 18px;
  padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
.modal-card h2 { font-family: var(--serif); font-weight: 400; margin: 0 0 4px; font-size: 1.7rem; }
.muted { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }
.close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 1.8rem; cursor: pointer; }
#bury-form { display: flex; flex-direction: column; gap: 14px; }
#bury-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: #aaa69d; }
#bury-form input, #bury-form select, #bury-form textarea { min-width: 0; width: 100%; }
#bury-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 0.88rem; margin: 0; min-height: 1em; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1d1f23; border: 1px solid #3a3e44; color: var(--text); padding: 11px 18px; border-radius: 999px;
  opacity: 0; transition: opacity .25s ease, transform .25s ease; z-index: 60; pointer-events: none; font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  #bury-form .row { grid-template-columns: 1fr; }
  .toolbar label { width: 100%; }
  select, input { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
