* {
  box-sizing: border-box;
}

* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, #0d1f0d 0%, #1a2e1a 50%, #0f2818 100%);
  color: #fff;
  min-height: 100vh;
  user-select: none;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  
}

.screen {
  display: none;
  height: 100vh;
  flex-direction: column;
  align-items: center;
}

.screen.active { 
  display: flex; 
}

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 16px 20px;
  background: #2b3d25;
}

.level-title {
  font-size: 22px;
  font-weight: bold;
  color: #f5c842;
}

.coins-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #053215;
  padding: 8px 14px;
  border-radius: 20px;
  font-weight: bold;
}

.coins-display::before {
  content: "💰";
  font-size: 18px;
}

/* ===== BOARD ===== */
.board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  align-content: center;
  gap: 8px 16px;
  padding: 10px 15px;
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 500px;
}

.word {
  display: flex;
  gap: 4px;
}

.cell {
  width: 36px;
  height: 36px;
  background: #484f46;
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  /*font-weight: 900;*/                      /* Максимальная жирность */
  font-size: 18px;                       /* Чуть крупнее */
  /*-webkit-text-stroke: 1px #142618;*/         /* Чёрная обводка */
  /*text-stroke: 1px #0d250d;*/
}

.word.solved .cell {
  background: #4a7c59;
}

/* ===== GAME AREA (кнопки по бокам) ===== */
/* ===== GAME AREA (кнопки по бокам) ===== */
.game-area {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Раздвигаем к краям */
  width: 100%;
  max-width: 500px; /* Ограничиваем ширину */
  padding: 0 20px;
  margin-bottom: 30px;
}

.side-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: -250px; /* Поднимаем кнопки выше */
}

.side-controls.left {
  align-items: flex-start;
}

.side-controls.right {
  align-items: flex-end;
}

/* ===== CONTROLS ===== */
.btn-control {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  position: relative;
}

.btn-shuffle {
  background: #35d2bd;
  color: #fff;
}

.btn-hint {
  background: #f0be28;
  color: #1a1d2e;
}

.btn-hint-word {
  background: #3993f3;
  color: #1a1d2e;
}

.btn-control .cost {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #1a3d1a;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid currentColor;
}

.btn-hint .cost {
  border-color: #f5c842;
  color: #f5c842;
}

.btn-hint-word .cost {
  border-color: #42c5f5;
  color: #42c5f5;
}

/* ===== CIRCLE ===== */
.circle-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;              /* Центрирует по горизонтали */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.circle {
  position: absolute;
  width: 200px;
  height: 200px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.letter {
  position: absolute;
  width: 44px;
  height: 44px;
  background: #fff;
  color: #1a1d2e;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.1s, background 0.1s;
  z-index: 20;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  font-weight: 900;                      /* Максимальная жирность */
  font-size: 22px;  
}

.letter.active {
  background: #f5c842;
  transform: scale(1.1);
}

svg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;     /* Чуть ниже букв */
  isolation: isolate;
}

/* ===== MENU SCREEN ===== */
#screen-menu {
  justify-content: center;
  gap: 20px;
}

#screen-menu h1 {
  font-size: 28px;
  color: #f5c842;
  text-align: center;
}

.btn-play {
  padding: 16px 48px;
  font-size: 20px;
  font-weight: bold;
  border: none;
  border-radius: 30px;
  background: #f5c842;
  color: #1a2e1a;
  cursor: pointer;
}

/* ===== FINISH SCREEN ===== */
#screen-finish {
  justify-content: center;
  gap: 20px;
}

#screen-finish h2 {
  font-size: 28px;
  color: #f5c842;
}

.btn-next {
  padding: 14px 40px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 25px;
  background: #f5c842;
  color: #1c2e1a;
  cursor: pointer;
}

/* ===== BONUS SYSTEM ===== */
.bonus-panel {
  position: absolute;
  top: 17px;
  right: 100px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(114, 219, 112, 0.3);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  z-index: 100;
}

.bonus-panel:hover,
.bonus-panel:active {
  transform: scale(1.05);
  background: rgba(147, 112, 219, 0.5);
}

.bonus-icon {
  font-size: 18px;
}

#bonus-count {
  font-weight: bold;
  color: #dda0dd;
  min-width: 16px;
  text-align: center;
}

