:root {
  --bg: #f4f5f8; --card: #fff; --text: #14161f; --muted: #6b7080; --line: #e4e6ec;
  --accent: #e31937; --accent-2: #b5102a; --ok: #12a150; --warn: #d98a00; --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .06), 0 4px 16px rgba(20, 22, 31, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* buttons & inputs */
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: #eceef3; }
.btn-danger { background: transparent; color: var(--accent); border: 1px solid #f3c2ca; }
.btn-danger:hover { background: #fdeef0; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 25, 55, .12); }
textarea { resize: vertical; min-height: 70px; }
input[type=color] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.err { color: var(--accent); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(120% 90% at 20% 0%, #3b1a5c 0%, #10132a 55%, #070914 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-hero h1 { font-size: 40px; letter-spacing: -.02em; margin-bottom: 14px; }
.auth-hero p { color: #c9cbe0; font-size: 17px; max-width: 460px; }
.auth-hero img { width: min(520px, 100%); margin: 28px 0 0 -10px; filter: drop-shadow(0 30px 30px rgba(0, 0, 0, .5)); }
.auth-hero ol { color: #dfe0f0; padding-left: 20px; margin: 18px 0 0; }
.auth-hero li { margin: 6px 0; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: 100%; max-width: 380px; }
.tabs { display: flex; gap: 4px; background: #e9ebf0; padding: 4px; border-radius: 12px; margin: 18px 0 22px; }
.tabs a { flex: 1; text-align: center; padding: 8px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600; }
.tabs a.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.auth-card button { width: 100%; justify-content: center; padding: 12px; }

/* shell */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.logo { font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.logo b { color: var(--accent); }
.top .sp { flex: 1; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 16px; margin-bottom: 14px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; flex: 1; min-width: 200px; }

/* games list */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.game-card { display: flex; flex-direction: column; gap: 12px; }
.game-card .gc-head { display: flex; gap: 12px; align-items: center; }
.gc-logo { width: 52px; height: 52px; border-radius: 12px; background: #f0f1f5 center/contain no-repeat; flex: none; border: 1px solid var(--line); }
.gc-head h3 { margin: 0 0 2px; font-size: 17px; }
.gc-link { font-size: 13px; word-break: break-all; }
.gc-stats { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.gc-stats b { color: var(--text); font-size: 18px; display: block; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #e6f6ed; color: var(--ok); }
.badge.off { background: #f1f1f4; color: var(--muted); }
.empty { text-align: center; padding: 48px 20px; }
.empty img { width: 280px; max-width: 80%; }

/* editor */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.ed-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.ed-tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.ed-tabs a.on { color: var(--text); border-color: var(--accent); }
.savebar { position: sticky; bottom: 16px; margin-top: 16px; background: #14161f; color: #fff; border-radius: 14px; padding: 12px 14px 12px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.savebar .sp { flex: 1; }
.savebar.clean { background: #fff; color: var(--muted); box-shadow: var(--shadow); }
.linkbox { display: flex; gap: 8px; align-items: center; background: #f6f7fa; border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; }
.linkbox code { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slug-in { display: flex; align-items: stretch; }
.slug-in span { background: #f0f1f5; border: 1px solid var(--line); border-right: 0; border-radius: 10px 0 0 10px; padding: 10px 10px; color: var(--muted); font-size: 14px; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.slug-in input { border-radius: 0 10px 10px 0; }
.logo-up { display: flex; gap: 14px; align-items: center; }
.logo-prev { width: 120px; height: 72px; border-radius: 12px; border: 1px dashed #c9ccd6; background: #fafbfc center/contain no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px; flex: none; }
.colors { display: flex; gap: 22px; flex-wrap: wrap; }
.colors .row { gap: 8px; }

/* tiers */
.ladder { position: relative; height: 74px; margin: 6px 0 22px; }
.ladder-track { position: absolute; left: 0; right: 0; top: 28px; height: 22px; background: #eef0f4; border-radius: 6px; }
.ladder-truck { position: absolute; top: 31px; height: 16px; background: #c7cbd6; border-radius: 3px; }
.ladder-mark { position: absolute; top: 0; transform: translateX(-50%); text-align: center; font-size: 11px; font-weight: 700; white-space: nowrap; }
.ladder-mark::after { content: ''; display: block; width: 2px; height: 34px; background: var(--accent); margin: 2px auto 0; }
.ladder-scale { position: absolute; top: 56px; left: 0; right: 0; font-size: 11px; color: var(--muted); }
.ladder-scale span { position: absolute; transform: translateX(-50%); }
.tier { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fcfcfd; }
.tier-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.tier-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.tier-grid { display: grid; grid-template-columns: 130px 1fr; gap: 0 12px; }
.dist-in { position: relative; }
.dist-in input { padding-right: 30px; }
.dist-in::after { content: attr(data-u); position: absolute; right: 12px; top: 10px; color: var(--muted); }
.code-modes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.code-modes label { margin: 0; font-weight: 600; font-size: 13px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; background: #fff; }
.code-modes input { display: none; }
.code-modes label:has(input:checked) { border-color: var(--accent); background: #fff1f3; color: var(--accent); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef0f4; color: var(--muted); font-weight: 600; }
.pill.warn { background: #fff4dc; color: var(--warn); }

/* preview */
.preview { position: sticky; top: 76px; }
.phone { width: 340px; height: 690px; margin: 0 auto; border-radius: 44px; background: #0d0f16; padding: 12px; box-shadow: 0 20px 50px rgba(20, 22, 31, .25); }
.phone iframe { width: 100%; height: 100%; border: 0; border-radius: 34px; background: #000; }
.preview .row { justify-content: center; margin-top: 12px; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; letter-spacing: -.02em; }
.kpi span { font-size: 13px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.bar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.bar em { font-style: normal; color: var(--text); font-weight: 700; margin-bottom: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid #f0f1f5; }
td code { background: #f3f4f7; padding: 2px 6px; border-radius: 6px; }
.table-wrap { overflow-x: auto; }
.qr { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
#qrbox { background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 20, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; }
.modal h2 { margin-bottom: 16px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #14161f; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 100; pointer-events: none; font-weight: 600; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--accent); }

@media (max-width: 1020px) {
  .ed { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 22px; }
  .auth-hero h1 { font-size: 30px; }
  .grid2, .tier-grid { grid-template-columns: 1fr; }
  .wrap { padding: 16px 12px 80px; }
  .phone { width: 300px; height: 610px; }
}

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.mode-card { display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; margin: 0; font-weight: 400; font-size: 14px; background: #fff; }
.mode-card input { display: none; }
.mode-card.on, .mode-card:has(input:checked) { border-color: var(--accent); background: #fff5f6; }
.mode-card b { font-size: 17px; }
.mode-ic { font-size: 30px; }
.mode-card .pill { align-self: flex-start; }
@media (max-width: 600px) {
  .top .logo .muted, .top-in > .muted { display: none; }
  .top-in { gap: 10px; }
}
