/* PUBG2 portal — dark military style. No external fonts. */
:root {
  --bg: #0e110d;
  --bg2: #151a13;
  --panel: #1b2118;
  --panel2: #232b1f;
  --line: #34402c;
  --text: #eef0e6;
  --muted: #a9b19b;
  --olive: #6f7f3c;
  --olive-2: #8fa04e;
  --orange: #f08a24;
  --orange-2: #ffa94d;
  --red: #e5534b;
  --green: #5cbf6a;
  --blue: #5aa9e6;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(240, 138, 36, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(111, 127, 60, .18), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 2px, transparent 2px 14px),
    var(--bg);
}
html { background: var(--bg); }

a { color: var(--orange-2); }
a:hover { color: #ffc685; }
:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: .01em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.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;
}

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 480px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(14, 17, 13, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-top: 10px; padding-bottom: 10px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.2rem; letter-spacing: .06em;
  color: var(--text); text-decoration: none; text-transform: uppercase;
}
.brand .logo {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 7px;
  background: linear-gradient(135deg, var(--orange), #b85e10);
  color: #1b1206; font-size: .95rem; font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
}
.brand b { color: var(--orange); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a, .nav button {
  color: var(--muted); text-decoration: none; font: inherit; font-size: .95rem;
  padding: 6px 10px; border-radius: 8px; background: none; border: 0; cursor: pointer;
}
.nav a:hover, .nav button:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--panel2); }
.nav .who { color: var(--text); font-weight: 600; padding: 6px 4px; }

.grid { display: grid; gap: 16px; }
@media (min-width: 860px) {
  .grid.home { grid-template-columns: 1fr 340px; align-items: start; }
}

