/* ── Link-Up · manager's chalkboard ─────────────────────────────── */

:root {
  --board: #15251c;
  --board-deep: #0e1a13;
  --chalk: #f0ecdf;
  --chalk-dim: rgba(240, 236, 223, 0.55);
  --chalk-faint: rgba(240, 236, 223, 0.14);
  --amber: #ffb648;
  --red: #ff6f61;
  --green: #8fdf9b;
  --display: "Bricolage Grotesque", sans-serif;
  --hand: "Caveat", cursive;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--board-deep); }

body {
  font-family: var(--display);
  color: var(--chalk);
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #1b2f23 0%, var(--board) 55%, var(--board-deep) 100%);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* pitch markings, very faint chalk */
.pitch-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  stroke: var(--chalk); stroke-width: 2; opacity: 0.05;
  pointer-events: none; z-index: 0;
}
.pitch-bg .dot { fill: var(--chalk); }

/* chalk-dust grain */
.grain {
  position: fixed; inset: -50%; width: 200%; height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.045;
  pointer-events: none; z-index: 1;
  animation: grain-shift 1.2s steps(3) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1%); }
  66% { transform: translate(1%, -2%); }
  100% { transform: translate(0, 0); }
}

.board {
  position: relative; z-index: 2;
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 18px calc(40px + env(safe-area-inset-bottom));
}

/* ── masthead ── */
.masthead { text-align: center; margin-bottom: 26px; }
.mast-row {
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  font-size: clamp(44px, 11vw, 58px);
  font-weight: 800;
  font-stretch: 90%;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 0 18px rgba(240, 236, 223, 0.18);
}
.wordmark .hyphen { color: var(--amber); }
.underline { width: 220px; height: 12px; margin: 2px auto 0; display: block; }
.underline path {
  stroke: var(--amber); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 270; stroke-dashoffset: 270;
  animation: drawline 0.7s 0.3s ease-out forwards;
}
@keyframes drawline { to { stroke-dashoffset: 0; } }
.strap {
  font-family: var(--hand); font-size: 21px; font-weight: 500;
  color: var(--chalk-dim); margin-top: 2px;
}
.match-no {
  font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--chalk-dim); margin-top: 10px; font-weight: 600;
}

