/* Life Bar Pinball - shared styles (public pages + admin) */

:root {
  --bg: #0a0912;
  --bg-2: #120f22;
  --panel: #171430;
  --panel-2: #1f1a3f;
  --line: #2d2752;
  --line-2: #3d3670;
  --text: #f3f0ff;
  --muted: #a49ec9;
  --amber: #ffb02e;
  --amber-2: #ff7a1a;
  --pink: #ff3ea5;
  --cyan: #38e8ff;
  --green: #4ade80;
  --red: #ff5c5c;
  --font-display: "Press Start 2P", "Courier New", monospace;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 62, 165, 0.18), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(56, 232, 255, 0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--cyan); }
a:hover { color: #fff; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* layout */
.wrap { width: min(1100px, 100% - 32px); margin: 0 auto; }
.wrap-narrow { width: min(720px, 100% - 32px); margin: 0 auto; }
.stack > * + * { margin-top: 1.25rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }

/* header */
.site-header {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 9, 18, 0.7);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--amber);
  text-decoration: none;
  text-shadow: 0 0 12px rgba(255, 176, 46, 0.55);
}
.wordmark span { color: var(--pink); text-shadow: 0 0 12px rgba(255, 62, 165, 0.55); }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; margin-left: 1.2rem; }
.site-nav a:hover { color: #fff; }

main { padding: 32px 0 64px; }
.site-footer { padding: 24px 0 40px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

/* panels & cards */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 1.25rem; }
.panel-title { font-family: var(--font-display); font-size: 0.7rem; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 14px; text-transform: uppercase; }

.card {
  display: block;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
a.card:hover { border-color: var(--pink); transform: translateY(-2px); color: inherit; }
.card h3 { margin-bottom: 4px; }

/* badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  vertical-align: middle;
  white-space: nowrap;
}
.badge.open { color: var(--green); border-color: rgba(74, 222, 128, 0.4); }
.badge.full, .badge.closed { color: var(--amber); border-color: rgba(255, 176, 46, 0.4); }
.badge.live { color: var(--pink); border-color: rgba(255, 62, 165, 0.5); animation: pulse 1.6s infinite; }
.badge.complete { color: var(--cyan); border-color: rgba(56, 232, 255, 0.4); }
.badge.draft { color: var(--muted); }
.badge.waitlist { color: var(--amber); border-color: rgba(255, 176, 46, 0.4); }
.badge.registered { color: var(--green); border-color: rgba(74, 222, 128, 0.4); }
.badge.checked_in { color: var(--cyan); border-color: rgba(56, 232, 255, 0.4); }
.badge.no_show { color: var(--red); border-color: rgba(255, 92, 92, 0.4); }
.badge.withdrawn { color: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* DMD-style counter */
.dmd {
  background: #120a02;
  border: 1px solid #3a2400;
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(255, 120, 0, 0.08), var(--shadow);
}
.dmd::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 176, 46, 0.14) 1px, transparent 1.3px);
  background-size: 6px 6px;
  pointer-events: none;
}
.dmd-number {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 9vw, 4rem);
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 176, 46, 0.8), 0 0 30px rgba(255, 122, 26, 0.5);
  line-height: 1;
  position: relative;
}
.dmd-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  color: var(--amber-2);
  margin-top: 14px;
  letter-spacing: 0.08em;
  position: relative;
}
.dmd-sub { color: #d9a25c; margin-top: 12px; font-size: 0.9rem; position: relative; }
.dmd.is-full .dmd-number { color: var(--pink); text-shadow: 0 0 10px rgba(255, 62, 165, 0.8), 0 0 30px rgba(255, 62, 165, 0.4); }
.dmd.is-full .dmd-label { color: var(--pink); }

.meter { height: 10px; background: rgba(255, 255, 255, 0.06); border-radius: 999px; overflow: hidden; margin-top: 16px; position: relative; }
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--amber-2), var(--amber)); border-radius: 999px; transition: width 0.4s; }
.meter.is-full > i { background: linear-gradient(90deg, var(--pink), #ff7ac4); }

/* forms */
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
label .opt { color: var(--muted); font-weight: 400; }
input[type="text"], input[type="email"], input[type="date"], input[type="number"], input[type="password"],
input[type="search"], input[type="datetime-local"], select, textarea {
  width: 100%;
  background: #0d0b19;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: dark;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.2); }
input.is-invalid, select.is-invalid { border-color: var(--red); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .err { color: var(--red); font-size: 0.85rem; margin-top: 5px; display: none; }
.field.has-error .err { display: block; }
.field .hint { color: var(--muted); font-size: 0.8rem; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
input.initials { text-transform: uppercase; letter-spacing: 0.25em; font-family: var(--font-display); font-size: 0.9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, filter 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--pink), #d61f82); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(255, 62, 165, 0.35); }
.btn-amber { background: linear-gradient(180deg, var(--amber), var(--amber-2)); border-color: transparent; color: #1a0e00; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: rgba(255, 92, 92, 0.5); color: var(--red); background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 6px; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: 8px; border: 1px solid; margin-bottom: 1rem; }
.alert-error { border-color: rgba(255, 92, 92, 0.5); background: rgba(255, 92, 92, 0.08); color: #ffb4b4; }
.alert-ok { border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.08); color: #b6f5c9; }
.alert-info { border-color: rgba(56, 232, 255, 0.4); background: rgba(56, 232, 255, 0.06); color: #c8f7ff; }

/* player chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  font-size: 0.9rem;
}
.chip .init {
  font-family: var(--font-display);
  font-size: 0.6rem;
  background: #2a2350;
  color: var(--amber);
  border-radius: 999px;
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}
.chip .loc { color: var(--muted); font-size: 0.8rem; }
.chip.wl .init { color: var(--muted); }
.chip .num { color: var(--muted); font-size: 0.8rem; margin-left: 2px; }

/* ---------- bracket ---------- */
.bracket-scroll { overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.bracket-hint { display: none; color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
@media (max-width: 800px) { .bracket-hint { display: block; } }
.bracket-inner { display: flex; align-items: stretch; gap: 44px; position: relative; min-width: max-content; padding: 4px 4px 4px 0; }
.bracket-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.bracket-lines path { fill: none; stroke: var(--line-2); stroke-width: 2; }
.bracket-lines path.won { stroke: var(--amber); }
.bracket-round { display: flex; flex-direction: column; width: 236px; flex: none; position: relative; z-index: 1; }
.bracket-round-title { font-family: var(--font-display); font-size: 0.6rem; color: var(--muted); text-align: center; margin-bottom: 14px; letter-spacing: 0.05em; height: 16px; }
.bracket-matches { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: 12px; }
.match {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.9rem;
}
.match.clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.match.clickable:hover { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.18); }
.match.status-ready { border-color: rgba(56, 232, 255, 0.45); }
.match.status-complete { border-color: rgba(255, 176, 46, 0.35); }
.match.status-bye { opacity: 0.55; }
.match-head { display: flex; justify-content: space-between; gap: 6px; padding: 5px 10px; font-size: 0.7rem; color: var(--muted); background: rgba(255, 255, 255, 0.03); border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.04em; }
.match-head .machine { color: var(--cyan); text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.player + .player { border-top: 1px solid var(--line); }
.player .init { font-family: var(--font-display); font-size: 0.55rem; color: var(--amber); min-width: 34px; text-align: center; background: #241e46; border-radius: 6px; padding: 5px 3px; }
.player .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.player .score { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.player.tbd .pname { color: var(--muted); font-weight: 400; font-style: italic; }
.player.tbd .init { color: var(--muted); }
.player.winner { background: rgba(255, 176, 46, 0.09); }
.player.winner .pname { color: var(--amber); }
.player.winner .score { color: var(--text); font-weight: 700; }
.player.loser .pname, .player.loser .score { opacity: 0.6; }

.champion {
  text-align: center;
  padding: 28px 20px;
  border: 1px solid rgba(255, 176, 46, 0.5);
  border-radius: var(--radius);
  background: radial-gradient(500px 200px at 50% 0%, rgba(255, 176, 46, 0.18), transparent 70%), var(--bg-2);
}
.champion .trophy { font-size: 2.2rem; }
.champion .who { font-family: var(--font-display); font-size: clamp(0.9rem, 3vw, 1.4rem); color: var(--amber); text-shadow: 0 0 14px rgba(255, 176, 46, 0.6); margin: 10px 0 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f1a3f; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); font-weight: 600; }
.toast.err { border-color: var(--red); color: #ffb4b4; }

/* records / history */
.site-nav a.active { color: var(--text); }
details.hist { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: rgba(255, 255, 255, 0.02); }
details.hist summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 14px; flex-wrap: wrap; }
details.hist summary::-webkit-details-marker { display: none; }
details.hist summary::before { content: "▸"; color: var(--muted); margin-right: 8px; }
details.hist[open] summary::before { content: "▾"; }
.hist-main { flex: 1; min-width: 200px; }
.hist-side { display: flex; gap: 10px; align-items: center; }
.hist-body { padding: 0 14px 14px 36px; }
table.games td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
table.games tr:last-child td { border-bottom: none; }
.wl { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; font-weight: 800; font-size: 0.75rem; margin-right: 4px; }
.wl.w { background: rgba(74, 222, 128, 0.18); color: var(--green); }
.wl.l { background: rgba(255, 92, 92, 0.15); color: var(--red); }
.init-pill { font-family: var(--font-display); font-size: 0.55rem; color: var(--amber); background: #241e46; border-radius: 6px; padding: 4px 6px; margin-right: 6px; vertical-align: middle; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters input[type="search"] { flex: 1; min-width: 200px; max-width: 420px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { background: transparent; border: 1px solid var(--line-2); color: var(--muted); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.chip-btn:hover { color: var(--text); }
.chip-btn.active { background: var(--panel-2); color: var(--text); border-color: var(--pink); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { width: auto; }

.ifpa-link { color: inherit; text-decoration: none; border-bottom: 1px dotted rgba(56, 232, 255, 0.6); }
.ifpa-link:hover { color: var(--cyan); }
.chip a.ifpa-link { border-bottom-color: rgba(56, 232, 255, 0.5); }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat.over b { color: var(--red); }

@media (max-width: 640px) {
  .site-header { padding: 14px 0; }
  .site-header .wrap { flex-wrap: wrap; gap: 8px; }
  .site-nav { white-space: nowrap; }
  .site-nav a { margin-left: 0; margin-right: 0.9rem; }
  .panel { padding: 16px; }
  .wordmark { font-size: 0.6rem; }
}
