/* ==========================================================================
   Остров Полонского — Mini App. Стиль «бортовой журнал»:
   кремовая бумага, чернила, серифные заголовки, красный акцент.
   Тёмная тема — «ночная вахта». Без backdrop-filter: он тормозит на телефонах.
   ========================================================================== */
:root {
  --bg: #f4efe4;
  --bg-2: #ece5d6;
  --card: #fffdf7;
  --card-2: #faf6ec;
  --ink: #1d2733;
  --ink-2: #3c4653;
  --muted: #7b7f86;
  --line: #e4dccb;
  --line-2: #d6ccb6;
  --accent: #c2362c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(194, 54, 44, .09);
  --sea: #1f3d5c;
  --sea-soft: rgba(31, 61, 92, .08);
  --gold: #b7862f;
  --gold-soft: rgba(183, 134, 47, .13);
  --good: #2f7d4f;
  --good-soft: rgba(47, 125, 79, .11);
  --shadow: 0 1px 0 rgba(29, 39, 51, .04), 0 6px 18px -10px rgba(29, 39, 51, .28);
  --shadow-lg: 0 18px 40px -18px rgba(29, 39, 51, .45);
  --r: 18px;
  --r-sm: 12px;
  --serif: "Lora", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --tier-common: #4f7a9a;
  --tier-rare: #7b4fc2;
  --tier-legendary: #c48a1b;
}
[data-theme="dark"] {
  --bg: #0f141a;
  --bg-2: #141a22;
  --card: #18202a;
  --card-2: #1d2631;
  --ink: #efe8da;
  --ink-2: #d2cbbd;
  --muted: #8e98a4;
  --line: #26303c;
  --line-2: #33404f;
  --accent: #e2574b;
  --accent-soft: rgba(226, 87, 75, .14);
  --sea: #8fb6dc;
  --sea-soft: rgba(143, 182, 220, .1);
  --gold: #e0b25a;
  --gold-soft: rgba(224, 178, 90, .14);
  --good: #5fbf86;
  --good-soft: rgba(95, 191, 134, .13);
  --shadow: 0 1px 0 rgba(0, 0, 0, .25), 0 8px 20px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 20px 44px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.serif { font-family: var(--serif); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }

/* ---------- Загрузка ---------- */
.boot {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; background: var(--bg); color: var(--ink);
  transition: opacity .35s var(--ease), visibility .35s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark { animation: spin-in 1.6s var(--ease) infinite alternate; }
.boot-title { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.boot-sub { color: var(--muted); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
@keyframes spin-in { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }

/* ---------- Сцена и экраны ---------- */
.stage { max-width: 640px; margin: 0 auto; min-height: 100vh; }
.screen {
  padding: 14px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px);
  min-height: 100vh;
  animation: screen-in .26s var(--ease) both;
}
.screen.no-tabbar { padding-bottom: calc(var(--safe-b) + 32px); }
.screen.back-in { animation: screen-back .24s var(--ease) both; }
.screen.fade-in { animation: fade-in .18s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translate3d(18px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes screen-back { from { opacity: 0; transform: translate3d(-14px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Шапка экрана ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin: 2px 0 16px; min-height: 40px; }
.topbar h1 { font-size: 26px; flex: 1; line-height: 1.15; }
.topbar .sub { display: block; font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; letter-spacing: 0; }
.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--sea); color: var(--bg); font-family: var(--serif); font-weight: 700; font-size: 17px;
  box-shadow: var(--shadow); position: relative;
}
[data-theme="dark"] .avatar-btn { color: #0f141a; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-2); font-size: 20px;
  transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.94); }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; position: relative;
}
.card.flat { box-shadow: none; }
.card.tap { transition: transform .14s ease, box-shadow .14s ease; cursor: pointer; }
.card.tap:active { transform: scale(.985); }
.card-title { font-family: var(--serif); font-weight: 600; font-size: 18px; margin: 0 0 4px; }
.card-kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.card-kicker i { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title {
  font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 22px 2px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.section-title .link { font-family: var(--sans); font-size: 13px; color: var(--accent); font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.ruled {
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, var(--line) 27px 28px);
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 600; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -10px var(--accent);
  transition: transform .12s ease, opacity .15s ease, background .2s ease; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn.soft { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.sea { background: var(--sea); color: var(--bg); box-shadow: none; }
.btn.gold { background: var(--gold); color: #fff; box-shadow: 0 8px 20px -10px var(--gold); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn i { font-size: 19px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; background: var(--bg-2); color: var(--ink-2); white-space: nowrap;
}
.chip.red { background: var(--accent-soft); color: var(--accent); }
.chip.sea { background: var(--sea-soft); color: var(--sea); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip i { font-size: 14px; }

/* ---------- Сегменты ---------- */
.seg {
  display: flex; background: var(--bg-2); border-radius: 12px; padding: 3px; margin-bottom: 14px; position: relative;
}
.seg button {
  flex: 1; height: 36px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted);
  transition: color .2s ease, background .2s ease;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Таббар ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line);
  transform: translateZ(0);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; position: relative; transition: color .18s ease;
}
.tab i { font-size: 24px; transition: transform .2s var(--ease); }
.tab.on { color: var(--accent); }
.tab.on i { transform: translateY(-1px) scale(1.06); }
.tab-dot { position: absolute; top: 9px; left: calc(50% + 9px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }

/* ---------- Главная ---------- */
.hello { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.15; }
.hello-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--serif); font-size: 22px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.stat .flame { color: var(--accent); }
.today-cta {
  background: var(--sea); color: #f4efe4; border: 0; overflow: hidden;
}
[data-theme="dark"] .today-cta { background: #1e3550; color: var(--ink); }
.today-cta .card-kicker { color: rgba(244, 239, 228, .7); }
.today-cta h3 { font-size: 21px; margin-bottom: 4px; }
.today-cta p { margin: 0 0 14px; opacity: .85; font-size: 14px; }
.today-cta .btn { background: #f4efe4; color: var(--sea); box-shadow: none; }
[data-theme="dark"] .today-cta .btn { background: var(--ink); color: #13263b; }
.today-cta .wave { position: absolute; right: -24px; top: -16px; width: 150px; opacity: .14; pointer-events: none; }
.today-cta.done { background: var(--good-soft); color: var(--ink); border: 1px solid var(--line); }
.today-cta.done .card-kicker { color: var(--good); }
.today-cta.done .btn { background: var(--card); color: var(--ink); border: 1px solid var(--line-2); }

.zoom-card .when { font-family: var(--serif); font-size: 15px; color: var(--accent); font-weight: 600; }
.zoom-card .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 54, 44, .5); } 70% { box-shadow: 0 0 0 8px rgba(194, 54, 44, 0); } 100% { box-shadow: 0 0 0 0 rgba(194, 54, 44, 0); } }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 130px; }

.chest-card {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold-soft), transparent 70%), var(--card);
  border-color: color-mix(in srgb, var(--gold) 35%, var(--line));
}
.chest-card .chest-mini { width: 54px; height: 54px; flex: none; }
.chest-card b { font-family: var(--serif); font-size: 17px; }

/* ---------- Прогресс ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s var(--ease); }
.bar.good > i { background: var(--good); }
.bar.gold > i { background: var(--gold); }
.step-line { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.step-line .t { flex: 1; min-width: 0; font-size: 14px; }
.step-line .p { font-weight: 700; font-size: 13px; width: 40px; text-align: right; color: var(--ink-2); }

/* ---------- Задачи ---------- */
.todo {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px dashed var(--line);
  transition: opacity .25s ease;
}
.todo:last-child { border-bottom: 0; }
.todo .check {
  width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--line-2);
  display: grid; place-items: center; color: transparent; transition: all .18s var(--ease);
}
.todo .check i { font-size: 16px; }
.todo.done .check { background: var(--good); border-color: var(--good); color: #fff; transform: scale(1.04); }
.todo .title { flex: 1; min-width: 0; font-size: 15px; word-break: break-word; }
.todo.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.todo .meta { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.todo .more { color: var(--muted); font-size: 19px; padding: 4px; }
.todo-add { display: flex; gap: 8px; margin-top: 10px; }
.todo-add input { flex: 1; }

/* ---------- Поля ввода ---------- */
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line); background: var(--card-2); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; transition: border-color .15s ease, background .15s ease;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--sea); background: var(--card); }
textarea.input { resize: none; min-height: 52px; line-height: 1.5; overflow: hidden; }
.field { margin-bottom: 16px; }
.field label, .label {
  display: flex; align-items: baseline; gap: 6px; font-family: var(--serif); font-weight: 600; font-size: 16px;
  margin: 0 2px 7px; color: var(--ink);
}
.field .hint { font-size: 12.5px; color: var(--muted); margin: -3px 2px 7px; }
.field.done label::after { content: "✓"; color: var(--good); font-family: var(--sans); font-size: 13px; }
.ro .input { background: transparent; border-style: dashed; }

/* Оценка 1–10 */
.score { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.score button {
  height: 40px; border-radius: 10px; background: var(--bg-2); font-weight: 700; color: var(--ink-2);
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.score button:active { transform: scale(.92); }
.score button.on { background: var(--accent); color: #fff; }
.score button.in { background: var(--accent-soft); color: var(--accent); }

/* Ползунок процентов */
.pct { display: flex; align-items: center; gap: 12px; }
.pct input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 28px; background: transparent; }
.pct input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: linear-gradient(to right, var(--accent) var(--v, 0%), var(--bg-2) var(--v, 0%)); }
.pct input[type=range]::-moz-range-track { height: 8px; border-radius: 99px; background: var(--bg-2); }
.pct input[type=range]::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--accent); }
.pct input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); box-shadow: var(--shadow); }
.pct input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }
.pct output { width: 48px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Шаги недели */
.step-edit { background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 6px; margin-bottom: 8px; }
.step-edit .num { font-family: var(--serif); font-weight: 700; color: var(--accent); width: 18px; flex: none; }
.step-edit input.plain { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; padding: 6px 0; min-width: 0; }
.carried { font-size: 11.5px; color: var(--gold); font-weight: 600; white-space: nowrap; }

/* Статус сохранения */
.savebar {
  position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -140%);
  z-index: 30; background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 99px; transition: transform .25s var(--ease), opacity .25s ease; opacity: 0;
}
.savebar.show { transform: translate(-50%, 0); opacity: .92; }

