/* Цвета берутся из темы Telegram; янтарь — фирменный акцент игры */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f0f1ec);
  --text: var(--tg-theme-text-color, #1d231d);
  --hint: var(--tg-theme-hint-color, #7a8277);
  --link: var(--tg-theme-link-color, #b47a0c);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --amber: #D2900F;
  --amber-ink: #ffffff;
  --amber-soft: color-mix(in srgb, #D2900F 16%, var(--bg));
  --good: #4f8a2a;
  --bad: #c2392f;
  --r: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; line-height: 1.4;
  font-variant-numeric: tabular-nums; padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Шапка: компания, деньги, влияние и полоса дней */
#top { background: var(--bg); padding: 12px 16px 10px; border-bottom: 1px solid var(--sep); }
.who { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.who b { font-size: 1.12rem; }
.who .phase { color: var(--hint); font-size: .85rem; white-space: nowrap; }
.purse { display: flex; gap: 16px; margin-top: 4px; font-size: .95rem; }
.purse span { color: var(--hint); }
.purse strong { color: var(--text); font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; margin-top: 10px; }
.days i { height: 6px; border-radius: 3px; background: var(--sep); }
.days i.past { background: var(--amber); }
.days i.now { background: var(--amber); box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 35%, transparent); height: 8px; margin-top: -1px; }
.event { margin-top: 8px; font-size: .85rem; color: var(--hint); }
.event b { color: var(--text); font-weight: 600; }

/* Списки в стиле Telegram */
#view { padding: 4px 0 20px; }
h3 { margin: 18px 16px 6px; font-size: .8rem; font-weight: 600; color: var(--hint); }
.group { background: var(--bg); border-top: 1px solid var(--sep); border-bottom: 1px solid var(--sep); }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 48px; }
.item + .item { border-top: 1px solid var(--sep); }
.item .main { flex: 1; min-width: 0; }
.item .sub { color: var(--hint); font-size: .84rem; }
.item .val { text-align: right; white-space: nowrap; }
.item .emo { font-size: 1.35rem; width: 28px; text-align: center; }
.item.tap { cursor: pointer; }
.note { margin: 6px 16px 0; color: var(--hint); font-size: .84rem; }
.empty { padding: 16px; color: var(--hint); }
pre.report { margin: 0; padding: 12px 16px; white-space: pre-wrap; font: inherit; font-size: .88rem; }
.up { color: var(--good); } .down { color: var(--bad); }

/* Кнопки */
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer;
  background: var(--amber); color: var(--amber-ink);
}
.btn.ghost { background: var(--amber-soft); color: var(--text); }
.btn.bad { background: color-mix(in srgb, var(--bad) 14%, var(--bg)); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { display: block; width: calc(100% - 32px); margin: 12px 16px 0; padding: 12px; }
.btn.sm { padding: 6px 11px; font-size: .88rem; }
.seg { display: flex; gap: 6px; padding: 10px 16px; }
.seg .btn { flex: 1; }
.seg.toggle .btn.on { background: var(--amber); color: var(--amber-ink); }
.seg.toggle .btn:not(.on) { background: var(--bg2); color: var(--text); }

/* Нижние вкладки */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--bg); border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabs button { border: 0; background: none; padding: 7px 0 8px; font-size: .72rem; color: var(--hint); cursor: pointer; }
#tabs button .ico { display: block; font-size: 1.25rem; line-height: 1.3; filter: grayscale(1); opacity: .7; }
#tabs button.on { color: var(--amber); font-weight: 600; }
#tabs button.on .ico { filter: none; opacity: 1; }

/* Нижний лист с формой */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 16px 16px 0 0; padding: 0 0 calc(16px + env(safe-area-inset-bottom, 0px));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet-body { animation: none; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 4px; position: sticky; top: 0; background: var(--bg); }
.x { border: 0; background: var(--bg2); border-radius: 50%; width: 30px; height: 30px; cursor: pointer; }
.field { padding: 8px 16px 0; }
.field label { display: block; font-size: .82rem; color: var(--hint); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--sep);
  border-radius: 10px; padding: 10px 12px;
}
.choices { display: grid; gap: 6px; }
.choice { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg2); cursor: pointer; }
.choice input { accent-color: var(--amber); }
.choice .sub { color: var(--hint); font-size: .82rem; }
.result { margin: 12px 16px 0; padding: 12px; border-radius: 10px; background: var(--amber-soft); white-space: pre-wrap; font-size: .9rem; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 11px 14px; font-size: .9rem;
}
#toast.err { background: var(--bad); color: #fff; }

/* Экраны входа */
.hero { padding: 36px 20px 10px; text-align: center; }
.hero h1 { margin: 6px 0; font-size: 1.6rem; }
.hero p { color: var(--hint); margin: 0 auto; max-width: 34ch; }
.mug { font-size: 3rem; }