.bonus-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #9370db, #ba55d3);
  color: white;
  padding: 20px 40px;
  border-radius: 25px;
  font-size: 22px;
  font-weight: bold;
  box-shadow: 0 8px 40px rgba(147, 112, 219, 0.6);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.bonus-toast.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.bonus-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.bonus-modal.show {
  opacity: 1;
  visibility: visible;
}

.bonus-modal-content {
  background: #2a3d25;
  padding: 30px;
  border-radius: 25px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.bonus-modal.show .bonus-modal-content {
  transform: scale(1);
}

.bonus-modal-content h3 {
  margin: 0 0 20px 0;
  color: #dda0dd;
  font-size: 22px;
}

.bonus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 25px;
  max-height: 200px;
  overflow-y: auto;
}

.bonus-word {
  background: rgba(147, 112, 219, 0.3);
  padding: 8px 16px;
  border-radius: 15px;
  font-size: 16px;
  color: #fff;
  font-weight: bold;
  animation: slideIn 0.3s ease forwards;
}

.bonus-empty {
  color: #888;
  font-style: italic;
  padding: 20px;
}

.btn-close-bonus {
  background: linear-gradient(135deg, #9370db, #ba55d3);
  color: white;
  border: none;
  padding: 12px 35px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-close-bonus:hover,
.btn-close-bonus:active {
  transform: scale(1.05);
}

.bonus-word.found {
  background: rgba(76, 175, 80, 0.4);
}

/* ===== TOASTS ===== */
.coins-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  padding: 25px 40px;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 8px 40px rgba(231, 76, 60, 0.5);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.coins-toast.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.coins-toast-icon {
  font-size: 40px;
}

.reward-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: white;
  padding: 25px 40px;
  border-radius: 25px;
  font-size: 22px;
  font-weight: bold;
  box-shadow: 0 8px 40px rgba(155, 89, 182, 0.6);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.reward-toast.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.repeat-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #4a7c59, #5a9c69);
  color: white;
  padding: 20px 35px;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 8px 40px rgba(74, 124, 89, 0.5);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  text-align: center;
}

.repeat-toast.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.repeat-toast-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}

/* ===== AD BUTTON ===== */
.btn-ad {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
  position: relative;
}

.btn-ad .reward {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #1a1d2e;
  color: #9b59b6;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid #9b59b6;
}

.btn-ad:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== ANIMATIONS ===== */
@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes coinPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.coins-display.pulse {
  animation: coinPulse 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.shake {
  animation: shake 0.5s ease;
}

@keyframes wrongShake {
  0%, 100% {
    transform: translateX(0);
    background: #e74c3c;
  }
  20% {
    transform: translateX(-12px);
  }
  40% {
    transform: translateX(12px);
  }
  60% {
    transform: translateX(-8px);
  }
  80% {
    transform: translateX(8px);
  }
}

.letter.wrong {
  animation: wrongShake 0.5s ease forwards;
}

@keyframes alreadySolved {
  0%, 100% { 
    transform: scale(1);
    box-shadow: none;
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(74, 124, 89, 0.8);
  }
}

.word.already-solved-flash .cell {
  animation: alreadySolved 0.6s ease;
  background: #5a9c69;
}

.cell.hint-revealed {
  animation: pop 0.3s ease forwards;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .game-area {
    gap: 10px;
  }
  
  .btn-control {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .circle-wrap {
    width: 180px;
    height: 180px;
  }
  
  .letter {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
}

@media (max-height: 700px) {
  .board {
    gap: 6px 12px;
    max-height: calc(100vh - 320px);
  }
  
  .cell {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  
  .game-area {
    gap: 15px;
    margin-bottom: 20px;
  }
  
  .circle-wrap {
    width: 180px;
    height: 180px;
  }
  
  .letter {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  
  .btn-control {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

@media (max-height: 600px) {
  .board {
    gap: 4px 10px;
    max-height: calc(100vh - 280px);
  }
  
  .cell {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
  
  .circle-wrap {
    width: 160px;
    height: 160px;
  }
  
  .letter {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }
  
  .btn-control {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  
  .side-controls {
    gap: 10px;
  }
}

@media (min-width: 600px) {
  .board {
    max-width: 700px;
    gap: 10px 24px;
  }
  
  .cell {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

/* ===== КНОПКА РЕКЛАМЫ (открыть слово) ===== */
.btn-ad {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
  position: relative;
}

.btn-ad::after {
  content: "AD";
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #1a1d2e;
  color: #9b59b6;
  font-size: 15px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 8px;
  border: 2px solid #9b59b6;
}

.btn-ad:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}