/* Color Dice — палитра и подача сняты с jabka.to (тёмно-зелёный холст, лаймовый акцент). */
:root {
  --bg: #0a120d;
  --bg-1: #0d1712;
  --bg-2: #101d18;
  --panel: #12211a;
  --panel-2: #16281f;
  --panel-hi: linear-gradient(180deg, #16261e 0%, #101a15 100%);
  --stroke: rgba(166, 255, 53, 0.10);
  --stroke-2: rgba(255, 255, 255, 0.07);
  --stroke-strong: rgba(166, 255, 53, 0.28);

  --text: #f2f7f0;
  --muted: #a7c2a2;
  --muted-2: #7c9a82;

  --lime: #a6ff35;
  --lime-dim: #8fe61f;
  --green-btn-a: #5bb815;
  --green-btn-b: #a6ff35;
  --danger: #ff5964;
  --warn: #ffd23f;

  --die-red: #ff5964;
  --die-orange: #ff9f45;
  --die-yellow: #ffd23f;
  --die-green: #28e07b;
  --die-blue: #3da5ff;
  --die-purple: #b06bff;

  --r-sm: 12px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.7);
  --glow-lime: 0 0 0 1px rgba(166, 255, 53, 0.25), 0 16px 40px -14px rgba(166, 255, 53, 0.35);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  height: 100%;
}
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Euclid Circular A", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(166, 255, 53, 0.10), transparent 62%),
    radial-gradient(760px 460px at 108% 4%, rgba(40, 224, 123, 0.07), transparent 58%),
    var(--bg);
  overflow-x: hidden;
}

#app {
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) 18px calc(34px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-x: clip;
}

