/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { background: var(--surface); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

a { color: #93c5fd; text-decoration: none; }
a:hover { color: var(--brand-snow); }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.025em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 600; }

code, .mono { font-family: var(--font-mono); font-size: 0.875em; }

:focus-visible { outline: 2px solid var(--brand-green); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: 0.8125rem; }
.eyebrow {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--brand-green);
}

/* ---------- Backdrop (hero gradient + grid, as on the public site) ---------- */
.backdrop { position: relative; isolation: isolate; }
.backdrop::before,
.backdrop::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
}
.backdrop::before { background-image: var(--hero-gradient); }
.backdrop::after {
  background-image: var(--grid-lines);
  background-size: 48px 48px;
  mask-image: radial-gradient(at top, #000 20%, transparent 70%);
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex; align-items: center; gap: 0.625rem;
  color: var(--text); font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand img { width: 32px; height: 32px; }
.brand small {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0.5rem 1.125rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  background: rgb(255 255 255 / 0.04); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.875rem; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgb(255 255 255 / 0.08); color: var(--text); }
.btn-primary { background: var(--brand-blue); border-color: transparent; box-shadow: var(--shadow-glow); }
.btn-primary:hover { background: var(--brand-blue-light); }
.btn-success { background: var(--brand-green); border-color: transparent; color: var(--brand-ink); }
.btn-success:hover { background: #4ade80; color: var(--brand-ink); }
.btn-danger { border-color: rgb(239 68 68 / 0.5); color: #fca5a5; background: transparent; }
.btn-danger:hover { background: rgb(239 68 68 / 0.12); color: #fecaca; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 2rem; padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem;
}
.card + .card { margin-top: 1.25rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1.125rem; }
.form-grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: grid; gap: 0.375rem; }
.field label { font-size: 0.8125rem; font-weight: 600; color: #cbd5e1; }
.field .help { font-size: 0.75rem; color: var(--text-subtle); }
.field .errorlist, .form-errors {
  margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; color: #fca5a5;
}
.form-errors {
  padding: 0.75rem 1rem; border-radius: var(--radius-md);
  background: rgb(239 68 68 / 0.1); border: 1px solid rgb(239 68 68 / 0.3);
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], select {
  width: 100%; min-height: 2.625rem; padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text); font: inherit;
}
input::placeholder { color: var(--text-subtle); }
input:focus, select:focus {
  outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px #2563eb4d;
}
textarea {
  width: 100%; padding: 0.75rem 0.875rem; resize: vertical;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text);
  font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.6;
}
textarea:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px #2563eb4d; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input[type="date"] { width: auto; min-height: 2.625rem; padding: 0.5rem 0.875rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text); font: inherit; color-scheme: dark; }

.field-checkbox { display: flex; align-items: flex-start; gap: 0.75rem; }
.field-checkbox input { width: 1.125rem; height: 1.125rem; margin-top: 0.15rem; accent-color: var(--brand-blue); }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left; font-weight: 600; font-size: 0.75rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-subtle);
  padding: 0.625rem 0.75rem; border-bottom: 1px solid var(--border);
}
td { padding: 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.125rem 0.625rem; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--border-strong); color: #cbd5e1;
}
.badge-super_admin { background: #2563eb26; border-color: #2563eb66; color: #93c5fd; }
.badge-admin { background: #22c55e26; border-color: #22c55e66; color: #86efac; }
.badge-player { background: rgb(255 255 255 / 0.04); }
.badge-active::before, .badge-inactive::before {
  content: ""; width: 0.4rem; height: 0.4rem; border-radius: 50%;
}
.badge-active::before { background: var(--brand-green); }
.badge-inactive::before { background: var(--text-subtle); }

/* ---------- Messages ---------- */
.messages { display: grid; gap: 0.5rem; margin: 0 0 1.25rem; padding: 0; list-style: none; }
.message {
  padding: 0.75rem 1rem; border-radius: var(--radius-md); font-size: 0.875rem;
  border: 1px solid var(--border-strong); background: var(--surface-raised);
}
.message-success { border-color: #22c55e66; background: #22c55e1a; }
.message-error { border-color: rgb(239 68 68 / 0.4); background: rgb(239 68 68 / 0.1); }
.message-info, .message-warning { border-color: #2563eb66; background: #2563eb1a; }

/* ---------- Auth layout ---------- */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { margin-bottom: 1.5rem; }
.auth-card h1 { margin-bottom: 0.375rem; }
.auth-card .lead { margin: 0 0 1.5rem; color: var(--text-muted); }
.auth-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-top: 1.5rem; font-size: 0.8125rem;
}

/* ---------- Console layout ---------- */
.console { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.5rem 1rem;
  background: var(--surface-overlay);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.sidebar .brand { padding: 0 0.5rem; }
.nav { display: grid; gap: 0.25rem; }
.nav-label {
  padding: 0.75rem 0.75rem 0.25rem; font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-subtle);
}
.nav a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-md);
  color: #cbd5e1; font-weight: 500; font-size: 0.9rem;
}
.nav a:hover { background: rgb(255 255 255 / 0.05); color: var(--text); }
.nav a[aria-current="page"] { background: #2563eb26; color: var(--text); box-shadow: inset 2px 0 0 var(--brand-blue); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; }

.sidebar-footer { margin-top: auto; display: grid; gap: 0.75rem; padding: 0 0.5rem; }
.user-chip { display: flex; align-items: center; gap: 0.75rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand-blue-light), var(--brand-blue-dark));
  font-weight: 700; font-size: 0.875rem;
}
.user-chip .name { font-weight: 600; font-size: 0.875rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form select { min-height: 2rem; padding: 0.25rem 0.5rem; font-size: 0.8125rem; }

.main { min-width: 0; padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem; }
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem;
}
.page-header p { margin: 0.375rem 0 0; color: var(--text-muted); }