/* ---------- cards ---------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2, .card-head h1 { margin: 0; }
.card-head .spacer { flex: 1; }
.stripe {
  height: 4px; border-radius: 4px; margin: -6px 0 14px;
  background: repeating-linear-gradient(-45deg, var(--orange) 0 10px, #1b1206 10px 20px);
  opacity: .8;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], textarea, select {
  width: 100%;
  font: inherit; color: var(--text);
  background: #0c0f0b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(240, 138, 36, .3);
}
input[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--red); }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.hint .bad { color: var(--red); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { min-width: 0; }
.row .grow { flex: 1 1 180px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; letter-spacing: .02em;
  min-height: 44px; padding: 10px 18px;
  border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  color: #1b1206;
  background: linear-gradient(180deg, var(--orange-2), var(--orange));
  box-shadow: 0 2px 0 #9b520d;
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.08); color: #1b1206; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #9b520d; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: grayscale(.4); }
.btn.secondary {
  color: var(--text); background: var(--panel2); border-color: var(--line); box-shadow: none;
}
.btn.secondary:hover { background: #2c3626; color: var(--text); }
.btn.olive { color: #f3f6e8; background: linear-gradient(180deg, var(--olive-2), var(--olive)); box-shadow: 0 2px 0 #3f4a1f; }
.btn.olive:hover { color: #fff; }
.btn.danger { color: #fff; background: linear-gradient(180deg, #f06b63, #c9423a); box-shadow: 0 2px 0 #7d2520; }
.btn.danger:hover { color: #fff; }
.btn.ghost { background: none; color: var(--muted); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 1.1rem; padding: 12px 26px; }

/* ---------- alerts ---------- */
.alert {
  border-radius: 8px; padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid; font-weight: 500;
}
.alert.error { background: rgba(229, 83, 75, .12); border-color: rgba(229, 83, 75, .55); color: #ffb3ae; }
.alert.ok { background: rgba(92, 191, 106, .12); border-color: rgba(92, 191, 106, .55); color: #b8f0c0; }
.alert.info { background: rgba(90, 169, 230, .10); border-color: rgba(90, 169, 230, .45); color: #c4e2fa; }
.alert.warn { background: rgba(240, 138, 36, .12); border-color: rgba(240, 138, 36, .55); color: #ffd3a3; }
.alert[hidden] { display: none; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel2); color: var(--muted);
}
.badge.waiting { color: #d6f0a8; border-color: #5d7a2a; background: rgba(111,127,60,.25); }
.badge.playing { color: #ffd3a3; border-color: #a35b17; background: rgba(240,138,36,.18); }
.badge.ended { color: var(--muted); }
.badge.pending { color: #ffd3a3; border-color: #a35b17; background: rgba(240,138,36,.18); }
.badge.active { color: #b8f0c0; border-color: #2f7a3a; background: rgba(92,191,106,.15); }
.badge.blocked { color: #ffb3ae; border-color: #8a2f2a; background: rgba(229,83,75,.15); }
.badge.rejected { color: var(--muted); }
.badge.admin { color: #c4e2fa; border-color: #2e5f86; background: rgba(90,169,230,.15); }
.count-pill {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--orange); color: #1b1206; font-size: .78rem; font-weight: 800;
}
.count-pill[hidden] { display: none; }

/* ---------- lobby list ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lobby-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 8px;
  background: rgba(0,0,0,.25); border: 1px solid var(--line);
}
.lobby-item.mine { border-color: var(--orange); box-shadow: inset 3px 0 0 var(--orange); }
.lobby-item .info { flex: 1 1 200px; min-width: 0; }
.lobby-item .name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.lobby-item .meta { color: var(--muted); font-size: .88rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cap { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.cap.full { color: var(--red); }
.empty {
  text-align: center; color: var(--muted); padding: 26px 10px;
  border: 1px dashed var(--line); border-radius: 8px;
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.stat {
  background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; text-align: center;
}
.stat .v { font-size: 1.4rem; font-weight: 800; color: var(--orange-2); font-variant-numeric: tabular-nums; }
.stat .k { font-size: .8rem; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--panel2); color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: rgba(240,138,36,.08); }
tr.winner td { background: rgba(240,138,36,.12); }
.rank { font-weight: 800; color: var(--muted); }
.rank.r1 { color: #ffd34d; } .rank.r2 { color: #d8dde3; } .rank.r3 { color: #e3a46b; }
.pname { font-weight: 600; overflow-wrap: break-word; }
.uname { color: var(--muted); font-size: .85rem; }

/* compact leaderboard (home) */
.lb { list-style: none; margin: 0; padding: 0; counter-reset: lb; }
.lb li {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.lb li:last-child { border-bottom: 0; }
.lb .pos { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.lb li:nth-child(1) .pos { color: #ffd34d; }
.lb li:nth-child(2) .pos { color: #d8dde3; }
.lb li:nth-child(3) .pos { color: #e3a46b; }
.lb .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .sc { font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lb .sc b { color: var(--text); }
.lb li.me { background: rgba(240,138,36,.08); border-radius: 6px; }

/* ---------- match history ---------- */
.match {
  border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.22);
  overflow: hidden;
}
.match + .match { margin-top: 10px; }
.match summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.match summary::-webkit-details-marker { display: none; }
.match summary::before {
  content: "▸"; color: var(--orange); font-size: 1rem; transition: transform .15s; display: inline-block;
}
.match[open] summary::before { transform: rotate(90deg); }
.match summary:hover { background: rgba(255,255,255,.03); }
.match .title { font-weight: 700; flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.match .when { color: var(--muted); font-size: .85rem; }
.match .win { font-size: .9rem; }
.match .win b { color: #ffd34d; }
.match .body { padding: 0 12px 12px; }

/* ---------- lobby room ---------- */
.room-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.room-head h1 { margin: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
.big-cap { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--orange-2); }
.big-cap small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.member {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px; min-width: 0;
}
.member.me { border-color: var(--olive-2); }
.member.owner { border-color: var(--orange); }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 800;
  background: var(--olive); color: #f3f6e8;
}
.member.owner .avatar { background: var(--orange); color: #1b1206; }
.member .mi { min-width: 0; flex: 1; }
.member .mn { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .mu { color: var(--muted); font-size: .85rem; }
.crown { font-size: 1.15rem; }
.slot { border-style: dashed; color: var(--muted); opacity: .55; }
.slot .avatar { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.waiting-msg { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.dots::after { content: ""; animation: dots 1.5s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab {
  font: inherit; font-weight: 700; color: var(--muted); background: none; border: 0;
  padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 44px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--orange); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  font: inherit; font-size: .88rem; color: var(--muted); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 36px;
}
.chip[aria-pressed=true] { color: #1b1206; background: var(--orange); border-color: var(--orange); font-weight: 700; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* applications (admin) */
.app {
  padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.22);
}
.app .an { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.app .reason {
  margin: 8px 0 12px; padding: 10px 12px; border-left: 3px solid var(--olive-2);
  background: rgba(111,127,60,.10); border-radius: 0 6px 6px 0; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.7);
  display: grid; place-items: center; padding: 16px;
}
.modal-back[hidden] { display: none; }
.modal {
  width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--orange); border-radius: 12px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.cred-card {
  margin: 14px 0; padding: 16px; border-radius: 10px;
  background: #0c0f0b; border: 2px dashed var(--orange);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cred-card .cr { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 4px 0; flex-wrap: wrap; }
.cred-card .ck { color: var(--muted); font-size: .9rem; }
.cred-card .cv { font-size: 1.45rem; font-weight: 800; color: var(--orange-2); letter-spacing: .04em; overflow-wrap: anywhere; }
.cred-card .cv.site { font-size: .95rem; color: var(--text); }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.auth .brand { justify-content: center; display: flex; margin-bottom: 18px; font-size: 1.5rem; }
.auth .brand .logo { width: 42px; height: 42px; font-size: 1.15rem; }
.auth .foot { text-align: center; margin-top: 16px; color: var(--muted); }
.success-box { text-align: center; }
.success-box .icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px;
  display: grid; place-items: center; font-size: 2rem;
  background: rgba(92,191,106,.15); border: 2px solid var(--green); color: var(--green);
}

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.error { border-color: var(--red); color: #ffb3ae; }
.toast[hidden] { display: none; }

.loading { color: var(--muted); padding: 14px 0; }
.show-sm { display: none; }

@media (max-width: 520px) {
  .wrap { padding: 12px; }
  .card { padding: 14px; }
  .topbar .wrap { gap: 6px; padding-top: 8px; padding-bottom: 6px; }
  .nav { width: 100%; margin-left: 0; justify-content: flex-start; gap: 2px; flex-wrap: nowrap; }
  .nav .who { margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .nav a, .nav button { padding: 6px 8px; font-size: .9rem; }
  .nav .home-link { display: none; }
  .row > .btn { flex: 1 1 100%; }
  .lobby-item .btn { width: 100%; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .member.slot { display: none; }
  .tab { flex: 1 1 auto; justify-content: center; padding: 10px 6px; font-size: .92rem; }
  .stack td.cell-rank { font-weight: 800; min-width: 34px; }
  th, td { padding: 8px 6px; }
  .actions .btn { flex: 1 1 100%; }
}

/* tables that turn into cards on phones */
@media (max-width: 640px) {
  .stack { border: 0; }
  .stack table, .stack tbody { display: block; }
  .stack thead { display: none; }
  .stack tr {
    display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
    padding: 12px; margin-bottom: 10px;
    border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.22);
  }
  .stack td { display: block; padding: 0; border: 0; text-align: left; }
  .stack td.cell-main { flex: 1 1 60%; min-width: 0; }
  .stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  .stack td.cell-actions { flex: 1 1 100%; margin-top: 8px; }
  .stack td.hide-sm { display: none; }
  .stack tbody tr:hover td, .stack tr.winner td, .stack tr.me td { background: none; }
  .stack tr.winner { background: rgba(240,138,36,.14); border-color: #a35b17; }
  .stack tr.me { box-shadow: inset 3px 0 0 var(--olive-2); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar, .nav, .btn, .modal-back { display: none !important; }
}
