/* ==========================================================================
   Boccia Mini Game — стили в духе темы Boccia Russia
   ========================================================================== */

.boccia-game-wrapper {
  --bg: #ffffff;
  --blue: #0039A6;
  --blue-dark: #002b7f;
  --blue-light: #e8f0fe;
  --red: #D52B1E;
  --red-dark: #b01f15;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-500: #6c757d;
  --gray-700: #343a40;
  --gray-900: #212529;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(0, 57, 166, 0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  font-family: var(--font);
  color: var(--gray-900);
  max-width: 780px;
  margin: 0 auto 48px;
  padding: 0 12px;
  position: relative;
}

.boccia-game-header {
  text-align: center;
  margin-bottom: 20px;
}

.boccia-game-title {
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 8px;
  line-height: 1.25;
}

.boccia-game-desc {
  font-size: 0.95rem;
  color: var(--gray-500);
  margin: 0 auto;
  max-width: 540px;
  line-height: 1.5;
}

/* Основной блок: поле + статы справа */
.boccia-game-main {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
  width: 100%;
}

/* Статистика — колонка справа */
.boccia-game-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 96px;
  width: 96px;
  margin: 0;
}

.boccia-stat {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  transition: border-color 0.2s ease;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.boccia-stat:hover {
  border-color: var(--blue);
}

.boccia-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.boccia-stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.2;
}

/* Поле — строго по размеру canvas, без полос по бокам */
.boccia-game-field-wrap {
  position: relative;
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  background: transparent;
  border: 3px solid var(--blue);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  line-height: 0;
  font-size: 0;
}

#boccia-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  vertical-align: top;
  cursor: crosshair;
}

/* Полоса силы */
.boccia-power-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(220px, 50%);
  height: 10px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  border: 1px solid rgba(0, 57, 166, 0.25);
}

.boccia-power-bar.visible {
  opacity: 1;
}

.boccia-power-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--red));
  border-radius: 20px;
  transition: width 0.05s linear;
}

/* Кнопки */
.boccia-game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.boccia-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
  min-height: 44px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.boccia-btn:active {
  transform: scale(0.97);
}

.boccia-btn:focus-visible {
  outline: 3px solid rgba(0, 57, 166, 0.45);
  outline-offset: 2px;
}

.boccia-btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(0, 57, 166, 0.22);
}

.boccia-btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  box-shadow: 0 4px 14px rgba(0, 57, 166, 0.32);
}

.boccia-btn-red {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 2px 8px rgba(213, 43, 30, 0.22);
}

.boccia-btn-red:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  box-shadow: 0 4px 14px rgba(213, 43, 30, 0.32);
}

.boccia-btn-outline {
  background: #fff;
  color: var(--blue);
  border: 2px solid var(--blue);
  box-shadow: none;
}

.boccia-btn-outline:hover {
  background: var(--blue-light);
  color: var(--blue-dark);
  border-color: var(--blue-dark);
}

/* Подсказка */
.boccia-game-hint {
  text-align: center;
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 14px;
  line-height: 1.45;
}

/* Оверлей конца раунда */
.boccia-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 26, 77, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: var(--radius);
  animation: bocciaFadeIn 0.3s ease;
}

.boccia-overlay[hidden] {
  display: none;
}

.boccia-overlay-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: bocciaSlideUp 0.35s ease;
}

.boccia-overlay-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.boccia-overlay-card h3 {
  font-size: 1.25rem;
  margin: 0 0 8px;
  color: var(--gray-900);
}

.boccia-overlay-card p {
  font-size: 0.95rem;
  color: var(--gray-500);
  margin: 0 0 20px;
  line-height: 1.45;
}