.icon-btn {
  width: 38px; height: 38px;
  font-family: var(--hand); font-size: 22px; font-weight: 700;
  color: var(--chalk-dim);
  background: none; cursor: pointer;
  border: 2px solid var(--chalk-faint);
  border-radius: 50% 45% 52% 48% / 48% 52% 45% 55%;
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.icon-btn:hover { color: var(--amber); border-color: var(--amber); transform: rotate(-6deg); }

/* ── brief ── */
.brief {
  font-family: var(--hand); font-size: 20px; text-align: center;
  color: var(--chalk-dim); margin-bottom: 18px; line-height: 1.25;
}
.brief b { color: var(--amber); font-weight: 700; }

/* ── chain ── */
.chain { display: flex; flex-direction: column; align-items: stretch; }

.card {
  position: relative;
  border: 2.5px solid var(--chalk);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 13px 18px 11px;
  background: rgba(14, 26, 19, 0.55);
  animation: card-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.card:nth-child(4n+1) { transform: rotate(-0.6deg); }
.card:nth-child(4n+3) { transform: rotate(0.5deg); }
.card .role {
  font-family: var(--hand); font-size: 15px; letter-spacing: 0.06em;
  color: var(--chalk-dim); display: block; line-height: 1;
}
.card .pname {
  font-size: clamp(21px, 5.6vw, 26px); font-weight: 700; font-stretch: 92%;
  line-height: 1.1;
}
.card .born {
  font-family: var(--hand); font-size: 15px; color: var(--chalk-dim);
  margin-left: 8px; font-weight: 500;
}
.card.start { border-color: var(--chalk); }
.card.target {
  border-color: var(--amber);
  border-style: dashed;
  box-shadow: 0 0 24px rgba(255, 182, 72, 0.12);
}
.card.target .pname { color: var(--amber); }
.card.won-target { border-style: solid; }
.card.ghost {
  border-color: var(--chalk-faint); border-width: 2px;
  background: none;
}
.card.ghost .pname { font-size: 18px; color: var(--chalk-dim); font-weight: 600; }

/* pass connector */
.pass {
  height: 52px; width: 100%; display: block; flex-shrink: 0;
  overflow: visible;
}
.pass path {
  stroke: var(--chalk); stroke-width: 2.5; fill: none;
  stroke-linecap: round;
  stroke-dasharray: 7 9;
  animation: pass-draw 0.45s ease-out both;
}
.pass .head { stroke-dasharray: none; animation: fade-in 0.3s 0.35s both; }
@keyframes pass-draw {
  from { stroke-dashoffset: 120; opacity: 0.3; }
  to   { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.pass text {
  font-family: var(--hand); font-size: 17px; font-weight: 700;
  fill: var(--amber); stroke: none;
  animation: fade-in 0.4s 0.25s both;
}
.pass.unsolved path {
  stroke: var(--chalk-faint);
  stroke-dasharray: 2 10;
  animation: none;
}
.pass.unsolved text { fill: var(--chalk-dim); font-size: 18px; }

/* ── controls ── */
.controls { margin-top: 22px; }
.searchwrap { position: relative; }
#guess {
  width: 100%;
  font-family: var(--display); font-size: 19px; font-weight: 600;
  color: var(--chalk);
  background: rgba(240, 236, 223, 0.06);
  border: 2.5px solid var(--chalk-dim);
  border-radius: 15px 255px 15px 225px / 225px 15px 255px 15px;
  padding: 14px 18px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#guess::placeholder { color: var(--chalk-dim); font-weight: 400; font-style: italic; }
#guess:focus { border-color: var(--amber); background: rgba(240, 236, 223, 0.09); }

.searchwrap.shake { animation: shake 0.4s; }
@keyframes shake {
  20% { transform: translateX(-9px); }
  45% { transform: translateX(7px); }
  70% { transform: translateX(-4px); }
  90% { transform: translateX(2px); }
}

.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #0d1812;
  border: 2px solid var(--chalk-dim);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  display: none;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.dropdown.open { display: block; }
.opt {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 11px 16px; cursor: pointer;
  font-size: 17px; font-weight: 600;
  border-bottom: 1px solid rgba(240, 236, 223, 0.07);
}
.opt:last-child { border-bottom: none; }
.opt .by { font-family: var(--hand); font-size: 15px; color: var(--chalk-dim); }
.opt.sel, .opt:hover { background: rgba(255, 182, 72, 0.14); color: var(--amber); }

.ctl-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; gap: 10px;
}

.misses { display: flex; gap: 7px; min-height: 22px; }
.miss-x {
  font-family: var(--hand); font-weight: 700; font-size: 21px; line-height: 1;
  color: var(--red);
  animation: stamp 0.3s cubic-bezier(0.2, 2, 0.4, 1) both;
}
.miss-slot { color: var(--chalk-faint); font-size: 21px; line-height: 1; font-family: var(--hand); }
@keyframes stamp {
  from { transform: scale(2.4) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(-6deg); opacity: 1; }
}

/* ── buttons ── */
.chalk-btn {
  font-family: var(--hand); font-size: 21px; font-weight: 700;
  color: var(--chalk);
  background: none; cursor: pointer;
  border: 2.5px solid var(--chalk);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 8px 22px;
  transition: all 0.15s;
}
.chalk-btn:hover { color: var(--board-deep); background: var(--chalk); }
.chalk-btn.small {
  font-size: 17px; padding: 4px 14px;
  color: var(--chalk-dim); border-color: var(--chalk-faint); border-width: 2px;
}
.chalk-btn.small:hover { color: var(--chalk); background: none; border-color: var(--chalk-dim); }
.chalk-btn.small.danger:hover { color: var(--red); border-color: var(--red); }
.chalk-btn.share {
  display: block; width: 100%; margin: 18px 0 10px;
  font-size: 24px; padding: 12px;
  color: var(--board-deep); background: var(--amber); border-color: var(--amber);
}
.chalk-btn.share:hover { background: var(--chalk); border-color: var(--chalk); }
.chalk-btn:disabled { opacity: 0.35; pointer-events: none; }

/* ── full time ── */
.fulltime { margin-top: 26px; text-align: center; }
.fulltime.hidden { display: none; }
.ft-stamp {
  font-family: var(--hand); font-size: 54px; font-weight: 700;
  line-height: 1; transform: rotate(-4deg);
  animation: stamp 0.5s cubic-bezier(0.2, 1.8, 0.4, 1) both;
}
.ft-stamp.win { color: var(--green); }
.ft-stamp.loss { color: var(--red); }
.ft-line { font-size: 16px; color: var(--chalk-dim); margin-top: 10px; line-height: 1.5; }
.ft-line b { color: var(--amber); }
.ft-reveal { margin-top: 16px; text-align: left; }
.ft-reveal .annot { text-align: center; margin-bottom: 8px; }
.ft-reveal .card { margin-bottom: 0; }
.ft-reveal .pass { height: 34px; }

.annot {
  font-family: var(--hand); font-size: 18px; color: var(--chalk-dim);
}

/* ── sheets ── */
.sheet {
  background: var(--board);
  color: var(--chalk);
  border: 2.5px solid var(--chalk);
  border-radius: 14px;
  padding: 26px 24px;
  max-width: 420px; width: calc(100vw - 40px);
  font-family: var(--display);
  font-size: 16px; line-height: 1.55;
}
.sheet::backdrop { background: rgba(5, 10, 7, 0.75); backdrop-filter: blur(3px); }
.sheet-title {
  font-size: 28px; font-weight: 800; font-stretch: 90%;
  margin-bottom: 12px;
}
.sheet p { margin-bottom: 10px; }
.sheet ol { margin: 0 0 10px 20px; }
.sheet li { margin-bottom: 5px; }
.sheet .chalk-red { color: var(--red); }
.sheet .chalk-btn { margin-top: 8px; }
.sheet em { color: var(--amber); font-style: normal; }

.statgrid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px; margin: 18px 0;
  text-align: center;
}
.stat .num { font-size: 38px; font-weight: 800; line-height: 1; color: var(--amber); }
.stat .lbl { font-family: var(--hand); font-size: 16px; color: var(--chalk-dim); margin-top: 4px; }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: 36px;
  transform: translateX(-50%) translateY(20px);
  background: var(--chalk); color: var(--board-deep);
  font-family: var(--hand); font-size: 19px; font-weight: 700;
  padding: 9px 22px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── practice zone / era slider ── */
.practice-zone {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 2px dashed var(--chalk-faint);
  text-align: center;
}
.pz-title { margin-bottom: 10px; }
.era { max-width: 360px; margin: 0 auto 16px; }
.era-label {
  font-family: var(--hand); font-size: 22px; font-weight: 700;
  color: var(--amber); display: block; margin-bottom: 4px;
}
.era-slider { position: relative; height: 30px; }
.era-track, .era-fill {
  position: absolute; top: 50%; height: 0; left: 0; right: 0;
  border-top: 2px dashed var(--chalk-faint);
}
.era-fill { border-top: 3px solid var(--chalk-dim); }
.era-slider input[type="range"] {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  -webkit-appearance: none; appearance: none;
  background: none; pointer-events: none; margin: 0;
}
.era-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px;
  border-radius: 50% 45% 52% 48% / 48% 52% 45% 55%;
  background: var(--amber);
  border: 3px solid var(--board-deep);
  box-shadow: 0 0 0 2px var(--amber);
  cursor: grab; pointer-events: auto;
}
.era-slider input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--board-deep);
  box-shadow: 0 0 0 2px var(--amber);
  cursor: grab; pointer-events: auto;
}

.diff {
  display: inline-flex; gap: 0; margin-bottom: 6px;
  border: 2px solid var(--chalk-dim);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  overflow: hidden;
}
.diff-opt {
  font-family: var(--hand); font-size: 18px; font-weight: 700;
  color: var(--chalk-dim);
  background: none; border: none; cursor: pointer;
  padding: 7px 18px;
  transition: all 0.15s;
}
.diff-opt + .diff-opt { border-left: 2px dashed var(--chalk-faint); }
.diff-opt.on { background: var(--amber); color: var(--board-deep); }
.diff-opt:not(.on):hover { color: var(--chalk); }
.diff-hint { margin-bottom: 14px; font-size: 16px; }

.boot {
  margin-top: 44px; text-align: center;
  font-family: var(--hand); font-size: 15px; color: var(--chalk-faint);
}
.boot a { color: var(--chalk-dim); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; }
}
