@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  /* Backgrounds */
  --void: #0d0810;
  --surface-1: #151018;
  --surface-2: #1e1525;
  --surface-3: #2a2033;

  /* Accents */
  --red: #dc143c;
  --red-deep: #8b0a1a;
  --red-glow: rgba(220, 20, 60, 0.22);
  --violet: #7b2d8e;
  --violet-deep: #4a1259;
  --violet-glow: rgba(123, 45, 142, 0.18);
  --gold: #c9a037;
  --gold-light: #e5c158;

  /* Playing card face */
  --card-face: #f5f0e8;
  --card-ink: #1a1a1a;
  --card-ink-red: #b81c1c;

  /* Text */
  --text: #f0ede5;
  --text-muted: #aa9fb3;
  --text-dim: #6a5f74;

  /* Borders */
  --border-dim: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.10);
  --border-medium: rgba(255, 255, 255, 0.18);
  --border-gold: rgba(201, 160, 55, 0.35);

  /* Status */
  --ok: #1e7f4e;
  --ok-text: #4dca8a;
  --warning: #a07800;
  --danger: #b52020;
  --danger-text: #f07070;

  /* Team */
  --team-a: #cc2222;
  --team-b: #3355cc;

  /* Typography */
  --font-display: "Cormorant Garamond", serif;
  --font-heading: "Cormorant Garamond", serif;
  --font-body: "Manrope", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(220, 20, 60, 0.11), transparent 28%),
    radial-gradient(circle at top right, rgba(123, 45, 142, 0.1), transparent 32%),
    linear-gradient(180deg, #0d0810 0%, #120a18 46%, #0d0810 100%);
  font-family: var(--font-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: var(--gold-light);
}

.container {
  width: min(1100px, 96vw);
  margin: 0 auto;
  padding: 24px 0 40px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
}

h2 {
  margin-top: 0;
  font-family: var(--font-heading);
  font-size: 1.08rem;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 10px;
  background: var(--surface-3);
  color: var(--text);
  transition: border-color 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-gold);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(229, 193, 88, 0.88);
  outline-offset: 2px;
}

select option {
  background: var(--surface-3);
  color: var(--text);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

button {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

button:hover {
  background: var(--surface-3);
  border-color: var(--border-medium);
}

button.secondary {
  background: transparent;
  color: var(--gold);
  border-color: var(--border-gold);
}

button.secondary:hover {
  background: rgba(201, 160, 55, 0.08);
}

button.danger {
  background: rgba(153, 21, 21, 0.55);
  border-color: var(--red);
  color: #ffb0b0;
}

button.danger:hover {
  background: var(--red-deep);
  color: #fff;
}

button.warning {
  background: rgba(130, 95, 0, 0.35);
  border-color: rgba(201, 160, 55, 0.5);
  color: var(--gold-light);
}

button.warning:hover {
  background: rgba(130, 95, 0, 0.55);
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
  filter: brightness(0.82);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Button async feedback states ────────────── */
button.btn-loading {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}

button.btn-loading::after {
  content: " …";
  opacity: 0.7;
}

@keyframes btn-flash-ok {
  0%   { background: rgba(30, 127, 78, 0.35); border-color: rgba(30, 127, 78, 0.7); color: #4dca8a; }
  70%  { background: rgba(30, 127, 78, 0.35); border-color: rgba(30, 127, 78, 0.7); color: #4dca8a; }
  100% { background: inherit; border-color: inherit; color: inherit; }
}

@keyframes btn-flash-err {
  0%   { background: rgba(204, 28, 28, 0.35); border-color: rgba(204, 28, 28, 0.7); color: #f07070; }
  70%  { background: rgba(204, 28, 28, 0.35); border-color: rgba(204, 28, 28, 0.7); color: #f07070; }
  100% { background: inherit; border-color: inherit; color: inherit; }
}

button.btn-ok {
  animation: btn-flash-ok 1.1s ease-out forwards;
}

button.btn-err {
  animation: btn-flash-err 1.4s ease-out forwards;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
}

.badge.ok {
  background: rgba(30, 127, 78, 0.15);
  color: #4dca8a;
  border-color: rgba(30, 127, 78, 0.3);
}

.badge.warn {
  background: rgba(160, 120, 0, 0.15);
  color: var(--gold-light);
  border-color: rgba(160, 120, 0, 0.3);
}

.badge.error {
  background: rgba(181, 32, 32, 0.15);
  color: #f07070;
  border-color: rgba(181, 32, 32, 0.3);
}

/* ── Log ─────────────────────────────────────── */
.log {
  border: 1px solid var(--border-dim);
  background: var(--void);
  border-radius: 8px;
  padding: 10px;
  min-height: 130px;
  max-height: 280px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Key-Value rows ──────────────────────────── */
.kv {
  display: grid;
  gap: 5px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 5px;
  font-size: 0.84rem;
}

.kv-row span:first-child {
  color: var(--text-dim);
}

.kv-row strong {
  color: var(--text);
}

/* ── Nav links ───────────────────────────────── */
.nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-links a {
  padding: 6px 11px;
  border: 1px solid var(--border-gold);
  border-radius: 7px;
  background: rgba(201, 160, 55, 0.06);
  color: var(--gold);
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 140ms ease;
}

.nav-links a:hover {
  background: rgba(201, 160, 55, 0.14);
}

/* ── Utility ─────────────────────────────────── */
.small {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* ── Scanner preview ─────────────────────────── */
.scan-preview-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: #000;
  overflow: hidden;
  margin-bottom: 8px;
}

.scan-preview {
  width: 100%;
  max-height: 300px;
  display: block;
  background: #000;
}

/* ── Tables ──────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: auto;
  background: var(--surface-1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.88rem;
}

th {
  background: var(--void);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  font-weight: 600;
}

td {
  color: var(--text);
}

/* ── Team pills ──────────────────────────────── */
.team-pill {
  display: inline-block;
  min-width: 68px;
  text-align: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.team-pill.a {
  background: rgba(204, 34, 34, 0.14);
  color: #f07070;
  border: 1px solid rgba(204, 34, 34, 0.28);
}

.team-pill.b {
  background: rgba(51, 85, 204, 0.14);
  color: #7090f5;
  border: 1px solid rgba(51, 85, 204, 0.28);
}

.team-pill.none {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  border: 1px solid var(--border-dim);
}

/* ── QR box ──────────────────────────────────── */
.qr-box {
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
  text-align: center;
}

.qr-box img {
  max-width: 210px;
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #fff;
}

.status-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* ── Hero ────────────────────────────────────── */
.hero {
  padding: 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1a0808 0%, #0f0a0a 60%, #080808 100%);
  border: 1px solid rgba(201, 160, 55, 0.2);
  color: var(--text);
  margin-bottom: 16px;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.3rem;
  }

  .container {
    width: 94vw;
    padding-top: 16px;
  }

  .panel {
    padding: 12px;
  }
}
