/* Образ: стол алхимика. Патинированная медь вместо сукна, латунь для акцентов,
   слоновая кость для карт и домино. Единая тёмная тема: это игровой стол. */
:root {
  color-scheme: dark;
  --table: #0f2a2b;
  --table-2: #163a3a;
  --table-3: #1f4b4a;
  --line: #2f6260;
  --ink: #ece6d3;
  --ink-soft: #a8bab0;
  --brass: #d3ac57;
  --brass-ink: #241a06;
  --ivory: #f3ecda;
  --ivory-2: #ddd3b8;
  --ivory-ink: #1d2422;
  --sq-a: #2c5c58;
  --sq-b: #204845;
  --opened: #16302f;
  --opened-2: #1a3736;
  --red: #e0493f;
  --blue: #4a8ee4;
  --yellow: #eebc2c;
  --green: #3db26b;
  --danger: #f0776d;
  --display: "Yeseva One", Georgia, "Times New Roman", serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --symbols: "Noto Sans Symbols 2", "Segoe UI Symbol", "DejaVu Sans", "Apple Symbols", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
  margin: 0;
  background: var(--table);
  color: var(--ink);
  font: 400 15px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.btn {
  border: 1px solid var(--line);
  background: var(--table-3);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
  min-height: 40px;
}
.btn:hover:not(:disabled) { border-color: var(--brass); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); background: transparent; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--table);
  color: var(--ink);
  font: inherit;
}
label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }

