/* WorkOS · мини-приложение «Квесты». Псевдопиксельное фэнтези в духе HD-2D. */
:root {
  --bg: #0A0D22;
  --ink: #ECE6D6;
  --ink-dim: #D9D4C4;
  --muted: #A9B0D6;
  --muted2: #8E96C4;
  --gold: #E8C170;
  --gold-hi: #F5D58A;
  --gold-pale: #F3E7C6;
  --gold-mid: #C9A45C;
  --gold-dim: #A8864A;
  --gold-dark: #6E5A2E;
  --line: #4A4F80;
  --line2: #2E3466;
  --copper: #B07A42;
  --copper-ink: #E0A866;
  --rose: #F2A491;
  --jade: #8FE0BC;
  --jade-line: #4E9C7E;
  --ember: #FF9F43;
  --serif: 'Cormorant SC', Georgia, serif;
  --sans: 'Alegreya Sans', 'Trebuchet MS', sans-serif;
  --safe-top: max(calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)), env(safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--tg-safe-area-inset-left, 0px), env(safe-area-inset-left, 0px));
  --safe-right: max(var(--tg-safe-area-inset-right, 0px), env(safe-area-inset-right, 0px));
  --nav-h: 70px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans); font-size: 15px; line-height: 1.35; overflow: hidden;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
a { color: var(--gold); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  position: relative; height: 100vh; height: 100dvh; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg);
  padding-left: var(--safe-left); padding-right: var(--safe-right);
}
.view { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.screen { min-height: 100%; padding-bottom: 104px; display: flex; flex-direction: column; }
.screen.plain { background: radial-gradient(ellipse 120% 60% at 50% 0%, #1A2150 0%, #0A0D22 70%); }

/* ---------- сцена у костра ---------- */
.scene { position: relative; flex: none; overflow: hidden; background: linear-gradient(180deg, #060A1D 0%, #131A44 58%, #2B2452 100%); }
.scene.small { height: calc(176px + var(--safe-top)); }
.scene.big { height: calc(236px + var(--safe-top)); }
.scene .full { position: absolute; left: 0; width: 100%; pointer-events: none; }
.stage { position: absolute; left: 50%; bottom: 0; width: 390px; margin-left: -195px; }
.scene.small .stage { height: 176px; }
.scene.big .stage { height: 236px; }
.stage > * { position: absolute; }
.px { position: absolute; left: 0; top: 0; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 85% 95% at 55% 62%, transparent 52%, rgba(4, 6, 16, 0.82) 100%); }
.scene-title { position: absolute; left: 20px; top: calc(var(--safe-top) + 16px); display: flex; flex-direction: column; gap: 2px; z-index: 2; }
.kicker { font-family: var(--serif); font-weight: 600; font-size: 13px; letter-spacing: 0.14em; color: var(--gold-mid); }
.scene-title h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1; color: var(--gold-pale); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8); }
.season { position: absolute; right: 20px; top: calc(var(--safe-top) + 18px); text-align: right; z-index: 2; }
.hero { border: 0; background: transparent; padding: 0; cursor: pointer; filter: drop-shadow(2px 0 0 rgba(255, 190, 110, 0.5)); z-index: 1; }
.scene.big .hero { filter: drop-shadow(3px 0 0 rgba(255, 190, 110, 0.5)); }
.eye { position: absolute; background: #F0C29A; opacity: 0; animation: hd-eye 4.2s steps(1) infinite; }

/* ---------- эффекты выполнения ---------- */
.spark { position: absolute; width: 5px; height: 5px; animation: hd-burst 0.8s ease-out forwards; pointer-events: none; z-index: 3; }
.xpfloat { position: absolute; width: 140px; text-align: center; font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--gold-hi); text-shadow: 0 0 10px rgba(245, 213, 138, 0.8), 0 2px 0 #000; animation: hd-float 1.2s ease-out forwards; pointer-events: none; z-index: 5; }
.ribbon {
  position: absolute; left: 50%; top: calc(var(--safe-top) + 14px); width: min(300px, calc(100% - 24px)); padding: 8px 14px; text-align: center; z-index: 4;
  background: linear-gradient(180deg, rgba(40, 32, 18, 0.95), rgba(20, 16, 10, 0.95)); border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold);
  box-shadow: 0 0 24px rgba(232, 193, 112, 0.35); overflow: hidden; transform: translateX(-50%); animation: hd-ribbon 1.6s ease-out forwards; pointer-events: none;
}
.ribbon .shine { position: absolute; left: 0; top: 0; width: 60px; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 236, 180, 0.45), transparent); animation: hd-sweep 1s ease-out 0.15s 1 both; }
.ribbon .big { font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: 0.12em; color: var(--gold-hi); }
.ribbon .small { font-size: 13px; color: #D9CDB0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lvlup { position: absolute; inset: 0; z-index: 40; pointer-events: none; }
.lvlup .dim { position: absolute; inset: 0; background: rgba(4, 6, 16, 0.6); animation: hd-fade 2.8s ease-out forwards; }
.lvlup .pillar { position: absolute; left: 50%; top: 0; width: 140px; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 226, 150, 0.4), transparent); filter: blur(6px); transform-origin: 50% 0; animation: hd-pillar 2.8s ease-out forwards; }
.lvlup .box {
  position: absolute; left: 50%; top: 44%; width: 290px; padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: linear-gradient(180deg, rgba(40, 46, 96, 0.98), rgba(16, 19, 48, 0.98)); border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 3px rgba(232, 193, 112, 0.3), 0 0 40px rgba(232, 193, 112, 0.35);
  transform: translate(-50%, -50%); animation: hd-pop 2.8s ease-out forwards;
}
.lvlup .who { font-family: var(--serif); font-weight: 600; font-size: 14px; letter-spacing: 0.2em; color: var(--gold-mid); }
.lvlup .head { font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1.05; color: var(--gold-hi); text-shadow: 0 0 14px rgba(245, 213, 138, 0.6); }
.lvlup .lv { font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--gold-pale); }
.lvlup .note { font-size: 13px; color: #D9CDB0; }

/* ---------- золотые панели ---------- */
.panel {
  position: relative; background: linear-gradient(180deg, rgba(30, 38, 84, 0.97), rgba(15, 19, 46, 0.97)); border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 2px rgba(232, 193, 112, 0.18), 0 8px 20px rgba(0, 0, 0, 0.45);
}
.corner { position: absolute; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); pointer-events: none; }
.corner.tl { left: -4px; top: -4px; } .corner.tr { right: -4px; top: -4px; }
.corner.bl { left: -4px; bottom: -4px; } .corner.br { right: -4px; bottom: -4px; }

