/* Асық ату — тёплая «степная» палитра: песок, кость, один акцент (красная краска сақа).
   Ровные поверхности, без градиентов и свечения (правила в Мозге: сценарии/сайт.md). */
:root {
  --bg: #f3e7d3; --card: #fbf4e4; --line: #dcc9a6; --ink: #2b2118; --muted: #6f5d48;
  --accent: #b3261e; --accent-ink: #fff7ee; --ok: #2e7d4f;
  --r: 14px; --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --display: 'Exo 2', Roboto, system-ui, sans-serif;
  --body: 'Montserrat', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { margin: 0; font: 500 16px/1.5 var(--body); }
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: 44px; } h2 { font-size: 26px; }
.muted { color: var(--muted); } .center { text-align: center; }
.err { color: var(--accent); min-height: 1.4em; margin: 0; font-weight: 700; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.xl { width: 48px; height: 48px; color: var(--accent); margin: 0 auto; }

.screen { display: flex; flex-direction: column; gap: 14px; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); animation: enter .2s var(--ease-out); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.bar { display: flex; justify-content: space-between; align-items: center; min-height: 48px; }

.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font: 700 17px var(--body);
  background: var(--card); color: var(--ink); cursor: pointer; min-height: 56px; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .12s var(--ease-out), background-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; color: var(--ink); font: 700 15px var(--body); cursor: pointer; min-height: 48px; min-width: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: #fffaf0; } .btn.primary:hover { background: #c22b22; } .btn.ghost:hover { background: var(--card); }
}

/* меню */
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 8px; }
.hero canvas { width: 240px; height: 120px; }
.lead { margin: 0; color: var(--muted); max-width: 30ch; }
.modes { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

fieldset { border: 0; padding: 0; margin: 0; }
legend { color: var(--muted); font-size: 14px; margin-bottom: 8px; padding: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: grid; place-items: center; min-height: 52px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 700; }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input { font: 700 18px var(--body); color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 52px; width: 100%; }
.field input:focus { border-color: var(--ink); outline: none; }
.or { height: 1px; background: var(--line); margin: 6px 0; }

/* комната */
.code { font: 800 44px var(--display); letter-spacing: .12em; text-align: center; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.plist .tag { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* игра: поле на весь экран */
.game { position: fixed; inset: 0; height: 100dvh; padding: 0; gap: 0; background: #d9b98a; animation: none; max-width: none; }
.hud { display: flex; align-items: center; gap: 4px; padding: calc(4px + env(safe-area-inset-top)) 6px 4px; background: var(--bg); border-bottom: 1px solid var(--line); }
.scores { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex: 1; justify-content: center; min-width: 0; }
.scores li { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 2px solid transparent; min-width: 0; font-weight: 700; }
.scores li.on { background: var(--card); border-color: var(--ink); }
.scores .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; font-size: 14px; }
.scores .sc { font: 800 18px var(--display); font-variant-numeric: tabular-nums; }
.scores .sc small { font: 700 12px var(--body); color: var(--muted); }
.field-wrap { position: relative; flex: 1; min-height: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.toast { position: fixed; z-index: 30; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-weight: 700; text-align: center; width: max-content; max-width: calc(100% - 24px); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-out); }
.toast.show { opacity: 1; }
.hint { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); text-align: center; font-weight: 700;
  height: calc(68px + env(safe-area-inset-bottom)); display: grid; place-items: center; line-height: 1.3; }

/* окна */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(43, 33, 24, .55); padding: 16px; }
.sheet { background: var(--bg); border-radius: 20px; padding: 24px 20px; width: min(100%, 400px); max-height: calc(100dvh - 32px); overflow: auto;
  display: flex; flex-direction: column; gap: 14px; text-align: center; animation: rise .25s var(--ease-out); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.big { font: 800 22px var(--display); margin: 0; }
.toss, .final { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.toss li, .final li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.toss .land { margin-left: auto; color: var(--muted); font-weight: 700; }
.toss li.best .land { color: var(--accent); font-weight: 800; }
.final .sc { margin-left: auto; font: 800 20px var(--display); }
.final li.win { border-color: var(--ink); border-width: 2px; }
.rules { text-align: left; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

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

/* меню: метка у кнопки, статистика */
.pill { margin-left: auto; font: 700 13px var(--body); padding: 3px 9px; border-radius: 99px; background: var(--ink); color: var(--bg); }
.btn .pill { margin-left: 4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 800 22px var(--display); font-variant-numeric: tabular-nums; }
.lead.left { text-align: left; max-width: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.card .row { display: flex; justify-content: space-between; gap: 12px; }
.card .row b { font: 800 18px var(--display); }
/* счёт: вдвоём — с именами, втроём-вчетвером — только цвет и число */
.scores.many .nm { display: none; }
.scores .nm { max-width: 12ch; }
/* телефон лежит на боку */
.rotate { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; font-weight: 700; }
.sheet { scroll-padding-top: 24px; }
