:root {
  --bg: #0f1014; --bg2: #16181f; --card: #1c1f28; --card2: #232733; --line: #2c3140;
  --text: #e8e9ee; --muted: #8b90a0; --red: #e0262b; --red2: #ff4a4f; --gold: #f2b134; --green: #2ecc71; --blue: #3b82f6;
  --radius: 12px; --nav-h: 62px; --top-h: 60px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif; font-size: 15px; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 700; letter-spacing: .2px; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.02rem; margin-top: 12px; color: #fff; }
p { margin: 6px 0; line-height: 1.45; }
a, .link { color: var(--red2); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.small { font-size: .84rem; } .muted { color: var(--muted); } .warn { color: #ffb347; } .note { color: var(--gold); } .pos { color: var(--green); } .negt { color: var(--red2); } .neg { color: var(--red2) !important; }
.row { display: flex; align-items: center; } .row.gap { gap: 8px; } .row.between { justify-content: space-between; } .row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.list { padding-left: 18px; margin: 6px 0; } .list li { margin: 3px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .95rem; }
select { cursor: pointer; }

.btn { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #4a5065; background: #2a2f3d; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; } .btn.primary:hover { background: var(--red2); }
.btn.danger { border-color: #7a2a2d; color: #ff8a8e; } .btn.danger:hover { background: #3a1c1e; }
.btn.small { padding: 5px 10px; font-size: .82rem; } .btn.big { width: 100%; padding: 13px; font-size: 1.05rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { color: #fff; }
.btn.opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; flex: 1; } .btn.opt span { font-size: .78rem; color: var(--muted); font-weight: 400; }
.opts { display: flex; gap: 8px; margin: 12px 0; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: 6px 10px; }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; padding: 0 2px; } .x:hover { color: var(--red2); }

/* Start */
#start { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(ellipse at top, #2a1416 0%, var(--bg) 55%); }
.start-box { width: 100%; max-width: 440px; text-align: center; }
.logo { font-size: 2.6rem; font-weight: 900; letter-spacing: 2px; margin-bottom: 4px; } .logo span { color: var(--red2); }
.tag { color: var(--muted); margin-bottom: 20px; }
.start-box .card { text-align: left; } .start-box label { margin-bottom: 10px; } .start-box .btn.big { margin: 10px 0; }

/* Layout */
#app { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: var(--top-h) 1fr; height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 4px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); }
.top-info { flex: 1; min-width: 0; } .top-date { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .top-stats { font-size: .82rem; color: var(--muted); } .top-stats #top-cash { color: var(--gold); font-weight: 700; }
.top-actions { display: flex; gap: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; background: var(--bg2); border-right: 1px solid var(--line); overflow-y: auto; }
.nav-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--muted); padding: 10px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600; text-align: left; position: relative; }
.nav-btn:hover { background: var(--card); color: #fff; } .nav-btn.active { background: var(--card2); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.nav-btn .ic { font-size: 1.15rem; width: 24px; text-align: center; }
.badge { position: absolute; right: 10px; top: 8px; background: var(--red); color: #fff; border-radius: 10px; font-size: .7rem; padding: 1px 6px; font-weight: 700; }
.screen { overflow-y: auto; padding: 16px; scroll-behavior: smooth; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0; }
.kpi { background: var(--bg2); border-radius: 10px; padding: 10px; text-align: center; } .kpi .v { font-size: 1.15rem; font-weight: 800; color: #fff; } .kpi .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Fighter cards */
.fighter-row, .fighter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.fcard { display: flex; gap: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; transition: .15s; }
.fcard:hover { border-color: #4a5065; transform: translateY(-1px); } .fcard.market { cursor: default; } .fcard.market:hover { transform: none; }
.fc-body { min-width: 0; flex: 1; } .fc-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard .row { margin-top: 6px; }
.avatar { flex: none; border-radius: 10px; }
.ovr { display: inline-block; background: var(--red); color: #fff; font-weight: 800; border-radius: 6px; padding: 1px 7px; font-size: .85rem; } .ovr.unk { background: #3b4050; }
.ovr-line { margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tag { display: inline-block; background: #2d3242; color: #cfd3de; border-radius: 6px; padding: 1px 7px; font-size: .72rem; font-weight: 600; }
.tag.camp { background: #1f3b2b; color: #7fe0a7; } .tag.inj { background: #4a1f21; color: #ff9a9e; } .tag.tired { background: #4a3a1a; color: #ffd27f; }
.org-pill { display: inline-block; color: #fff; font-weight: 700; font-size: .72rem; padding: 2px 8px; border-radius: 6px; text-shadow: 0 1px 1px rgba(0,0,0,.5); vertical-align: middle; }
.big-ovr { font-size: 2rem; font-weight: 900; color: var(--red2); margin: 4px 0; }
.attrs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 12px; }
.attr { display: grid; grid-template-columns: 82px 1fr 30px; align-items: center; gap: 8px; font-size: .82rem; }
.bar { height: 8px; background: #2a2f3d; border-radius: 4px; overflow: hidden; } .fill { height: 100%; background: linear-gradient(90deg, #c0392b, #ff6b6b); border-radius: 4px; } .fill.unk { background: #3b4050; }
.attr .av { text-align: right; font-weight: 700; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.meter { display: grid; grid-template-columns: 90px 1fr 30px; align-items: center; gap: 8px; font-size: .82rem; } .meter .mv { text-align: right; font-weight: 700; }
.fill.hype { background: linear-gradient(90deg, #f39c12, #f1c40f); } .fill.morale { background: linear-gradient(90deg, #27ae60, #2ecc71); } .fill.fatigue { background: linear-gradient(90deg, #8e44ad, #e74c3c); } .fill.sharp { background: linear-gradient(90deg, #2980b9, #3498db); }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; } .tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: .76rem; text-transform: uppercase; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid #23273199; } .tbl tr.mine td { background: #2a1a1c; } .tbl tr.w td:last-child { color: var(--green); } .tbl tr.l td:last-child { color: var(--red2); }
.tbl td.w { color: var(--green); font-weight: 700; } .tbl [data-fighter] { cursor: pointer; } .tbl [data-fighter]:hover { color: #fff; text-decoration: underline; }
.card-tbl td:nth-child(2), .card-tbl td:nth-child(4) { width: 34%; }

/* News */
.news-item { padding: 6px 0; border-bottom: 1px solid #23273199; font-size: .88rem; display: flex; gap: 10px; } .news-item .d { color: var(--muted); flex: none; width: 52px; font-size: .78rem; padding-top: 2px; } .news-item.imp { color: #fff; }

/* Calendar */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--muted); font-size: .75rem; margin-bottom: 4px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { min-height: 74px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px; font-size: .75rem; } .cal-cell.empty { background: transparent; border-color: transparent; } .cal-cell.today { border-color: var(--red2); box-shadow: 0 0 0 1px var(--red2); } .cal-cell.past { opacity: .55; }
.cal-cell .cd { color: var(--muted); margin-bottom: 2px; }
.cal-ev { display: block; width: 100%; text-align: left; background: var(--bg2); border: 0; border-left: 3px solid; color: var(--text); font-size: .7rem; padding: 2px 4px; margin-top: 2px; border-radius: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.mine { background: #4a1f21; color: #fff; font-weight: 700; }

/* Inbox */
.inbox-item { display: flex; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; align-items: center; }
.inbox-item.fight { border-left-color: var(--red); } .inbox-item.sponsor { border-left-color: var(--gold); } .inbox-item.closed { opacity: .5; }
.ii-title { font-weight: 700; } .ii-side { text-align: right; flex: none; } .ii-side .btn { margin-top: 4px; }
.offer-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; } .offer-terms div { background: var(--bg2); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; } .offer-terms .muted { font-size: .75rem; }

/* Gyms */
.gym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; } .gym { margin: 0; } .gym select { width: 100%; margin-top: 8px; }
.org-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.org-tab { background: var(--card); border: 1px solid var(--line); color: var(--muted); padding: 6px 10px; border-radius: 8px; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600; border-left: 4px solid var(--c); }
.org-tab.active { background: var(--c); color: #fff; border-color: var(--c); }

/* Ledger */
.ledger-item { display: grid; grid-template-columns: 50px 1fr auto; gap: 8px; padding: 5px 0; border-bottom: 1px solid #23273199; font-size: .84rem; } .ledger-item .d { color: var(--muted); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal.open { display: flex; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; position: relative; animation: pop .18s ease-out; }
.modal-box.fight-modal { max-width: 640px; }
.modal-close { position: absolute; top: 8px; right: 8px; background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Fight */
.fight-head { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.fight-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.fv { text-align: center; } .fv .avatar { margin: 0 auto; display: block; } .fv-name { font-weight: 700; margin-top: 4px; } .fv.mine .fv-name { color: var(--red2); }
.vs { font-weight: 900; font-size: 1.3rem; color: var(--muted); text-align: center; }
.hp { height: 8px; background: #2a2f3d; border-radius: 4px; margin-top: 6px; overflow: hidden; } .hp-bar { height: 100%; background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c); background-size: 300% 100%; transition: width .4s; }
.cage { background: radial-gradient(circle, #2a2f3d 0%, #16181f 80%); border: 2px solid #3d4356; border-radius: 40px; height: 70px; position: relative; margin-bottom: 10px; overflow: hidden; }
.cage::before { content: ''; position: absolute; inset: 4px; border: 1px dashed #3d4356; border-radius: 36px; }
.fighter-dot { position: absolute; top: 50%; width: 22px; height: 22px; border-radius: 50%; transform: translateY(-50%); transition: .4s; border: 2px solid #fff; }
.fighter-dot.a { left: 38%; background: var(--red); } .fighter-dot.b { left: 56%; background: var(--blue); }
.fighter-dot.hit { animation: shake .4s; } .fighter-dot.down { top: 70%; width: 30px; height: 14px; border-radius: 8px; }
@keyframes shake { 0%, 100% { transform: translateY(-50%); } 25% { transform: translate(-6px, -50%); } 75% { transform: translate(6px, -50%); } }
.fight-log { height: 200px; overflow-y: auto; background: var(--bg2); border-radius: 10px; padding: 10px; font-size: .86rem; margin-bottom: 10px; }
.fight-log .ln { padding: 3px 0; border-bottom: 1px solid #23273166; } .fight-log .t { color: var(--muted); font-size: .74rem; margin-right: 8px; font-family: monospace; }
.fight-log .big { color: #ffb347; font-weight: 700; } .fight-log .round { color: var(--blue); font-weight: 700; } .fight-log .td { color: #7fe0a7; } .fight-log .sub { color: #c39bd3; } .fight-log .result { color: #fff; font-weight: 800; font-size: .95rem; }
.fight-result { margin-top: 12px; padding: 14px; border-radius: 10px; text-align: center; background: var(--bg2); border: 1px solid var(--line); }
.fight-result.win { border-color: var(--green); } .fight-result.loss { border-color: var(--red); }
.fr-title { font-size: 1.3rem; font-weight: 900; margin-bottom: 4px; } .fight-result.win .fr-title { color: var(--green); } .fight-result.loss .fr-title { color: var(--red2); }
.fight-result .btn { margin-top: 10px; }

/* Toasts */
#toasts { position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #2a2f3d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .88rem; opacity: 0; transform: translateY(8px); transition: .25s; border-left: 4px solid var(--blue); box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90vw; }
.toast.show { opacity: 1; transform: none; } .toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }

/* Mobile */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .topbar { flex-wrap: wrap; padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top)); gap: 6px; height: auto; }
  .top-info { flex: 1; } .top-actions { width: 100%; justify-content: flex-end; } .top-actions .btn.primary { flex: 1; }
  .nav { grid-row: 3; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); overflow-x: auto; }
  .nav-btn { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .62rem; min-width: 44px; align-items: center; } .nav-btn.active { box-shadow: none; }
  .nav-btn .ic { font-size: 1.2rem; width: auto; } .badge { right: 2px; top: 0; }
  .screen { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, 1fr); } .kpi .v { font-size: .95rem; }
  .attrs, .meters { grid-template-columns: 1fr; }
  .cal-cell { min-height: 54px; padding: 2px; } .cal-ev { font-size: .58rem; padding: 1px 2px; }
  .opts { flex-wrap: wrap; } .btn.opt { min-width: 45%; }
  .inbox-item { flex-direction: column; align-items: stretch; } .ii-side { text-align: left; display: flex; justify-content: space-between; align-items: center; }
  .fight-log { height: 160px; }
  .profile .row.gap { flex-wrap: wrap; }
  #toasts { bottom: calc(var(--nav-h) + 20px); }
}
