:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #1d1b18;
  --muted: #6d675e;
  --accent: #d1481f;
  --accent-strong: #bf3f19;
  --on-accent: #ffffff;
  --accent-soft: #fdece5;
  --line: #e6ded1;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --card: #211f25;
    --ink: #f2efe9;
    --muted: #a29b91;
    --accent: #ff7a4d;
    --accent-strong: #ff8f66;
    --on-accent: #2a1206;
    --accent-soft: #3a241c;
    --line: #332f38;
  }
}

* { box-sizing: border-box; }

/* Атрибут hidden обязан побеждать любые display-правила ниже:
   #invite задаёт display: flex, и по специфичности он перебил бы
   браузерное [hidden] { display: none }. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 24px 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
}

#app { width: 100%; max-width: 680px; }

#invite {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(78vh, 620px);
}

.screen { animation: appear .28s ease-out both; }
@keyframes appear {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.noscript {
  display: block;
  max-width: 680px;
  margin: 40px auto;
  padding: 16px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  text-align: center;
}

h1 { font-size: clamp(26px, 6vw, 38px); line-height: 1.15; margin: 0 0 12px; }
h2.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 12px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 24px; }
.counter { font-weight: 600; margin: 0 0 20px; }
.privacy { font-size: 14px; color: var(--muted); margin-top: 20px; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; }

.primary { background: var(--accent-strong); color: var(--on-accent); padding: 14px 24px; font-weight: 600; font-size: 17px; }
.primary:disabled { opacity: .55; cursor: default; }
.secondary { background: transparent; color: var(--accent-strong); border-color: var(--line); padding: 12px 18px; }
.submit { width: 100%; margin-top: 28px; }

.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.who-label { color: var(--muted); font-size: 14px; }
.nickname { background: var(--accent-soft); color: var(--ink); padding: 10px 14px; font-weight: 600; border-color: var(--line); min-height: 44px; }
.roll {
  width: 44px; height: 44px; padding: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  border-color: var(--line);
  font-size: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}

.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  background: var(--card); border: 1.5px solid var(--line);
  padding: 14px; border-radius: var(--radius); width: 100%; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
/* Состояние читается не только цветом: рамка плюс галочка — для дальтонизма. */
.card[aria-pressed="true"] { border-color: var(--accent); border-width: 2.5px; background: var(--accent-soft); box-shadow: 0 3px 14px rgba(0,0,0,.10); }
.card[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 700; }
.card .emoji { font-size: 20px; line-height: 1.3; }

.exit-card .card { border-style: dashed; }

.customs { display: flex; flex-direction: column; gap: 8px; }
.customs input {
  font: inherit; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.customs input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

#results { position: relative; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
.who-result { color: var(--muted); margin-bottom: 24px; }

.results-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row .bar-label { display: flex; gap: 8px; align-items: baseline; margin-bottom: 5px; font-size: 15px; }
.bar-row .pct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar-row.mine .bar-label { font-weight: 700; }
.bar-row.mine .bar-label::before { content: "★"; color: var(--accent); }

.meta { color: var(--muted); font-size: 14px; margin: 16px 0 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

.show-all { margin-top: 12px; }

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