/* Атрибут hidden сильнее любых display */
[hidden] { display: none !important; }
#top:empty { display: none; }
.field label.choice { display: flex; margin: 0; font-size: inherit; color: var(--text); }
.field label.choice b { font-weight: 600; }
.field .choice input { width: auto; flex: 0 0 auto; margin: 0; padding: 0; }

/* Голдкоин и влияние */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.17em; margin-left: .22em; flex: 0 0 auto; }
.amt { display: inline-flex; align-items: center; white-space: nowrap; font-weight: inherit; }
.purse { align-items: center; }
.purse .amt { font-weight: 600; font-size: 1rem; }
.emo .ic { width: 1.3em; height: 1.3em; margin: 0; }

/* Кнопки в шапке */
.hbtns { display: flex; gap: 6px; }
.hb { position: relative; border: 0; background: var(--bg2); border-radius: 50%; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }
.hb .dot { position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: #C62828; border: 2px solid var(--bg); }
.btn.pkg { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; }
.btn.pkg small { font-weight: 500; opacity: .9; font-size: .78rem; }

/* Полоса «Завершить ход» над вкладками */
#turnbar {
  position: fixed; left: 0; right: 0; z-index: 4; bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  padding: 8px 16px; background: var(--bg); border-top: 1px solid var(--sep);
}
body.with-turnbar { padding-bottom: calc(126px + env(safe-area-inset-bottom, 0px)); }
.turn-btn { width: 100%; padding: 12px; font-size: 1rem; }
.turn-done { text-align: center; padding: 10px; color: var(--good); font-weight: 600; }
.emo.ok { color: var(--good); font-weight: 700; }
.emo.warn { color: #fff; background: var(--amber); border-radius: 50%; width: 22px; height: 22px; font-size: .85rem; font-weight: 700; display: grid; place-items: center; margin: 0 3px; }
.rule { border-top: 1px solid var(--sep); }

/* Переключатель дней */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--sep); background: var(--bg); color: var(--text); border-radius: 99px; padding: 5px 12px; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--amber); border-color: var(--amber); color: #fff; font-weight: 600; }

