:root {
  --bg: #f4efe6; --panel: #fffdf8; --ink: #2d2a26; --muted: #8a8378; --line: #e4dccd;
  --accent: #2b6cb0; --accent2: #e07b24; --good: #2f855a; --bad: #c53030;
  --red: #e25555; --blue: #3b82c4; --green: #3f9b4f; --purple: #8a55c4;
  --orange: #e8912d; --violet: #b04f8f;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.35 -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px;
  background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.warn { background: var(--bad); }
button.alt { background: var(--accent2); }
button:disabled { opacity: .45; cursor: default; }
input[type=text] { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  width: 100%; background: #fff; }
.wrap { max-width: 980px; margin: 0 auto; padding: 12px 12px 140px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
h1 { font-size: 26px; margin: 18px 0 6px; } h2 { font-size: 17px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; background: var(--accent); color: #fff;
  padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.top .code { font-weight: 800; letter-spacing: 2px; background: rgba(255,255,255,.18); padding: 2px 8px; border-radius: 6px; }
.top .grow { font-size: 14px; }
.top button { padding: 6px 10px; background: rgba(255,255,255,.18); }

/* игроки */
.players { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.pchip { min-width: 112px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
  padding: 7px 9px; cursor: pointer; }
.pchip.cur { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(224,123,36,.18); }
.pchip.me .pname::after { content: " (вы)"; color: var(--muted); font-weight: 400; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.pstats { font-size: 13px; margin-top: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #bbb; margin-right: 5px; vertical-align: 1px; }
.dot.on { background: #38a169; }

/* кубики */
.dicebox { display: flex; gap: 10px; align-items: center; justify-content: center; min-height: 64px; }
.die { width: 54px; height: 54px; border-radius: 12px; background: #fff; border: 2px solid var(--ink);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 7px; }
.die i { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); place-self: center; visibility: hidden; }
.die.roll { animation: shake .6s ease; }
@keyframes shake { 0%{transform:rotate(0)} 25%{transform:rotate(-20deg) scale(1.1)} 50%{transform:rotate(15deg)} 75%{transform:rotate(-8deg)} 100%{transform:rotate(0)} }
.dicesum { font-size: 22px; font-weight: 800; }

/* карты */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.card { position: relative; border-radius: 11px; background: #fff; border: 1px solid var(--line);
  padding: 0 0 6px; cursor: pointer; overflow: hidden; text-align: center; min-height: 112px; }
.card .band { color: #fff; font-weight: 800; font-size: 13px; padding: 3px 4px; }
.card .ic { font-size: 28px; margin-top: 4px; }
.card .ttl { font-size: 12px; font-weight: 700; padding: 0 4px; line-height: 1.15; min-height: 28px; }
.card .cost { font-size: 13px; font-weight: 700; margin-top: 2px; }
.card .qty { position: absolute; top: 24px; right: 5px; background: var(--ink); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 0 6px; font-weight: 700; }
.card.can { outline: 3px solid var(--good); box-shadow: 0 0 0 5px rgba(47,133,90,.15); }
.card.dim { opacity: .5; }
.card.sel { outline: 3px solid var(--accent2); }
.c-red .band { background: var(--red); } .c-blue .band { background: var(--blue); }
.c-green .band { background: var(--green); } .c-purple .band { background: var(--purple); }
.c-orange .band { background: var(--orange); } .c-violet .band { background: var(--violet); }
.city .card { min-height: 96px; }
.section-title { font-weight: 700; margin: 10px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* панель действий */
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel);
  border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 18px rgba(0,0,0,.06); }
.actions .inner { max-width: 980px; margin: 0 auto; }
.actions .hint { font-weight: 700; margin-bottom: 8px; }
.actions.mine { background: #fff7ec; border-top: 3px solid var(--accent2); }
.actions .row button { flex: 1; min-width: 130px; padding: 13px 10px; }

/* журнал */
.log { max-height: 320px; overflow-y: auto; font-size: 13px; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.log .turn { font-weight: 700; color: var(--accent); padding-top: 8px; }
.log .dice { color: var(--ink); font-weight: 600; } .log .money { color: var(--good); }
.log .warn { color: var(--bad); } .log .big, .log .build { color: #6b46c1; } .log .win { color: var(--accent2); font-weight: 800; font-size: 15px; }

/* лобби */
.code-big { font-size: 40px; font-weight: 900; letter-spacing: 8px; text-align: center; color: var(--accent); }
.plist div { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
label.chk { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

/* модалка и тост */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 85vh; overflow-y: auto; }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
.toast { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.banner { text-align: center; padding: 10px; border-radius: 12px; background: #fff7ec; border: 1px solid #f3cf9f; font-weight: 700; }
.scores li { padding: 4px 0; font-size: 16px; }
.coin { display: inline-block; width: .95em; height: .95em; border-radius: 50%; vertical-align: -.12em; margin-right: 1px;
  background: radial-gradient(circle at 35% 35%, #ffe58a, #e0a526 60%, #b7791f); box-shadow: inset 0 0 0 1.5px #a86a12; }
