:root {
  /* Gamers Escape brand: #422A71 purple, #3CF7D3 mint */
  --brand: #422a71;
  --brand-light: #5b3c96;
  --bg: #0c0916;
  --bg-elev: #161029;
  --bg-elev-2: #1f1739;
  --line: #3a2c68;
  --line-soft: #271d47;
  --text: #f0ecfa;
  --text-dim: #a79bc6;
  --text-faint: #7a6da0;
  --accent: #3cf7d3;
  --accent-dim: #1f9f88;
  --accent-glow: rgba(60, 247, 211, 0.13);
  --danger: #ff6b8a;
  --warn: #efb54a;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(900px 520px at 50% -200px, rgba(66, 42, 113, 0.72), transparent 72%),
    radial-gradient(640px 400px at 50% 0, rgba(60, 247, 211, 0.06), transparent 70%),
    var(--bg);
  position: relative;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); }

/* Faint brand watermark, kept behind everything and out of the way of text. */
body::before {
  content: '';
  position: fixed;
  top: 64px;
  left: 50%;
  width: min(620px, 92vw);
  aspect-ratio: 2058 / 1282;
  transform: translateX(-50%);
  background: url('/assets/watermark.png') no-repeat center / contain;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}
.wrap { position: relative; z-index: 1; }

.wrap { max-width: 760px; margin: 0 auto; padding: 40px 20px 80px; }
.wrap-wide { max-width: 1280px; }

/* ---------- header ---------- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { width: 40px; height: 40px; flex: none; display: block; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.brand-sub { font-size: 12px; color: var(--text-faint); }
.pill {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text-dim); background: var(--bg-elev); white-space: nowrap;
}
.pill-live { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-glow); }
.pill-closed { color: var(--danger); border-color: rgba(242,101,107,.35); background: rgba(242,101,107,.1); }

/* ---------- card ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 32px;
}
.card + .card { margin-top: 20px; }

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.5px; }
h2 { font-size: 17px; margin: 0 0 6px; letter-spacing: -0.2px; }
.lede { color: var(--text-dim); margin: 0 0 28px; font-size: 14.5px; }

/* ---------- form ---------- */
.field { margin-bottom: 22px; }
.field:last-of-type { margin-bottom: 0; }

