@font-face { font-family: 'Izba'; src: url('../media/ui/izbushka.ttf') format('truetype'); font-display: swap; }
:root {
  --bg: #120d1f; --ink: #f3e9d2; --muted: #b9aecb; --gold: #e6b65c; --gold-2: #f7d98b; --gold-d: #8a5a17;
  --panel: rgba(28, 19, 46, .86); --line: rgba(230, 182, 92, .35);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { color: var(--ink); font: 16px/1.5 Georgia, 'Times New Roman', serif; -webkit-user-select: none; user-select: none; }
#app { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 0%, rgba(120, 70, 170, .35), transparent 60%), url('../media/ui/menu-bg.webp') center / cover no-repeat, var(--bg); }
#app::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(18, 13, 31, .35), rgba(18, 13, 31, .85)); pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: calc(10px + var(--safe-t)) 14px calc(12px + var(--safe-b) + var(--ad-b, 0px)); }
.screen.show { display: flex; }
.center { margin: auto; text-align: center; }
button { font: inherit; cursor: pointer; color: inherit; }
h1, h2, .title, .gold, .ghost, .think-title { font-family: 'Izba', Georgia, serif; letter-spacing: .5px; }

/* кнопки */
.gold {
  border: 0; border-radius: 14px; padding: .7em 1.2em; min-height: 48px; color: #3a2207; font-size: 19px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, #c98e33);
  box-shadow: 0 0 0 2px #6b4410, 0 6px 18px rgba(230, 182, 92, .25), inset 0 2px 0 rgba(255, 255, 255, .5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
}
.gold.big { font-size: clamp(20px, 2.4vmin + 12px, 26px); width: 100%; }
.gold:disabled { filter: grayscale(.7) brightness(.7); cursor: default; }
.gold:active:not(:disabled) { transform: translateY(1px); }
.ghost { border: 1px solid var(--line); background: rgba(255, 255, 255, .04); border-radius: 12px; padding: .6em .9em; min-height: 44px; font-size: 17px; color: var(--gold-2); }
.ghost:active { background: rgba(230, 182, 92, .12); }
.link { border: 0; background: none; color: var(--gold); text-decoration: underline; padding: 0 .2em; }
.icon { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: var(--gold-2); font-size: 20px; flex: none; }
@media (hover: hover) { .gold:hover:not(:disabled) { filter: brightness(1.08); } .ghost:hover { background: rgba(230, 182, 92, .1); } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.bar { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.bar h2 { margin: 0; font-size: clamp(20px, 2.4vmin + 12px, 28px); color: var(--gold-2); text-align: center; font-weight: normal; }
.bar > span { width: 42px; }
.spinner { width: 46px; height: 46px; margin: 0 auto 10px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* меню */
.menu { position: relative; z-index: 1; margin: auto; width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: stretch; gap: 12px; overflow-y: auto; max-height: 100%; padding: 4px; scrollbar-width: none; }
.menu::-webkit-scrollbar { display: none; }   /* полосу прокрутки не показываем вообще */
.menu > * { flex: none; }
/* гадалка сжимается по высоте, чтобы меню влезало в окно без прокрутки */
.menu .seer { flex: 0 1 auto; min-height: 70px; object-fit: contain; }
/* ПК (фрейм vk.com невысокий): «наши приложения» в один ряд, промежутки поменьше */
@media (min-width: 600px) and (max-height: 820px) {
  .menu { gap: 10px; }
  .menu .gold.big { padding: .45em 1em; }
  .menu .xapps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 0; }
  .menu .xapps .hint { grid-column: 1 / -1; }
  .menu .xapps .xapp { font-size: 14px; padding: .4em .6em; gap: 8px; }
}
.title { margin: 0; text-align: center; font-size: clamp(44px, 9vmin + 10px, 72px); line-height: .95; color: var(--gold-2); text-shadow: 0 0 22px rgba(230, 182, 92, .45), 0 3px 0 #3a2207; font-weight: normal; }
.title span { display: block; font-size: .36em; color: var(--ink); margin-top: 6px; letter-spacing: 2px; }
.seer { width: min(70%, 300px); align-self: center; filter: drop-shadow(0 0 20px rgba(230, 182, 92, .3)); }
.balance-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, .25); }
.balance b { color: var(--gold-2); font-size: 1.25em; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* вопрос */
.ask { position: relative; z-index: 1; width: 100%; max-width: 560px; margin: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.hint { margin: 0; color: var(--muted); }
textarea { width: 100%; resize: none; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); color: var(--ink); font: 18px/1.4 Georgia, serif; padding: 12px; -webkit-user-select: text; user-select: text; }
textarea:focus { outline: 2px solid var(--gold); }
.counter { align-self: flex-end; margin-top: -8px; font-size: 13px; color: var(--muted); }
.deck-line { color: var(--muted); } .deck-line b { color: var(--gold-2); font-weight: normal; }

/* расклад: 5 карт */
.s-question { position: relative; z-index: 1; margin: 0 0 8px; text-align: center; color: var(--muted); font-style: italic; min-height: 1.5em; }
.spread { position: relative; z-index: 1; flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(6px, 1.5vw, 18px); align-items: center; justify-items: center; max-width: 980px; width: 100%; margin: 0 auto; }
.tcard { --w: min(100%, 170px); width: var(--w); aspect-ratio: 348 / 500; perspective: 900px; border: 0; background: none; padding: 0; position: relative; }
.tcard .in { position: absolute; inset: 0; transition: transform .6s cubic-bezier(.3, .8, .3, 1); transform-style: preserve-3d; }
.tcard.open .in { transform: rotateY(180deg); }
.tcard .face, .tcard .back { position: absolute; inset: 0; border-radius: 8px; backface-visibility: hidden; background-size: cover; background-position: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .55); }
.tcard .back { background-image: url('../media/ui/card-back.webp'); }
.tcard .face { transform: rotateY(180deg); }
.tcard.deal { animation: deal .5s backwards; }
@keyframes deal { from { transform: translateY(-40vh) rotate(-20deg); opacity: 0; } }
.tcard .pos, .tcard .name { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: clamp(11px, 1.2vmin + 6px, 14px); text-align: center; }
.tcard .pos { top: -1.6em; color: var(--muted); }
.tcard .name { bottom: -1.7em; color: var(--gold-2); opacity: 0; transition: opacity .4s .3s; max-width: 140%; overflow: hidden; text-overflow: ellipsis; }
.tcard.open .name { opacity: 1; }
.s-hint { position: relative; z-index: 1; text-align: center; color: var(--muted); margin: 1.8em 0 8px; min-height: 1.5em; }
.s-actions { position: relative; z-index: 1; display: flex; gap: 10px; width: 100%; max-width: 560px; margin: 0 auto; }
.s-actions .gold { flex: 1; }
@media (max-aspect-ratio: 1/1) {   /* телефон вертикально: 3 + 2 */
  .spread { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 3.2em; align-content: center; }
  .tcard { grid-column: span 2; --w: min(100%, 150px); }
  .tcard:nth-child(4) { grid-column: 2 / span 2; }
}

/* толкование: читаемый текст с прокруткой, без уменьшения шрифта */
.reading { position: relative; z-index: 1; flex: 1; min-height: 0; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.r-cards { display: flex; gap: 6px; justify-content: center; flex: none; }
.r-cards button { width: clamp(44px, 9vmin, 76px); aspect-ratio: 348 / 500; border: 0; border-radius: 6px; background-size: cover; background-position: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .5); padding: 0; }
.r-question { margin: 0; text-align: center; color: var(--muted); font-style: italic; flex: none; }
.r-text { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 10px 4px 4px; font-size: clamp(16px, 1.1vmin + 13px, 19px); line-height: 1.6; -webkit-user-select: text; user-select: text; }
.r-text p { margin: 0 0 .9em; }
.r-text p:first-child::first-letter { font-family: 'Izba', Georgia, serif; font-size: 2.6em; float: left; line-height: .9; margin: .05em .1em 0 0; color: var(--gold-2); }
.r-text::-webkit-scrollbar { width: 6px; } .r-text::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.r-actions { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; width: 100%; max-width: 760px; margin: 10px auto 0; }

/* ожидание */
.overlay { position: absolute; inset: 0; z-index: 30; display: none; background: rgba(10, 6, 20, .88); }
.overlay.show { display: flex; }
.shuffle { width: min(46vmin, 220px); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
.think-title { font-size: clamp(20px, 2.4vmin + 12px, 28px); color: var(--gold-2); margin: 10px 0 4px; }
.think-line { color: var(--muted); font-style: italic; min-height: 3em; max-width: 520px; padding: 0 14px; }

/* модалки */
.modal { position: absolute; inset: 0; z-index: 40; background: rgba(5, 3, 12, .7); display: none; align-items: center; justify-content: center; padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b) + var(--ad-b, 0px)); }
.modal.show { display: flex; }
.modal-box { position: relative; width: 100%; max-width: 640px; max-height: 100%; padding: 18px 16px 16px; display: flex; flex-direction: column; }
.modal-box .close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; font-size: 16px; }
#modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-right: 4px; }
#modal-body h3 { margin: 0 40px 10px 0; font-family: 'Izba', Georgia, serif; font-weight: normal; color: var(--gold-2); font-size: 24px; }
#modal-body p { margin: 0 0 .8em; }
.shop { display: grid; gap: 10px; margin-top: 8px; }
.pack { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, .25); text-align: left; }
.pack b { font-family: 'Izba', Georgia, serif; font-weight: normal; font-size: 22px; color: var(--gold-2); }
.pack small { color: var(--muted); grid-column: 1; }
.pack .price { grid-row: 1 / span 2; grid-column: 2; }
.pack.best { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--gold); color: #3a2207; font-size: 12px; vertical-align: middle; }
.decks { display: grid; gap: 12px; }
.deck { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, .25); }
.deck img { width: 110px; }
.deck b { font-family: 'Izba', Georgia, serif; font-weight: normal; font-size: 22px; color: var(--gold-2); display: block; }
.deck.active { border-color: var(--gold); }
.hist { display: grid; gap: 8px; }
.hist button { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .25); }
.hist small { color: var(--muted); display: block; }
.card-full { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.card-full img { width: 120px; border-radius: 8px; }
@media (max-width: 420px) { .card-full { grid-template-columns: 1fr; } .card-full img { width: 140px; justify-self: center; } }
.toast { position: absolute; left: 50%; bottom: calc(24px + var(--safe-b) + var(--ad-b, 0px)); transform: translateX(-50%); z-index: 50; background: rgba(20, 12, 34, .95); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; display: none; max-width: 90%; text-align: center; }
.toast.show { display: block; }
.xapps { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.xapps .hint { text-align: center; font-size: 14px; }
.xapp { width: 100%; font-size: 15px; background: linear-gradient(135deg, rgba(120,70,170,.35), rgba(230,182,92,.12)); display: flex; flex-direction: column; align-items: center; }
.xapp small { font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.xapp { flex-direction: row; justify-content: center; gap: 10px; }
.xapp .xi { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }

/* веб-версия сайта */
.balance-row,#m-shop,#r-share,#r-story,.xapps,#s-read,#m-history{display:none!important}
.r-actions{grid-template-columns:1fr 1fr!important}
