@font-face { font-family: "Playfair Display"; src: url(fonts/playfair-display-latin-wght-normal.woff2) format("woff2"); font-weight: 400 900; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Playfair Display"; src: url(fonts/playfair-display-cyrillic-wght-normal.woff2) format("woff2"); font-weight: 400 900; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: italic; src: url(fonts/playfair-display-latin-wght-italic.woff2) format("woff2"); font-weight: 400 900; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Playfair Display"; font-style: italic; src: url(fonts/playfair-display-cyrillic-wght-italic.woff2) format("woff2"); font-weight: 400 900; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Inter; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2"); font-weight: 100 900; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: Inter; src: url(fonts/inter-cyrillic-wght-normal.woff2) format("woff2"); font-weight: 100 900; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

:root {
  --ink: #18181b; --muted: #6f6c66; --paper: rgba(255, 255, 255, 0.92); --line: rgba(20, 20, 24, 0.08);
  --red: #e0475a; --shadow: 0 6px 24px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08);
  --serif: "Playfair Display", Georgia, serif; --sans: Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1e22; font-family: var(--sans); color: var(--ink); overscroll-behavior: none; }
#app canvas { display: block; touch-action: none; cursor: grab; }
#app canvas:active { cursor: grabbing; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; background: #fff; border: 1px solid #d9d6cf; border-bottom-width: 2px; font: 600 11px var(--sans); color: var(--ink); }

.pill { background: var(--paper); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 999px; box-shadow: var(--shadow); }
.card { background: var(--paper); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 16px; box-shadow: var(--shadow); }

/* интерфейс прячется, пока идёт загрузка */
#hud, #help, #bar, #prompt, #joy { opacity: 0; transition: opacity .6s; pointer-events: none; }
body.ready #hud, body.ready #help, body.ready #bar, body.ready #joy { opacity: 1; pointer-events: auto; }
body.viewing #bar, body.viewing #help, body.viewing #joy, body.viewing #hud { opacity: 0; pointer-events: none; }

#hud { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 16px; }
#hud { display: flex; gap: 8px; align-items: flex-start; }
#snd { width: 40px; height: 40px; display: grid; place-items: center; font-size: 17px; flex: none; }
#snd.off { opacity: .55; text-decoration: line-through; }
#toast { position: fixed; left: 16px; top: calc(max(14px, env(safe-area-inset-top)) + 54px); padding: 7px 14px; font: italic 500 13px var(--serif); opacity: 0; transform: translateY(-4px); transition: opacity .5s, transform .5s; pointer-events: none; }
#toast.on { opacity: 1; transform: none; }
#hud .pill:first-child { display: flex; align-items: baseline; gap: 10px; padding: 9px 16px; }
#hud b { font: 600 17px var(--serif); }
#hud span { font-size: 12px; color: var(--muted); }

#help { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px; padding: 12px 14px; display: grid; gap: 8px; font-size: 12.5px; color: #3c3a36; transition: opacity .8s, transform .8s; }
#help .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#help .row span { margin-right: 6px; }
#help.off { opacity: 0 !important; transform: translateY(-8px); pointer-events: none !important; }
.only-touch { display: none !important; }
body.touch .only-touch { display: flex !important; }
body.touch #help .row:not(.only-touch) { display: none; }

#prompt { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 8px); display: flex; align-items: center; gap: 10px; padding: 9px 18px 9px 10px; font-size: 14px; font-weight: 500; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; transition: opacity .25s, transform .25s; }
#prompt.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

#bar { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: var(--paper); box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#bar button { position: relative; width: 50px; height: 50px; border-radius: 999px; background: transparent; font-size: 22px; transition: background .2s, transform .15s; }
#bar button:hover { background: rgba(0, 0, 0, 0.06); }
#bar button:active { transform: scale(0.92); }
#bar small { position: absolute; right: 4px; bottom: 3px; font: 600 9px var(--sans); color: var(--muted); }
body.touch #bar small { display: none; }
body.touch #bar { left: auto; right: 16px; transform: none; flex-direction: column; bottom: max(24px, env(safe-area-inset-bottom)); }

#chat { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity .2s; }
#chat.on { opacity: 1; pointer-events: auto; }
#chat input { width: min(420px, calc(100vw - 32px)); padding: 13px 18px; border-radius: 999px; border: 0; outline: 0; font: 15px var(--sans); background: #fff; box-shadow: var(--shadow); }

#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; will-change: transform; }
.tag .name { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px; background: rgba(28, 28, 32, 0.78); color: #fff; font: 600 11px var(--sans); white-space: nowrap; }
.tag .name i { width: 7px; height: 7px; border-radius: 50%; }
.tag .bubble { position: absolute; left: 0; bottom: 26px; transform: translate(-50%, 6px) scale(.9); transform-origin: 50% 100%; max-width: 230px; width: max-content; padding: 8px 13px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); font-size: 13px; line-height: 1.35; opacity: 0; transition: opacity .25s, transform .25s; }
.tag .bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.tag.talk .bubble { opacity: 1; transform: translate(-50%, 0) scale(1); }

#joy { position: fixed; left: 26px; bottom: max(30px, env(safe-area-inset-bottom)); width: 124px; height: 124px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); border: 1.5px solid rgba(255, 255, 255, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: none; touch-action: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .06s; }
body.touch #joy { display: block; }
body.touch #prompt { bottom: 170px; padding: 12px 20px 12px 12px; font-size: 15px; }
body.touch #prompt kbd { display: none; }

#viewer { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s; }
#viewer.on { opacity: 1; }
#viewer.on > * { pointer-events: auto; }
#viewer .round { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); font-size: 18px; display: grid; place-items: center; }
#v-close { top: max(16px, env(safe-area-inset-top)); right: 16px; }
#viewer .side { top: 50%; margin-top: -23px; font-size: 28px; line-height: 1; padding-bottom: 4px; }
#v-prev { left: 16px; } #v-next { right: 16px; }
#viewer .cap { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); padding: 16px 22px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: center; }
#viewer h2 { margin: 0; font: 600 22px var(--serif); }
#viewer time { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#viewer time:empty { display: none; }
#viewer p { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: #3c3a36; }
#viewer p:empty { display: none; }

#loader { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(120% 90% at 50% 40%, #4b5068 0%, #34384b 45%, #22242f 100%); color: #f3f1ec; transition: opacity 1.1s ease, visibility 1.1s; z-index: 10; }
#loader.off { opacity: 0; visibility: hidden; }
.ld { width: min(340px, calc(100vw - 48px)); text-align: center; }
.ld h1 { margin: 0; font: 500 clamp(44px, 9vw, 64px)/1 var(--serif); letter-spacing: -0.02em; transform: scaleX(.88); }
.ld .ft { margin-top: 18px; font-size: 13px; color: rgba(243, 241, 236, 0.7); display: flex; justify-content: center; align-items: center; gap: 8px; }
.ld em { font: italic 600 16px var(--serif); color: #fff; }
.ld .sep { width: 1px; height: 14px; background: rgba(255, 255, 255, 0.35); margin: 0 6px; }
.ld .bar { margin-top: 30px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
#ld-fill { height: 100%; width: 0; background: linear-gradient(90deg, #9fd8d0, #e8f6f3); border-radius: 3px; box-shadow: 0 0 12px rgba(160, 230, 220, 0.6); }
#ld-go { margin-top: 30px; padding: 13px 38px; border-radius: 999px; background: #f3f1ec; color: #22242f; font: 600 15px var(--sans); letter-spacing: .02em; opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .6s, transform .6s, background .2s; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
#ld-go:hover { background: #fff; }
#loader.done #ld-go { opacity: 1; transform: none; pointer-events: auto; }
#loader.done .bar, #loader.done .st { opacity: .0; transition: opacity .5s; }
.ld .st { margin-top: 10px; display: flex; justify-content: space-between; font-size: 11px; color: rgba(243, 241, 236, 0.6); letter-spacing: .02em; }

/* на телефоне без размытия под панелями: оно пересчитывается каждый кадр поверх 3D */
body.touch .pill, body.touch .card, body.touch #bar, body.touch #joy, body.touch #viewer .cap, body.touch #viewer .round { backdrop-filter: none; -webkit-backdrop-filter: none; }
body.touch { --paper: rgba(255, 255, 255, 0.96); }
body.touch #joy { background: rgba(255, 255, 255, 0.28); }

@media (max-width: 640px) {
  #hud .pill:first-child { flex-direction: column; gap: 0; padding: 8px 14px; border-radius: 14px; }
  #help { left: 16px; right: 16px; top: calc(max(14px, env(safe-area-inset-top)) + 64px); }
}
