:root {
  --bg: #0b0d14;
  --panel: #141824;
  --panel2: #1c2132;
  --line: #2b3247;
  --text: #ece6d6;
  --muted: #9aa0b5;
  --gold: #e9c46a;
  --blood: #ff6b85;
  --danger: #ef6a5b;
  --ok: #8fc47a;
  --violet: #9a78e8;
  --serif: Georgia, "Times New Roman", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* боковые поля: не меньше 16px и не под системной полосой телефона */
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); overscroll-behavior: none; }
body { color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; touch-action: manipulation; }
h1, h2, h3 { font-family: var(--serif); margin: 0; font-weight: 700; }
h2 { font-size: 22px; margin-bottom: 6px; }
h3 { font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.2; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
p { margin: 8px 0; }
small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
[hidden] { display: none !important; }

button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; min-height: 44px; cursor: pointer; transition: border-color .15s, background .15s, transform .05s; }
button:active:not([disabled]) { transform: translateY(1px); }
button:hover:not([disabled]) { border-color: var(--gold); }
button[disabled] { opacity: .42; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #4a3d1c, #3a3018); border-color: #8a7232; color: #fff2cf; font-weight: 600; }
button.big { padding: 13px 18px; font-size: 16px; width: 100%; }
button.wide { width: 100%; margin-top: 10px; }
button.danger { border-color: #7a3531; color: #ffb9ae; }
button.on { background: var(--gold); color: #1b1608; border-color: var(--gold); }
button.icon { padding: 0; width: 40px; min-height: 40px; display: grid; place-items: center; background: transparent; border-color: transparent; }

#app { height: 100%; display: flex; flex-direction: column; max-width: 1240px; margin: 0 auto; position: relative; }
#app.out #top, #app.out #main, #app.out #nav { display: none; }

/* ---------- Верхняя строка ---------- */
#top { flex: none; background: #0d1018; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar { display: flex; align-items: center; gap: 10px; padding: 6px calc(var(--gr) - 8px) 6px var(--gl); }
.when { display: flex; align-items: center; gap: 6px; color: var(--gold); flex: none; }
.when span { font-size: 13px; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.when i { display: block; font-style: normal; color: var(--muted); font-size: 12px; }
.hpbox { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.hpic { color: #e2606e; display: flex; }
.meter { position: relative; height: 18px; background: #232839; border-radius: 9px; overflow: hidden; flex: 1; min-width: 0; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 9px; transition: width .25s; }
.meter b { position: relative; display: block; text-align: center; font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; }
.meter.hp i { background: linear-gradient(90deg, #8e2f3f, #d9566a); }
.meter.dk { height: 6px; } .meter.dk i { background: linear-gradient(90deg, #4b3d78, #a3478f); }
.meter.fhp { height: 12px; border-radius: 6px; } .meter.fhp i { background: linear-gradient(90deg, #7a2f3a, #d0545f); border-radius: 6px; } .meter.fhp b { font-size: 10.5px; line-height: 12px; }
.meter.xpbig { height: 8px; margin: 6px 0; } .meter.xpbig i { background: linear-gradient(90deg, #a98432, var(--gold)); }
.blood { color: var(--blood); display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.blood .ic { width: 15px; height: 15px; }
.lvl { flex: none; min-height: 36px; padding: 2px 8px; display: grid; grid-template-columns: auto auto; gap: 0 4px; align-items: center; color: var(--gold); background: transparent; border-color: var(--line); }
.lvl b { color: var(--text); } .lvl .ic { width: 15px; height: 15px; }
.lvl .xp { grid-column: 1 / 3; height: 3px; background: #232839; border-radius: 2px; overflow: hidden; width: 34px; }
.lvl .xp i { display: block; height: 100%; background: var(--gold); }
.dkchip { flex: none; display: grid; justify-items: center; line-height: 1.05; color: #c9a2e6; }
.dkchip span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dkchip b { font-variant-numeric: tabular-nums; }
.darkline { height: 3px; background: #1a1d2b; }
.darkline i { display: block; height: 100%; background: linear-gradient(90deg, #4b3d78, #b04a9a); transition: width .6s; }

/* ---------- Раскладка ---------- */
#main { flex: 1; min-height: 0; position: relative; display: flex; }
#scene { flex: 1; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
#panel { position: absolute; inset: 0; background: var(--bg); overflow-y: auto; display: none; z-index: 4; -webkit-overflow-scrolling: touch; }
#app.tab-open #panel { display: block; }
.pane { padding: 14px var(--gr) 28px var(--gl); max-width: 640px; margin: 0 auto; }

#nav { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); background: #0d1018; border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px); z-index: 6; }
#nav button { position: relative; background: transparent; border: 0; border-radius: 0; min-height: 54px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; }
#nav button .ic { width: 22px; height: 22px; }
#nav button.on { color: var(--gold); background: transparent; }
#nav button.on::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 2px; background: var(--gold); border-radius: 2px; }
#nav em { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--blood); color: #200; font: 700 10.5px/15px inherit; font-style: normal; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; }

/* ---------- Карта ---------- */
.mapwrap { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.mapwrap.wide { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.mapwrap.wide .map { grid-row: 1 / 3; grid-column: 1; }
.mapwrap.wide .goal, .mapwrap.wide .sheet { grid-column: 2; }
.map { position: relative; flex: none; margin: 0 auto; overflow: hidden; background: #000; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.mapimg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: filter 1.2s; pointer-events: none; }
.map.night .mapimg { filter: brightness(.82) saturate(.72) hue-rotate(10deg); }
.dark { position: absolute; inset: 0; pointer-events: none; transition: background 1s; }
.fog { position: absolute; inset: -3%; width: 106%; height: 106%; pointer-events: none; filter: blur(var(--blur, 6px)); }
.over { position: absolute; inset: 0; width: 100%; height: 100%; }
.goal { min-height: 34px; padding: 5px var(--gr) 5px var(--gl); display: flex; gap: 8px; align-items: baseline; text-align: left; background: #17130a; border: 0; border-bottom: 1px solid #4d4020; border-radius: 0; font-size: 13px; line-height: 1.3; width: 100%; }
.goal b { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; flex: none; }
.goal span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.mapwrap.wide .goal span, .goal.in span { white-space: normal; }
.goal.in { position: sticky; top: 0; z-index: 2; }

.ring { fill: none; stroke: #f3d98a; stroke-opacity: .5; }
.road { fill: none; stroke: #f1e3b4; stroke-opacity: .5; stroke-linecap: round; }
.route { stroke: var(--gold); stroke-linecap: round; opacity: .9; }
.route.on { animation: march .7s linear infinite; }
@keyframes march { to { stroke-dashoffset: -34; } }
.hit { fill: transparent; }
.pin, .beacon, .site { cursor: pointer; }
.pin .disc { stroke: #0b0d14; }
.pin.sel .disc, .pin:hover .disc { stroke: #fff; }
.pin.far .disc { fill-opacity: .72; }
.pin .glyph { fill: #14161f; pointer-events: none; }
.pin.fallen .glyph { fill: #a79bbd; }
.pin .label { fill: #f4eedd; font-weight: 600; paint-order: stroke; stroke: rgba(7, 8, 13, .9); stroke-linejoin: round; pointer-events: none; }
.pin.fallen .label { fill: #a79bbd; }
.want { fill: none; stroke: var(--gold); animation: want 1.4s ease-in-out infinite; }
@keyframes want { 50% { stroke-opacity: .2; } }
.beacon .core { fill: #3a3f52; stroke: #9aa0b5; }
.beacon.lit .core { fill: #ffd98a; stroke: #fff6dd; }
.beacon .glow { fill: #ffcf70; opacity: .22; animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .34; } }
.selring { fill: none; stroke: #fff; }
.site rect { fill: #7fd6c8; stroke: #0b0d14; }
.npc { stroke: #0b0d14; pointer-events: none; }
.mark circle { fill: none; stroke: var(--gold); } .mark .c { fill: var(--gold); stroke: none; }
.hero { pointer-events: none; }
.hero .sight { fill: rgba(255, 220, 140, .05); stroke: rgba(255, 220, 140, .28); }
.hero .dot { fill: var(--gold); stroke: #fff; }
.hero .pulse { fill: none; stroke: var(--gold); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { stroke-opacity: .9; transform: scale(.6); } 100% { stroke-opacity: 0; transform: scale(1.5); } }

.sheet { min-height: 0; overflow-y: auto; padding: 10px var(--gr) 10px var(--gl); display: flex; flex-direction: column; gap: 8px; background: linear-gradient(180deg, #121622, var(--bg)); border-top: 1px solid var(--line); }
.mapwrap.wide .sheet { border-top: 0; border-left: 1px solid var(--line); min-width: 280px; }
.sh-row { display: flex; gap: 10px; align-items: center; } .sh-row .sh-text { flex: 1; min-width: 0; }
.sh-title { font: 700 18px/1.2 var(--serif); }
.sh-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sh-hint { color: var(--gold); font-size: 13px; margin-top: 6px; }
.sh-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.sh-acts button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sh-acts .primary { flex: 2 1 60%; }
.dng { font-weight: 600; } .d0, .d1 { color: var(--ok); } .d2 { color: var(--gold); } .d3 { color: #f0934e; } .d4, .d5 { color: var(--danger); }

/* ---------- Место ---------- */
.loc { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.loc-art { position: relative; height: min(34vh, 300px); background: #111 center / cover; }
.loc-art.fallen { filter: grayscale(.8) brightness(.55); }
.loc-head { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px var(--gr) 10px var(--gl); background: linear-gradient(180deg, transparent, rgba(11, 13, 20, .95)); }
.loc-head h1 { font-size: 26px; text-shadow: 0 2px 8px #000; margin-bottom: 4px; }
.loc-body { padding: 4px var(--gr) 24px var(--gl); max-width: 760px; margin: 0 auto; }
.desc { color: #d6d0c0; }
.tag { display: inline-block; font-style: normal; font-size: 11.5px; line-height: 1.5; border: 1px solid var(--c, var(--line)); color: var(--c, var(--muted)); border-radius: 6px; padding: 0 6px; margin-right: 6px; white-space: nowrap; }
.tag.bad { --c: var(--danger); }
.spots { display: grid; gap: 8px; grid-template-columns: 1fr; margin-top: 10px; }
.spot { display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px 8px 8px; position: relative; }
.spot img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; flex: none; background: #0b0d14; }
.spot.person img { border-radius: 50%; width: 42px; height: 42px; }
.sp-t { flex: 1; min-width: 0; } .sp-t b { display: block; }
.spot.dim { opacity: .62; }
.spots.people { grid-template-columns: 1fr 1fr; }
.spots.people .spot { padding: 6px 8px 6px 6px; gap: 8px; min-width: 0; }
.spots.people .spot img { width: 36px; height: 36px; }
.spots.people b { font-size: 13.5px; line-height: 1.2; } .spots.people small { font-size: 11.5px; }
.mk { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #1b1608; font: 800 16px/26px var(--serif); text-align: center; font-style: normal; animation: want 1.4s ease-in-out infinite; }
.mk.q { background: #7fd6c8; }

/* ---------- Панели ---------- */
.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #1f2536; }
.row > div { flex: 1; min-width: 0; }
.row button { flex: none; min-height: 38px; padding: 6px 12px; }
.ava { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: #0b0d14; }
.ava.sq { border-radius: 9px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.box.gold { border-color: #6d5b2c; background: #1f1b12; }
.hero-head { display: flex; gap: 12px; align-items: flex-start; }
.hero-head img { width: 96px; height: 96px; border-radius: 14px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.hero-head > div { flex: 1; min-width: 0; font-size: 13px; }
.lvline { display: flex; justify-content: space-between; margin-top: 6px; font-size: 14px; } .lvline span { color: var(--muted); }
.attrs { display: grid; gap: 6px; }
.attr { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.attr > div { flex: 1; min-width: 0; }
.attr .val { font: 700 20px/1 var(--serif); color: var(--gold); min-width: 24px; text-align: center; }
.plus { min-height: 36px; width: 40px; padding: 0; font-size: 20px; font-weight: 700; background: #3a3018; border-color: #8a7232; color: #fff2cf; }
.stats, .spend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div, .spend div { background: var(--panel); border-radius: 9px; padding: 8px 4px; text-align: center; }
.stats b, .spend b { display: block; font: 700 17px/1.1 var(--serif); }
.spend b { color: var(--blood); }
.stats span, .spend span { font-size: 11px; color: var(--muted); line-height: 1.2; display: block; margin-top: 3px; }
.perk { padding: 7px 0; border-bottom: 1px solid #1f2536; }
.repline { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 0; font-size: 14px; }
.repline.dead { opacity: .5; } .repline small { grid-column: 1 / 3; }
.repbar { grid-column: 1 / 3; position: relative; height: 5px; border-radius: 3px; background: linear-gradient(90deg, #7a2f2f, #3a3f52 50%, #3f6b3a); }
.repbar i { position: absolute; top: -3px; width: 4px; height: 11px; background: var(--text); border-radius: 2px; transform: translateX(-2px); }
.quest { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.quest.tracked { border-color: var(--gold); }
.quest.done { border-left-color: var(--ok); opacity: .6; } .quest.failed { border-left-color: var(--danger); opacity: .6; }
.quest p { margin: 4px 0 0; color: #d6d0c0; }
.q-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-bottom: 2px; }
.mini { display: flex; gap: 6px; margin-top: 8px; } .mini button { min-height: 36px; padding: 5px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.ev { display: grid; grid-template-columns: 30px 1fr; gap: 2px 8px; padding: 7px 0; border-bottom: 1px solid #1f2536; font-size: 14px; }
.ev .d { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.ev .tag { grid-column: 2; justify-self: start; }
.ev.imp3 .t { color: var(--gold); font-weight: 600; } .ev.imp1 .t { color: #c4c0b4; }
.truth { max-height: 34vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: rgba(11, 13, 20, .6); }

/* ---------- Окна ---------- */
#modal { position: fixed; inset: 0; z-index: 20; }
.veil { position: absolute; inset: 0; background: rgba(4, 5, 9, .74); display: flex; align-items: flex-end; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; box-shadow: 0 -10px 50px rgba(0, 0, 0, .6); -webkit-overflow-scrolling: touch; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.card-in { padding: 14px var(--gr) calc(16px + var(--safe-b)) var(--gl); }
.card-art { height: min(26vh, 220px); background: #111 center / cover; border-radius: 16px 16px 0 0; }
.card-pic { display: block; width: 110px; height: 110px; object-fit: cover; border-radius: 14px; margin: 16px auto 0; }
.card.tip { border-color: #6d5b2c; }
.who { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.who b { font: 700 19px/1.2 var(--serif); display: block; }
.face { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.say { font-size: 15.5px; line-height: 1.5; }
.dialog .say, .story-text p { font-family: var(--serif); }
.note { display: inline-block; font-size: 12.5px; border-radius: 6px; padding: 2px 8px; margin-bottom: 4px; }
.note.ok { background: #213322; color: var(--ok); } .note.fail { background: #3a1f1d; color: #ffa99c; }
.timer { height: 5px; background: #232839; border-radius: 3px; overflow: hidden; margin: 8px 0 2px; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--danger), var(--gold)); }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; }
.choice span { flex: 1; min-width: 0; }
.choice em { flex: none; font-style: normal; font-size: 12px; color: var(--gold); border: 1px solid #6d5b2c; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
kbd { flex: none; font: 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; }

.story { position: absolute; inset: 0; background: #07080d center / cover; display: flex; align-items: flex-end; justify-content: center; }
.story-text { width: 100%; max-width: 720px; max-height: 78dvh; overflow-y: auto; padding: 60px var(--gr) calc(18px + var(--safe-b)) var(--gl); background: linear-gradient(180deg, transparent, rgba(7, 8, 13, .9) 70px, rgba(7, 8, 13, .96)); font-size: 16.5px; line-height: 1.55; }
.story-text h2 { font-size: 26px; }
.story.sq { background-size: contain; background-repeat: no-repeat; background-position: center 8%; }

/* ---------- Бой ---------- */
.combat { position: absolute; inset: 0; background: #07080d center / cover; }
.c-in { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(7, 8, 13, .55), rgba(7, 8, 13, .86) 46%, rgba(7, 8, 13, .97)); display: flex; flex-direction: column; padding: calc(8px + env(safe-area-inset-top, 0px)) var(--gr) calc(10px + var(--safe-b)) var(--gl); max-width: 760px; margin: 0 auto; overflow-y: auto; }
.foes { display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); flex: none; }
.foes.n1 { grid-template-columns: minmax(0, 190px); justify-content: center; }
.foes.n2 { grid-template-columns: repeat(2, minmax(0, 170px)); justify-content: center; }
.foe { padding: 5px; display: flex; flex-direction: column; gap: 4px; min-height: 0; background: rgba(20, 24, 36, .9); border-width: 2px; text-align: center; position: relative; }
.foe .meter { flex: none; }
.foe.target { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233, 196, 106, .25); }
.foe.down { opacity: .35; } .foe.hidden .f-art { opacity: .35; filter: blur(1.5px); }
.foe.hit { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.f-art { display: block; position: relative; width: 100%; aspect-ratio: 1.15; border-radius: 8px; background: #111 center 22% / cover; }
.dmg { position: absolute; top: 26%; left: 0; right: 0; text-align: center; font: 800 24px/1 var(--serif); color: #ffd3c8; text-shadow: 0 2px 6px #000, 0 0 2px #000; animation: float .9s ease-out forwards; pointer-events: none; }
@keyframes float { to { transform: translateY(-26px); opacity: 0; } }
.blk { position: absolute; right: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; background: rgba(13, 16, 24, .85); color: #9cc7f5; border-radius: 6px; padding: 1px 5px; font-size: 12px; }
.blk .ic { width: 12px; height: 12px; }
.f-name { font-size: 12.5px; font-weight: 600; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; justify-content: center; }
.f-st { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.f-st i { font-style: normal; font-size: 10.5px; background: #2a2f44; border-radius: 5px; padding: 0 5px; color: #cfd3e6; } .f-st i.bad { background: #3b2a16; color: #f0c27a; }
.intent { font-size: 12px; line-height: 1.2; border-radius: 6px; padding: 3px 4px; background: #232839; }
.intent.atk { background: #43202a; color: #ffc1c7; } .intent.big { background: #6b1f2a; color: #fff; font-weight: 700; }
.intent.warn { background: #4a3a14; color: #ffe2a0; } .intent.def { background: #1f3350; color: #bcd9ff; } .intent.buff { background: #3a2456; color: #dcc6ff; }
.cnote.tut { border: 1px solid #8a7232; background: rgba(42, 36, 19, .92); color: #fff2cf; border-radius: 10px; padding: 7px 10px; margin: 6px 0 2px; font-size: 13.5px; }
.cnote { min-height: 34px; font-size: 12.5px; color: #d6d0c0; padding: 6px 2px 2px; line-height: 1.3; flex: none; }
.clog { flex: 1 1 60px; min-height: 60px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; color: #c9c5b8; padding: 2px; }
.clog .sep { color: var(--muted); font-size: 11px; margin-top: 3px; }
.me { flex: none; position: relative; display: flex; align-items: center; gap: 10px; background: rgba(20, 24, 36, .92); border: 1px solid var(--line); border-radius: 12px; padding: 7px 9px; margin: 6px 0; }
.me.hit { animation: shake .3s; border-color: var(--danger); }
.me > img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; }
.me-bars { flex: 1; min-width: 0; display: grid; gap: 5px; }
.me-row { display: flex; align-items: center; gap: 12px; }
.ap { display: inline-flex; gap: 4px; } .ap i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #8a7232; } .ap i.on { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 6px rgba(233, 196, 106, .6); }
.blkme { color: #9cc7f5; display: inline-flex; align-items: center; gap: 3px; font-weight: 700; } .blkme .ic { width: 15px; height: 15px; }
.me .dmg { top: -6px; left: auto; right: 14px; color: #ff9c8f; }
.ally { flex: none; display: flex; align-items: center; gap: 6px; font-size: 11.5px; max-width: 34%; } .ally img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; } .ally span { min-width: 0; overflow: hidden; } .ally.down { opacity: .4; }
.acts { flex: none; display: grid; gap: 7px; }
.grid { display: grid; gap: 7px; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); } .grid.two { grid-template-columns: 2fr 1fr; } .grid.g2 { grid-template-columns: 1fr 1fr; } .grid.g3 { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }
.act { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 8px; min-height: 52px; text-align: center; line-height: 1.2; }
.act b { display: block; font-size: 14.5px; } .act small { font-size: 11.5px; }
.act img { width: 38px; height: 38px; border-radius: 8px; flex: none; }
.act.long { justify-content: flex-start; text-align: left; } .act.long .n { color: #b8b3a4; margin-top: 2px; }
.act.rune { border-color: #7a3e55; } .act.end { background: #1d2c44; border-color: #3d5f92; } .act.flee { color: var(--muted); }
.act.ok { background: #1e3320; border-color: #4f8a4a; } .act.danger { background: #3a1c1a; }
.act.wide { width: 100%; } .act.back { justify-content: center; color: var(--muted); min-height: 44px; }
.sub { display: grid; gap: 7px; }
.cresult { background: rgba(20, 24, 36, .92); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.cresult.won h3 { color: var(--ok); } .cresult.lost h3 { color: var(--danger); } .cresult h3 { margin: 0 0 4px; font-size: 14px; }

/* ---------- Уровень ---------- */
.lvbadge { display: flex; align-items: center; gap: 10px; font: 700 26px/1 var(--serif); color: var(--gold); } .lvbadge .ic { width: 28px; height: 28px; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .pick.one { grid-template-columns: 1fr; }
.pick button { text-align: left; padding: 9px 11px; } .pick b { display: block; }

/* ---------- Заставка и создание ---------- */
.title { position: absolute; inset: 0; background: #07080d 16% center / cover; display: flex; align-items: flex-end; justify-content: center; }
.title-box { width: 100%; max-width: 520px; padding: 90px var(--gr) calc(26px + var(--safe-b)) var(--gl); background: linear-gradient(180deg, transparent, rgba(7, 8, 13, .88) 90px, rgba(7, 8, 13, .96)); display: grid; gap: 10px; text-align: center; }
.title-box h1 { font-size: 42px; letter-spacing: .02em; color: #fff2cf; text-shadow: 0 2px 18px rgba(233, 196, 106, .45); }
.title-box .sub { font-family: var(--serif); font-size: 17px; color: #d6d0c0; margin-bottom: 8px; }
.create { position: absolute; inset: 0; overflow-y: auto; background: radial-gradient(ellipse at 50% 0, #1a1f30, var(--bg) 70%); }
.create-in { max-width: 560px; margin: 0 auto; padding: calc(22px + env(safe-area-inset-top, 0px)) var(--gr) calc(24px + var(--safe-b)) var(--gl); }
.faces { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.facepick { padding: 6px; display: grid; gap: 6px; border-width: 2px; } .facepick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.facepick.on, .bent.on { border-color: var(--gold); background: #2a2413; color: var(--text); }
.bents { display: grid; gap: 8px; } .bent { text-align: left; padding: 10px 12px; border-width: 2px; } .bent b { font: 700 17px/1.2 var(--serif); } .bent .n { color: var(--gold); margin-top: 3px; }

/* ---------- Всплывающие строки ---------- */
#toasts { position: fixed; top: calc(74px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 var(--gr) 0 var(--gl); }
.toast { background: rgba(13, 16, 24, .92); border: 1px solid #6d5b2c; color: #fff2cf; border-radius: 999px; padding: 5px 14px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); animation: toast 3.2s ease forwards; max-width: 100%; text-align: center; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }

/* ---------- Широкий экран ---------- */
@media (min-width: 900px) {
  #main { gap: 14px; padding: 12px var(--gr) 12px var(--gl); }
  #panel, #app.tab-open #panel { position: static; display: block; flex: none; width: 400px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
  #scene { border: 1px solid var(--line); border-radius: 14px; background: #0d1018; }
  #nav { border: 1px solid var(--line); border-radius: 14px; margin: 0 var(--gr) 12px var(--gl); padding: 0; overflow: hidden; }
  #nav button { flex-direction: row; justify-content: center; gap: 8px; font-size: 14px; min-height: 46px; }
  #nav button:first-child { display: none; } #nav { grid-template-columns: repeat(4, 1fr); }
  #nav em { position: static; }
  .veil { align-items: center; padding: 20px; }
  .card { border-radius: 16px; max-height: calc(100dvh - 40px); }
  .card-art { border-radius: 16px 16px 0 0; }
  .spots { grid-template-columns: 1fr 1fr; }
  .face { width: 120px; height: 120px; }
  .foes.n1 { grid-template-columns: minmax(0, 240px); } .foes.n2 { grid-template-columns: repeat(2, minmax(0, 220px)); }
  .story-text { font-size: 18px; }
  .title-box h1 { font-size: 56px; }
}
@media (max-height: 700px) {
  .foes.n1 { grid-template-columns: minmax(0, 150px); } .foes.n2 { grid-template-columns: repeat(2, minmax(0, 140px)); }
  .f-art { aspect-ratio: 1.45; } .act { min-height: 46px; } .cnote { min-height: 0; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .bar { padding-top: 3px; padding-bottom: 3px; }
  #nav button { min-height: 42px; flex-direction: row; justify-content: center; gap: 6px; }
  .loc-art { height: 38vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; transition-duration: .01s !important; } }
