:root {
  color-scheme: dark;
  --bg: #07101c;
  --bg-elevated: #0b1625;
  --panel: rgba(13, 26, 43, 0.88);
  --panel-solid: #0d1a2b;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #f4f7fb;
  --muted: #8492a6;
  --accent: #c8ff31;
  --accent-dark: #243500;
  --cyan: #3bd6ff;
  --danger: #ff5d70;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

body.light {
  color-scheme: light;
  --bg: #eef1eb;
  --bg-elevated: #f8faf6;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.2);
  --text: #132016;
  --muted: #677267;
  --accent-dark: #e6f9af;
  --shadow: 0 22px 60px rgba(36, 50, 30, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(59, 214, 255, 0.12), transparent 30rem),
    radial-gradient(circle at 10% 30%, rgba(200, 255, 49, 0.07), transparent 25rem),
    var(--bg);
  font-family: "Manrope", sans-serif;
  transition: color .25s, background-color .25s;
}

button, input { font: inherit; }
button { color: inherit; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: .035; z-index: 10; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E"); }

.topbar {
  height: 76px;
  padding: 0 clamp(18px, 4vw, 62px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 9;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; background: var(--accent); color: #101807; font-family: "Russo One"; transform: skew(-7deg); border-radius: 4px 12px 4px 12px; }
.brand strong { display: block; font-family: "Russo One"; letter-spacing: .06em; font-size: 16px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.formula-chip { color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: 11px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; cursor: pointer; font-size: 20px; }
.icon-button:hover { border-color: var(--accent); }

.app-shell { display: grid; grid-template-columns: 220px minmax(470px, 1fr) 340px; gap: 18px; max-width: 1500px; margin: 0 auto; padding: 24px clamp(18px, 4vw, 62px) 60px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.sidebar { padding: 20px; position: sticky; top: 100px; }
.section-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 20px; }
.section-heading.compact { margin-bottom: 14px; }
.eyebrow { display: block; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.03em; }
.section-heading h2 { margin-top: 5px; }
.position-groups { display: grid; gap: 18px; }
.position-group-title { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .16em; margin: 0 0 8px 2px; }
.position-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.position-button { padding: 9px 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elevated); cursor: pointer; font-size: 12px; font-weight: 800; }
.position-button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.position-button.active { color: #111a08; background: var(--accent); border-color: var(--accent); box-shadow: 0 8px 24px rgba(200, 255, 49, .15); }
.sidebar-note { display: flex; gap: 10px; margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.55; }
.sidebar-note p { margin: 0; }
.note-icon { flex: 0 0 19px; height: 19px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--accent); font-weight: 800; }

.workspace, .results { display: grid; gap: 18px; }
.player-toolbar { padding: 14px; display: grid; grid-template-columns: 1.2fr 1fr auto auto; align-items: end; gap: 10px; position: relative; z-index: 6; }
.database-search { position: relative; }
.database-search label, .name-field label { display: block; color: var(--muted); font-size: 10px; margin: 0 0 6px 2px; }
.database-search input { height: 42px; padding: 0 13px; }
.search-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: 340px; overflow: auto; padding: 6px; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); }
.search-result { width: 100%; display: grid; grid-template-columns: 40px 1fr auto; gap: 9px; align-items: center; padding: 9px; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--accent-dark); }
.search-result-rating { font-family: "Russo One"; color: var(--accent); font-size: 16px; }
.search-result strong { display: block; font-size: 10px; }
.search-result small { color: var(--muted); font-size: 8px; }
.search-result-position { color: var(--muted); font-size: 9px; font-weight: 800; }
.name-field label { display: block; color: var(--muted); font-size: 10px; margin: 0 0 6px 2px; }
input { width: 100%; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200, 255, 49, .08); }
.name-field input { height: 42px; padding: 0 13px; }
.button { min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; font-size: 11px; font-weight: 800; cursor: pointer; transition: .2s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #101807; background: var(--accent); }
.button-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.button-danger { color: white; background: var(--danger); }
.button.full { width: 100%; }

.team-color-panel { padding: 18px 22px; }
.team-color-panel .stats-header { margin-bottom: 6px; }
.panel-description { margin-bottom: 14px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.team-color-list { display: grid; gap: 8px; }
.team-color-row { display: grid; grid-template-columns: 25px 110px minmax(105px, .8fr) 65px minmax(180px, 1.4fr); gap: 8px; align-items: center; padding: 9px; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 11px; }
.team-color-row.inactive { opacity: .48; }
.team-color-row input, .team-color-row select { height: 34px; padding: 0 9px; font-size: 9px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.team-color-row select:focus { border-color: var(--accent); outline: none; }
.team-color-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.team-color-type { font-size: 9px; font-weight: 800; }
.all-bonus-wrap { position: relative; }
.all-bonus-wrap:after { content: "всем"; position: absolute; right: 7px; top: 10px; color: var(--muted); font-size: 7px; pointer-events: none; }
.all-bonus-wrap input { padding-right: 35px; }

.stats-panel { padding: 22px; }
.stats-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.stats-header h2 { margin-top: 5px; }
.stats-actions { display: flex; gap: 8px; align-items: center; }
.tc-counter, .sort-button { border: 1px solid var(--line); background: var(--bg-elevated); border-radius: 9px; padding: 8px 10px; font-size: 10px; }
.tc-counter strong { color: var(--accent); }
.sort-button { color: var(--muted); cursor: pointer; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stat-item { padding: 11px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg-elevated) 70%, transparent); border-radius: 12px; transition: .2s ease; }
.stat-item.tc-active { border-color: rgba(200, 255, 49, .5); background: rgba(200, 255, 49, .055); }
.stat-meta { min-height: 28px; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.stat-meta label { font-size: 10px; font-weight: 700; line-height: 1.3; }
.stat-weight { color: var(--accent); font-family: "Russo One"; font-size: 9px; }
.stat-controls { display: grid; grid-template-columns: 1fr 39px; gap: 6px; margin-top: 8px; }
.stat-controls input { min-width: 0; height: 35px; padding: 0 6px; text-align: center; font-family: "Russo One"; font-size: 13px; }
.tc-button { border: 1px solid var(--line); background: transparent; border-radius: 8px; color: var(--muted); font-size: 9px; font-weight: 800; cursor: pointer; }
.tc-button.active { color: #101807; background: var(--accent); border-color: var(--accent); }
.tc-button:disabled { opacity: .3; cursor: not-allowed; }

.results { position: sticky; top: 100px; }
.result-panel, .radar-panel, .strategy-panel { padding: 18px; }
.tier-label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.player-card { width: 218px; height: 292px; margin: 0 auto; position: relative; isolation: isolate; overflow: hidden; color: white; clip-path: polygon(10% 0, 90% 0, 100% 8%, 96% 90%, 84% 100%, 16% 100%, 4% 90%, 0 8%); background: linear-gradient(150deg, #4b291f 0%, #1a2533 48%, #09111e 100%); filter: drop-shadow(0 22px 24px rgba(0, 0, 0, .4)); }
.player-card.tier-silver { background: linear-gradient(150deg, #d9e2e5 0%, #61717a 43%, #17242e 100%); }
.player-card.tier-gold { background: linear-gradient(150deg, #fff18c 0%, #bb7312 42%, #38240a 100%); }
.player-card.tier-icon { background: linear-gradient(150deg, #ff76f1 0%, #6729c8 42%, #111343 100%); }
.card-grid { position: absolute; inset: 0; z-index: -1; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px); background-size: 22px 22px; transform: perspective(180px) rotateX(62deg) scale(1.8); transform-origin: bottom; }
.card-shine { position: absolute; width: 100px; height: 420px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent); top: -70px; left: -120px; transform: rotate(25deg); animation: shine 6s infinite 1s; }
@keyframes shine { 0%, 65% { left: -140px; } 90%, 100% { left: 300px; } }
.card-topline { display: flex; justify-content: space-between; padding: 23px 27px 0; font-size: 7px; letter-spacing: .14em; opacity: .7; }
.card-rating { position: absolute; top: 43px; left: 28px; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.card-rating strong { font-family: "Russo One"; font-size: 46px; line-height: .9; text-shadow: 0 3px 12px rgba(0,0,0,.35); }
.card-rating span { margin-top: 6px; font-family: "Russo One"; font-size: 12px; }
.player-silhouette { position: absolute; width: 145px; height: 180px; right: -2px; top: 45px; overflow: hidden; opacity: .82; }
.player-silhouette:before { content: ""; position: absolute; width: 68px; height: 68px; left: 38px; top: 9px; border-radius: 50%; background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(255,255,255,.25)); }
.player-silhouette:after { content: ""; position: absolute; width: 130px; height: 125px; left: 8px; top: 70px; border-radius: 54% 54% 18% 18%; background: linear-gradient(145deg, rgba(255,255,255,.8), rgba(255,255,255,.18)); transform: perspective(100px) rotateX(-8deg); }
.card-identity { position: absolute; left: 20px; right: 20px; bottom: 29px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.28); text-align: center; }
.card-identity strong { display: block; font-family: "Russo One"; font-size: 16px; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-identity span { display: block; margin-top: 5px; opacity: .65; font-size: 7px; letter-spacing: .12em; }
.grade-control { display: grid; grid-template-columns: 1fr 72px; gap: 6px 8px; align-items: center; margin-top: 16px; padding: 10px; background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 10px; }
.grade-control-title { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding-bottom: 5px; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
.grade-control-title strong { font-size: 9px; }
.grade-control-title span { color: var(--accent); font-size: 8px; font-weight: 800; }
.grade-control label { font-size: 9px; font-weight: 800; }
.grade-control select { height: 32px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-weight: 800; }
.grade-control span { grid-column: 1 / -1; color: var(--muted); font-size: 8px; }
.precise-rating { display: flex; align-items: end; justify-content: space-between; margin-top: 17px; }
.precise-rating span { color: var(--muted); font-size: 9px; }
.precise-rating strong { font-family: "Russo One"; font-size: 22px; }
.rating-progress { height: 5px; margin-top: 9px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.rating-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--cyan)); transition: width .3s; }
.progress-labels { display: flex; justify-content: space-between; margin-top: 5px; color: var(--muted); font-size: 8px; }
.mini-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mini-heading h3 { margin: 0; font-size: 13px; }
.mini-heading span { color: var(--accent); font-size: 9px; font-weight: 800; }
.radar-chart { height: 210px; display: grid; place-items: center; }
.radar-chart svg { overflow: visible; }
.strategy-tabs { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.strategy-tabs::-webkit-scrollbar { display: none; }
.strategy-tab { white-space: nowrap; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 7px 8px; font-size: 8px; font-weight: 800; cursor: pointer; }
.strategy-tab.active { color: #111a08; background: var(--accent); border-color: var(--accent); }
.strategy-content { display: grid; gap: 5px; margin-bottom: 12px; }
.strategy-row { display: flex; justify-content: space-between; padding: 6px 8px; background: var(--bg-elevated); border-radius: 7px; font-size: 8px; }
.strategy-row span:last-child { color: var(--muted); }

.saved-section { grid-column: 1 / -1; padding: 22px; }
.saved-header { display: flex; justify-content: space-between; align-items: end; margin-bottom: 16px; }
.saved-header h2 { margin-top: 5px; }
.saved-count { color: var(--muted); font-size: 10px; }
.saved-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.saved-player { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); background: var(--bg-elevated); border-radius: 12px; }
.saved-rating { width: 48px; height: 52px; display: grid; place-items: center; background: var(--accent-dark); color: var(--accent); border-radius: 9px; font-family: "Russo One"; font-size: 18px; }
.saved-info strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-info span { color: var(--muted); font-size: 8px; }
.saved-actions { display: flex; gap: 4px; }
.saved-action { width: 27px; height: 27px; border: 1px solid var(--line); background: transparent; border-radius: 7px; cursor: pointer; font-size: 11px; }
.saved-action:hover { border-color: var(--accent); }

.toast-region { position: fixed; z-index: 30; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { max-width: 320px; color: #101807; background: var(--accent); padding: 11px 14px; border-radius: 10px; font-size: 10px; font-weight: 800; box-shadow: var(--shadow); animation: toast-in .25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.modal { width: min(420px, calc(100% - 30px)); color: var(--text); background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 30px 100px rgba(0,0,0,.55); padding: 0; }
.modal::backdrop { background: rgba(2, 7, 13, .78); backdrop-filter: blur(7px); }
.modal form { padding: 24px; }
.modal h2 { margin: 7px 0 10px; }
.modal p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.compare-modal { width: min(650px, calc(100% - 30px)); }
.compare-header { display: flex; justify-content: space-between; align-items: flex-start; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.compare-player { padding: 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.compare-player strong { display: block; font-family: "Russo One"; font-size: 22px; }
.compare-player h3 { margin: 6px 0; font-size: 13px; }
.compare-diff { grid-column: 1 / -1; text-align: center; color: var(--accent); font-size: 11px; font-weight: 800; }

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 190px minmax(430px, 1fr) 310px; padding-left: 18px; padding-right: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .saved-list { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 940px) {
  .app-shell { grid-template-columns: 190px 1fr; }
  .results { grid-column: 2; position: static; grid-template-columns: 1fr 1fr; }
  .result-panel { grid-row: span 2; }
  .saved-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .formula-chip { display: none; }
  .app-shell { display: block; padding: 14px; }
  .sidebar, .results { position: static; }
  .sidebar { margin-bottom: 14px; }
  .position-groups { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .workspace, .results { gap: 14px; }
  .player-toolbar { grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
  .database-search, .name-field { grid-column: 1 / -1; }
  .team-color-panel { margin-bottom: 14px; padding: 15px; }
  .team-color-row { grid-template-columns: 25px 1fr 70px; }
  .team-color-row .color-name { grid-column: 2; }
  .team-color-row .color-specific { grid-column: 2 / -1; }
  .stats-panel { padding: 15px; margin-bottom: 14px; }
  .stats-header { align-items: flex-start; flex-direction: column; }
  .results { display: grid; grid-template-columns: 1fr; }
  .result-panel { grid-row: auto; }
  .saved-section { margin-top: 14px; }
  .saved-list { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
  .topbar { height: 66px; padding: 0 14px; }
  .brand small { display: none; }
  .position-groups { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .stat-item { padding: 9px; }
  .stat-meta label { font-size: 9px; }
  .compare-grid { grid-template-columns: 1fr; }
  .compare-diff { grid-column: 1; }
}
