/* Проказники — фиолетовая шапка, оранжевый акцент, карточки проказ */
@font-face { font-family: Onest; src: url(/fonts/onest-cyr.woff2) format('woff2'); font-weight: 400 600; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; src: url(/fonts/onest-lat.woff2) format('woff2'); font-weight: 400 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
:root {
  --bg: #f6f3fb; --card: #fff; --ink: #1f1830; --muted: #6d6580; --line: #e6e0f0;
  --brand: #3b1f6e; --brand2: #5a33a3; --acc: #ff7a2f; --acc-ink: #fff; --ok: #1f9d6b; --bad: #d03a3a;
  --r: 16px; --gap: 16px; --h: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 Onest, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
.boot { padding: 48px 24px; text-align: center; color: var(--muted); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* Шапка */
.top { background: linear-gradient(160deg, var(--brand), var(--brand2)); color: #fff; padding: calc(env(safe-area-inset-top) + 16px) 0 20px; }
.top .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 600; }
.top .me { font-size: 14px; opacity: .85; margin-top: 4px; }
.pts { background: rgba(255,255,255,.14); border-radius: 12px; padding: 8px 12px; text-align: center; min-width: 64px; }
.pts b { display: block; font-size: 22px; line-height: 1.1; }
.pts small { font-size: 12px; opacity: .85; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stats div { background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.stats small { font-size: 12px; opacity: .85; }

main { padding: 16px 0 calc(96px + env(safe-area-inset-bottom)); }
h2 { font-size: 18px; margin: 24px 0 12px; font-weight: 600; }
h2:first-child { margin-top: 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Кнопки — одна высота 48, малые 40 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); padding: 0 20px; border-radius: 12px; border: 0; background: var(--acc); color: var(--acc-ink); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.wide { width: 100%; }
.btn.ghost { background: #efe9f8; color: var(--brand); }
.btn.line { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.on { background: var(--brand); color: #fff; }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px #f1cccc; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .tab:focus-visible, .seg button:focus-visible { outline: 3px solid #ffb98e; outline-offset: 2px; }

/* Переключатель */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: #ebe5f5; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 16px; }
.seg button { border: 0; background: transparent; min-height: 40px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(59,31,110,.15); }

/* Карточки */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(31,24,48,.06); }
.card h3 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; }
.card .text { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.card .story { margin-top: 12px; padding: 12px; background: #f3fbf7; border-radius: 12px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.chip { flex: none; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: #fff1e8; color: #b4501a; }
.chip.l3 { background: #fde8f3; color: #a3266a; }
.chip.l5 { background: #3b1f6e; color: #fff; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.crew { font-size: 14px; margin-top: 8px; color: var(--brand2); }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* Рейтинг */
.rank { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.rank + .rank { border-top: 1px solid var(--line); }
.rank .n { width: 28px; text-align: center; font-weight: 600; color: var(--muted); }
.rank .who { flex: 1; min-width: 0; }
.rank .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .score { font-weight: 600; font-size: 18px; }
.rank.mine { background: #fff7f1; }
.list { padding: 0; overflow: hidden; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 15px; }
.feed li:first-child { border-top: 0; }
.feed time { display: block; font-size: 12px; color: var(--muted); }

/* Формы */
label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; }
input[type=text], input[type=password], textarea { width: 100%; min-height: var(--h); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; font-size: 16px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--brand2); }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: 15px; margin-top: 16px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--acc); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.levels button { min-height: var(--h); border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; line-height: 1.2; }
.levels button small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.levels button.on { border-color: var(--acc); background: #fff6f0; }
.err { color: var(--bad); font-size: 14px; margin-top: 12px; min-height: 0; }
.err:empty { display: none; }
.linkbox { display: flex; gap: 8px; margin-top: 8px; }
.linkbox input { flex: 1; min-width: 0; font-size: 14px; }

/* Вход */
.hero { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 0; }
.hero .logo { font-size: 56px; line-height: 1; }
.hero h1 { font-size: 28px; line-height: 1.2; margin: 16px 0 8px; }
.hero p { margin: 0 0 8px; color: var(--muted); }
.hero .card { margin-top: 24px; }
.rules { margin: 16px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.rules li + li { margin-top: 4px; }
.linkbtn { background: none; border: 0; color: var(--brand2); text-decoration: underline; padding: 12px 0; cursor: pointer; font-size: 14px; }

/* Нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs .in { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; min-height: 60px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab span { font-size: 20px; line-height: 1; }
.tab.on { color: var(--brand); }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; box-shadow: 0 6px 16px rgba(255,122,47,.4); border-radius: 99px; }
@media (min-width: 672px) { .fab { right: calc(50% - 304px); } }

/* Окно */
.sheet-bg { position: fixed; inset: 0; background: rgba(20,12,36,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet h2 { margin: 0 0 4px; }
.sheet .bar { display: flex; gap: 8px; margin-top: 20px; }
.sheet .bar .btn { flex: 1; }
@media (min-width: 672px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

#toast { position: fixed; left: 50%; bottom: calc(144px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