/* Экран входа */
.home {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
  gap: 48px;
  align-items: center;
  max-width: 1020px;
  margin: 0 auto;
  padding-block: 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.home h1 { font-size: clamp(48px, 9vw, 92px); line-height: 1; color: var(--brass); }
.home .lead { font-size: 19px; max-width: 30em; margin: 16px 0 28px; }
.ingredients { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.ingredients .big-glyph { font: 64px/1 var(--symbols); color: var(--ivory); }
.ingredients .plus { font: 28px/1 var(--display); color: var(--brass); }
.panel { background: var(--table-2); border: 1px solid var(--line); border-radius: 10px; padding: 20px; display: grid; gap: 14px; }
.panel h2 { font-size: 22px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.row { display: flex; gap: 8px; align-items: end; }
.row > label { flex: 1; min-width: 0; }
.code-input { text-transform: uppercase; letter-spacing: .14em; }

/* Лобби */
.lobby {
  max-width: 720px;
  margin: 0 auto;
  padding-block: 36px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 18px;
}
.room-code { font: 44px/1 var(--display); letter-spacing: .12em; color: var(--brass); overflow-wrap: anywhere; }
.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite code { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink-soft); font-size: 13px; }
.lobby-players { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.lobby-players li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--table); border-radius: 6px; min-height: 46px; }
.lobby-players .pname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lobby-players .empty { color: var(--ink-soft); }
.tag { font-size: 12px; color: var(--ink-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-soft); }
.dot.on { background: var(--green); }
.options { display: grid; gap: 12px; }
.setting { display: grid; gap: 4px; }
.setting-title { font-weight: 700; }
.add-bot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bot-tag { margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--table-3); color: var(--ink-soft); font-size: 11px; font-weight: 500; white-space: nowrap; }
.module-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px; }
.module { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--table); cursor: pointer; color: var(--ink-soft); }
.module.on { border-color: var(--brass); }
.module input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brass); cursor: pointer; }
.module-text { display: grid; gap: 1px; min-width: 0; font-size: 12px; line-height: 1.3; }
.module-text b { color: var(--ink); font-size: 14px; }
.spy { display: grid; gap: 4px; padding: 8px 10px; background: var(--table-2); border: 1px solid var(--brass); border-radius: 8px; font-size: 13px; }
.spy-cards { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.spy-cards .card { width: 42px; height: 60px; border-width: 2px; flex: none; }
.spy-cards .card .oval { width: 28px; height: 38px; }
.spy-cards .card .sym { font-size: 18px; }
.spy-cards .card .sym.text { font-size: 11px; }
.spy-cards .card .name, .spy-cards .card .corner, .spy-cards .card .trump { display: none; }
.inv-note { font-weight: 400; opacity: .75; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented .btn[aria-pressed="true"] { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }

/* Игровой экран: сверху панель «что делать сейчас», слева доска и рука, справа всё про партию. */
.game {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "board side" "hand side";
  gap: 8px 14px;
  padding-block: 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  height: 100%;
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-height: 60px;
  padding: 8px 14px;
  background: var(--table-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.topbar.my-turn { background: #2b3f2c; border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.who { display: flex; align-items: center; gap: 6px; font-size: 15px; white-space: nowrap; }
.who .suit { font: 20px/1 var(--symbols); }
.steps { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-soft); }
.steps li { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 3px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.step-n { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--table-3); font-weight: 700; font-size: 11px; }
.steps li.now { color: var(--ink); border-color: var(--brass); font-weight: 700; }
.steps li.now .step-n { background: var(--brass); color: var(--brass-ink); }
.steps li.done .step-n { background: transparent; color: var(--green); }
.prompt { flex: 1 1 260px; min-width: 200px; font-size: 16px; font-weight: 500; line-height: 1.3; }
.prompt.mine { color: #f4dd9c; font-weight: 700; }
.clock-box { display: grid; gap: 3px; width: 54px; flex: none; }
.clock { font: 700 16px/1 var(--body); font-variant-numeric: tabular-nums; text-align: right; }
.clock.low { color: var(--danger); }
.clock-track { display: block; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.clock-track i { display: block; height: 100%; width: 100%; background: var(--brass); transition: width .5s linear; }
.clock-track i.low { background: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn.attention { border-color: var(--brass); background: #4a3b16; color: #f4dd9c; font-weight: 700; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: var(--brass); color: var(--brass-ink); font-size: 12px; font-weight: 700; }
.btn.uno { background: var(--red); border-color: var(--red); color: #fff; font: 400 18px/1 var(--display); animation: pulse 1s infinite; }
.btn.catch { background: var(--yellow); border-color: var(--yellow); color: var(--brass-ink); font-weight: 700; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* Доска вписывается в свободную область: сторона равна меньшему из её размеров. */
.board-wrap { grid-area: board; display: grid; place-items: center; min-height: 0; min-width: 0; container-type: size; }
/* Арена: кольцо монополии рамкой вокруг доски. Угловые поля чуть уже боковых, чтобы доска осталась крупной. */
.arena {
  --ring: 8.6%;
  display: grid;
  grid-template-columns: var(--ring) repeat(9, minmax(0, 1fr)) var(--ring);
  grid-template-rows: var(--ring) repeat(9, minmax(0, 1fr)) var(--ring);
  gap: 1px;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  container-type: inline-size;
  container-name: arena;
}
.arena.no-ring { display: block; }
.arena > .board { grid-row: 2 / 11; grid-column: 2 / 11; padding: 4px; }
.board {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  grid-template-rows: repeat(14, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  container-type: inline-size;
}
.field {
  --band: transparent;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--table-2);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.05;
}
.field:hover { border-color: var(--brass); }
.field.focus { outline: 2px solid var(--brass); z-index: 2; }
.field.mortgaged { background: repeating-linear-gradient(45deg, var(--table-2) 0 4px, #0c2021 4px 8px); }
.field.mortgaged .band { opacity: .4; }
.field.owner-red { box-shadow: inset 0 0 0 2px var(--red); }
.field.owner-blue { box-shadow: inset 0 0 0 2px var(--blue); }
.field.owner-yellow { box-shadow: inset 0 0 0 2px var(--yellow); }
.field.owner-green { box-shadow: inset 0 0 0 2px var(--green); }
.band { flex: none; display: block; width: 100%; height: 24%; background: var(--band); text-align: center; }
.marks { display: block; font-size: 1.15cqw; line-height: 1; color: #0c2021; letter-spacing: -.5px; }
.marks.hotel { color: #7a0d0d; }
.field-mark { font: 2cqw/1.1 var(--symbols); color: var(--brass); margin-top: 1px; }
.field-name { font-size: 1.2cqw; padding: 1px 2px 0; text-align: center; overflow-wrap: break-word; hyphens: manual; overflow: hidden; max-width: 100%; }
.field-price { font-size: 1.35cqw; font-weight: 700; color: var(--brass); margin-top: auto; padding-bottom: 1px; }
.tokens { position: absolute; left: 0; right: 0; bottom: 8%; display: flex; flex-wrap: wrap; gap: 1px; justify-content: center; pointer-events: none; }
.token { display: block; width: 2cqw; height: 2cqw; min-width: 8px; min-height: 8px; border-radius: 50%; border: 1.5px solid var(--ivory); box-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
.seat-bg-red { background: var(--red); }
.seat-bg-blue { background: var(--blue); }
.seat-bg-yellow { background: var(--yellow); }
.seat-bg-green { background: var(--green); }
@container arena (max-width: 560px) {
  .field-name, .field-price { display: none; }
  .marks { font-size: 1.8cqw; }
  .band { height: 30%; }
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--sq-b);
  cursor: default;
  min-width: 0;
  min-height: 0;
}
.cell.light { background: var(--sq-a); }
.cell.last { box-shadow: inset 0 0 0 100px rgba(211, 172, 87, .24); }
.cell.source { cursor: pointer; box-shadow: inset 0 0 0 2px var(--brass); }
.cell.selected { box-shadow: inset 0 0 0 100px rgba(211, 172, 87, .55); }
.cell.target { cursor: pointer; }
.cell.target::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--brass);
  opacity: .9;
}
.cell.target.hit::after {
  width: 86%;
  height: 86%;
  background: transparent;
  border: 3px solid var(--danger);
  opacity: 1;
}
.cell.placeable { cursor: pointer; }
.cell.placeable:hover { box-shadow: inset 0 0 0 2px var(--ivory); }
.cell.link::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px dashed var(--ivory);
  border-radius: 3px;
  opacity: .75;
}
.cell.first { box-shadow: inset 0 0 0 100px rgba(243, 236, 218, .45); }

.glyph {
  font-family: var(--symbols);
  font-size: 5.6cqw;
  line-height: 1;
  -webkit-text-stroke: .35cqw #071615;
  paint-order: stroke fill;
  pointer-events: none;
  user-select: none;
}
.seat-red { color: var(--red); }
.seat-blue { color: var(--blue); }
.seat-yellow { color: var(--yellow); }
.seat-green { color: var(--green); }

.half { position: absolute; inset: 1px; background: var(--ivory); border-radius: 3px; border: 2px solid var(--owner); }
.half.join-n { top: 0; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.half.join-s { bottom: 0; border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.half.join-w { left: 0; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.half.join-e { right: 0; border-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.half.owner-red { --owner: var(--red); }
.half.owner-blue { --owner: var(--blue); }
.half.owner-yellow { --owner: var(--yellow); }
.half.owner-green { --owner: var(--green); }
/* Сапёр: закрытые клетки выпуклые, открытые утоплены и светлее. */
.cell:not(.opened) { box-shadow: inset 1px 1px 0 rgba(236, 230, 211, .09), inset -1px -1px 0 rgba(0, 0, 0, .28); }
.cell.opened { background: var(--opened); }
.cell.opened.light { background: var(--opened-2); }
.digit { font: 700 3.6cqw/1 var(--body); pointer-events: none; }
.digit.d1 { color: #8fc7ff; }
.digit.d2 { color: #8fe2a4; }
.digit.d3 { color: #ff9a8f; }
.digit.d4 { color: #f2d36b; }
.digit.d5 { color: #e7a6ff; }
.mine-mark { font: 4.6cqw/1 var(--symbols); pointer-events: none; }
.mine-mark.own { color: var(--ivory); }
.mine-mark.enemy { color: var(--danger); }
.shield-ring { position: absolute; inset: 6%; border: 2px solid var(--ivory); border-radius: 50%; box-shadow: 0 0 5px var(--ivory); pointer-events: none; }
.wound { position: absolute; top: 8%; right: 8%; width: 24%; height: 24%; background: var(--danger); border: 1px solid #071615; border-radius: 50%; pointer-events: none; }
.glyph { position: relative; }
.pips { display: block; width: 100%; height: 100%; }
.pips circle { fill: var(--ivory-ink); }

/* Рука: подписанные разделы */
.hand-zone { grid-area: hand; display: flex; gap: 16px; align-items: flex-start; min-width: 0; padding: 6px 10px 4px; background: var(--table-2); border-radius: 10px; }
.dock-part { min-width: 0; display: grid; gap: 2px; }
.dock-cards { flex: 1 1 auto; }
.dock-bones { flex: 0 0 auto; max-width: 176px; }
.dock-items { flex: 0 0 116px; }
.dock-title { font: 700 12px/1.3 var(--body); color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 0 8px; }
.dock-hint { font-weight: 400; color: var(--brass); }
.dock-empty { margin: 4px 0 0; font-size: 12px; line-height: 1.35; color: var(--ink-soft); }
.hand-group { display: flex; gap: 6px; overflow-x: auto; padding: 8px 4px 4px; min-width: 0; scrollbar-width: thin; }
.card {
  --face: var(--ink-soft);
  position: relative;
  flex: none;
  width: 68px;
  height: 98px;
  border-radius: 8px;
  border: 3px solid var(--ivory);
  background: var(--face);
  padding: 0;
  cursor: pointer;
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform .12s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
}
.card.c-red { --face: var(--red); }
.card.c-blue { --face: var(--blue); }
.card.c-yellow { --face: var(--yellow); color: var(--brass-ink); }
.card.c-green { --face: var(--green); }
.card.c-wild { background: conic-gradient(var(--red) 0 25%, var(--blue) 0 50%, var(--yellow) 0 75%, var(--green) 0); }
.card:hover:not(:disabled):not(.unplayable) { transform: translateY(-4px); }
.card:disabled { filter: saturate(.25) brightness(.62); cursor: default; }
.card.unplayable, .card.dim { filter: saturate(.3) brightness(.6); }
.card.unplayable { cursor: help; }
.card.playable { box-shadow: 0 0 0 2px var(--brass), 0 0 12px rgba(211, 172, 87, .65); }
/* Пока ход чужой, рука остаётся цветной: по ней планируют следующий ход. */
.idle .card.unplayable, .idle .bone:disabled { filter: none; }
.card.picked { transform: translateY(-8px); outline: 3px solid #fff; }
.card.hinted { outline: 2px dashed var(--brass); }
.card .oval {
  width: 48px;
  height: 66px;
  border-radius: 50%;
  background: var(--ivory);
  color: var(--ivory-ink);
  display: grid;
  place-items: center;
  transform: rotate(14deg);
}
.card .sym { font: 32px/1 var(--symbols); transform: rotate(-14deg); }
.card .sym.text { font: 700 19px/1 var(--body); }
.card .corner { position: absolute; top: 1px; left: 3px; font: 13px/1.1 var(--symbols); }
.card .name { position: absolute; bottom: 1px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; line-height: 1.2; }
.card .trump { position: absolute; top: 1px; right: 3px; font-size: 12px; line-height: 1.1; color: inherit; }
.card.back { background: var(--table-3); border-color: var(--brass); color: var(--brass); }
.card.back .sym.text { transform: none; font-size: 15px; }
.card.back:disabled { filter: brightness(.7); }

.bone {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 76px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--ivory);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
  transition: transform .12s;
  overflow: hidden;
}
.bone > span { display: block; padding: 2px; min-width: 0; }
.bone > span + span { border-left: 2px solid var(--ivory-2); }
.bone:hover:not(:disabled) { transform: translateY(-3px); }
.bone:disabled { filter: brightness(.6); cursor: default; }
.bone.picked { outline: 3px solid var(--brass); transform: translateY(-5px); }
.bones-col { display: grid; grid-template-columns: repeat(2, 76px); gap: 6px; padding-top: 6px; }
.inventory { display: grid; gap: 4px; padding-top: 6px; }
.inv-item { font: 500 12px/1.1 var(--body); min-height: 28px; padding: 3px 6px; border-radius: 5px; border: 1px solid var(--brass); background: var(--table-3); color: var(--ink); cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.inv-item:disabled { opacity: .55; cursor: default; }
.inv-item.picked { background: var(--brass); color: var(--brass-ink); }
.inv-item.empty { display: none; }
.shop { max-width: 560px !important; text-align: left !important; justify-items: stretch !important; max-height: 100%; overflow-y: auto; }
.shop h2 { font-size: 28px !important; }
.shop p { margin: 0; }
.shop-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.shop-head h2 { flex: 1; }
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.shop-list li { display: flex; align-items: center; gap: 12px; background: var(--table); padding: 8px 10px; border-radius: 6px; }
.shop-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; color: var(--ink-soft); }
.shop-text b { color: var(--ink); font-size: 15px; }
.shop-list .btn { flex: none; min-width: 72px; }

/* Боковая панель */
.side { grid-area: side; display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.wallet { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: var(--table-2); border-radius: 10px; }
.wallet-gold { display: grid; line-height: 1.1; }
.wallet-gold .gold { font-size: 26px; }
.wallet-actions { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.wallet-actions .btn { padding: 6px 8px; min-height: 36px; font-size: 13px; }
.side > * { flex: none; }
.log-box { flex: none; display: flex; flex-direction: column; background: var(--table-2); border-radius: 6px; padding: 6px 10px; }
.log-box.open { flex: 1 1 0; min-height: 96px; }
.log-toggle { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.event { display: flex; gap: 10px; align-items: center; font-size: 13px; background: var(--table-2); border-radius: 6px; padding: 8px 10px; }
.event p { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.die { flex: none; width: 38px; height: 38px; background: var(--ivory); border-radius: 7px; padding: 2px; box-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.die.idle-die { opacity: .45; }
.die.rolled { animation: tumble .6s ease-out; }
@keyframes tumble { 0% { transform: rotate(-200deg) scale(.5); } 70% { transform: rotate(16deg) scale(1.12); } 100% { transform: none; } }
.econ { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.econ-buttons { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.ring-status { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--ink-soft); }
.ring-status .ring-card { flex: 1 1 100%; overflow-wrap: anywhere; }
.mini-dice { display: inline-flex; gap: 3px; }
.mini-die { width: 20px; height: 20px; padding: 1px; background: var(--ivory); border-radius: 4px; }
.pile-slot { flex: none; }
.pile-slot .card { animation: pile-in .22s ease-out; }
@keyframes pile-in { from { transform: scale(.82) rotate(-5deg); } to { transform: none; } }
#bid-amount { width: 76px; min-height: 40px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--table); color: var(--ink); font: inherit; }
.field-panel { max-width: 440px !important; }
.field-panel p { margin: 0; }
.field-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.rent-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.rent-table th, .rent-table td { text-align: left; padding: 4px 6px; border-top: 1px solid var(--line); font-weight: 400; }
.rent-table td { text-align: right; font-variant-numeric: tabular-nums; }
.rent-table tr.now { color: var(--brass); font-weight: 700; }
.trade-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.trade-cols h3 { font-size: 16px; margin-bottom: 6px; color: var(--brass); }
.trade-cols > div { display: grid; gap: 4px; align-content: start; min-width: 0; }
.trade-field { display: flex; flex-direction: row; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.trade-cols input[type="number"] { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--table); color: var(--ink); font: inherit; }
/* Слой эффектов поверх страницы */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.fx { position: fixed; pointer-events: none; display: grid; place-items: center; }
.glyph-fx { font-family: var(--symbols); line-height: 1; -webkit-text-stroke: 1.5px #071615; paint-order: stroke fill; }
.flash { border-radius: 50%; background: radial-gradient(circle, #fff6c8 0%, #ffb13c 35%, rgba(224, 73, 63, .6) 60%, transparent 72%); }
.spark { border-radius: 50%; }
.pulse { border-radius: 50%; border: 3px solid var(--ivory); }
.shield-fx { border-color: #9fd8ff; box-shadow: 0 0 12px #9fd8ff; }
.tele-fx { border-color: #d4a6ff; box-shadow: 0 0 14px #d4a6ff; }
.mine-fx { border-color: var(--danger); }
.bone-fx { border-radius: 4px; border-color: var(--ivory); }
.flying-card { border-radius: 6px; border: 2px solid var(--ivory); background: var(--ink-soft); }
.flying-card.c-red { background: var(--red); }
.flying-card.c-blue { background: var(--blue); }
.flying-card.c-yellow { background: var(--yellow); }
.flying-card.c-green { background: var(--green); }
.flying-card.c-wild { background: conic-gradient(var(--red) 0 25%, var(--blue) 0 50%, var(--yellow) 0 75%, var(--green) 0); }
.flying-card.c-back { background: var(--table-3); border-color: var(--brass); }
.coin-fx { font: 700 15px/1 var(--body); justify-items: end; }
.coin-fx.up { color: var(--brass); }
.coin-fx.down { color: var(--danger); }
.dice-fx { background: var(--ivory); border-radius: 16%; box-shadow: 0 6px 18px rgba(0, 0, 0, .6); }
.die-face { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 76%; height: 76%; place-items: center; }
.die-face i { display: block; width: 62%; aspect-ratio: 1; border-radius: 50%; }
.die-face i.on { background: var(--ivory-ink); }
.token-fx { border-radius: 50%; border: 1.5px solid var(--ivory); box-shadow: 0 2px 5px rgba(0, 0, 0, .7); }
.gold { color: var(--brass); font-weight: 700; font-variant-numeric: tabular-nums; }
.seats { display: grid; gap: 4px; }
.seat-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 6px; background: var(--table-2); border: 1px solid transparent; }
.seat-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.offline { color: var(--danger); white-space: nowrap; }
.seat-row.turn { border-color: var(--brass); }
.seat-row.out { opacity: .45; text-decoration: line-through; }
.seat-row .suit { font: 18px/1 var(--symbols); }
.seat-row .sname { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.seat-row .counts { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dir { font-size: 12px; color: var(--ink-soft); }
.pile-row { display: flex; align-items: flex-start; gap: 10px; }
.pile-col { display: grid; gap: 2px; justify-items: center; flex: none; }
.extras { margin-top: 2px; }
.pile-row .card { cursor: default; }
.pile-row .card.back:not(:disabled) { cursor: pointer; }
.pile-row .card:hover { transform: none; }
.pile-info { font-size: 13px; color: var(--ink-soft); display: grid; gap: 4px; min-width: 0; }
.color-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); }
.color-chip i { width: 14px; height: 14px; border-radius: 3px; background: var(--chip); display: inline-block; }
.log { overflow-y: auto; font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column-reverse; gap: 4px; flex: 1 1 0; min-height: 0; margin-top: 4px; }
.lobby-next { margin: 0; font-size: 16px; color: #f4dd9c; }
.link-button { background: none; border: 0; padding: 0; text-align: left; color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.build-hint { color: #f4dd9c; font-size: 12px; line-height: 1.35; }
.district { display: grid; gap: 6px; }
.district h3 { display: flex; align-items: center; gap: 8px; font: 700 14px/1.2 var(--body); border-left: 6px solid var(--band); padding-left: 8px; }
.district-count { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.district-count.full { color: var(--green); font-weight: 700; }
.tutorial .tutorial-steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.tutorial li { font-size: 14px; line-height: 1.4; color: var(--ink-soft); }
.tutorial li::marker { color: var(--brass); font-weight: 700; font-size: 16px; }
.tutorial li b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 2px; }
.tutorial li span { display: block; }
.tutorial .btn { justify-self: end; }
.rules-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px; position: sticky; top: -20px; background: var(--table-2); padding-block: 6px; z-index: 1; }
dialog h3 { scroll-margin-top: 90px; }
.log p { margin: 0; overflow-wrap: anywhere; }
.log p:first-child { color: var(--ink); }
.side-foot { display: flex; gap: 4px; flex-wrap: wrap; }
.side-foot .btn { padding: 4px 8px; }

.color-pick { display: inline-flex; gap: 6px; align-items: center; }
.swatch { width: 38px; height: 38px; border-radius: 6px; border: 2px solid var(--ivory); cursor: pointer; font: 18px/1 var(--symbols); color: #fff; padding: 0; }
.swatch.red { background: var(--red); }
.swatch.blue { background: var(--blue); }
.swatch.yellow { background: var(--yellow); color: var(--brass-ink); }
.swatch.green { background: var(--green); }

.result {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 22, 21, .72);
  padding: 16px;
  z-index: 20;
}
.result .panel { max-width: 420px; width: 100%; text-align: center; justify-items: center; }
.result h2 { font-size: 34px; color: var(--brass); }

#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(78px + env(safe-area-inset-top, 0px));
  background: var(--ivory);
  color: var(--ivory-ink);
  padding: 10px 16px;
  border-radius: 6px;
  z-index: 40;
  pointer-events: none;
  max-width: min(92vw, 460px);
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}

dialog {
  background: var(--table-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 660px;
  width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  padding: 20px;
}
dialog::backdrop { background: rgba(7, 22, 21, .75); }
dialog h2 { font-size: 30px; color: var(--brass); }
dialog h3 { font-size: 19px; margin-top: 18px; margin-bottom: 4px; color: var(--brass); }
dialog p, dialog li { line-height: 1.5; }
dialog p { margin: 4px 0; }
dialog ol, dialog ul { margin: 4px 0; padding-left: 20px; }
dialog table { border-collapse: collapse; width: 100%; font-size: 14px; }
dialog th, dialog td { text-align: left; vertical-align: top; padding: 5px 8px 5px 0; border-top: 1px solid var(--line); font-weight: 400; }
dialog th { font-weight: 700; width: 38%; }
.rules-close { float: right; margin: 0; }

@media (max-width: 900px) {
  html, body, #app { height: auto; }
  .home { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-block: 24px; }
  .ingredients .big-glyph { font-size: 44px; }
  .game {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "top" "board" "hand" "side";
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }
  .board-wrap { container-type: normal; }
  .arena { width: 100%; height: auto; aspect-ratio: 1; }
  .board { width: 100%; height: 100%; }
  .arena.no-ring .board { aspect-ratio: 1; height: auto; }
  .topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; padding: 6px 10px; min-height: 0; }
  .prompt { flex-basis: 100%; font-size: 15px; order: 3; }
  .actions { order: 4; flex: 1 1 auto; }
  .clock-box { margin-left: auto; }
  .steps li { padding-right: 4px; }
  .hand-zone { flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 8px; }
  .dock-bones, .dock-items { max-width: none; flex: none; }
  .bones-col { display: flex; overflow-x: auto; padding: 6px 2px 2px; }
  .inventory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side { overflow: visible; }
  .log-box.open { flex: none; }
  .log { flex: none; max-height: 200px; }
  .wallet-actions .btn { flex: 1 1 auto; }
  #toast { top: auto; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