/* screen transition */
.screen { animation: screen-in 0.42s var(--ease) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- loader ---------- */
.loader {
  margin: 32vh auto;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  color: var(--muted); font-weight: 700; letter-spacing: 0.4px;
}
.loader-dice {
  width: 58px; height: 58px; border-radius: 16px;
  background: linear-gradient(150deg, var(--lime), var(--die-green));
  animation: tumble 1.05s var(--ease) infinite;
  box-shadow: var(--glow-lime);
}
@keyframes tumble {
  0% { transform: rotate(0) scale(1); border-radius: 16px; }
  50% { transform: rotate(180deg) scale(0.78); border-radius: 30px; }
  100% { transform: rotate(360deg) scale(1); border-radius: 16px; }
}

/* ---------- primitives ---------- */
.card {
  background: var(--panel-hi);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.center { text-align: center; }

h1 { font-size: clamp(26px, 8vw, 34px); font-weight: 900; letter-spacing: -0.03em; line-height: 1.08; }
h2 { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.lead { color: var(--muted); font-size: 14px; line-height: 1.6; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.dim { color: var(--muted-2); font-size: 12px; }

.i { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
.i svg { width: 100%; height: 100%; display: block; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--stroke-2);
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  appearance: none; cursor: pointer; font-family: inherit;
  max-width: 46vw; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.between { gap: 10px; min-width: 0; }
.brand { min-width: 0; flex-shrink: 1; }
.brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill .i { color: var(--lime); }
.pill.warm .i { color: var(--warn); }

.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(180deg, var(--green-btn-a), var(--green-btn-b));
  color: #08210a;
  box-shadow: 0 8px 22px -8px rgba(166, 255, 53, 0.55);
}
.brand .logo .i { width: 22px; height: 22px; }
.brand b { font-size: 17px; font-weight: 900; letter-spacing: -0.02em; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  font-weight: 800; font-size: 15px; letter-spacing: -0.01em;
  padding: 16px 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  border: 1px solid var(--stroke-2);
  transition: transform 0.14s var(--ease-out), filter 0.14s, box-shadow 0.2s, opacity 0.15s, background 0.15s;
}
.btn .i { width: 19px; height: 19px; }
.btn:active { transform: scale(0.966); }
.btn.primary {
  background: linear-gradient(180deg, var(--green-btn-a) 0%, var(--green-btn-b) 100%);
  color: #08210a; border-color: transparent;
  box-shadow: 0 16px 36px -14px rgba(166, 255, 53, 0.5);
}
.btn.primary:active { filter: brightness(1.05); }
.btn.outline { background: transparent; border-color: var(--stroke-strong); color: var(--lime); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-sm { width: auto; padding: 10px 15px; font-size: 13px; border-radius: 11px; }

/* ---------- round picker ---------- */
.rounds { display: grid; gap: 12px; }
.round-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--r);
  background: var(--panel); border: 1.5px solid var(--stroke-2);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s var(--ease-out);
}
.round-opt:active { transform: scale(0.99); }
.round-opt.sel { border-color: var(--stroke-strong); background: rgba(166, 255, 53, 0.08); }
.round-opt .ico {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; color: var(--lime);
  background: rgba(166, 255, 53, 0.09); border: 1px solid var(--stroke);
}
.round-opt .ico .i { width: 22px; height: 22px; }
.round-opt b { font-size: 15px; font-weight: 800; }
.round-opt .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.round-opt .tick { margin-left: auto; color: var(--lime); opacity: 0; transition: opacity 0.18s; }
.round-opt .tick .i { width: 20px; height: 20px; }
.round-opt.sel .tick { opacity: 1; }

/* ---------- versus ---------- */
.versus {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px; align-items: stretch;
}
.pcard {
  min-width: 0;
  background: var(--panel); border: 1px solid var(--stroke-2);
  border-radius: var(--r); padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 9px; text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--ease), opacity 0.3s;
}
.pcard.win { border-color: var(--stroke-strong); box-shadow: var(--glow-lime); }
.pcard.lose { opacity: 0.5; }
.pcard.turn { border-color: var(--stroke-strong); }
.pcard.locked { animation: lock-pulse 0.4s var(--ease); }
@keyframes lock-pulse { 50% { transform: scale(1.03); } }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-weight: 900; font-size: 21px; color: #08210a;
  background: linear-gradient(180deg, var(--green-btn-a), var(--green-btn-b));
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 14px; border-radius: 11px; }
.pcard .pn { font-weight: 800; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .ps { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.pcard .ps.ok { color: var(--lime); }
.pcard .chip {
  margin-top: 2px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.02em;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--stroke-2); color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .swatch { width: 10px; height: 10px; border-radius: 3px; }

.mid { display: grid; place-items: center; gap: 8px; }
.mid .sc {
  font-size: 24px; font-weight: 900;
  background: var(--panel-2); border: 1px solid var(--stroke-2);
  border-radius: 12px; padding: 6px 12px; min-width: 46px;
  transition: color 0.3s, transform 0.3s var(--ease);
}
.mid .sc.bump { color: var(--lime); transform: scale(1.14); }
.mid .vs { font-size: 12px; font-weight: 800; color: var(--muted-2); letter-spacing: 0.08em; }

/* ---------- shared dice tray (always one horizontal row) ---------- */
.tray-wrap { margin-top: 4px; }
.tray-label {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 12px;
  min-height: 18px;
}
.tray-label .i { width: 15px; height: 15px; }
.dice-row {
  display: flex; flex-wrap: nowrap; gap: clamp(7px, 2.6vw, 12px);
  justify-content: center; align-items: center;
}
/* Кубик в духе bongodice: сочная плитка цвета, белая рамка, цветное свечение,
   одна белая точка — но чище и под нашу тёмно-зелёную тему. */
.die {
  --dc: #444;
  --dc-d: #222;                 /* тёмный оттенок для фаски */
  --dc-g: rgba(0, 0, 0, 0.4);   /* цвет внешнего свечения */
  width: clamp(48px, 15.5vw, 66px);
  aspect-ratio: 1;
  border-radius: clamp(13px, 3.7vw, 17px);
  border: clamp(3px, 0.95vw, 4px) solid rgba(255, 255, 255, 0.94);
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 44%),
    var(--dc);
  box-shadow:
    var(--dc-d) -0.13em -0.13em 0 0 inset,
    rgba(255, 255, 255, 0.3) 0.13em 0.13em 0 0 inset,
    var(--dc-g) 0 0.32em 1.35em 0,
    rgba(0, 0, 0, 0.5) 0 4px 10px -3px;
  display: grid;
  place-items: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s var(--ease), opacity 0.25s, filter 0.25s;
}
.die::after {
  content: '';
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff, rgba(255, 255, 255, 0.85) 55%, rgba(255, 255, 255, 0.6));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 9px rgba(255, 255, 255, 0.4);
}
.die.spin { animation: die-spin 0.32s cubic-bezier(0.5, 0, 0.5, 1) infinite; }
@keyframes die-spin {
  0%, 100% { transform: translateY(0) rotate(-8deg) scale(0.98); }
  25% { transform: translateY(-6px) rotate(7deg) scale(1.02); }
  50% { transform: translateY(4px) rotate(-5deg) scale(0.97); }
  75% { transform: translateY(-3px) rotate(6deg) scale(1.01); }
}
.die.settle { animation: die-settle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes die-settle {
  0% { transform: scale(1.3) rotate(-5deg); }
  55% { transform: scale(0.92) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}
/* кубик совпал с чьим-то цветом — свечение вспыхивает ярче, кубик чуть крупнее */
.die.hit {
  transform: scale(1.06);
  box-shadow:
    var(--dc-d) -0.13em -0.13em 0 0 inset,
    rgba(255, 255, 255, 0.34) 0.13em 0.13em 0 0 inset,
    var(--dc-g) 0 0 0.5em 0.12em,
    var(--dc-g) 0 0.3em 1.7em 0.1em,
    rgba(0, 0, 0, 0.5) 0 4px 10px -3px;
}
.die.miss { opacity: 0.44; filter: saturate(0.7); }
/* пустой кубик до броска — нейтральный, без цвета */
.die.empty {
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 44%), #182720;
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    rgba(0, 0, 0, 0.35) -0.13em -0.13em 0 0 inset,
    rgba(255, 255, 255, 0.08) 0.13em 0.13em 0 0 inset,
    rgba(0, 0, 0, 0.4) 0 4px 10px -3px;
}
.die.empty::after { background: rgba(255, 255, 255, 0.14); box-shadow: none; }

/* ---------- color picker ---------- */
.pick-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px;
  width: 100%; margin: 2px 0;
}
.swatch-btn {
  --sc: #444; --sc-d: #222; --sc-g: rgba(0, 0, 0, 0.4);
  aspect-ratio: 1; border-radius: 13px;
  border: 2px solid rgba(255, 255, 255, 0.16); cursor: pointer; position: relative;
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 46%),
    var(--sc);
  box-shadow:
    var(--sc-d) -0.11em -0.11em 0 0 inset,
    rgba(255, 255, 255, 0.28) 0.11em 0.11em 0 0 inset,
    var(--sc-g) 0 0.2em 0.6em 0;
  transition: transform 0.16s var(--ease), box-shadow 0.22s, border-color 0.22s, opacity 0.22s;
}
.swatch-btn:active { transform: scale(0.9); }
.swatch-btn.sel {
  border-color: rgba(255, 255, 255, 0.95);
  transform: translateY(-3px) scale(1.08);
  z-index: 1;
  box-shadow:
    var(--sc-d) -0.11em -0.11em 0 0 inset,
    rgba(255, 255, 255, 0.32) 0.11em 0.11em 0 0 inset,
    var(--sc-g) 0 0 0.4em 0.12em,
    var(--sc-g) 0 0.3em 1em 0.06em;
}
.swatch-btn.taken { opacity: 0.28; filter: saturate(0.7); pointer-events: none; }
.swatch-btn .lk {
  position: absolute; inset: 0; margin: auto; width: 55%; height: 55%;
  color: #fff; opacity: 0; transform: scale(0.5); transition: 0.2s var(--ease);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.swatch-btn.sel .lk { opacity: 1; transform: scale(1); }

.pick-status {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted); min-height: 20px;
}
.countdown {
  font-variant-numeric: tabular-nums; color: var(--lime); font-weight: 800;
}