@keyframes bocciaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bocciaSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Адаптив */
@media (max-width: 780px) {
  .boccia-game-wrapper {
    max-width: 100%;
  }

  .boccia-game-main {
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .boccia-game-wrapper {
    padding: 0 8px;
    margin-bottom: 28px;
    max-width: 100%;
  }

  .boccia-game-main {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .boccia-game-field-wrap {
    width: fit-content;
    max-width: calc(100vw - 24px);
    margin-left: auto;
    margin-right: auto;
    border-width: 2px;
    background: transparent;
  }

  #boccia-canvas {
    max-width: calc(100vw - 28px);
  }

  .boccia-game-stats {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: 360px;
    flex: 0 0 auto;
    gap: 8px;
  }

  .boccia-stat {
    padding: 10px 6px;
    flex: 1 1 calc(50% - 8px);
    min-height: 56px;
  }

  .boccia-stat-value {
    font-size: 1.1rem;
  }

  .boccia-game-controls {
    width: 100%;
    max-width: 360px;
  }

  .boccia-btn {
    flex: 1 1 auto;
  }

  .boccia-btn {
    padding: 11px 18px;
    font-size: 0.9rem;
    flex: 1 1 auto;
  }

  .boccia-game-controls {
    gap: 8px;
  }
}

/* Уважение к prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .boccia-overlay,
  .boccia-overlay-card,
  .boccia-btn {
    animation: none;
    transition: none;
  }
}

/* ==========================================================================
   Режим theme="hero" — справа от текста в синем hero
   ========================================================================== */
.boccia-game-wrapper.boccia-game--hero {
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  color: #ffffff;
}

.boccia-game--hero .boccia-game-header {
  margin-bottom: 8px;
}

.boccia-game--hero .boccia-game-title {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.2);
  margin-bottom: 0;
}

.boccia-game--hero .boccia-game-desc {
  display: none;
}

.boccia-game--hero .boccia-game-main {
  gap: 10px;
  margin-bottom: 10px;
}

.boccia-game--hero .boccia-game-stats {
  flex: 0 0 88px;
  width: 88px;
  gap: 6px;
  margin: 0;
}

.boccia-game--hero .boccia-stat {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  padding: 10px 6px;
}

.boccia-game--hero .boccia-stat:hover {
  border-color: rgba(255, 255, 255, 0.45);
}

.boccia-game--hero .boccia-stat-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.62rem;
}

.boccia-game--hero .boccia-stat-value {
  color: #ffffff;
  font-size: 1.05rem;
}

.boccia-game--hero .boccia-game-field-wrap {
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  background: transparent;
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  line-height: 0;
}

.boccia-game--hero .boccia-game-controls {
  margin-top: 10px;
  gap: 8px;
}

.boccia-game--hero .boccia-btn {
  padding: 10px 18px;
  font-size: 0.875rem;
  min-height: 42px;
  border-radius: 10px;
}

.boccia-game--hero .boccia-btn-primary {
  background: #ffffff;
  color: #0039A6;
  border-color: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.boccia-game--hero .boccia-btn-primary:hover {
  background: #f0f4ff;
  border-color: #f0f4ff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.boccia-game--hero .boccia-btn-outline {
  background: transparent;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: none;
}

.boccia-game--hero .boccia-btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: #ffffff;
}

.boccia-game--hero .boccia-btn:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.boccia-game--hero .boccia-game-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  margin-top: 8px;
}

.boccia-game--hero .boccia-overlay {
  background: rgba(0, 20, 60, 0.65);
  border-radius: 12px;
}

/* Колонка с игрой в hero-grid — чуть левее */
.hero-game {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 760px;
  margin-left: 8px;
  display: flex;
  justify-content: center;
}

.hero-game .boccia-game-wrapper {
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 1100px) {
  .hero-game {
    margin-left: 12px;
  }
}

.boccia-game--hero .boccia-game-field-wrap {
  max-height: none;
}

.boccia-game--hero #boccia-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}

.boccia-game--hero .boccia-game-main {
  justify-content: center;
  align-items: stretch;
}

.hero-game .boccia-game-wrapper {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .hero-game {
    max-width: 100%;
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }

  .boccia-game-wrapper.boccia-game--hero {
    margin-top: 8px;
    max-width: 100%;
  }

  .boccia-game--hero .boccia-game-main {
    flex-direction: column;
    align-items: center;
  }

  .boccia-game--hero .boccia-game-field-wrap {
    width: fit-content;
    max-width: calc(100vw - 24px);
    margin-left: auto;
    margin-right: auto;
    background: transparent;
  }

  .boccia-game--hero #boccia-canvas {
    max-width: calc(100vw - 28px);
  }

  .boccia-game--hero .boccia-game-stats {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: 360px;
    flex: 0 0 auto;
  }

  .boccia-game--hero .boccia-stat {
    flex: 1 1 calc(50% - 6px);
  }

  .boccia-game--hero .boccia-game-controls {
    width: 100%;
    max-width: 360px;
  }
}

@media (max-width: 600px) {
  .boccia-game--hero .boccia-stat-value {
    font-size: 1rem;
  }
}
