/* Dead Cert: gothic churchyard theme */
@font-face { font-family: "Maguntia"; src: url(/fonts/unifrakturmaguntia-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Cinzel"; font-weight: 400; src: url(/fonts/cinzel-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Cinzel"; font-weight: 700; src: url(/fonts/cinzel-latin-700-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 400; src: url(/fonts/eb-garamond-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 400; font-style: italic; src: url(/fonts/eb-garamond-latin-400-italic.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Garamond"; font-weight: 600; src: url(/fonts/eb-garamond-latin-600-normal.woff2) format("woff2"); font-display: swap; }

:root {
  --night: #0b0b0e;
  --stone: #19191e;
  --stone-2: #212128;
  --stone-3: #2b2a32;
  --edge: #3b3943;
  --ink: #e8e1d1;        /* bone */
  --muted: #9a9387;
  --candle: #e3ac52;
  --candle-dim: #9c7438;
  --wine: #6e1c27;
  --wine-hi: #8f2a37;
  --moss: #7e9468;
  --glass-red: #9b2a37;
  --glass-blue: #2d4d8a;
  --blackletter: "Maguntia", "Old English Text MT", serif;
  --inscribed: "Cinzel", "Trajan Pro", Georgia, serif;
  --serif: "Garamond", "EB Garamond", Garamond, Georgia, serif;
  --r: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--night); }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font: 18px/1.5 var(--serif);
  padding-bottom: env(safe-area-inset-bottom);
}
/* night sky lives on a fixed layer so it never seams or scrolls (iOS ignores background-attachment: fixed) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 82% -6%, rgba(205, 210, 230, .16), transparent 70%),      /* moon */
    radial-gradient(ellipse 120% 60% at 50% 115%, rgba(120, 128, 140, .18), transparent 70%),    /* ground mist */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #0f0f14 0%, var(--night) 55%, #101114 100%);
}
/* drifting fog along the bottom */
body::after {
  content: ""; position: fixed; left: -20%; right: -20%; bottom: 0; height: 32vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 40% 60% at 25% 100%, rgba(170, 176, 190, .10), transparent 70%),
    radial-gradient(ellipse 45% 55% at 75% 100%, rgba(170, 176, 190, .08), transparent 70%);
  animation: fog 38s ease-in-out infinite alternate;
}
@keyframes fog { from { transform: translateX(-4%); } to { transform: translateX(4%); } }

a { color: var(--candle); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--inscribed); font-weight: 700; margin: 0 0 .5rem; letter-spacing: .06em;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .9), 0 1px 0 rgba(255, 255, 255, .07); }   /* chiselled */
h1 { font-size: 1.85rem; line-height: 1.15; }
h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .14em; }
h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .14em; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 2rem 1rem; }
.small { font-size: .88rem; }
.label { font-family: var(--inscribed); font-size: .68rem; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- header: a lychgate with an arcade trim ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap;
  padding: .65rem 1rem 1rem; padding-top: max(.65rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(11, 11, 14, .97), rgba(16, 16, 20, .94));
  backdrop-filter: blur(6px);
}
.top::after {   /* row of little gothic arches */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 9px;
  background:
    radial-gradient(circle at 50% 100%, transparent 6px, var(--edge) 6.5px, var(--edge) 7.5px, transparent 8px) 0 0 / 18px 9px repeat-x,
    linear-gradient(var(--edge), var(--edge)) 0 100% / 100% 1px no-repeat;
  opacity: .9;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink); font-family: var(--blackletter); font-size: 1.7rem; line-height: 1; }
