/* Общие основы игр студии. Цвета — токены на :root, тёмная тема — [data-theme=dark].
   data-theme выставляет shared/tg.js (Телеграм или prefers-color-scheme). */

:root {
  --bg: #f1f5f9;
  --text: #16212c;
  --muted: #4b5b6b;
  --surface: #ffffff;
  --line: #d3dde7;
  --accent: #174d78;
  --on-accent: #ffffff;
  --shadow: rgba(20, 40, 60, 0.14);
  --gold: #b87400;
  --gold-off: #8a98a6;
  --vscrim: rgba(12, 24, 36, 0.42);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #131a21;
  --text: #e9eff5;
  --muted: #bac8d4;
  --surface: #1e2832;
  --line: #34424f;
  --accent: #b4dcf6;
  --on-accent: #06101a;
  --shadow: rgba(0, 0, 0, 0.45);
  --gold: #f0b43c;
  --gold-off: #6a7d90;
  --vscrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* до того как скрипт выставил data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #131a21;
    --text: #e9eff5;
    --muted: #bac8d4;
    --surface: #1e2832;
    --line: #34424f;
    --accent: #b4dcf6;
    --on-accent: #06101a;
    --shadow: rgba(0, 0, 0, 0.45);
    --gold: #f0b43c;
    --gold-off: #6a7d90;
    --vscrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, Roboto, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* игровая область: без выделения и контекстного меню по долгому нажатию */
.game,
.game * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* круглая кнопка */
.rbtn {
  display: inline-grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.1s ease-out, opacity 0.15s;
}
.rbtn:active:not(:disabled) {
  transform: scale(0.94);
}
.rbtn:disabled {
  opacity: 0.38;
  box-shadow: none;
}
.rbtn.small {
  width: 44px;
  height: 44px;
}

/* карточка */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 40px var(--shadow);
  padding: 24px 20px 20px;
}

/* значки: линии одной толщины, цвет от текста */
.ic {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- одна шапка игры: слева что, по центру главное, справа счётчик ---------- */

.ghd {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  min-height: 48px;
  padding: 8px 16px 0;
  color: var(--text);
}
.ghd-l {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ghd-c {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}
.ghd-r {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
}
.ghd-r b { font-weight: 650; }

/* ---------- одна нижняя линия: круглые кнопки 52×52, подписи 14 px ---------- */

.cbar {
  flex: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: start;
  gap: 4px;
  padding: 8px 8px 14px;
}
.cbar .cb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cbar .cb span {
  font-size: 14px;
  line-height: 1.3;
  color: var(--muted);
}
.cbar .rbtn {
  width: 52px;
  height: 52px;
}
.cbar .rbtn .ic { width: 24px; height: 24px; }
.cbar .cb.warn .rbtn { border-color: var(--accent); color: var(--accent); }
.cbar .cb.warn span { color: var(--text); font-weight: 600; }

/* ---------- строка-инструкция: цветом основного текста ---------- */

.gtip {
  text-align: center;
  font-size: 15px;
  line-height: 20px;
  color: var(--text);
  padding: 0 16px;
}

/* ---------- одна карточка победы и итога (shared/card.js) ---------- */

.vscrim {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--vscrim);
  animation: vFade 0.2s ease-out;
}
.vscrim.fixed { position: fixed; }
.vcard {
  width: min(100%, 320px);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  animation: vRise 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.vcard h2 { font-size: 24px; font-weight: 700; line-height: 1.2; }
.vstars { display: flex; justify-content: center; gap: 6px; margin: 16px 0 12px; }
.vstar {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--gold-off);
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.vstar.on {
  fill: var(--gold);
  stroke: var(--gold);
  animation: vStar 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  animation-delay: calc(var(--i, 0) * 0.22s + 0.12s);
}
.vstar.s { width: 18px; height: 18px; }
.vstar.s.on { animation: none; }
.vline { font-size: 18px; }
.vline b { font-size: 22px; font-weight: 700; }
.vsub { margin-top: 4px; font-size: 14px; color: var(--muted); }
.vsub:empty { display: none; }
.vrow { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.vbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 18px;
  font-weight: 600;
  transition: transform 0.1s ease-out;
}
.vbtn:active { transform: scale(0.98); }
.vbtn.plain { min-height: 48px; background: transparent; color: var(--accent); font-weight: 500; }

@keyframes vFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vRise { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes vStar { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .rbtn, .vbtn {
    transition: none;
  }
  .vscrim, .vcard, .vstar.on { animation: none; }
}