/* ---------- Журнал: месяц ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav h1 { flex: 1; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.cal .d {
  aspect-ratio: 1; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--card-2); border: 1px solid transparent;
  position: relative; transition: transform .12s ease;
}
.cal .d:active { transform: scale(.92); }
.cal .d.out { visibility: hidden; }
.cal .d.future { color: var(--muted); background: transparent; border: 1px dashed var(--line); }
.cal .d.today { border-color: var(--accent); color: var(--accent); }
.cal .d.rec { background: var(--accent); color: #fff; }
.cal .d.rec.lo { background: color-mix(in srgb, var(--accent) 55%, var(--card)); }
.cal .d .zm { position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--sea); }
.cal .d.rec .zm { background: #fff; }
.cal .d .td { position: absolute; top: 4px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease;
}
.list-row:active { transform: scale(.985); }
.list-row .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--bg-2); color: var(--ink-2); font-size: 20px; flex: none; }
.list-row .ic.red { background: var(--accent-soft); color: var(--accent); }
.list-row .ic.sea { background: var(--sea-soft); color: var(--sea); }
.list-row .ic.good { background: var(--good-soft); color: var(--good); }
.list-row .ic.gold { background: var(--gold-soft); color: var(--gold); }
.list-row b { display: block; font-weight: 600; font-size: 15px; }
.list-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .chev { color: var(--muted); font-size: 18px; }

/* Мини-график оценок */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; padding-top: 6px; }
.spark i { flex: 1 1 0; min-width: 0; background: var(--accent); border-radius: 3px 3px 1px 1px; opacity: .85; min-height: 3px; }
.spark i.nil { background: var(--bg-2); opacity: 1; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--card-2); border-radius: 12px; padding: 10px 12px; }
.kpi b { font-family: var(--serif); font-size: 21px; display: block; }
.kpi span { font-size: 12px; color: var(--muted); }