.brand:hover { text-decoration: none; }
.brand .rose { width: 30px; height: 30px; }
nav { display: flex; gap: .15rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
nav a { font-family: var(--inscribed); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  padding: .45rem .6rem; white-space: nowrap; border-bottom: 1px solid transparent; }
nav a:hover { color: var(--ink); text-decoration: none; }
nav a.on { color: var(--candle); border-bottom-color: var(--candle-dim); text-shadow: 0 0 12px rgba(227, 172, 82, .45); }
@media (max-width: 560px) { nav { margin-left: -.5rem; width: calc(100% + .5rem); } }
@media (max-width: 420px) { nav a { padding: .45rem .42rem; letter-spacing: .08em; font-size: .7rem; } }

main { position: relative; z-index: 1; max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* ---------- stone slabs ---------- */
.panel {
  position: relative; margin-bottom: 1.1rem; padding: 1.2rem 1.15rem;
  background: linear-gradient(175deg, var(--stone-2), var(--stone) 70%);
  border: 1px solid var(--edge); border-radius: var(--r);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045), inset 0 -3px 8px rgba(0, 0, 0, .35), 0 10px 26px rgba(0, 0, 0, .45);
}
/* section heads flanked by rules and crosses */
.panel > h2:first-child { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: 1rem; }
.panel > h2:first-child::before, .panel > h2:first-child::after {
  content: "✠"; flex: 1; font-size: .7rem; color: var(--candle-dim); letter-spacing: 0; text-shadow: none;
  background: linear-gradient(var(--edge), var(--edge)) center / 100% 1px no-repeat;
}
.panel > h2:first-child::before { text-align: right; background-position: left center; background-size: calc(100% - 1.1rem) 1px; }
.panel > h2:first-child::after { text-align: left; background-position: right center; background-size: calc(100% - 1.1rem) 1px; }

/* the headline slab is a headstone with an arched top */
.hero {
  text-align: center; padding: 2.4rem 1.2rem 1.4rem;
  border-radius: 50% 50% var(--r) var(--r) / 72px 72px var(--r) var(--r);
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(227, 172, 82, .07), transparent 70%),
    linear-gradient(175deg, var(--stone-3), var(--stone) 80%);
}
.hero::before {  /* a carved cross at the crown */
  content: "✝"; display: block; margin: -1.2rem auto .5rem; font-size: 1.1rem; color: var(--candle-dim);
  text-shadow: 0 -1px 0 #000, 0 1px 0 rgba(255, 255, 255, .06);
}
.hero-row { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.hero h1 { font-size: 2rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: .75rem; margin-top: 1.1rem; text-align: center; }
.fact { border-top: 1px solid var(--edge); padding-top: .55rem; }
.fact b { display: block; font-family: var(--inscribed); font-size: 1.35rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: lining-nums; }

/* brass plaques */
.chip { display: inline-block; font-family: var(--inscribed); font-size: .62rem; letter-spacing: .2em; text-transform: uppercase;
  padding: .28rem .65rem; border: 1px solid var(--candle-dim); color: var(--candle);
  background: linear-gradient(180deg, rgba(227, 172, 82, .1), rgba(227, 172, 82, .02)); border-radius: 2px; }
.chip.open { color: var(--moss); border-color: rgba(126, 148, 104, .55); background: rgba(126, 148, 104, .08); }
.chip.ended { color: var(--muted); border-color: var(--edge); background: none; }

/* ---------- the ledger ---------- */
table { width: 100%; border-collapse: collapse; }
th { font-family: var(--inscribed); text-align: left; font-weight: 400; font-size: .64rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--muted); padding: .4rem .5rem; border-bottom: 1px solid var(--edge); }
td { padding: .65rem .5rem; border-bottom: 1px solid rgba(59, 57, 67, .6); vertical-align: middle; font-variant-numeric: lining-nums; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: lining-nums tabular-nums; }
td a { color: var(--ink); font-weight: 600; }
.rank { font-family: var(--inscribed); font-size: .95rem; color: var(--muted); width: 3rem; letter-spacing: .04em; }
tr.lead { background: linear-gradient(90deg, rgba(227, 172, 82, .13), rgba(227, 172, 82, .02)); }
tr.lead .rank { color: var(--candle); text-shadow: 0 0 10px rgba(227, 172, 82, .6); animation: flicker 4s infinite; }
tr.me td a { color: var(--candle); }
.pts { font-family: var(--inscribed); font-size: 1.1rem; font-weight: 700; font-variant-numeric: lining-nums; }
@keyframes flicker { 0%, 100% { opacity: 1; } 42% { opacity: .82; } 44% { opacity: 1; } 71% { opacity: .9; } }

