.yz-dice {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 14px);
}

.yz-die {
  display: grid;
  grid-template: repeat(3, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr));
  gap: 3px;
  width: clamp(48px, 14vw, 64px);
  aspect-ratio: 1;
  padding: clamp(7px, 2vw, 10px);
  border: 2px solid transparent;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 #cbd5e1, 0 6px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s, border-color 0.15s;
}

.yz-die:disabled {
  cursor: default;
}

.yz-die i {
  border-radius: 50%;
}

.yz-die i.on {
  background: #111827;
}

.yz-die.blank i.on {
  background: #cbd5e1;
}

.yz-die.held {
  border-color: var(--accent);
  transform: translateY(-8px);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 10px 16px rgba(0, 0, 0, 0.2);
}

.yz-die.rolling {
  animation: yz-roll 0.8s cubic-bezier(0.25, 0.8, 0.35, 1);
}

.yz-table {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.yz-table th,
.yz-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}

.yz-table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.yz-table tbody th {
  font-weight: 600;
  text-align: left;
}

.yz-table small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.yz-table td {
  width: 72px;
  font-weight: 700;
  text-align: center;
}

.yz-table td.fresh {
  color: var(--accent);
}

.yz-table tr.sub th,
.yz-table tr.sub td {
  background: var(--surface-2);
  font-size: 0.85rem;
}

.yz-table tr.total th,
.yz-table tr.total td {
  border-bottom: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.yz-pick {
  width: 100%;
  padding: 0;
  line-height: 1.5;
  border: 1px dashed var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.yz-pick.zero {
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
}

.yz-pick:hover {
  background: var(--accent);
  color: #fff;
}

@keyframes yz-roll {
  0% {
    transform: translateY(-8px) rotate(-450deg);
  }
  75% {
    transform: translateY(1px) rotate(6deg);
  }
  100% {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .yz-die.rolling {
    animation: none;
  }
}

/* копия шапки таблицы нужна только в двухколоночном виде на телефоне */
.yz-table tr.yz-dup {
  display: none;
}

/* телефон */
@media (max-width: 640px) {
  .game-stage {
    gap: 10px;
  }

  .yz-dice .yz-die.held {
    transform: translateY(-5px);
  }
}

/* невысокий телефон (таблица в одну колонку не помещается под костями): таблица очков
   в две колонки — верхняя секция слева, нижняя справа, — и кости, «Бросить» и вся таблица
   видны вместе */
@media (max-width: 640px) and (max-height: 800px) {
  .yz-table {
    display: block;
    max-width: none;
    font-size: 0.8rem;
  }

  .yz-table thead,
  .yz-table tbody {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 10px;
  }

  .yz-table tbody {
    grid-auto-flow: column;
    grid-template-rows: repeat(8, auto);
  }

  /* нижняя секция (с «Тройки» по «Итого») — во второй колонке */
  .yz-table tbody tr:nth-child(n + 8) {
    grid-column: 2;
  }

  .yz-table tbody tr:nth-child(8) { grid-row: 1; }
  .yz-table tbody tr:nth-child(9) { grid-row: 2; }
  .yz-table tbody tr:nth-child(10) { grid-row: 3; }
  .yz-table tbody tr:nth-child(11) { grid-row: 4; }
  .yz-table tbody tr:nth-child(12) { grid-row: 5; }
  .yz-table tbody tr:nth-child(13) { grid-row: 6; }
  .yz-table tbody tr:nth-child(14) { grid-row: 7; }
  .yz-table tbody tr:nth-child(15) { grid-row: 8; }

  .yz-table tr,
  .yz-table thead tr.yz-dup {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-columns: 34px;
    grid-auto-flow: column;
    align-items: center;
    border-bottom: 1px solid var(--border);
  }

  .yz-table th,
  .yz-table td {
    padding: 3px 2px;
    border-bottom: 0;
  }

  .yz-table tbody th {
    padding-left: 4px;
    line-height: 1.15;
  }

  .yz-table td {
    width: auto;
  }

  .yz-table thead th {
    font-size: 0.72rem;
  }

  /* подсказки к строкам есть в правилах, в узкой колонке им нет места */
  .yz-table small {
    display: none;
  }

  .yz-table tr.sub,
  .yz-table tr.sub th,
  .yz-table tr.sub td {
    font-size: 0.78rem;
  }

  .yz-table tr.sub {
    background: var(--surface-2);
  }

  .yz-table tr.total th,
  .yz-table tr.total td {
    font-size: 1rem;
  }

  .yz-pick {
    min-height: 28px;
  }
}