/* Полоса дней недели */
.days-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days-strip button { height: 52px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); font-weight: 600; }
.days-strip button b { font-size: 16px; color: var(--ink); }
.days-strip button.rec { background: var(--accent); border-color: var(--accent); color: rgba(255, 255, 255, .8); }
.days-strip button.rec b { color: #fff; }
.days-strip button.today { border-color: var(--accent); }

/* Фазы зума */
.phase-note { font-size: 13px; color: var(--muted); margin: -4px 2px 12px; }
.goals-report { background: var(--gold-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.goals-report b { font-family: var(--serif); }

/* ---------- Задания ---------- */
.quest { overflow: hidden; }
.quest .pts { font-family: var(--serif); font-weight: 700; color: var(--gold); font-size: 17px; white-space: nowrap; }
.quest p { margin: 8px 0 0; color: var(--ink-2); font-size: 14px; white-space: pre-wrap; }
.quest.done { opacity: .78; }
.quest .foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.progress-case { display: flex; align-items: center; gap: 14px; }
.dots3 { display: flex; gap: 6px; }
.dots3 i { width: 28px; height: 8px; border-radius: 99px; background: var(--bg-2); }
.dots3 i.on { background: var(--gold); }

/* ---------- Кейсы ---------- */
.cases-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.case-tile {
  border-radius: var(--r); padding: 14px 12px 12px; text-align: center; background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); cursor: pointer; transition: transform .14s ease; position: relative; overflow: hidden;
}
.case-tile:active { transform: scale(.97); }
.case-tile .chest { width: 84px; height: 84px; margin: 2px auto 6px; display: block; }
.case-tile.closed .chest { animation: bob 2.6s ease-in-out infinite; }
.case-tile b { display: block; font-family: var(--serif); font-size: 15px; }
.case-tile small { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.case-tile.closed::before {
  content: ""; position: absolute; inset: -40%; background: radial-gradient(circle, var(--tc-soft, rgba(183, 134, 47, .25)), transparent 55%);
  pointer-events: none;
}
.case-tile[data-tier="common"] { --tc: var(--tier-common); --tc-soft: rgba(79, 122, 154, .22); }
.case-tile[data-tier="rare"] { --tc: var(--tier-rare); --tc-soft: rgba(123, 79, 194, .24); }
.case-tile[data-tier="legendary"] { --tc: var(--tier-legendary); --tc-soft: rgba(196, 138, 27, .3); }
.case-tile .tier-line { height: 3px; border-radius: 99px; background: var(--tc); width: 40%; margin: 8px auto 0; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-4px) rotate(1.5deg); } }
.prize-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.prize-row:last-child { border-bottom: 0; }
.prize-row .em { font-size: 26px; width: 36px; text-align: center; }

/* Экран открытия кейса */
.opening { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(120% 80% at 50% 30%, #23344a 0%, #0c1118 70%); color: #f4efe4; padding: 24px 0 calc(24px + var(--safe-b));
  animation: fade-in .25s ease both; overflow: hidden; }
.opening .close-x { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; font-size: 20px; display: grid; place-items: center; }
.opening .o-title { font-family: var(--serif); font-size: 24px; font-weight: 600; text-align: center; padding: 0 24px; }
.opening .o-sub { color: rgba(244, 239, 228, .65); font-size: 14px; margin-top: 6px; text-align: center; padding: 0 24px; }
.opening .o-stage { width: 100%; display: flex; justify-content: center; position: relative; z-index: 1; }
.opening [data-cta] { position: relative; z-index: 1; }
.opening .big-chest { width: 190px; height: 190px; margin: 26px 0 22px; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .55)); }
.opening .big-chest.shake { animation: shake .5s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-4deg) scale(1.02); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg) scale(1.03); } 80% { transform: rotate(3deg); } }
.opening .rays { position: absolute; width: 760px; height: 760px; left: 50%; top: 50%; margin: -380px 0 0 -380px; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 120, .16) 0 9deg, transparent 9deg 22deg); border-radius: 50%;
  mask-image: radial-gradient(circle, #000 20%, transparent 62%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 62%);
  transition: opacity .6s ease; }