.topbar, .topbar-close { display: none; }

/* ---------- Dashboard ---------- */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.25rem; }
.stat { padding: 1.25rem 1.5rem; }
.stat .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.stat .label { color: var(--text-muted); font-size: 0.8125rem; }

.event-list { margin: 0; padding: 0; list-style: none; }
.event-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem;
}
.event-list li:last-child { border-bottom: 0; }

/* ---------- Filters / tabs / pagination ---------- */
.filters { display: grid; gap: 0.75rem; grid-template-columns: 2fr 1fr 1fr auto; margin-bottom: 1.25rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.tabs a {
  padding: 0.5rem 1rem; border-radius: var(--radius-full); border: 1px solid var(--border);
  color: #cbd5e1; font-size: 0.875rem; font-weight: 500;
}
.tabs a[aria-current="page"] { background: var(--brand-blue); border-color: transparent; color: var(--text); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1.25rem; font-size: 0.875rem; }

.changes { margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--text-muted); }

/* ---------- Secret reveal ---------- */
.secret-box {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; margin: 1.25rem 0;
  border-radius: var(--radius-md); border: 1px dashed #22c55e80; background: #22c55e14;
  font-family: var(--font-mono); font-size: 1.125rem; word-break: break-all;
}

/* ---------- Play placeholder ---------- */
.play-hero { text-align: center; max-width: 640px; margin: 4rem auto; }
.play-hero h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0.75rem 0; }
.play-hero p { color: var(--text-muted); font-size: 1.0625rem; }
.tiles { display: flex; justify-content: center; gap: 1rem; margin: 2.5rem 0; }
.tile {
  width: 56px; height: 112px; border-radius: 12px; background: var(--brand-snow);
  display: grid; grid-template-rows: 1fr 1fr; padding: 8px; box-shadow: var(--shadow-glow);
  position: relative;
}
.tile::after {
  content: ""; position: absolute; left: 10px; right: 10px; top: calc(50% - 1px);
  height: 2px; border-radius: 1px; background: var(--brand-green);
}
.tile:nth-child(1) { transform: rotate(-12deg); }
.tile:nth-child(3) { transform: rotate(12deg); }
.pips { display: grid; grid-template-columns: repeat(3, 1fr); place-items: center; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-ink); }
.pips i.off { background: transparent; }
.play-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--border); background: var(--surface-overlay);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10;
}
.site-header nav { display: flex; align-items: center; gap: 0.5rem; }

