:root {
  --primary: #FF6600;
  --primary-soft: rgba(255,102,0,.14);
  --primary-border: rgba(255,102,0,.45);
  --cyan: #00E0FF;
  --cyan-soft: rgba(0,224,255,.14);
  --green: #10B981;
  --green-soft: rgba(16,185,129,.14);
  --gold: #F59E0B;
  --red: #E5484D;
  --bg: #0d0f17;
  --bg2: #131722;
  --card: #161b27;
  --card2: #0d1017;
  --line: #2a3247;
  --text: #e8ecf4;
  --muted: #8b93a7;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea {
  font-family: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: #5a6275; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3247; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

#app { height: 100%; }

/* ---------- Login screen ---------- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, rgba(255,102,0,.08), transparent), var(--bg); }
.login-card { width: 100%; max-width: 440px; }
.login-logo { width: 80px; height: 80px; border-radius: 20px; margin: 0 auto 14px; display: block; object-fit: cover; border: 2px solid var(--primary); box-shadow: 0 0 30px rgba(255,102,0,.35); }
.login-title { text-align: center; font-size: 24px; font-weight: 900; letter-spacing: 1px; }
.login-sub { text-align: center; color: var(--cyan); font-size: 12px; margin: 4px 0 22px; font-weight: 600; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab { flex: 1; text-align: center; padding: 9px 0; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--muted); background: transparent; }
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.auth-header .tag { color: var(--primary); font-size: 13px; font-weight: 700; }
.auth-badge { background: var(--cyan-soft); color: var(--cyan); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; }
.id-preview { background: var(--bg2); border: 1px dashed rgba(0,224,255,.35); border-radius: 8px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); margin-bottom: 14px; }
.id-preview b { color: var(--cyan); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; font-weight: 700; padding: 10px 16px; font-size: 14px; transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-cyan { background: var(--cyan); color: #0b1a20; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn-red { background: var(--red); color: #fff; }
.btn-gold { background: var(--gold); color: #1a1205; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.login-footer { text-align: center; color: var(--muted); font-size: 11px; margin-top: 18px; }
.hint-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 12px; }
.hint-box .hl { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }

/* ---------- App shell ---------- */
.shell { display: flex; flex-direction: column; height: 100%; }
.banner { background: #2c2216; border: 1px solid var(--primary-border); color: #fff; font-size: 12px; padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
.banner .ic { color: var(--primary); }
.banner .txt { flex: 1; }
.banner .close { background: transparent; color: var(--muted); font-size: 14px; padding: 0 4px; }
.content { flex: 1; overflow-y: auto; padding-bottom: 74px; }
.navbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(19,23,34,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex;
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); font-size: 10px; background: transparent; }
.nav-item .ico { font-size: 18px; line-height: 1; }
.nav-item.active { color: var(--primary); }
.nav-item.active .ico { filter: drop-shadow(0 0 8px rgba(255,102,0,.6)); }

.page { padding: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.page-title { font-size: 17px; font-weight: 800; }
.page-sub { font-size: 12px; color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-row { display: flex; align-items: center; gap: 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-orange { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-border); }
.badge-cyan { background: var(--cyan-soft); color: var(--cyan); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: rgba(229,72,77,.15); color: var(--red); }
.badge-gray { background: rgba(139,147,167,.15); color: var(--muted); }
.badge-gold { background: rgba(245,158,11,.15); color: var(--gold); }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.chip { flex-shrink: 0; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Tournament cards ---------- */
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; cursor: pointer; }
.tcard.selected { border: 2px solid var(--primary); }
.tcard-cover { height: 120px; background-size: cover; background-position: center; position: relative; }
.tcard-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 20%, rgba(13,15,23,.92)); }
.tcard-body { padding: 12px 14px; }
.tcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tcard-name { font-size: 15px; font-weight: 800; flex: 1; }
.tcard-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tcard-actions { display: flex; gap: 4px; }
.tcard-actions button { background: transparent; color: var(--muted); font-size: 15px; padding: 4px 6px; border-radius: 6px; }
.tcard-actions button:hover { color: var(--primary); background: var(--primary-soft); }
.progress { height: 5px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--cyan)); border-radius: 4px; }
.progress-label { font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ---------- Bracket ---------- */
.bracket-toolbar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.bracket-toolbar button { flex-shrink: 0; }
.match-grid { display: grid; gap: 10px; }
.mcard { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; transition: border-color .15s; }
.mcard:hover { border-color: var(--primary); }
.mcard.complete { border-color: rgba(16,185,129,.4); }
.mcard .mhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mcard .mnum { font-size: 11px; color: var(--muted); }
.mcard .mstatus { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.st-complete { background: var(--green-soft); color: var(--green); }
.st-ready { background: var(--cyan-soft); color: var(--cyan); }
.st-pending { background: var(--bg2); color: var(--muted); }
.st-progress { background: var(--primary-soft); color: var(--primary); }
.st-bye { background: var(--gold); color: #1a1205; }
.mplayer { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; border-radius: 6px; font-size: 12.5px; }
.mplayer.winner { background: var(--green-soft); color: var(--green); font-weight: 700; }
.mplayer .pscore { font-weight: 800; font-size: 13px; }
.mplayer .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th, table.tbl td { padding: 7px 6px; text-align: center; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-weight: 600; }
table.tbl td:first-child { color: var(--primary); font-weight: 700; }
table.tbl .cell-name { text-align: left; }

/* ---------- Dialogs ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(5,7,12,.7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; padding: 18px; box-shadow: var(--shadow); }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close { background: transparent; color: var(--muted); font-size: 20px; }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: fadein .2s; max-width: 90vw; }
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.tag .x { color: var(--muted); cursor: pointer; margin-left: 4px; }
.tag .x:hover { color: var(--red); }

.avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--cyan)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 800; flex-shrink: 0; }
.theme-swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.theme-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); }
.log-list { max-height: 460px; overflow-y: auto; }
.log-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.log-row .log-action { font-weight: 700; white-space: nowrap; }
.role-select { background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 8px; font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Lucky wheel ---------- */
.wheel-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.wheel-box { position: relative; width: 300px; height: 300px; }
.wheel-box canvas { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 40px rgba(255,102,0,.25); }
.wheel-pointer { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 26px solid var(--gold); z-index: 2; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.wheel-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 72px; height: 72px; border-radius: 50%; background: var(--bg2); border: 2px solid var(--primary); color: var(--primary); font-weight: 900; font-size: 15px; z-index: 3; }

/* ---------- Admin ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 800; margin-top: 4px; color: var(--cyan); }
.log-item { font-size: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.log-item .t { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.log-item .act { font-weight: 700; margin: 1px 0; }
.role-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.role-ADMIN { background: rgba(245,158,11,.18); color: var(--gold); }
.role-MODERATOR { background: var(--cyan-soft); color: var(--cyan); }
.role-USER { background: rgba(139,147,167,.18); color: var(--muted); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-1 { flex: 1; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.text-primary { color: var(--primary); }
.text-cyan { color: var(--cyan); }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }
textarea.ta { width: 100%; min-height: 80px; resize: vertical; }

/* Round robin / group standings */
.standings { margin-top: 4px; }

@media (min-width: 900px) {
  .match-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .match-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .wrap-lg { max-width: 1000px; margin: 0 auto; }
}
