:root {
  --bg: #120c22;
  --panel: rgba(30, 21, 54, .94);
  --line: #3d3063;
  --text: #ece6f5;
  --muted: #bcb2d4;
  --gold: #e9cf93;
  --gold-strong: #f3dca6;
  --button-text: #23183b;
  --bottom: max(14px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { margin: 0 0 10px; font: normal 1.35rem/1.25 Georgia, "Times New Roman", serif; color: var(--gold); }

#stage { position: fixed; inset: 0; }
#table { display: block; width: 100%; height: 100%; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

.bar {
  position: absolute; top: 0; left: 0; right: 0; padding: 12px 16px; pointer-events: none;
  background: linear-gradient(var(--bg), transparent);
}
.in-telegram .bar, .embedded .bar { display: none; }
/* outside Telegram, which has its own: the way back, and the name leading to the site */
.bar { display: flex; align-items: center; justify-content: space-between; }
.bar a, .bar button { pointer-events: auto; }
.bar-back {
  font: 0.95rem system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: rgba(18, 12, 34, 0.6);
  border: 1px solid rgba(233, 207, 147, 0.45); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.logo { font: 1.15rem Georgia, "Times New Roman", serif; color: var(--text); text-decoration: none; }
.logo b { font-weight: normal; color: var(--gold); }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px var(--bottom);
  border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; background: var(--panel);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .45); backdrop-filter: blur(6px);
  animation: rise .35s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* the tabs: free things first, then the spreads by topic; the list under them scrolls inside the panel, which keeps
   one height on every tab, so it does not jump when the tab changes */
.topics { display: flex; gap: 6px; margin: 0 -16px 12px; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
.topics::-webkit-scrollbar { display: none; }
.topic {
  flex: none; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(18, 12, 34, .7);
  color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer;
}
.topic.is-current { border-color: var(--gold); background: var(--gold); color: var(--button-text); font-weight: 600; }
.spreads {
  display: grid; grid-template-columns: 1fr; align-content: start; gap: 8px; height: min(42vh, 300px); overflow-y: auto;
  overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px 2px;
}
/* a row: the picture, the name with its price on the right, what it is for below */
.spread {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px;
  align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(18, 12, 34, .7);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .2s, transform .2s;
}
.spread:active { transform: scale(.97); border-color: var(--gold); }
.spread.is-used { opacity: .55; }
.spread-icon { grid-row: 1 / 3; display: flex; flex-wrap: wrap; gap: 2px; width: 40px; align-content: center; justify-content: center; }
/* a spread laid out on a grid of half-cards: the same picture as its cards on the table */
.spread-icon .mini { display: grid; grid-template-columns: repeat(var(--cols), calc(var(--w) / 2)); grid-template-rows: repeat(var(--rows), calc(var(--w) * 7 / 8)); gap: 1px; }
.spread-icon .mini i { width: auto; height: auto; }
.spread-icon i { display: block; width: 8px; height: 13px; border-radius: 2px; background: var(--gold); opacity: .85; }
.spread-celtic .spread-icon i { width: 5px; height: 8px; }
/* the destiny matrix: its icon nine dots of the octagram */
.spread-matrix .spread-icon { display: grid; grid-template-columns: repeat(3, 6px); gap: 3px; }
.spread-matrix .spread-icon i { width: 6px; height: 6px; border-radius: 50%; }
/* an angel number: beside the matrix, its icon three gold digits */
.spread-dream .spread-icon { font: 1.25rem/1 Georgia, "Times New Roman", serif; color: var(--gold); }
.spread-angel .spread-icon { width: 30px; font: 600 .82rem/1 Georgia, "Times New Roman", serif; color: var(--gold); letter-spacing: .02em; }
.spread-name { grid-column: 2; grid-row: 1; font: 1rem Georgia, "Times New Roman", serif; color: var(--gold); line-height: 1.2; }
.spread-text { grid-column: 2 / 4; grid-row: 2; font-size: .8rem; color: var(--muted); line-height: 1.3; }
/* what it costs, as a badge: green — free, blue — free with a paid full reading, pink — a gift, gold — stars */
.spread-cost {
  grid-column: 3; grid-row: 1; justify-self: end; max-width: 10em; padding: 2px 8px; border-radius: 10px;
  font-size: .72rem; font-weight: 600; text-align: right;
  line-height: 1.35; color: var(--gold-strong); background: rgba(233, 207, 147, .14);
}
.spread-cost.cost-free { color: #9be3b4; background: rgba(76, 175, 110, .18); }
.spread-cost.cost-part { color: #a9cdf5; background: rgba(79, 127, 214, .2); }
.spread-cost.cost-gift { color: #f5b6d2; background: rgba(214, 79, 140, .18); }
.spread-cost.cost-used { color: var(--muted); background: rgba(188, 178, 212, .12); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
textarea {
  display: block; width: 100%; margin: 6px 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(18, 12, 34, .85); color: var(--text); font: inherit; resize: none;
}
textarea:focus { outline: none; border-color: var(--gold); }
.date-fields { display: flex; gap: 8px; margin: 6px 0 12px; }
.date-fields select, .date-fields input {
  flex: 1; min-width: 0; padding: 12px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(18, 12, 34, .85); color: var(--text); font: inherit;
}
.date-fields input { flex: 0 0 5.2em; }
/* the personal matrix and a couple's compatibility: one screen, two tabs */
.tabs { display: flex; gap: 4px; width: fit-content; margin: 0 0 12px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.tabs button { padding: 7px 14px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--gold); color: var(--button-text); font-weight: 600; }
.field-label { margin: 2px 0 -2px; font-size: .85rem; color: var(--muted); }
.number-field {
  display: block; width: 100%; margin: 6px 0 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(18, 12, 34, .85); color: var(--gold-strong); font: 2rem/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: .12em; text-align: center;
}
.number-field:focus { outline: none; border-color: var(--gold); }
.number-field::placeholder { color: var(--muted); font-size: 1.05rem; letter-spacing: 0; }
.lead-line { color: var(--gold-strong); font: 1.05rem/1.4 Georgia, "Times New Roman", serif; }
.card-line { color: var(--gold-strong); font-size: .92rem; }
.offer { margin: 10px 0 4px; }
.date-fields select:focus, .date-fields input:focus { outline: none; border-color: var(--gold); }
.error { margin: 0 0 10px; color: #f0a0a0; }
.matrix-list { font-size: .85rem; padding-left: 16px; }
.matrix-list li { margin-bottom: 4px; }
.row { display: flex; gap: 10px; }
.row .button { flex: 1; }
.button {
  padding: 13px 18px; border: 0; border-radius: 999px; background: var(--gold); color: var(--button-text);
  font: 600 1rem system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer;
}
.button:active { background: var(--gold-strong); }
.button.ghost { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.link { padding: 0; border: 0; background: none; color: var(--gold); font: inherit; text-decoration: underline; cursor: pointer; }

.hint {
  position: absolute; left: 12px; right: 12px; bottom: var(--bottom); padding: 12px 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); text-align: center; color: var(--text);
  display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; align-items: center; animation: rise .3s ease-out;
}

.reading { max-height: 82%; display: flex; flex-direction: column; padding-top: 6px; transition: max-height .35s ease; }
.reading.is-peek { max-height: 22%; } /* the table above it is framed for this: INSET.peek in app.js */
#matrix.reading:not(.is-peek) { max-height: 46%; } /* the octagram stays in sight: INSET.matrix */
#angelinfo.reading:not(.is-peek) { max-height: 50%; } /* the number's card and digits stay in sight: INSET.angel */
.handle {
  align-self: center; margin: 0 0 8px; padding: 14px 18px 6px; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .85rem; cursor: pointer; position: relative;
}
.handle::before {
  content: ""; position: absolute; top: 4px; left: 50%; width: 44px; height: 4px; margin-left: -22px;
  border-radius: 2px; background: var(--line);
}
.reading-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.cards { margin: 8px 0 12px; padding-left: 18px; color: var(--gold-strong); font-size: .92rem; }
.text p { margin: 0 0 12px; }

/* The cards of a spread on the site (taro3d.ru), as its destiny matrix page shows the arcana */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.tile {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 10px;
  background: rgba(43, 30, 80, .55); color: var(--text); text-decoration: none; line-height: 1.35; font-size: .9rem;
}
a.tile:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.tile img { flex: none; width: 56px; height: auto; aspect-ratio: 4 / 7; border-radius: 4px; object-fit: cover; }
.tile img.is-reversed { transform: rotate(180deg); }
.tile-words { display: flex; flex-direction: column; gap: 3px; }
.tile-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.tile-plus { color: #9fd8b7; }
.tile-minus { color: #e7a9a9; }
.tile-text { color: var(--muted); font-size: .86rem; }
.tile-more { color: var(--gold); font-size: .85rem; }
.writing { color: var(--muted); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }

.toast {
  position: absolute; top: 54px; left: 16px; right: 16px; padding: 12px 16px; border-radius: 12px;
  background: #3a2a63; border: 1px solid var(--gold); color: var(--text); text-align: center; animation: rise .3s ease-out;
}
/* What a position of a spread is about, over its number on the table */
.tip {
  position: fixed; z-index: 5; max-width: 290px; padding: 9px 12px; border-radius: 10px; pointer-events: none;
  background: #2b1e50; border: 1px solid var(--gold); color: var(--text); font-size: .86rem; line-height: 1.38;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.tip b { display: block; margin-bottom: 2px; color: var(--gold); font-weight: 600; }
.demo { margin: 12px 0 0; font-size: .85rem; color: var(--muted); text-align: center; }

.failure, .loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; background: var(--bg); text-align: center;
}
.loading { gap: 22px; color: var(--muted); }
.loading-card {
  width: 70px; height: 120px; border-radius: 8px; border: 1.5px solid var(--gold);
  background: radial-gradient(circle, var(--gold) 0 3px, transparent 4px), repeating-linear-gradient(45deg, rgba(233, 207, 147, .14) 0 2px, transparent 2px 9px), #2b1e50;
  animation: turn 1.8s ease-in-out infinite;
}
@keyframes turn { 50% { transform: rotateY(180deg); } }

@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 560px; margin-left: -280px; }
  .hint { left: 50%; right: auto; width: 520px; margin-left: -260px; }
}
/* Built into a page of the site (?embed=1): the table keeps a height of its own, the hints stay over it, and the
   panels follow it below as text the page scrolls through — the page makes the frame as tall as all this
   (tarot-site/sitegen/static/embed.js, told by app.js). */
:root { --table-height: 560px; }
@media (max-width: 699px) { :root { --table-height: 440px; } }
html.embedded, html.embedded body { height: auto; overflow: visible; }
.embedded #stage { position: relative; height: var(--table-height); }
.embedded #ui { position: absolute; top: 0; left: 0; right: 0; height: var(--table-height); }
.embedded .sheet {
  top: 100%; bottom: auto; padding: 22px 16px 28px; border-radius: 0; background: var(--bg); box-shadow: none;
  backdrop-filter: none; animation: none;
}
.embedded .reading, .embedded #matrix.reading:not(.is-peek), .embedded #angelinfo.reading:not(.is-peek) { max-height: none; }
.embedded .reading-body { overflow: visible; }
.embedded .handle { display: none; }
@media (min-width: 700px) {
  .embedded .sheet { width: 680px; margin-left: -340px; border-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .hint, .toast { animation: none; }
  .loading-card { animation-duration: 3s; }
}