/* ---------- Public legal pages ---------- */
.lang-switch { display: flex; gap: 0.25rem; }
.lang-switch a { padding: 0.25rem 0.75rem; border-radius: var(--radius-full); color: var(--text-muted); font-size: 0.8125rem; }
.lang-switch a[aria-current] { background: #2563eb26; color: var(--text); }
.legal { max-width: 760px; margin: 0 auto; padding: 2.5rem 16px 3rem; }
.legal-text h1 { font-size: clamp(1.75rem, 5vw, 2.25rem); }
.legal-text h2 { font-size: 1.1875rem; margin: 2rem 0 0.5rem; }
.legal-text p, .legal-text li { color: #cbd5e1; font-size: 1rem; line-height: 1.7; }
.legal-text p { margin: 0 0 1rem; }
.legal-text ul { margin: 0 0 1rem; padding-left: 1.25rem; display: grid; gap: 0.375rem; }
.legal-text strong { color: var(--text); }
.legal-text a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.legal-meta { margin: 0.5rem 0 1.75rem !important; color: var(--text-subtle) !important; font-size: 0.875rem !important; }
.legal-form { margin-top: 2rem; display: grid; gap: 1rem; }
.legal-form .form-actions { justify-content: flex-start; margin-top: 1rem; }
.legal-secondary { flex-wrap: wrap; }
.legal-footer {
  max-width: 760px; margin: 0 auto; padding: 1.5rem 16px 3rem;
  border-top: 1px solid var(--border); display: grid; gap: 0.5rem;
}
.legal-footer nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.875rem; }

/* ---------- Notification templates ---------- */
.notify-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.notify-layout > .card { margin-bottom: 0; }
.notify-layout + .card { margin-top: 1.25rem; }
.notify-language { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem 1.25rem 0.25rem; margin: 0 0 1.25rem; }
.notify-language legend { padding: 0 0.5rem; font-weight: 600; }
.notify-preview { position: sticky; top: 1rem; }
.notify-subjects { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; margin: 0 0 1rem; font-size: 0.875rem; }
.notify-subjects dt { color: var(--text-muted); }
.notify-subjects dd { margin: 0; overflow-wrap: anywhere; }
.email-frame { display: block; width: 100%; height: 760px; border: 1px solid var(--border); border-radius: var(--radius-md); background: #F3F4F6; }
.notify-look { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.notify-logo { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.notify-swatch { display: inline-block; width: 0.875rem; height: 0.875rem; border-radius: 4px; vertical-align: -2px; margin-right: 0.375rem; border: 1px solid var(--border); }
/* The list: one card per email, with a live, scaled-down preview of it on top. */
.notify-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 1.25rem; }
.notify-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; margin-bottom: 0; }
.notify-thumb { display: block; position: relative; height: 330px; overflow: hidden; background: #F3F4F6; border-bottom: 1px solid var(--border); }
.notify-thumb iframe { position: absolute; top: 0; left: 0; width: 200%; height: 200%; border: 0; transform: scale(0.5); transform-origin: 0 0; pointer-events: none; background: #F3F4F6; }
.notify-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 70%, var(--surface-raised, #141B2D) 100%); opacity: 0.9; }
.notify-card-body { padding: 1rem 1.25rem 1.25rem; display: grid; gap: 0.5rem; flex: 1; }
.notify-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.notify-card-head h2 { margin: 0; font-size: 1.0625rem; }
.notify-card-body .muted { margin: 0; font-size: 0.875rem; }
.notify-subject { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.notify-subject .subtle { margin-right: 0.375rem; }
.notify-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: auto; padding-top: 0.5rem; font-size: 0.8125rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .notify-layout { grid-template-columns: 1fr; }
  .notify-preview { position: static; }
}
@media (max-width: 900px) {
  .console { grid-template-columns: 1fr; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--surface-overlay); position: sticky; top: 0; z-index: 20;
    backdrop-filter: blur(12px);
  }
  .sidebar {
    display: none; position: fixed; inset: 0; z-index: 30; height: 100vh;
    background: var(--surface); border-right: 0;
  }
  .sidebar.is-open { display: flex; }
  .topbar-close { display: inline-flex; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .main { padding-top: 1.25rem; }
}

@media (max-width: 520px) {
  .filters { grid-template-columns: 1fr; }
  .card { padding: 1.125rem; border-radius: var(--radius-lg); }
  .table-wrap { margin: 0 -1.125rem; padding: 0 1.125rem; }
}
