/* js/demo_game/demo_game_base.css */

/* Панель под доской */
.players-panel{
  max-width: min(1200px, 100%);
  margin: 16px auto 0;
  background: linear-gradient(180deg, rgba(7,11,30,.90), rgba(7,11,30,.86));
  border: 1px solid var(--panel-bd);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

/* Лента карточек: центр и авто-колонки */
.players-list{
  list-style: none; margin: 0; padding: 0;

  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  justify-content: center;
  align-items: stretch;
}

/* Карточка игрока */
.player-row{
  position: relative; /* для inline-ответов */
  display: grid;
  grid-template-columns: 46px 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "ava name"
    "ava score";
  column-gap: 12px;
  row-gap: 6px;

  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(2px);
}

/* Аватар — всегда идеальный круг */
.player-avatar-wrap{
  grid-area: ava;
  align-self: center;

  position: relative;
  width: 46px; height: 46px;
  border-radius: 50% !important;
  overflow: hidden;
  display: block;
  background: #1e234f;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  box-sizing: border-box;
}

/* Абсолютно центрированное изображение */
.player-avatar{
  position: absolute; left: 50%; top: 50%;
  width: 100%; height: 100%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  object-position: 50% 50%;
  display: block; margin: 0; padding: 0; border: 0;
  image-rendering: auto;
}

/* Fallback буква */
.player-avatar-fallback{
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-weight: 900; font-size: 16px; line-height: 1; color: #fff;
  user-select: none;
}

/* Лёгкая «аура» вокруг собственного аватара (видна только у self, см. разметку) */
.buzz-pulse{
  position: absolute; inset: -6px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(60% 60% at 50% 50%, rgba(227,255,136,.20), transparent 70%);
  filter: blur(12px);
  opacity: .65;
  animation: demo-buzz-pulse 2.4s ease-in-out infinite;
}
@keyframes demo-buzz-pulse{
  0%,100%{ transform: scale(1); opacity: .50; }
  50%    { transform: scale(1.03); opacity: .90; }
}

/* Имя + бейджи */
.player-name{
  grid-area: name;
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-weight: 800;
  letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
  min-height: 1.25em; /* выравнивает линию очков */
  justify-content: center;
}

.buzz-badge{
  display: inline-flex; align-items: center; justify-content: center;
  height: 20px; padding: 0 6px;
  border-radius: 6px;
  font-size: 12px; font-weight: 800;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  color: #fff;
}
.badge-first   { background: #ffe76a; color: #1a1a1a; border-color: #ffe76a; }
.badge-correct { background: #6bff85; color: #102215; border-color: #6bff85; }
.badge-wrong   { background: #ff7a7a; color: #2a0d12; border-color: #ff7a7a; }

/* Очки — под именем, центр, табличные цифры */
.player-score{
  grid-area: score;
  align-self: start;
  text-align: center;
  min-width: 48px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #ffe86a;
}

/* Inline-ответы (демо: геометрия и стиль; логика позже) */
.answer-inline-global,
.answer-display-global{
  position: absolute;
  left: 52px; right: 12px; top: -6px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}

/* Форма отправки ответа */
.answer-inline__row{ display: flex; gap: 8px; }
.answer-inline__input{
  flex: 1; min-width: 0;
  height: 36px; border-radius: 10px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: #fff; outline: none;
}
.answer-inline__input::placeholder{ color: rgba(255,255,255,.6); }
.answer-inline__submit{
  height: 36px; padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--info);
  background: var(--info);
  color: #fff; font-weight: 800; cursor: pointer;
}
.answer-display__text{ font-weight: 800; }

/* Прячет блоки по атрибутам */
.answer-inline-global[data-open="false"],
.answer-display-global[data-open="false"]{ display: none; }

/* Фокус-видимость для кликабельных областей (a11y) */
.player-avatar-wrap:focus-visible,
.answer-inline__input:focus-visible,
.answer-inline__submit:focus-visible{
  outline: 2px solid color-mix(in srgb, var(--info) 80%, #fff);
  outline-offset: 2px;
}

/* Чуть компактнее на очень узких экранах */
@media (max-width: 480px){
  .players-panel{ padding: 10px; }
  .players-list{ gap: 10px; }
  .player-row{ padding: 6px 10px; }
}

/* Вежливость к reduced motion */
@media (prefers-reduced-motion: reduce){
  .buzz-pulse{ animation: none !important; }
}




/* =========================================================
   PLAYER ANSWER FEEDBACK (enhanced)
   ========================================================= */

:root {
  --answer-correct-ms: 5000ms; /* длительность зелёной вспышки */
  --answer-wrong-ms:   2000ms; /* длительность красной вспышки */
}

/* ——— Правильный ответ ——— */
.player-row.correct,
.player-row.is-correct {
  animation: player-correct-blink var(--answer-correct-ms) cubic-bezier(.22,.61,.36,1) forwards;
}

/* ——— Неправильный ответ ——— */
.player-row.wrong,
.player-row.is-wrong {
  animation: player-wrong-blink var(--answer-wrong-ms) cubic-bezier(.22,.61,.36,1) forwards;
}

/* Общие параметры для обеих вспышек */
.player-row.correct,
.player-row.is-correct,
.player-row.wrong,
.player-row.is-wrong {
  position: relative;
  z-index: 2;
  animation-fill-mode: both;
  will-change: background-color, box-shadow;
}

/* контейнер не должен обрезать свечение */
.players-list {
  overflow: visible !important;
}

/* ——— Зелёная вспышка (правильный ответ) ——— */
@keyframes player-correct-blink {
  0% {
    box-shadow: 0 0 0 rgba(0,255,100,0);
    background-color: transparent;
  }
  20% {
    box-shadow: 0 0 24px rgba(0,255,100,0.75);
    background-color: rgba(0,255,100,0.15);
  }
  70% {
    box-shadow: 0 0 24px rgba(0,255,100,0.75);
    background-color: rgba(0,255,100,0.15);
  }
  100% {
    box-shadow: 0 0 0 rgba(0,255,100,0);
    background-color: transparent;
  }
}

/* ——— Красная вспышка (неправильный ответ) ——— */
@keyframes player-wrong-blink {
  0% {
    box-shadow: 0 0 0 rgba(255,0,0,0);
    background-color: transparent;
  }
  20% {
    box-shadow: 0 0 24px rgba(255,0,0,0.75);
    background-color: rgba(255,0,0,0.15);
  }
  70% {
    box-shadow: 0 0 24px rgba(255,0,0,0.75);
    background-color: rgba(255,0,0,0.15);
  }
  100% {
    box-shadow: 0 0 0 rgba(255,0,0,0);
    background-color: transparent;
  }
}