/* ---------- graveyard: departed as headstones ---------- */
.graves { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem .8rem; padding-top: .3rem; }
.grave {
  position: relative; text-align: center; padding: 1.6rem .7rem .9rem;
  border: 1px solid #45434c; border-bottom-width: 0;
  border-radius: 50% 50% 3px 3px / 46px 46px 3px 3px;
  background:
    radial-gradient(ellipse 60% 30% at 30% 85%, rgba(126, 148, 104, .14), transparent 70%),   /* lichen */
    linear-gradient(170deg, #34333b, #24232a 75%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .06), inset 0 -10px 16px rgba(0, 0, 0, .35), 0 8px 0 -2px #121216, 0 12px 18px rgba(0, 0, 0, .5);
}
.grave .rip { font-family: var(--inscribed); font-size: .62rem; letter-spacing: .3em; color: var(--muted); }
.grave .name { font-family: var(--inscribed); font-weight: 700; font-size: .92rem; letter-spacing: .05em; line-height: 1.25; margin: .35rem 0 .25rem;
  text-shadow: 0 -1px 0 #000, 0 1px 0 rgba(255, 255, 255, .06); }
.grave .dates { font-family: var(--inscribed); font-size: .72rem; letter-spacing: .1em; color: var(--muted); font-variant-numeric: lining-nums; }
.grave .by { font-style: italic; font-size: .85rem; color: var(--muted); margin-top: .45rem; line-height: 1.3; }
.grave .pts { display: block; margin-top: .4rem; color: var(--candle); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid rgba(59, 57, 67, .6); }
.list li:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.desc { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: lining-nums; }
.avatar { /* a tiny headstone */
  flex: none; width: 2.1rem; height: 2.5rem; display: grid; place-items: center; padding-top: .3rem;
  font-family: var(--inscribed); font-size: .72rem; font-weight: 700; color: var(--muted);
  border: 1px solid var(--edge); border-radius: 50% 50% 2px 2px / 40% 40% 2px 2px;
  background: linear-gradient(170deg, var(--stone-3), var(--stone)); }
.dead .avatar { color: var(--candle); border-color: var(--candle-dim); }
.dead .name::after { content: " †"; color: var(--candle); }
.right { text-align: right; flex: none; }

/* ---------- forms ---------- */
label { display: block; font-size: .92rem; color: var(--muted); margin-bottom: .8rem; }
input, select, textarea { display: block; width: 100%; margin-top: .3rem; font: inherit; font-size: 1rem; color: var(--ink);
  background: #0f0f13; border: 1px solid var(--edge); border-radius: 3px; padding: .6rem .7rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5); }
input::placeholder { color: #6b665e; font-style: italic; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--candle-dim); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5), 0 0 0 3px rgba(227, 172, 82, .15); }
input[type=checkbox] { display: inline; width: auto; margin: 0 .5rem 0 0; accent-color: var(--wine-hi); box-shadow: none; }
::-webkit-calendar-picker-indicator { filter: invert(.7); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

button, .btn {
  font-family: var(--inscribed); font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.1rem; border-radius: 3px; color: #f3e6cf;
  border: 1px solid var(--candle-dim);
  background: linear-gradient(180deg, var(--wine-hi), var(--wine));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 2px 8px rgba(0, 0, 0, .5);
}
.btn:hover { text-decoration: none; }
button:hover, .btn:hover { filter: brightness(1.12); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 14px rgba(155, 42, 55, .45); }
button:disabled { opacity: .45; cursor: default; filter: grayscale(.6); }
button.ghost { background: linear-gradient(180deg, var(--stone-3), var(--stone-2)); color: var(--ink); border-color: var(--edge); }
button.ghost:hover { border-color: var(--muted); box-shadow: none; }
button.danger { background: transparent; color: #d07a6d; border-color: rgba(208, 122, 109, .4); box-shadow: none; }
button.sm { padding: .38rem .7rem; font-size: .66rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; justify-content: center; }
.err { color: #d98a7d; font-size: .95rem; min-height: 1.2em; }

/* ---------- the gate (sign in) ---------- */
.auth { max-width: 400px; margin: 5vh auto 0; text-align: center; }
.auth .rose { width: 108px; height: 108px; margin: 0 auto .4rem; display: block; filter: drop-shadow(0 0 22px rgba(155, 42, 55, .35)); }
.auth h1 { font-family: var(--blackletter); font-weight: 400; font-size: 3.4rem; letter-spacing: 0; text-shadow: 0 2px 0 #000, 0 0 30px rgba(227, 172, 82, .15); }
.auth .tag { color: var(--muted); font-style: italic; font-size: 1.1rem; margin-bottom: 1.6rem; }
.auth .panel { text-align: left; border-radius: 50% 50% var(--r) var(--r) / 56px 56px var(--r) var(--r); padding-top: 2rem; }
.tabs { display: flex; border-bottom: 1px solid var(--edge); margin-bottom: 1.1rem; }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); box-shadow: none; }
.tabs button.on { color: var(--candle); border-bottom-color: var(--candle-dim); }
.tabs button:hover { box-shadow: none; }

/* ---------- picks ---------- */
.progress { height: 8px; max-width: 360px; margin: .8rem auto; border-radius: 99px; overflow: hidden; background: #0f0f13; border: 1px solid var(--edge); }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--candle-dim), var(--candle)); box-shadow: 0 0 10px rgba(227, 172, 82, .6); }
.fame { font-size: .8rem; color: var(--muted); font-style: italic; }
.notice { position: relative; z-index: 1; border: 1px dashed var(--edge); border-radius: var(--r); padding: .9rem 1rem; color: var(--muted);
  font-style: italic; text-align: center; background: rgba(11, 11, 14, .5); margin-bottom: 1.1rem; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 680px) { .cols { grid-template-columns: 1fr; } }
.select-season { width: auto; display: inline-block; margin: 0; padding: .3rem .5rem; font-size: .9rem; }

/* rules read like a church notice board */
.rules { padding-left: 1.4rem; }
.rules li { margin-bottom: .55rem; }
.rules li::marker { font-family: var(--inscribed); color: var(--candle-dim); }
details summary { cursor: pointer; color: var(--muted); font-style: italic; }

#toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: #e9dfc8; color: #1d1a15; padding: .6rem 1.1rem; border-radius: 3px; border: 1px solid #b59d6b;
  font-size: 1rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  transition: transform .2s, opacity .2s; max-width: calc(100% - 2rem); z-index: 10; opacity: 0; pointer-events: none; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.bad { background: var(--wine); color: #f3e6cf; border-color: var(--candle-dim); }

@media (prefers-reduced-motion: reduce) {
  body::after, tr.lead .rank { animation: none; }
}