label.lbl {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  margin-bottom: 8px; color: var(--text);
}
.req { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.opt { color: var(--text-faint); font-size: 11px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 7px; }

input[type="text"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input.invalid, select.invalid, .drop.invalid { border-color: var(--danger); }
/* No background-image here on purpose: an inline SVG arrow tiled across the
   whole field on some mobile browsers. The chevron is drawn by .selectwrap. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  cursor: pointer;
}

.selectwrap { position: relative; display: block; }
.selectwrap::after {
  content: '';
  position: absolute;
  right: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg);
  pointer-events: none;
}
.selectwrap:focus-within::after { border-color: var(--accent); }
select option { background: var(--bg-elev); color: var(--text); }

.field-team select { font-size: 15.5px; font-weight: 600; padding: 13px; }

.err { color: var(--danger); font-size: 12.5px; margin-top: 7px; display: none; }
.err.show { display: block; }

/* ---------- dropzone ---------- */
.drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: rgba(255,255,255,.012);
}
.drop:hover, .drop.over { border-color: var(--accent-dim); background: var(--accent-glow); }
.drop-title { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.drop-sub { color: var(--text-faint); font-size: 12.5px; }
.drop input { display: none; }

.filelist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.fileitem {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.fileitem .fname { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileitem .fsize { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fileitem .fx {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 17px; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.fileitem .fx:hover { color: var(--danger); background: rgba(242,101,107,.1); }
.fileitem.bad { border-color: rgba(242,101,107,.4); }
.fileitem .fwarn { font-size: 12px; color: var(--danger); }

/* ---------- button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #062a24; font-weight: 700; font-size: 15px;
  border: none; border-radius: var(--radius-sm);
  padding: 13px 24px; cursor: pointer; font-family: inherit;
  transition: filter .15s, transform .05s;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; margin-top: 28px; }
.btn-ghost {
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--line);
  font-weight: 600; font-size: 13px; padding: 8px 14px;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent-dim); filter: none; }
.btn-danger { background: rgba(242,101,107,.12); color: var(--danger); border: 1px solid rgba(242,101,107,.35); font-weight: 600; font-size: 13px; padding: 8px 14px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- progress ---------- */
.progress { margin-top: 24px; display: none; }
.progress.show { display: block; }
.bar { height: 7px; border-radius: 999px; background: var(--bg-elev-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); transition: width .25s; }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }

/* ---------- success ---------- */
.success { text-align: center; padding: 16px 0 6px; }
.tick {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 20px;
  background: var(--accent-glow); border: 1.5px solid var(--accent-dim);
  display: grid; place-items: center; color: var(--accent); font-size: 28px;
}
.receipt {
  text-align: left; margin-top: 26px;
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden;
}
.receipt div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 15px; font-size: 13.5px; }
.receipt div + div { border-top: 1px solid var(--line-soft); }
.receipt dt { color: var(--text-faint); }
.receipt dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }
.receipt .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- banner ---------- */
.banner {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px;
  border: 1px solid rgba(242,101,107,.3); background: rgba(242,101,107,.08); color: #ffb4b8;
  margin-bottom: 20px; display: none;
}
.banner.show { display: block; }
.banner-info { border-color: var(--line); background: var(--bg-elev-2); color: var(--text-dim); }

/* ---------- admin ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar input[type="text"], .toolbar select { width: auto; min-width: 150px; padding: 9px 12px; font-size: 13.5px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--bg-elev); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 15px 17px; }
.stat .n { font-size: 25px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px; }

.tablewrap { background: var(--bg-elev); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 600; padding: 13px 15px;
  border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
}
th:hover { color: var(--text-dim); }
th .arrow { display: inline-block; width: 0; height: 0; margin-left: 5px; vertical-align: middle; }
th .arrow.up { border-bottom: 5px solid var(--accent); border-left: 4px solid transparent; border-right: 4px solid transparent; }
th .arrow.down { border-top: 5px solid var(--accent); border-left: 4px solid transparent; border-right: 4px solid transparent; }
td { padding: 12px 15px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.team-cell { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.filechip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 12.5px;
  cursor: pointer; color: var(--text); margin: 2px 4px 2px 0; font-family: inherit;
}
.filechip:hover { border-color: var(--accent-dim); color: var(--accent); }

details.teamgroup { background: var(--bg-elev); border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 10px; }
details.teamgroup > summary {
  padding: 14px 18px; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 10px;
  list-style: none;
}
details.teamgroup > summary::-webkit-details-marker { display: none; }
details.teamgroup > summary::before {
  content: '';
  width: 0; height: 0; flex: none;
  border-left: 6px solid var(--text-faint);
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
  transition: transform .15s;
}
details.teamgroup[open] > summary::before { transform: rotate(90deg); }
details.teamgroup .count { color: var(--text-faint); font-weight: 500; font-size: 12.5px; }
.groupbody { padding: 0 18px 16px 34px; }
.playerrow { border-top: 1px solid var(--line-soft); padding: 11px 0; }
.playerrow:first-child { border-top: none; }

.empty { text-align: center; padding: 56px 20px; color: var(--text-faint); font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line-soft); }
.tab {
  background: none; border: none; color: var(--text-faint); font-family: inherit;
  font-size: 13.5px; font-weight: 600; padding: 10px 15px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.editor { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.editor textarea { min-height: 300px; font-family: var(--mono); font-size: 13px; line-height: 1.7; }

.modal-back {
  position: fixed; inset: 0; background: rgba(4,6,11,.72); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-back.show { display: flex; }
.modal { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; padding: 26px; max-width: 560px; width: 100%; max-height: 86vh; overflow: auto; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer { text-align: center; color: var(--text-faint); font-size: 12.5px; margin-top: 34px; }

@media (max-width: 600px) {
  .wrap { padding: 26px 15px 60px; }
  .card { padding: 22px 18px; }
  h1 { font-size: 22px; }
}

/* ---------- team availability ---------- */
.teamgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.teamrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.teamrow .tname { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teamrow.is-closed { border-color: rgba(242,101,107,.35); background: rgba(242,101,107,.07); }
.teamrow.is-closed .tname { color: var(--danger); }
.statechip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--accent-glow); color: var(--accent); border: 1px solid var(--accent-dim);
}
.teamrow.is-closed .statechip { background: rgba(242,101,107,.12); color: var(--danger); border-color: rgba(242,101,107,.35); }

/* ---------- brand chrome ---------- */
.card { backdrop-filter: blur(2px); }
.pill-live { box-shadow: 0 0 0 1px rgba(60,247,211,.08) inset; }
.tick svg { width: 30px; height: 30px; }
.fx svg { width: 13px; height: 13px; display: block; }
.chipicon { width: 12px; height: 12px; flex: none; }