.opening.won .rays { opacity: 1; animation: rays 14s linear infinite; }
@keyframes rays { to { transform: rotate(360deg); } }
.reel-wrap { position: relative; width: 100%; height: 132px; margin: 24px 0 18px; overflow: hidden;
  mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent); }
.reel { position: absolute; left: 0; top: 10px; display: flex; gap: 10px; will-change: transform; }
.reel .tile { width: 104px; height: 112px; flex: none; border-radius: 16px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; text-align: center; }
.reel .tile .em { font-size: 36px; line-height: 1; }
.reel .tile small { font-size: 11px; line-height: 1.2; color: rgba(244, 239, 228, .8); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel .tile.win { background: rgba(224, 178, 90, .22); border-color: #e0b25a; box-shadow: 0 0 0 2px #e0b25a, 0 0 32px rgba(224, 178, 90, .6); transform: scale(1.06); transition: all .35s var(--ease); }
.reel-marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #e0b25a; border-radius: 2px; box-shadow: 0 0 12px #e0b25a; z-index: 2; }
.reel-marker::before, .reel-marker::after { content: ""; position: absolute; left: 50%; margin-left: -8px; border: 8px solid transparent; }
.reel-marker::before { top: -2px; border-top-color: #e0b25a; }
.reel-marker::after { bottom: -2px; border-bottom-color: #e0b25a; }
.win-card { text-align: center; padding: 0 24px; animation: pop .5s var(--ease) both; }
.win-card .em { font-size: 64px; line-height: 1; display: block; margin-bottom: 8px; }
.win-card h2 { font-size: 26px; }
.win-card p { color: rgba(244, 239, 228, .72); margin: 8px 0 18px; font-size: 14px; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
.opening .btn { min-width: 220px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }

/* ---------- Навигатор ---------- */
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; height: 46px; margin-bottom: 14px; }
.search i { color: var(--muted); font-size: 19px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.rubrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px; }
.rubric { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease; position: relative; }
.rubric:active { transform: scale(.97); }
.rubric .glyph { font-size: 26px; line-height: 1; color: var(--accent); }
.rubric .name { font-family: var(--serif); font-weight: 600; font-size: 15.5px; line-height: 1.25; margin-top: 10px; }
.rubric .count { position: absolute; top: 12px; right: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.vcard { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease; content-visibility: auto; contain-intrinsic-size: 96px; }
.vcard:active { transform: scale(.985); }
.vcard .cover { width: 92px; height: 76px; border-radius: 12px; flex: none; background: var(--bg-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 26px; position: relative; overflow: hidden; }
.vcard .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vcard .t { font-weight: 600; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vcard .d { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vcard .meta { margin-top: auto; padding-top: 6px; display: flex; gap: 6px; align-items: center; }
.new-badge { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; letter-spacing: .03em; }
.fav { color: var(--muted); font-size: 22px; padding: 4px; transition: transform .2s var(--ease), color .2s ease; }
.fav.on { color: var(--gold); transform: scale(1.12); }
.item-cover { width: 100%; aspect-ratio: 16/9; border-radius: var(--r); background: var(--bg-2) center/cover no-repeat; margin-bottom: 14px; display: grid; place-items: center; font-size: 44px; color: var(--muted); box-shadow: var(--shadow); }
.tc-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.tc-row:last-child { border-bottom: 0; }
.tc-time { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; min-width: 56px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ---------- Команда и рейтинг ---------- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-row.me { background: var(--accent-soft); border-radius: 10px; padding-left: 8px; padding-right: 8px; border-bottom-color: transparent; }
.lb-pos { width: 26px; font-family: var(--serif); font-weight: 700; color: var(--muted); text-align: center; }
.lb-pos.top { color: var(--gold); }
.lb-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--bg-2); color: var(--ink-2); margin-left: 4px; vertical-align: 1px; }
.badge.red { background: var(--accent-soft); color: var(--accent); }

/* ---------- Профиль ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.profile-head .avatar-btn { width: 64px; height: 64px; font-size: 26px; }
.profile-head h1 { font-size: 24px; }
.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-2); transition: background .2s ease; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .22s var(--ease); }
.toggle input:checked + span { background: var(--good); }
.toggle input:checked + span::after { transform: translateX(20px); }
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { font-size: 15px; }
.set-row select, .set-row input[type=time] { border: 1px solid var(--line); background: var(--card-2); border-radius: 10px; padding: 7px 10px; font-size: 15px; outline: none; max-width: 190px; }

/* ---------- Нижний лист (sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(10, 14, 20, .45); opacity: 0; transition: opacity .25s ease; }
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  transform: translate3d(0, 100%, 0); transition: transform .32s var(--ease); max-width: 640px; margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.sheet.show { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 4px auto 14px; }
.sheet h2 { font-size: 21px; margin-bottom: 12px; }

/* ---------- Тосты ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 45; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .3s var(--ease) both; max-width: 100%; display: flex; align-items: center; gap: 8px; }
.toast.miles { background: var(--gold); color: #fff; }
.toast.err { background: var(--accent); color: #fff; }
.toast.out { animation: toast-out .25s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Пустые состояния / скелеты ---------- */
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .em { font-size: 40px; display: block; margin-bottom: 8px; }
.empty h3 { color: var(--ink); font-size: 18px; margin-bottom: 4px; }
.sk { background: linear-gradient(90deg, var(--bg-2) 25%, var(--card-2) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; border-radius: var(--r); }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Онбординг ---------- */
.onb { text-align: center; padding: 30px 8px 10px; }
.onb .art { font-size: 64px; margin-bottom: 14px; display: block; animation: pop .45s var(--ease) both; }
.onb h1 { font-size: 26px; margin-bottom: 10px; }
.onb p { color: var(--ink-2); font-size: 15.5px; max-width: 420px; margin: 0 auto 8px; }
.onb-dots { display: flex; justify-content: center; gap: 6px; margin: 22px 0; }
.onb-dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line-2); transition: width .25s var(--ease), background .25s; }
.onb-dots i.on { width: 22px; background: var(--accent); }

/* ---------- Мостик (админ) ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.admin-grid .kpi b { font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.sub-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--card-2); }
.sub-card p { margin: 6px 0; font-size: 14px; white-space: pre-wrap; word-break: break-word; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Шаги недели — строки с галочкой */
.step-row input.plain { width: 100%; border: 0; background: transparent; outline: none; font-size: 15px; padding: 4px 0; color: var(--ink); }
.step-row.done input.plain, .step-row.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.step-row .check[disabled] { opacity: .6; }