/* ---------- outcome tag ---------- */
.outcome {
  margin-top: 12px; text-align: center; min-height: 20px;
  font-size: 13px; font-weight: 800; letter-spacing: 0.01em; color: var(--muted);
  transition: color 0.3s;
}
.outcome.win { color: var(--lime); }
.outcome.jackpot { color: var(--warn); }

.reroll-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: rgba(255, 210, 63, 0.12); border: 1px solid rgba(255, 210, 63, 0.3);
  color: var(--warn); font-size: 12px; font-weight: 800;
}

/* ---------- fair ---------- */
.fair { font-size: 11.5px; color: var(--muted-2); word-break: break-all; line-height: 1.65; }
.fair code { color: var(--muted); background: rgba(255, 255, 255, 0.05); padding: 1px 5px; border-radius: 5px; }
.fair .ok { color: var(--lime); font-weight: 800; }
.fair .bad { color: var(--danger); font-weight: 800; }

/* ---------- history ---------- */
.hist { display: flex; flex-direction: column; gap: 8px; }
.hline { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.hline .n { color: var(--muted-2); min-width: 20px; font-weight: 700; }
.hline .mini { display: flex; gap: 3px; }
.hline .mini i { width: 13px; height: 13px; border-radius: 3.5px; display: block; }
.hline .res { margin-left: auto; font-weight: 800; display: inline-flex; align-items: center; gap: 5px; }
.hline .res .i { width: 13px; height: 13px; }
.hline .res.j { color: var(--warn); }
.hline .res.w { color: var(--lime); }

/* ---------- rules screen ---------- */
.btn.btn-inline { width: auto; align-self: flex-start; padding: 9px 14px; font-size: 13px; color: var(--lime); }
.pill.icon-only { padding: 8px; }
.pill.icon-only .i { width: 15px; height: 15px; color: var(--lime); }
.rule-step .step-n {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
  background: rgba(166, 255, 53, 0.12); color: var(--lime);
}
.rules-dice { margin-top: 4px; justify-content: flex-start; gap: 8px; }
.rules-dice .die { width: clamp(40px, 12vw, 50px); }

/* ---------- game history (profile) ---------- */
.games { display: flex; flex-direction: column; gap: 8px; }
.game-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--r-sm);
  background: var(--panel); border: 1px solid var(--stroke-2);
}
.game-row .grow > div:first-child { font-size: 13.5px; }
.g-badge {
  width: 28px; height: 28px; flex: none; border-radius: 9px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
}
.g-badge.w { background: rgba(166, 255, 53, 0.16); color: var(--lime); }
.g-badge.l { background: rgba(255, 89, 100, 0.14); color: var(--danger); }
.g-badge.d { background: rgba(255, 210, 63, 0.14); color: var(--warn); }
.g-score { font-weight: 800; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- profile ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--stroke-2);
  border-radius: var(--r); padding: 14px 16px;
}
.stat .v { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.stat .k { font-size: 11.5px; color: var(--muted); margin-top: 3px; font-weight: 600; }
.stat .v .i { width: 18px; height: 18px; color: var(--warn); vertical-align: -2px; }

.level-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.level-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--green-btn-a), var(--green-btn-b));
  transition: width 0.6s var(--ease);
}
.fav-color { display: inline-flex; align-items: center; gap: 8px; }
.fav-color .sw { width: 16px; height: 16px; border-radius: 5px; }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 8, 6, 0.76); backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: grid; place-items: center; padding: 26px;
  animation: fade 0.22s ease;
}
@keyframes fade { from { opacity: 0; } }
.overlay .box {
  background: var(--panel-2); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-lg); padding: 26px; width: 100%; max-width: 380px;
  text-align: center; box-shadow: var(--shadow);
  animation: rise 0.34s var(--ease);
}
@keyframes rise { from { transform: translateY(26px) scale(0.95); opacity: 0; } }
.overlay .ic {
  width: 66px; height: 66px; margin: 0 auto 6px;
  display: grid; place-items: center; border-radius: 20px;
  background: rgba(166, 255, 53, 0.1); color: var(--lime);
}
.overlay .ic .i { width: 34px; height: 34px; }
.overlay .ic.warm { background: rgba(255, 210, 63, 0.12); color: var(--warn); }
.overlay .big { font-size: 27px; font-weight: 900; margin: 8px 0 4px; letter-spacing: -0.02em; }

/* ---------- fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti { position: absolute; width: 9px; height: 15px; border-radius: 2px; will-change: transform; }

/* ---------- spectator ---------- */
.spectator {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(166, 255, 53, 0.09); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 12.5px; font-weight: 700;
  color: var(--lime);
}
.spectator .i { width: 16px; height: 16px; }

.link-box {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--stroke-2);
  border-radius: 12px; padding: 12px 14px; font-size: 12px; color: var(--muted);
}
.link-box span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.link-box .i { color: var(--lime); flex: none; }

.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%);
  z-index: 90; max-width: 88%;
  background: var(--panel-2); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-pill); padding: 10px 18px;
  font-size: 13px; font-weight: 700; color: var(--text);
  box-shadow: var(--shadow); animation: toast-in 0.3s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -12px); } }

/* light theme (Telegram) — jabka всё равно тёмный, лишь чуть мягче */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #0d1712; --text: #f2f7f0;
  }
}