/* Газета: всегда бумага и чёрная краска, в любой теме */
.paper {
  margin: 10px 12px 0; padding: 14px 16px 18px; background: #F3EEE1; color: #1B1914;
  font-family: "PT Serif", Georgia, "Times New Roman", serif; border-radius: 4px;
  box-shadow: 0 1px 0 #d9d0bb, 0 6px 18px rgba(0,0,0,.12);
}
.paper .mast { text-align: center; border-bottom: 3px double #1B1914; padding-bottom: 6px; }
.paper .mast h1 { margin: 2px 0; font-size: 2.6rem; line-height: 1; letter-spacing: .02em; font-weight: 700; }
.paper .mast-line { display: flex; justify-content: space-between; font-size: .74rem; border-top: 1px solid #1B1914; border-bottom: 1px solid #1B1914; padding: 2px 0; }
.paper .mast-line:first-child { border-top: 0; border-bottom: 1px solid #1B1914; }
.paper .kicker { font-size: .74rem; font-style: italic; color: #5a5245; }
.paper .lead { padding: 12px 0 10px; border-bottom: 1px solid #1B1914; text-align: center; }
.paper .lead h2 { margin: 2px 0 4px; font-size: 1.85rem; line-height: 1.1; }
.paper .deck { margin: 0; font-style: italic; font-size: 1rem; }
.paper .urgent { margin-top: 10px; padding: 8px 10px; border: 2px solid #8E1F17; }
.paper .urgent .kicker { color: #8E1F17; font-weight: 700; font-style: normal; }
.paper .urgent p { margin: 4px 0; font-weight: 700; }
.paper .sec { margin: 14px 0 4px; font-size: 1.05rem; border-bottom: 1px solid #1B1914; padding-bottom: 2px; color: #1B1914; }
.paper .brief { margin: 5px 0; font-size: .95rem; line-height: 1.38; }
.paper .ptable { width: 100%; border-collapse: collapse; font-size: .88rem; }
.paper .ptable th { text-align: left; font-weight: 400; font-style: italic; color: #5a5245; border-bottom: 1px solid #1B1914; padding: 3px 0; }
.paper .ptable td { padding: 4px 0; border-bottom: 1px dotted #b9ae95; }
.paper .ptable td:last-child, .paper .ptable th:last-child { text-align: right; }
.paper .ptable .fall { color: #8E1F17; }
.paper .ptable small { color: #5a5245; }
.paper .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.paper .cols section + section { border-left: 1px solid #1B1914; padding-left: 12px; }
.paper .rating { margin: 4px 0 0; padding-left: 1.3em; font-size: .95rem; }

/* Финансовый отчёт */
.stmt { margin: 10px 12px 0; padding: 14px 16px 18px; background: var(--bg); border: 1px solid var(--sep); border-radius: var(--r); }
.stmt header { border-bottom: 2px solid var(--text); padding-bottom: 8px; }
.stmt header h2 { margin: 2px 0; font-size: 1.3rem; }
.stmt .sec { margin: 16px 0 4px; font-size: .95rem; color: var(--text); }
.ft { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.ft td { padding: 6px 0; border-bottom: 1px solid var(--sep); vertical-align: top; }
.ft td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.ft .sub { color: var(--hint); font-size: .8rem; }
.ft .head td { color: var(--hint); font-size: .8rem; padding-top: 10px; border-bottom: 0; }
.ft .sumrow td { font-weight: 600; border-top: 1px solid var(--text); }
.ft .total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 3px double var(--text); }
.neg { color: var(--bad); }
.purse .amt { color: var(--text); }

/* Кнопка пояснения (?) */
.q {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 6px; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--hint); background: transparent; color: var(--hint);
  font: 700 11px/1 -apple-system, system-ui, sans-serif; cursor: pointer; vertical-align: 1px; flex: 0 0 auto;
}
.q:hover, .q:focus-visible { border-color: var(--amber); color: var(--amber); }
h3 .q { width: 16px; height: 16px; font-size: 10px; }
.purse .pi { display: inline-flex; align-items: center; color: var(--hint); }
.purse .pi strong { color: var(--text); margin-left: 4px; }
.qrow { display: flex; gap: 6px; align-items: center; justify-content: center; color: var(--hint); font-size: .8rem; margin-top: -2px; }
.qrow .q { margin: 0 2px 0 12px; }
.wide-row { display: flex; align-items: center; padding-right: 12px; }
.wide-row .btn.wide { flex: 1; margin-right: 8px; }
.turn-row { display: flex; align-items: center; gap: 10px; }
.turn-row .turn-btn { flex: 1; }
.choice .q { margin-left: auto; }

/* Окно пояснения поверх всего */
.hint { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; }
.hint-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.hint-card {
  position: relative; width: min(420px, 100%); max-height: 80vh; overflow-y: auto; background: var(--bg); color: var(--text);
  border-radius: 16px; padding: 14px 0 16px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.hint-head { display: flex; justify-content: space-between; align-items: center; padding: 0 16px 8px; }
.hint-head b { font-size: 1.05rem; }
#hint-text { padding: 0 16px; font-size: .95rem; line-height: 1.5; }
#tabs button { font-size: .66rem; }

/* Картинки */
.art { display: block; flex: 0 0 auto; }
.pic { display: grid; place-items: center; flex: 0 0 auto; min-width: 40px; }
.item .pic .art { filter: drop-shadow(0 1px 0 rgba(0,0,0,.06)); }
.choice .pic { min-width: 0; }
.minis { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.minis .art { display: inline-block; }
.hero .hero-art { display: block; width: min(220px, 64vw); height: auto; margin: 0 auto 6px; }
.stmt-head { display: flex; gap: 12px; align-items: center; }
.btn .art { display: inline-block; vertical-align: -5px; margin-right: 2px; }

/* Значки вкладок и шапки: однотонные, цвет как у текста */
#tabs button .ico { filter: none; opacity: 1; display: grid; place-items: center; height: 26px; }
#tabs button .ticon { width: 24px; height: 24px; }
#tabs button.on .ticon { stroke-width: 2.2; }
.hb { display: grid; place-items: center; color: var(--text); }
.hb .ticon { width: 20px; height: 20px; }

/* Газета: иллюстрации в тон бумаги */
.paper .minis .art { opacity: .95; }

/* Курс рынка: таблица как у обменника */
.rate-h { display: flex; align-items: center; gap: 8px; padding: 10px 16px 4px; }
.rate-h .pic { min-width: 0; }
.rate-h .sub { color: var(--hint); font-size: .82rem; margin-left: auto; }
.rate { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rate th { text-align: left; font-weight: 500; font-size: .74rem; color: var(--hint); padding: 4px 16px 6px 0; border-bottom: 1px solid var(--sep); }
.rate th:first-child { padding-left: 16px; }
.rate td { padding: 9px 16px 9px 0; vertical-align: top; border-top: 1px solid var(--sep); }
.rate td:first-child { padding-left: 16px; }
.rate tr:first-child td { border-top: 0; }
.rate td .sub { color: var(--hint); font-size: .78rem; line-height: 1.3; }
.rate td.p, .rate td.m { white-space: nowrap; }
.rate td.p .amt { font-size: 1.05rem; font-weight: 700; }
.rate td.m > b { font-size: 1.05rem; }
.rate td.m .sub { white-space: normal; max-width: 150px; }
.rate tr.dim td { opacity: .55; }
.best { margin: 6px 0 0; padding-left: 1.2em; font-size: .92rem; }
.best li + li { margin-top: 3px; }
