/* Мобильные стили (до 899px включительно) */
@media (max-width: 899px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .game-container {
    max-width: 100%;
    height: 100dvh;
    padding: 8px;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .game-board {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
  }

  .side-panel.left-panel {
    display: flex;
    flex-direction: row;
    gap: 6px;
    width: 100%;
    flex-shrink: 0;
  }

  /* --- КАРТОЧКИ ИГРОКОВ --- */
  .player-card {
    padding: 6px 8px;
  }

  .player-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .score {
    font-size: clamp(20px, 5.5vw, 24px);
    line-height: 1.1;
  }

  .score-max {
    font-size: 16px;
    font-weight: 600;
  }

  .stat-label {
    font-size: 13px;
    font-weight: 400;
  }

  .stat-value {
    font-size: 14px;
    font-weight: 700;
  }

  /* --- ИГРОВОЙ СТОЛ (Забирает всё свободное место) --- */
  .table {
    padding: 12px 8px;
    gap: 36px;
    /* flex: 1; Зеленый стол плавно растягивается на высоту экрана */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .ai-section .section-title {
    margin-bottom: 24px; 
  }

  .section-title {
    font-size: 12px;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
  }

  .status-message {
    font-size: 13px;
    font-weight: 600;
    min-height: 56px;
    padding: 4px 8px;
    line-height: 1.2;
  }

  /* Кубики */
  .dice-container {
    gap: 4px;
  }

  .die {
    width: 48px;
    height: 48px;
  }

  .pip {
    width: 8px;
    height: 8px;
  }

  .die-info-panel {
    height: 84px;           /* Фиксированная высота всей карточки */
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;       /* Сама карточка не скроллится */
  }

  .die-info-title {
    flex-shrink: 0;         /* Заголовок НАМЕРТВО зафиксирован и не уезжает */
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 3px;
  }

  .die-info-desc {
    flex: 1;                /* Описание занимает всю оставшуюся высоту */
    min-height: 0;          /* Позволяет флексу правильно сжиматься */
    overflow-y: auto;       /* Скроллится ТОЛЬКО текст описания, если не влезает */
    font-size: 11.5px;
    line-height: 1.25;
  }

  /* --- ЛОГ И КНОПКИ (Сидят плотно внизу без дыр) --- */
  .side-panel.right-panel {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    flex:1;
    min-height: 0;
    /* flex-shrink: 0; Запрещаем нижней панели растягиваться впустую */
  }

  /* Лог умеренной высоты (на 5-6 строчек) */
  .game-log {
    flex: 1;
    min-height: 0;     /* КЛЮЧЕВАЯ СТРОКА: запрещает логу раздуваться от количества строк */
    overflow-y: auto;  /* Включает внутренний скролл при переполнении */
    font-size: 12px;
    line-height: 1.3;
  }

  .controls {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-shrink: 0;
  }

  .controls .btn {
    padding: 10px 4px;
    font-size: clamp(11px, 3.2vw, 13px);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .controls .btn.btn-icon {
    flex: 0 0 40px;
    font-size: 18px;
  }
}

/* Спец-стили для очень коротких экранов (меньше 640px по высоте) */
@media (max-width: 899px) and (max-height: 640px) {
  .die { width: 42px; height: 42px; }
  .table { padding: 6px; gap: 6px; }
  .die-info-panel { height: 56px; min-height: 56px; max-height: 56px; }
  .game-log { height: 75px; }
}