.status { z-index: 2; margin: -20px 16px 0; display: grid; grid-template-columns: 48px minmax(0, 1fr) 44px; gap: 12px; align-items: center; padding: 10px 10px 10px 14px; }
.status.char { margin-top: -22px; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; padding: 12px 14px 12px 16px; }
.lvl { width: 36px; height: 36px; margin-left: 4px; transform: rotate(45deg); border: 2px solid var(--gold); background: linear-gradient(135deg, #2D3878, #121633); box-shadow: 0 0 12px rgba(232, 193, 112, 0.35); display: flex; align-items: center; justify-content: center; }
.lvl span { transform: rotate(-45deg); font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--gold-hi); }
.status.char .lvl { width: 42px; height: 42px; margin-left: 6px; box-shadow: 0 0 14px rgba(232, 193, 112, 0.4); }
.status.char .lvl span { font-size: 24px; }
.stack { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.name { font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--gold-pale); margin: 0; line-height: 1.05; }
.status.char .name { font-size: 24px; }
.xptext { font-family: var(--serif); font-weight: 600; font-size: 14px; color: #C9C2AE; white-space: nowrap; }
.bar { position: relative; height: 8px; border: 1px solid var(--line); background: #080A1C; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #A97B34, #F5D58A); box-shadow: 0 0 8px rgba(245, 213, 138, 0.6); transition: width 0.8s ease-out; }
.sub { font-size: 12px; color: var(--muted); }
.reward { font-size: 13px; line-height: 1.3; color: #D9CDB0; }
.reward.open { color: var(--gold-hi); }
.iconbtn { width: 44px; height: 44px; border: 1px solid var(--gold-dark); background: rgba(10, 13, 34, 0.6); color: var(--gold); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.iconbtn:active { background: rgba(232, 193, 112, 0.12); }
.iconbtn.loading svg { animation: spin 0.9s linear infinite; }

/* ---------- привычки ---------- */
.habits { margin: 12px 16px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, rgba(22, 28, 64, 0.92), rgba(12, 15, 38, 0.92)); border: 1px solid var(--gold-dark);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 2px rgba(232, 193, 112, 0.12); }
.habit { width: 100%; min-height: 44px; border: 1px solid var(--line2); background: rgba(18, 23, 54, 0.8); padding: 7px 10px; color: var(--ink);
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; cursor: pointer; text-align: left; font: inherit; }
.hdir { margin: 6px 0 0; font-family: var(--serif); font-weight: 600; font-size: 13px; letter-spacing: 0.1em; color: var(--gold-mid); }
.hmore { min-height: 40px; margin-top: 2px; border: 1px dashed var(--line); background: transparent; color: var(--gold); font-family: var(--serif);
  font-weight: 600; font-size: 15px; letter-spacing: 0.04em; cursor: pointer; }
.hmore:active { background: rgba(232, 193, 112, 0.08); }
.habit .gem { width: 9px; height: 9px; flex: none; transform: rotate(45deg); border: 1.5px solid #6A719E; }
.habit.on { border-color: var(--jade-line); background: rgba(36, 78, 64, 0.45); }
.habit.on .gem { border-color: var(--jade); background: var(--jade); box-shadow: 0 0 8px rgba(143, 224, 188, 0.7); }
.habit.auto { cursor: default; }
.habit .hn { font-size: 14px; font-weight: 500; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.habit .hs { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- оценка дня ---------- */
.rate { margin: 0 16px 12px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px;
  background: linear-gradient(180deg, rgba(22, 28, 64, 0.92), rgba(12, 15, 38, 0.92)); border: 1px solid var(--gold-dark);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 2px rgba(232, 193, 112, 0.12); }
.rhead { display: flex; align-items: center; gap: 8px; }
.rhead .dia { width: 6px; height: 6px; flex: none; background: var(--gold); transform: rotate(45deg); }
.rhead h2 { margin: 0; flex: 1; font-family: var(--serif); font-weight: 700; font-size: 16px; letter-spacing: 0.12em; color: var(--gold); }
.rv { min-width: 48px; text-align: right; font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1; color: var(--gold-hi);
  font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(232, 193, 112, 0.35); }
.rv.up { color: var(--jade); text-shadow: 0 0 10px rgba(143, 224, 188, 0.35); }
.rv.down { color: var(--rose); text-shadow: 0 0 10px rgba(242, 164, 145, 0.3); }
.rtrack { position: relative; }
.rtrack::after { content: ''; position: absolute; left: 50%; top: 13px; width: 1px; height: 18px; background: var(--gold-dim); pointer-events: none; }
.rate input[type=range] { --trk: #1A2050; display: block; width: 100%; height: 44px; margin: 0; padding: 0; background: transparent;
  -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: pan-y; }
.rate input[type=range]:focus { outline: none; }
.rate input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #0A0D22, 0 0 0 4px var(--gold-hi), 0 0 14px rgba(245, 213, 138, 0.8); }
.rate input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 2px #0A0D22, 0 0 0 4px var(--gold-hi), 0 0 14px rgba(245, 213, 138, 0.8); }
.rv.blank { color: var(--muted2); text-shadow: none; }
.rate input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--trk); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px #0A0D22; }
.rate input[type=range]::-moz-range-track { height: 8px; background: var(--trk); border: 1px solid var(--line); box-shadow: inset 0 0 0 1px #0A0D22; }
.rate input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px;
  background: linear-gradient(135deg, var(--gold-pale), var(--gold) 55%, var(--gold-dark)); border: 1px solid #1A1408;
  transform: rotate(45deg); box-shadow: 0 0 10px rgba(232, 193, 112, 0.55); }
.rate input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 0;
  background: linear-gradient(135deg, var(--gold-pale), var(--gold) 55%, var(--gold-dark)); border: 1px solid #1A1408;
  transform: rotate(45deg); box-shadow: 0 0 10px rgba(232, 193, 112, 0.55); }
.rate input[type=range]:active::-webkit-slider-thumb { box-shadow: 0 0 16px rgba(245, 213, 138, 0.9); }
.rticks { display: flex; justify-content: space-between; margin-top: -6px; font-size: 11px; color: var(--muted2); font-variant-numeric: tabular-nums; }
.rfoot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.rm { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rsave { height: 40px; min-width: 112px; font-size: 16px; }

/* ---------- квесты дня ---------- */
.quests { position: relative; margin: 0 16px 12px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, rgba(22, 28, 64, 0.92), rgba(12, 15, 38, 0.92)); border: 1px solid var(--gold-dark);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 2px rgba(232, 193, 112, 0.12); }
.sec { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.sec .dia { width: 6px; height: 6px; flex: none; background: var(--gold); transform: rotate(45deg); }
.sec h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 16px; letter-spacing: 0.12em; color: var(--gold); }
.sec .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-dim), transparent); }
.sec .count { font-family: var(--serif); font-weight: 600; font-size: 13px; color: var(--muted); }
.sec.later { margin-top: 10px; }
.row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; align-items: start; }
.row > .t { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--muted); padding-top: 14px; }
.row.compact > .t { padding-top: 9px; }
.nowrow { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.nowrow .t { font-family: var(--serif); font-weight: 700; font-size: 14px; color: #FFB067; width: 40px; }
.nowrow .nd { width: 6px; height: 6px; background: var(--ember); transform: rotate(45deg); box-shadow: 0 0 8px var(--ember); animation: hd-twinkle 1.4s ease-in-out infinite; }
.nowrow .nl { flex: 1; height: 1px; background: linear-gradient(90deg, var(--ember), transparent); }
.empty { padding: 14px 4px; font-size: 14px; color: var(--muted); font-style: italic; }

.card { position: relative; overflow: hidden; display: flex; align-items: center; gap: 2px; min-height: 50px; background: rgba(30, 37, 82, 0.75); border: 1px solid var(--line); padding: 2px 0;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.card.done { background: rgba(10, 13, 30, 0.6); border-color: #3A3626; }
.card.overdue { border-color: #8A5A3A; background: linear-gradient(90deg, rgba(76, 40, 30, 0.55), rgba(30, 37, 82, 0.75)); }
.card.leaving { opacity: 0.4; transition: opacity 0.4s; }
.check { width: 44px; height: 44px; flex: none; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.check .gem { width: 13px; height: 13px; transform: rotate(45deg); border: 1.5px solid var(--gold-dim); transition: background 0.2s, box-shadow 0.2s; }
.card.done .check .gem { border-color: var(--gold-hi); background: linear-gradient(135deg, #FFF1B8, #C99A45); box-shadow: 0 0 10px rgba(245, 213, 138, 0.8); }
.gem.pop { animation: hd-gem 0.45s ease-out 1; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.card .title { font-size: 15px; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.card.done .title { color: #8E8A80; text-decoration: line-through; text-decoration-color: var(--gold-dim); }
.meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.meta > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .late { color: var(--copper-ink); }
.dot { width: 6px; height: 6px; flex: none; transform: rotate(45deg); }
.card .xp { font-family: var(--serif); font-weight: 700; font-size: 17px; color: #F0CF85; flex: none; }
.card.done .xp { color: #8C8470; }
.more { width: 40px; height: 44px; flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.sweep { position: absolute; left: 0; top: 0; width: 50px; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 228, 160, 0.35), transparent); animation: hd-sweep 0.9s ease-out 1 both; pointer-events: none; }
.meet { display: flex; align-items: center; gap: 10px; min-height: 44px; border: 1px solid var(--line2); background: rgba(10, 13, 34, 0.55); padding: 6px 12px; }
.meet .dot { width: 8px; height: 8px; }
.meet .mt { font-size: 15px; line-height: 1.25; color: var(--ink-dim); overflow-wrap: anywhere; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gapbox { min-height: 34px; border: 1px dashed #3A4170; display: flex; align-items: center; padding: 0 12px; font-size: 13px; font-style: italic; color: var(--muted); }
.train { display: flex; align-items: center; gap: 10px; min-height: 50px; background: linear-gradient(90deg, rgba(36, 78, 64, 0.55), rgba(14, 30, 30, 0.55)); border: 1px solid var(--jade-line); padding: 6px 12px; }
.train .tt { font-size: 15px; line-height: 1.25; }
.train .tm { font-size: 12px; color: #A8DCC7; }
.train.done { opacity: 0.7; }

.fab { position: absolute; right: calc(28px + var(--safe-right)); bottom: calc(var(--nav-h) + var(--safe-bottom) + 30px); width: 48px; height: 48px; z-index: 6;
  transform: rotate(45deg); border: 1px solid var(--gold-hi); background: linear-gradient(135deg, #F5D58A, #B98A3E); color: #1A1408;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; box-shadow: 0 0 16px rgba(232, 193, 112, 0.5), 0 6px 14px rgba(0, 0, 0, 0.5); }
.fab svg { transform: rotate(-45deg); }
.fab:active { filter: brightness(1.1); }

/* ---------- нижняя панель ---------- */
.tabbar { flex: none; position: relative; z-index: 7; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 8px calc(8px + var(--safe-bottom));
  background: linear-gradient(180deg, #151B40, #0A0D22); border-top: 1px solid #8C7340; box-shadow: inset 0 1px 0 rgba(232, 193, 112, 0.2); }
.tab { position: relative; min-height: 52px; border: 0; background: transparent; color: var(--muted2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--serif); font-weight: 600; font-size: 14px; cursor: pointer; padding: 0; }
.tab[aria-current="page"] { color: #F0CF85; font-weight: 700; }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -12px; width: 7px; height: 7px; background: #F0CF85; transform: rotate(45deg); box-shadow: 0 0 8px #F0CF85; }

/* ---------- журнал ---------- */
.head { padding: calc(var(--safe-top) + 22px) 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.head h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 32px; line-height: 1; color: var(--gold-pale); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7); }
.seg { margin: 0 20px 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--gold-dark); background: rgba(10, 13, 34, 0.7); }
.seg button { height: 44px; border: 0; background: transparent; color: var(--muted); font-family: var(--serif); font-weight: 600; font-size: 17px; cursor: pointer; }
.seg button + button { border-left: 1px solid #3A3626; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, rgba(232, 193, 112, 0.22), rgba(232, 193, 112, 0.06)); box-shadow: inset 0 -2px 0 var(--gold); color: #F0CF85; font-weight: 700; }
.addform { margin: 0 20px 6px; display: flex; gap: 8px; }
.input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line); background: rgba(8, 10, 28, 0.85); color: var(--ink); font: inherit; font-size: 16px; padding: 0 12px; border-radius: 0; -webkit-appearance: none; }
.input::placeholder { color: #6E76A6; }
.btn-gold { height: 46px; padding: 0 16px; border: 1px solid var(--gold-hi); background: linear-gradient(180deg, #F5D58A, #B98A3E); color: #1A1408; font-family: var(--serif); font-size: 17px; font-weight: 700; cursor: pointer; box-shadow: 0 0 12px rgba(232, 193, 112, 0.35); }
.btn-gold:disabled { filter: grayscale(0.6) brightness(0.8); cursor: default; }
.hint { margin: 0 20px 14px; font-size: 13px; color: var(--muted); }
.groups { padding: 0 20px; display: flex; flex-direction: column; gap: 16px; }
.group { display: flex; flex-direction: column; gap: 8px; }
.group .sec h2 { letter-spacing: 0.08em; }
.group .card { min-height: 54px; }

/* ---------- персонаж ---------- */
.charbody { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 14px; }
.mainquest { padding: 9px 14px; display: flex; flex-direction: column; gap: 3px; background: linear-gradient(180deg, rgba(76, 24, 32, 0.9), rgba(32, 12, 20, 0.92)); border: 1px solid #C9705F; box-shadow: inset 0 0 0 1px #0A0D22, 0 0 16px rgba(201, 112, 95, 0.2); }
.mainquest .mq-h { font-family: var(--serif); font-weight: 700; font-size: 14px; letter-spacing: 0.14em; color: var(--rose); }
.mainquest .mq-t { font-size: 15px; line-height: 1.35; color: #F6DCD3; }
.mainquest.none .mq-t { color: #C9A9A0; font-style: italic; }
.attrs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.attr { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.attr .an { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attr .al { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1; color: var(--gold-hi); }
.attr .ab { height: 5px; background: #12163A; box-shadow: inset 0 0 0 1px var(--line2); }
.attr .ab > i { display: block; height: 100%; background: linear-gradient(90deg, #A97B34, #F5D58A); box-shadow: 0 0 6px rgba(245, 213, 138, 0.5); }
.attr.rusty .an, .attr.rusty .al { color: var(--copper-ink); }
.attr.rusty .ab > i { background: linear-gradient(90deg, #6E4A2A, #B07A42); box-shadow: none; }
.rustnote { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 1.35; color: var(--copper-ink); }
.rustnote .rd { width: 7px; height: 7px; flex: none; background: var(--copper); transform: rotate(45deg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border: 1px solid var(--line2); background: rgba(18, 23, 54, 0.8); font-size: 13px; color: var(--ink-dim); }
.chip b { font-family: var(--serif); color: var(--gold-hi); }
.badges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.badge .ring { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--gold); background: radial-gradient(circle at 50% 40%, #2A3270, #0C0F27 75%); box-shadow: 0 0 12px rgba(232, 193, 112, 0.35); }
.badge.locked .ring { border: 2px dashed var(--line); box-shadow: none; }
.badge .bn { font-size: 12px; line-height: 1.2; color: #D9CDB0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.badge.locked .bn { color: var(--muted2); }
.dialog { position: absolute; left: 12px; right: 12px; top: calc(var(--safe-top) + 46px); padding: 12px 14px 10px; z-index: 5;
  background: linear-gradient(180deg, rgba(30, 38, 84, 0.97), rgba(12, 15, 38, 0.97)); border: 1px solid var(--gold-dim);
  box-shadow: inset 0 0 0 1px #0A0D22, inset 0 0 0 2px rgba(232, 193, 112, 0.2), 0 8px 20px rgba(0, 0, 0, 0.5); animation: hd-box 3.2s ease-out forwards; }
.dialog .who { position: absolute; left: 12px; top: -11px; padding: 1px 10px; background: #1A1408; border: 1px solid var(--gold-dim); font-family: var(--serif); font-weight: 700; font-size: 13px; letter-spacing: 0.1em; color: #F0CF85; }
.dialog .say { display: block; font-size: 15px; line-height: 1.35; color: var(--ink); animation: hd-type 0.9s steps(24) both; }
.chest { pointer-events: none; filter: drop-shadow(-2px 0 0 rgba(255, 190, 110, 0.45)); animation: hd-shake 3.2s steps(1) infinite; }
.chest .glint { position: absolute; left: 42px; top: -8px; width: 5px; height: 5px; background: #FFF1B8; transform: rotate(45deg); box-shadow: 0 0 8px var(--gold-hi); animation: hd-twinkle 1.2s ease-in-out infinite; }

/* ---------- карта ---------- */
.mapbody { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }
.tiles, .cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { min-height: 72px; min-width: 0; border: 1px solid #3A4170; background: rgba(22, 28, 64, 0.85); padding: 7px 8px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; }
.tile .tn { font-size: 14px; font-weight: 500; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .tl { font-family: var(--serif); font-weight: 700; font-size: 17px; line-height: 1; color: var(--gold-hi); flex: none; }
.tile .gems { display: flex; gap: 3px; flex-wrap: wrap; }
.tile .gems i { width: 5px; height: 5px; margin: 1px; transform: rotate(45deg); background: var(--line2); }
.tile .gems i.on { background: var(--gold); }
.tile.rusty { border-color: #6E4A2A; }
.tile.rusty .tn, .tile.rusty .tl { color: var(--copper-ink); }
.tile.rusty .gems i.on { background: var(--copper); }
.tile[aria-pressed="true"] { border-color: var(--gold); background: linear-gradient(180deg, rgba(56, 52, 40, 0.95), rgba(26, 24, 30, 0.95)); box-shadow: 0 0 14px rgba(232, 193, 112, 0.35); }
.tile.center { border-color: #C9705F; background: linear-gradient(180deg, rgba(76, 24, 32, 0.9), rgba(32, 12, 20, 0.92)); box-shadow: 0 0 14px rgba(201, 112, 95, 0.3); }
.tile.center .tn { color: #F6DCD3; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile.center .gems i { background: var(--rose); }
.tile.center[aria-pressed="true"] { border-color: var(--rose); }
.tile.void { cursor: default; border-style: dashed; color: var(--muted); }
.cell { min-height: 98px; min-width: 0; border: 1px solid #3A4170; background: rgba(22, 28, 64, 0.85); padding: 8px; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }
.cell .cn { font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.cell .ck { display: flex; align-items: center; gap: 5px; font-size: 11px; letter-spacing: 0.04em; }
.cell .ck i { width: 6px; height: 6px; flex: none; transform: rotate(45deg); }
.cell .cs { font-family: var(--serif); font-weight: 700; font-size: 14px; color: #D9CDB0; }
.cell.mid { border-color: var(--gold); background: linear-gradient(180deg, rgba(56, 52, 40, 0.95), rgba(26, 24, 30, 0.95)); box-shadow: 0 0 14px rgba(232, 193, 112, 0.3); }
.cell.mid .cn { font-family: var(--serif); font-weight: 700; color: var(--gold-hi); }
.cell.mid.quest { border-color: #C9705F; background: linear-gradient(180deg, rgba(76, 24, 32, 0.9), rgba(32, 12, 20, 0.92)); }
.cell.mid.quest .cn { color: #F6DCD3; font-family: var(--sans); font-weight: 500; }
.cell.void { background: transparent; border: 1px dashed var(--line); }
.cell.void .cn { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; transform: rotate(45deg); }

/* ---------- листы, тосты, заглушки ---------- */
.backdrop { position: absolute; inset: 0; z-index: 30; background: rgba(4, 6, 16, 0.62); display: flex; align-items: flex-end; justify-content: center; animation: fade-in 0.18s ease-out; }
.sheet { position: relative; width: 100%; padding: 18px 18px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, rgba(30, 38, 84, 0.99), rgba(12, 15, 38, 0.99)); border-top: 1px solid var(--gold-dim);
  box-shadow: inset 0 1px 0 rgba(232, 193, 112, 0.25), 0 -10px 30px rgba(0, 0, 0, 0.5); animation: sheet-in 0.22s ease-out; }
.sheet h2 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: 0.06em; color: var(--gold); overflow-wrap: anywhere; }
.sheet .addform, .sheet .hint { margin: 0; }
.btn-line { min-height: 48px; width: 100%; border: 1px solid var(--line); background: rgba(22, 28, 64, 0.85); color: var(--ink); font-size: 16px; text-align: left; padding: 0 14px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.btn-line.danger { color: var(--rose); border-color: #6E3A32; }
.btn-line.quiet { justify-content: center; color: var(--muted); }
.toast { position: absolute; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 96px); transform: translateX(-50%); width: max-content; max-width: calc(100% - 40px); z-index: 35;
  padding: 10px 14px; background: rgba(20, 16, 10, 0.96); border: 1px solid var(--gold-dim); color: var(--ink); font-size: 14px; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); animation: fade-in 0.2s ease-out; }
.toast.err { border-color: #8A4E3A; color: #F6DCD3; }
.gate { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: calc(var(--safe-top) + 30px) 28px 40px; text-align: center; }
.gate h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 28px; color: var(--gold-pale); }
.gate p { margin: 0; color: var(--muted); max-width: 320px; }
.gate .btn-gold { display: inline-flex; align-items: center; text-decoration: none; }
.loading { padding: 40px 20px; text-align: center; font-family: var(--serif); font-size: 18px; color: var(--gold-mid); }
.demo-flag { position: absolute; left: 8px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 6px); z-index: 8; padding: 2px 8px; font-size: 11px; letter-spacing: 0.1em; color: #1A1408; background: var(--gold); font-family: var(--serif); font-weight: 700; pointer-events: none; }

/* ---------- анимации (из макета) ---------- */
@keyframes hd-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes hd-jump { 0% { transform: translateY(0); } 30% { transform: translateY(-18px); } 55% { transform: translateY(0); } 75% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
@keyframes hd-idleB { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes hd-jumpB { 0% { transform: translateY(0); } 30% { transform: translateY(-24px); } 55% { transform: translateY(0); } 75% { transform: translateY(-6px); } 100% { transform: translateY(0); } }
@keyframes hd-eye { 0%, 90% { opacity: 0; } 91%, 95% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes hd-fa { 0%, 49.9% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes hd-fb { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
@keyframes hd-glow { 0% { opacity: 0.7; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1.05); } }
@keyframes hd-e0 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(-14px, -84px); opacity: 0; } }
@keyframes hd-e1 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(12px, -96px); opacity: 0; } }
@keyframes hd-e2 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(-3px, -70px); opacity: 0; } }
@keyframes hd-E0 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(-16px, -110px); opacity: 0; } }
@keyframes hd-E1 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(14px, -124px); opacity: 0; } }
@keyframes hd-E2 { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(-4px, -96px); opacity: 0; } }
@keyframes hd-twinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes hd-float { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
@keyframes hd-burst { 0% { transform: translate(0, 0) rotate(45deg) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(45deg) scale(0.3); opacity: 0; } }
@keyframes hd-ribbon { 0% { transform: translateX(-50%) scaleX(0.2); opacity: 0; } 12% { transform: translateX(-50%) scaleX(1.04); opacity: 1; } 20% { transform: translateX(-50%) scaleX(1); } 82% { opacity: 1; } 100% { transform: translateX(-50%) scaleX(1); opacity: 0; } }
@keyframes hd-sweep { 0% { transform: translateX(-120%) skewX(-20deg); } 100% { transform: translateX(520%) skewX(-20deg); } }
@keyframes hd-gem { 0% { transform: rotate(45deg) scale(0.4); } 60% { transform: rotate(45deg) scale(1.4); } 100% { transform: rotate(45deg) scale(1); } }
@keyframes hd-pillar { 0% { opacity: 0; transform: translateX(-50%) scaleY(0.2); } 20% { opacity: 1; transform: translateX(-50%) scaleY(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) scaleY(1); } }
@keyframes hd-pop { 0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; } 25% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
@keyframes hd-fade { 0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hd-shake { 0%, 78%, 100% { transform: translateX(0); } 82% { transform: translateX(-2px); } 86% { transform: translateX(2px); } 90% { transform: translateX(-2px); } 94% { transform: translateX(2px); } }
@keyframes hd-type { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }
@keyframes hd-box { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: translateY(0); } 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sheet-in { 0% { transform: translateY(24px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
  .status { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; padding-left: 10px; }
  .name { font-size: 17px; }
  .xptext { font-size: 12px; }
  .quests { margin: 0 10px 12px; padding: 8px 8px 10px; }
  .rate { margin: 0 10px 12px; padding: 8px 10px 10px; }
  .habits { margin: 12px 10px; padding: 8px 10px 10px; }
  .row { grid-template-columns: 36px minmax(0, 1fr); gap: 6px; }
  .row > .t { font-size: 14px; }
  .check { width: 38px; }
  .more { width: 30px; }
  .card .xp { font-size: 15px; }
  .groups, .mapbody { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fire-b, .eye, .ember { display: none; }
}
