:root {
  --ink: #17132b; --paper: #fffdf5; --sun: #ffd23f; --pink: #ff3d7f;
  --violet: #4b2fb3; --blue: #1f6feb; --green: #35d07f; --muted: #57526b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 17px/1.45 "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--violet) radial-gradient(#ffffff2e 2px, transparent 2.5px) 0 0 / 14px 14px;
}
.site {
  max-width: 640px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.site.wide { max-width: 980px; }
h1, h2 { margin: 0 0 14px; font-family: "Arial Black", Arial, sans-serif; line-height: 1.15; overflow-wrap: anywhere; }
h1 { font-size: clamp(24px, 6vw, 38px); text-shadow: 2px 2px 0 var(--sun); }
h2 { font-size: clamp(19px, 4vw, 24px); }
h2:not(:first-child) { margin-top: 26px; }
p { margin: 0 0 12px; overflow-wrap: anywhere; }
a { color: #1553b8; }
.panel {
  display: block; margin: 0 0 20px; padding: clamp(14px, 4vw, 24px);
  border: 4px solid var(--ink); background: var(--paper); box-shadow: 6px 6px 0 var(--ink);
}
.panel > :last-child { margin-bottom: 0; }
.center { text-align: center; }
.lead { font-size: 20px; font-weight: 700; }
.hint, small { color: var(--muted); font-size: 15px; }
footer { color: #fff; text-align: center; font-size: 15px; }
footer a { display: inline-block; padding: 10px 4px; color: #fff; }
.about { max-width: 560px; margin: 8px auto 0; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }

/* Кнопки */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 18px;
  border: 3px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink);
  font: 700 17px/1.2 "Segoe UI", Roboto, Arial, sans-serif; text-align: center; text-decoration: none; cursor: pointer;
}
button.main, .button.main { background: var(--sun); box-shadow: 4px 4px 0 var(--ink); }
button.danger { background: #ffd3e0; }
button:disabled { opacity: .5; cursor: not-allowed; }
.small { font-size: 15px; padding: 6px 12px; }
form > button.main, .center > .button, .center > form, .center > form > button { width: 100%; }
.center > form { display: block; }
.center > .button, .center > button, .center > form { margin-top: 12px; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.buttons form { max-width: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.buttons select, .buttons input:not([type="hidden"]) { width: auto; max-width: 100%; margin: 0; }
.buttons + *, .link + * { margin-top: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.links a { padding: 10px 0; font-weight: 700; }
.arrow {
  display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 16px; color: inherit;
  border: 4px solid var(--ink); border-radius: 50%; background: var(--sun); box-shadow: 4px 4px 0 var(--ink);
}
.arrow svg { width: 34px; fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

.text-link { display: inline-block; margin-top: 14px; padding: 10px; font-weight: 700; }

/* Формы */
form.panel label, details label { display: block; margin-bottom: 14px; font-weight: 700; }
label small { display: block; margin-top: 4px; font-weight: 400; }
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 8px 12px;
  border: 3px solid var(--ink); border-radius: 0; background: #fff; color: inherit; font: 17px/1.3 "Segoe UI", Roboto, Arial, sans-serif;
}
input[type="radio"], input[type="checkbox"] { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--blue); }
fieldset { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
legend { margin-bottom: 8px; padding: 0; font-weight: 700; }
.choice label, form.panel .choice label, .line, form.panel label.line {
  display: flex; gap: 10px; align-items: center; min-height: 48px; margin-bottom: 8px; padding: 8px 12px;
  border: 3px solid var(--ink); background: #fff; cursor: pointer;
}
.choice label:has(:checked), form.panel .choice label:has(:checked) { background: var(--sun); }
.check-row { margin-bottom: 14px; padding: 12px; border: 3px solid var(--ink); background: #fff; }
form.panel .check-row label { display: flex; gap: 12px; margin-bottom: 10px; cursor: pointer; }
.images { display: block; }
.images label, form.panel .images label, details .images label { display: inline-block; position: relative; width: 72px; height: 72px; margin: 0 6px 8px 0; cursor: pointer; }
.images input { position: absolute; inset: 0; width: 100% !important; height: 100% !important; opacity: 0; cursor: pointer; }
.images img { display: block; width: 100%; padding: 4px; border: 4px solid transparent; border-radius: 12px; }
.images input:checked + img { border-color: var(--pink); background: var(--sun); }
.images input:focus-visible + img { outline: 4px solid var(--blue); }
.inline { display: flex; gap: 10px; }
.field { margin-bottom: 14px; }
form.panel .field label { margin-bottom: 4px; }
.inline input:not([type="hidden"]) { flex: 1; min-width: 0; margin: 0; }

/* Сообщения */
.notice, .error, .warning { margin: 0 0 16px; padding: 12px 14px; border: 3px solid var(--ink); background: #d9f7e3; font-weight: 600; }
.error { background: #ffd3e0; }
.warning { background: #fff0b0; font-weight: 400; }
.status { display: inline-block; margin: 0; padding: 3px 10px; border: 2px solid var(--ink); background: #fff0b0; font-weight: 700; }

/* Раскрывающиеся разделы */
summary { min-height: 32px; font: 900 19px/1.5 "Arial Black", Arial, sans-serif; cursor: pointer; }
details[open] > summary { margin-bottom: 14px; }
.moderation summary { font: 700 16px/2 "Segoe UI", Roboto, Arial, sans-serif; }
hr { margin: 20px 0; border: 0; border-top: 3px solid var(--ink); }

/* Главная для гостей и приглашение */
.welcome { display: grid; gap: 4px; }
.welcome-fox { padding: 0; overflow: hidden; }
.welcome-fox .avatar { display: block; width: 100%; height: min(46vh, 420px); margin: 0; border: 0; border-radius: 0; }
.welcome-fox svg { display: block; width: 100%; height: 100%; }
.invite img { width: min(46vw, 180px); }
@media (min-width: 760px) {
  .welcome { grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
  .welcome-fox .avatar { height: 100%; min-height: 420px; }
}

/* Карточка персонажа по ссылке */
.hero-card .avatar { display: block; width: 100%; height: min(52vh, 460px); margin-bottom: 14px; border: 4px solid var(--ink); border-radius: 0; }
.hero-card .lead { margin: 0; }
.hero-power { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; }
.hero-power img { width: clamp(44px, 12vw, 64px); }
.hero-power strong { font: 900 clamp(36px, 11vw, 60px)/1.2 "Arial Black", Arial, sans-serif; }

/* Группы и рейтинги */
.group-head { display: flex; gap: 16px; align-items: center; }
.group-head img { flex: none; width: clamp(72px, 18vw, 120px); }
.group-head > div { min-width: 0; }
.group-head h1 { margin-bottom: 6px; }
.switch { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.switch a {
  flex: 1 1 auto; display: grid; place-items: center; min-height: 48px; padding: 6px 12px;
  border: 3px solid var(--ink); background: #fff; color: inherit; font-weight: 700; text-align: center; text-decoration: none;
}
.switch a[aria-current] { background: var(--sun); box-shadow: inset 0 -5px 0 var(--pink); }
.rating, .members { margin: 0; padding: 0; list-style: none; }
.rating li { display: flex; align-items: center; gap: clamp(6px, 2vw, 14px); padding: 8px; border-bottom: 3px solid var(--ink); }
.rating li:last-child { border-bottom: 0; }
.rating .me { background: #fff0b0; box-shadow: inset 6px 0 0 var(--pink); }
.place {
  flex: none; display: grid; place-items: center; min-width: 40px; height: 40px; padding: 0 4px;
  border: 3px solid var(--ink); border-radius: 20px; background: #fff; font-weight: 900;
}
.p1 { background: var(--sun); } .p2 { background: #cfd8e6; } .p3 { background: #f0a868; }
.avatar { flex: none; width: 56px; height: 56px; overflow: hidden; border: 3px solid var(--ink); border-radius: 50%; }
img.avatar { border: 0; }
.avatar svg { display: block; width: 100%; height: 100%; }
.who { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.who small { display: block; margin-top: 3px; font-size: 14px; }
.score { flex: none; display: flex; align-items: center; gap: 4px; font: 900 clamp(17px, 4.5vw, 26px)/1 "Arial Black", Arial, sans-serif; }
.score img { width: 1.1em; }
.places { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.places a { display: grid; gap: 6px; padding: 12px 6px; border: 3px solid var(--ink); background: #fff; color: inherit; text-align: center; text-decoration: none; }
.places strong { font: 900 clamp(26px, 8vw, 44px)/1 "Arial Black", Arial, sans-serif; }
.members li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 2px solid var(--ink); }
.link { font-size: 15px !important; margin: 12px 0 8px !important; }

/* Узкий телефон: результат под именем */
@media (max-width: 420px) {
  .rating li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); }
  .rating .place, .rating .avatar { grid-row: 1 / 3; }
  .rating .score { grid-column: 3; }
}

/* Админка */
.variants { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.variant { flex: 1 1 200px; display: grid; justify-items: center; gap: 6px; padding: 10px; border: 3px solid var(--ink); background: #fff; text-align: center; overflow-wrap: anywhere; }
.variant img { width: 80px; }
.variant strong { font-size: 20px; max-width: 100%; }
.person { display: flex; gap: 14px; }
.person > div { min-width: 0; }

/* Статистика в админке */
.big-numbers { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.big-numbers strong { font: 900 clamp(26px, 7vw, 40px)/1.1 "Arial Black", Arial, sans-serif; }
.table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 2px solid var(--ink); text-align: right; white-space: nowrap; }
th:first-child { text-align: left; white-space: normal; }
td { font-weight: 700; }

/* Документы */
dialog {
  width: min(760px, calc(100% - 20px)); max-height: 90vh; max-height: 90dvh; padding: 0;
  border: 4px solid var(--ink); background: var(--paper); color: var(--ink);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #17132bcc; }
.dialog-head, .dialog-foot { flex: none; padding: 12px 16px; }
.dialog-head { border-bottom: 4px solid var(--ink); background: var(--sun); }
.dialog-head h2 { margin: 0; }
.dialog-foot { border-top: 4px solid var(--ink); text-align: right; }
.dialog-body { overflow: auto; padding: 14px 16px; }
.legal h3 { margin: 20px 0 6px; }
.legal ul { padding-left: 22px; }

/* Страница участника: персонаж, титул, медали */
.player-card { text-align: center; }
.player-card .avatar { display: block; width: 100%; height: min(48vh, 420px); margin-bottom: 14px; border: 4px solid var(--ink); border-radius: 0; }
.player-card h1 { margin-bottom: 8px; }
.player-title { margin-bottom: 10px; }
.title-tag {
  display: inline-block; padding: 3px 10px; border: 2px solid var(--ink); border-radius: 14px; background: #fff0b0;
  font-weight: 800; font-size: 15px; line-height: 1.3; white-space: nowrap; color: var(--ink);
}
.player-title .title-tag { font-size: 20px; padding: 4px 16px; border-width: 3px; border-radius: 20px; }
.title-tag.t5, .title-tag.t6 { background: #cfe9ff; }
.title-tag.t7, .title-tag.t8 { background: var(--sun); }
.title-tag.t9, .title-tag.t10 { background: #c9f5ff; box-shadow: 0 0 0 2px #5ad1ff; }
.bar { height: 16px; margin: 8px 0; border: 3px solid var(--ink); background: #fff; overflow: hidden; }
.bar span { display: block; width: 0; height: 100%; background: var(--green); }
.player-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 16px 0 0; }
.player-stats div { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 3px solid var(--ink); background: #fff; }
.player-stats img { width: 34px; height: 34px; }
.player-stats .big { font-size: 26px; line-height: 34px; }
.player-stats strong { font: 900 clamp(18px, 5vw, 28px)/1.1 "Arial Black", Arial, sans-serif; }
.player-stats span:last-child { font-size: 13px; color: var(--muted); }
.center-buttons { justify-content: center; margin-top: 14px; }
@media (max-width: 480px) { .player-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.medal { position: relative; display: grid; justify-items: center; align-content: start; gap: 4px; padding: 10px 8px; border: 3px solid var(--ink); background: #fff; text-align: center; }
.medal.none { background: #f1eff6; }
.medal.none strong { color: var(--muted); }
.medal.gold { background: #fff6cc; }
.medal.diamond { background: #e6fbff; }
.medal-icon { width: 72px; height: 80px; }
.medal-level { position: absolute; top: 6px; right: 6px; padding: 1px 7px; border: 2px solid var(--ink); border-radius: 10px; background: var(--sun); font-weight: 900; font-size: 13px; }
.medal strong { line-height: 1.2; }
.medal small { font-size: 13px; line-height: 1.25; }
.medal .bar { width: 100%; height: 12px; margin: 4px 0 0; border-width: 2px; }
.titles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.titles li { display: grid; justify-items: center; padding: 8px; border: 3px solid var(--ink); background: #f1eff6; opacity: .6; text-align: center; }
.titles li.got { background: #fff; opacity: 1; }
.titles li[aria-current] { background: var(--sun); box-shadow: inset 0 -5px 0 var(--pink); }
.titles span { font-size: 28px; }
a.who-link { color: inherit; text-decoration: none; }
a.who-link:hover strong { text-decoration: underline; }

/* Игра в группе */
.game-block { background: #bdf0ff; }
.game-block h2 { display: flex; align-items: center; gap: 10px; }
.school-bar { position: relative; height: 34px; margin: 6px 0 12px; border: 4px solid var(--ink); background: #fff; overflow: hidden; }
.school-bar span { display: block; height: 100%; background: var(--green); }
.school-bar.warn span { background: var(--sun); }
.school-bar.bad span { background: var(--pink); }
.school-bar b { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; }
.game-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.game-stats div { display: grid; justify-items: center; padding: 8px 4px; border: 3px solid var(--ink); background: #fff; text-align: center; }
.game-stats strong { font: 900 clamp(20px, 5vw, 30px)/1.1 "Arial Black", Arial, sans-serif; }
.game-stats small { font-size: 13px; line-height: 1.2; }
@media (max-width: 480px) { .game-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.defenders { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.defenders li { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 3px solid var(--ink); border-radius: 30px; background: #fff; }
.defenders .avatar { width: 36px; height: 36px; border-width: 2px; }
.play { width: 100%; min-height: 64px; font: 900 clamp(22px, 6vw, 30px)/1 "Arial Black", Arial, sans-serif; text-transform: uppercase; background: var(--pink) !important; }

/* Скругления: блоки мягче, кнопки аккуратнее */
:root { --round: 20px; --round-btn: 14px; --round-sm: 10px; }
.panel, dialog, .welcome-fox, .variant { border-radius: var(--round); }
.panel { overflow: hidden; overflow: clip; }
.welcome-fox .avatar, .hero-card .avatar, .player-card .avatar { border-radius: var(--round-btn); }
button, .button, input:not([type="radio"]):not([type="checkbox"]), select, textarea { border-radius: var(--round-btn); }
.arrow { border-radius: 50%; }
.notice, .error, .warning, .check-row, .choice label, form.panel .choice label, .line, form.panel label.line { border-radius: var(--round-btn); }
.status { border-radius: 14px; }
.switch a, .places a, .medal, .titles li, .player-stats div, .game-stats div { border-radius: var(--round-btn); }
.bar, .school-bar { border-radius: 999px; }
.dialog-head { border-radius: calc(var(--round) - 4px) calc(var(--round) - 4px) 0 0; }
.rating li:first-child { border-radius: var(--round-sm) var(--round-sm) 0 0; }
.rating li:last-child { border-radius: 0 0 var(--round-sm) var(--round-sm); }

/* Выбор игры группы */
.games label { align-items: flex-start; }
.games label > span { display: grid; gap: 2px; }
.games small { font-weight: 400; }
.game-top { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.game-top h2 { margin: 0 0 6px; }
.game-top p { margin: 0; }
.game-cover { flex: none; width: clamp(120px, 32%, 200px); border: 4px solid var(--ink); border-radius: 14px; }
@media (max-width: 480px) { .game-top { flex-direction: column; align-items: stretch; } .game-cover { width: 100%; } }
.game-rocket { background: #d9d3ff; } .game-zoo { background: #dcf5c6; } .game-football { background: #cdeed6; }
.game-city { background: #e3efff; } .game-dragon { background: #ffe3c2; }
