@font-face {
  font-family: 'Sans';
  src: url('./Sans.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #009900;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: 'Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

/* Поддержка safe-area для iOS */
@supports (padding: env(safe-area-inset-top)) {
  html, body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

#game-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #009900;
  overflow: hidden;
  touch-action: none;
}

#game-root {
  position: absolute;
  width: 1280px;
  height: 720px;
  transform-origin: top left;
  overflow: hidden;
  -webkit-user-drag: none;
  user-select: none;
  background: #009900;
  touch-action: none;
}

#game-root * {
  -webkit-user-drag: none;
  user-select: none;
}

.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#bg {
  position: absolute;
  inset: 0;
  background: #009900;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px;
  box-sizing: border-box;
}

#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
  z-index: 10;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  padding-left: 140px;
}

/* coins-moves-container больше не используется */

#coins-box {
  z-index: 15002;
  min-width: 126px;
  padding: 8px 10px;
  background-image: url('./bb.png');
  background-size: 103.5% 100%;
  background-repeat: no-repeat;
  background-position: calc(50% + 10px) center;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  position: fixed;
  top: 18px;
  left: 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#coins-box.clickable-box:hover {
  filter: brightness(1.1);
}

.coins-plus {
  position: absolute;
  left: 45px;
  bottom: -19px;
  color: #ffffff;
  font-size: 29px;
  font-weight: 900;
  text-shadow: 0 0 4px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.3);
  animation: coinsPlusShine 2s ease-in-out infinite;
}

@keyframes coinsPlusShine {
  0%, 100% {
    text-shadow: 0 0 4px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.3);
    opacity: 1;
  }
  50% {
    text-shadow: 0 0 12px rgba(255,255,255,1), 0 0 20px rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.3);
    opacity: 1;
  }
}

#level-title {
  flex: 1;
  display: flex;
  justify-content: center;
}

#deck-area {
  margin-left: auto;
  margin-right: 80px;
}

.coins-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
}

#coins-value {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  margin-left: 50px;
}

#level-title {
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  min-width: 140px;
}

#moves-box {
  min-width: 110px;
  padding: 8px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: fixed !important;
  top: 73px !important;
  left: 18px !important;
  background: transparent;
  z-index: 10;
}

#moves-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('./hod.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 0;
  transform: scale(1.30) translateY(5px);
}

.moves-title {
  font-size: 13.65px;
  color: #ffffff;
  margin-top: -5%;
  position: relative;
  z-index: 1;
}

#moves-value {
  position: relative;
  z-index: 1;
  font-size: 18.9px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  transition: color 0.3s ease;
}

#moves-value.low-moves {
  color: #f39c12;
}

#moves-value.critical-moves {
  color: #e74c3c;
  animation: pulseRed 0.5s ease-in-out infinite;
}

@keyframes pulseRed {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

#deck-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

#category-slots-container {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 30px;
}

#category-slots {
  display: flex;
  gap: 18px;
}

.category-slot {
  flex: 0 0 94px;
  width: 94px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-slot {
  width: 100%;
  height: 100%;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.4;
}

.koron-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

#deck-area {
  display: flex;
  gap: 8px;
  align-items: center;
}

.deck-pile {
  width: 77px;
  height: 102px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

#deck {
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.1s;
  overflow: hidden;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#deck:hover {
  transform: scale(1.05);
}

#deck:active {
  transform: scale(0.95);
}

.empty-deck {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.3);
}

.deck-count {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
}

#piles-container {
  flex: 0 0 auto;
  overflow: visible;
  max-height: 180px;
  min-height: 180px;
}

#piles {
  display: flex;
  gap: 20px;
  height: 100%;
  justify-content: center;
}

.pile {
  flex: 0 0 85px;
  width: 85px;
  position: relative;
  min-height: 102px;
  max-height: 450px;
  background: transparent;
  border-radius: 8px;
  padding: 0;
  overflow: visible;
}

.empty-pile {
  width: 85px;
  height: 102px;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: transparent;
  opacity: 0.4;
}

.card {
  border-radius: 10px;
  padding: 6px 5px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
  width: 77px;
  height: 102px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 100% 100%;
  border: none;
  box-shadow: inset 0 0 0 1px #000;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.card--flight {
  pointer-events: none;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.45);
}

.card--face-up:hover {
  transform: translateY(-5px);
}

.card--face-up:active {
  transform: scale(0.95);
}

.card--face-down:hover {
  transform: none;
}

.pile .card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 85px;
}

.card--category {
  background-image: url('./kart0.png');
  border: inherit;
}

.card--word {
  background-image: url('./kart1.png');
  border: inherit;
}

.card--joker.card--face-up {
  background: white;
  border: 3px solid #FFD700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3);
  animation: joker-glow 2s ease-in-out infinite;
}

.card--joker.card--face-up .card-joker-image {
  width: 60px;
  height: 60px;
  background-image: url('./joker.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
  animation: joker-bounce 1.5s ease-in-out infinite;
}

@keyframes joker-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.3); }
  50% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.9), inset 0 0 15px rgba(255, 255, 255, 0.5); }
}

@keyframes joker-bounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.1); }
}

.card--in-slot {
  width: 85px;
  height: 100%;
  min-height: 102px;
  margin: 0 auto;
}

.card--deck {
  width: 100%;
  height: 100%;
  background-image: url('./kart2.png');
  cursor: pointer;
  border: inherit;
}

.card--face-down {
  background-image: url('./kart2.png');
  cursor: default;
  border: inherit;
}

.card--face-down .card-back {
  font-size: 42px;
  color: #654321;
  display: none;
}

.card-back {
  font-size: 44px;
  text-align: center;
}

.card-title {
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  color: #333;
  line-height: 1.3;
  word-wrap: break-word;
  overflow: hidden;
  max-width: 100%;
}

.card-title--small {
  font-size: 8.82px;
  margin-top: 2px;
  opacity: 0.8;
}

.card--category .card-title {
  font-size: 11px;
  color: #000;
}

.card-crown {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 15.75px;
}

/* Счётчик вместимости категории (0/сколько карт нужно собрать) */
.card-capacity-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  color: #000;
  font-size: 9px;
  font-weight: bold;
  text-shadow: 
    -1px -1px 0 white,
    1px -1px 0 white,
    -1px 1px 0 white,
    1px 1px 0 white;
}

.card-icon {
  font-size: 24.15px;
  text-align: center;
  margin-top: 4px;
}

.card-emoji {
  font-size: 31.5px;
  text-align: center;
  margin-top: 6px;
}

.card--covered {
  justify-content: flex-start;
  padding-top: 7px;
}

.card--covered .card-title {
  font-size: 11px;
  margin-top: 2px;
}

.card--covered .card-emoji {
  font-size: 18.9px;
  margin-top: -4px;
}

.card--covered .card-icon {
  font-size: 15.75px;
  margin-top: 1px;
}

.deck-pile--discard .card.card--covered {
  position: relative;
  justify-content: center;
  align-items: center;
  padding: 0;
}

.deck-pile--discard .card.card--covered .card-title,
.deck-pile--discard .card.card--covered .card-emoji {
  position: absolute;
  top: 50%;
  right: 4px;
  transform-origin: right center;
  margin: 0;
  text-align: right;
}

.deck-pile--discard .card.card--covered .card-title {
  font-size: 9.92px;
  right: 2px;
  top: 67%;
  line-height: 1;
  white-space: nowrap;
  transform: translate(-27%, -50%) rotate(90deg);
}

.deck-pile--discard .card.card--covered .card-emoji {
  font-size: 13.65px;
  right: 4px;
  line-height: 1;
  top: 55%;
  transform: translate(-24%, -50%) rotate(90deg);
}

.deck-pile--discard .card.card--covered.card--face-up:hover {
  transform: none;
}

.card-progress {
  text-align: center;
  font-size: 9.45px;
  margin-top: 4px;
  font-weight: bold;
  color: #000;
}

#bottom-bar {
  display: flex;
  justify-content: center;
  gap: 15px;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

#bottom-bar button {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#bottom-bar button > img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

#bottom-bar button:active {
  transform: scale(0.95);
}

/* Счётчики подсказок */
.btn-with-counter {
  position: relative;
}

.hint-counter {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #e74c3c;
  color: white;
  font-size: 12px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 10;
}

/* cost-badge больше не используется - подсказки показывают только число */

/* Кнопка меню (три точки) */
.btn-menu {
  position: fixed;
  right: 15px;
  top: 15px;
  background: rgba(0,0,0,0.3);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 16px;
  z-index: 15000;
  border-radius: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.menu-dot {
  width: 7px;
  height: 7px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.btn-menu:hover .menu-dot {
  background: #f0f0f0;
}

.btn-menu:active {
  opacity: 0.8;
}

/* Модальное окно настроек */
.settings-content {
  background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
  border-radius: 20px;
  padding: 30px;
  min-width: 280px;
  max-width: 350px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.1);
}

.settings-title {
  font-size: 24px;
  font-weight: bold;
  color: white;
  text-align: center;
  margin-bottom: 25px;
}

.btn-close-settings {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 20px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-close-settings:hover {
  background: rgba(255,255,255,0.2);
}

.settings-sound {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
}

.settings-label {
  color: white;
  font-size: 18px;
}

/* Переключатель звука */
.sound-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sound-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #555;
  transition: 0.3s;
  border-radius: 26px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.sound-toggle input:checked + .toggle-slider {
  background-color: #27ae60;
}

.sound-toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Кнопка перезапуска в меню */
.btn-restart-menu {
  width: 100%;
  position: relative;
}

.btn-restart-menu img {
  width: 100%;
  height: 70px;
  object-fit: contain;
}

.btn-restart-menu .btn-restart-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 32px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* Модальное окно покупки подсказки */
.buy-hint-content {
  background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
  border-radius: 20px;
  padding: 30px;
  min-width: 280px;
  max-width: 350px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.1);
  text-align: center;
}

.buy-hint-title {
  font-size: 24px;
  font-weight: bold;
  color: white;
  margin-bottom: 20px;
}

.buy-hint-cost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
}

.buy-hint-coin {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.buy-hint-price {
  color: #f39c12;
  font-size: 28px;
  font-weight: bold;
}

.btn-buy-hint-confirm {
  width: 100%;
  position: relative;
}

.btn-buy-hint-confirm img {
  width: 100%;
  height: 60px;
  object-fit: contain;
}

.btn-buy-hint-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.btn-image {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.btn-image:active {
  transform: scale(0.95);
}

.drag-ghost {
  opacity: 0.9;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

.card--ghost {
  pointer-events: none;
}

.card--flip {
  animation: flipCard 0.5s ease-out;
}

.card--will-flip {
  transform: translateX(-50%) rotateY(180deg) !important;
}

@keyframes flipCard {
  0% {
    transform: translateX(-50%) rotateY(180deg);
  }
  100% {
    transform: translateX(-50%) rotateY(0deg);
  }
}

.card--dissolve {
  animation: dissolveCard 0.6s ease-out forwards;
  position: relative;
}

.card--dissolve::before {
  content: '✨';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  opacity: 0;
  animation: sparkle 0.6s ease-out;
  pointer-events: none;
}

.card--dissolve::after {
  content: '⭐';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 33px;
  opacity: 0;
  animation: sparkle2 0.6s 0.1s ease-out;
  pointer-events: none;
}

@keyframes dissolveCard {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  30% {
    opacity: 0.9;
    transform: scale(1.15) rotate(5deg);
  }
  60% {
    opacity: 0.5;
    transform: scale(0.6) rotate(-5deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.1) rotate(10deg);
  }
}

@keyframes sparkle {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2) rotate(180deg);
  }
}

@keyframes sparkle2 {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2) rotate(90deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.8) rotate(180deg);
  }
}

.card--hint-phantom {
  opacity: 0.6 !important;
  filter: drop-shadow(0 8px 16px rgba(255, 255, 0, 0.6));
  pointer-events: none !important;
  cursor: default !important;
}

#deck.hint-highlight {
  box-shadow: 0 0 20px rgba(255, 255, 0, 0.8) !important;
  animation: pulseDeck 1s ease-in-out infinite;
  transform-origin: center center;
}

@keyframes pulseDeck {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.8);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 255, 0, 1);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-content {
  background: #ffffff;
  border: 3px solid #d4c5a9;
  border-radius: 20px;
  padding: 30px 40px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  overflow: hidden;
}

.modal-title {
  font-size: 28px;
  font-weight: 800;
  color: #333;
  margin-bottom: 15px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.modal-subtitle {
  font-size: 18px;
  color: #666;
  margin-bottom: 25px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.btn-buy-moves,
.btn-watch-ad,
.btn-restart-level {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.btn-buy-moves img,
.btn-watch-ad img,
.btn-restart-level img {
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 69px;
  position: relative;
  z-index: 1;
}

.btn-buy-moves .btn-text,
.btn-watch-ad .btn-text {
  position: absolute;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  z-index: 10;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-coin-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  margin-right: 6px;
  vertical-align: middle;
}

.btn-ad-icon {
  font-size: 16px;
}

.btn-restart-text {
  position: absolute;
  font-size: 18px;
  font-weight: 700;
  color: #5d4037;
  z-index: 10;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.btn-buy-moves:active,
.btn-watch-ad:active,
.btn-restart-level:active {
  transform: scale(0.95);
}

.btn-icon {
  font-size: 24px;
  line-height: 1;
}

.btn-text {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Окно выигрыша */
.victory-overlay {
  background: rgba(0, 0, 0, 0.7);
  z-index: 15000;
}

.victory-content {
  background: #ffffff;
  border: 3px solid #d4c5a9;
  border-radius: 20px;
  padding: 40px 50px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  overflow: visible;
  position: relative;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: translateY(400px) translateX(calc(var(--drift-x, 0) * 1px)) rotate(360deg);
    opacity: 0.8;
  }
  100% {
    transform: translateY(800px) translateX(calc(var(--drift-x, 0) * 2px)) rotate(720deg);
    opacity: 0;
  }
}

.victory-garlands {
  display: none;
}

.garland {
  font-size: 40px;
  animation: garlandBounce 1s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.garland-1 {
  animation-delay: 0s;
}

.garland-2 {
  animation-delay: 0.2s;
}

.garland-3 {
  animation-delay: 0.4s;
}

.garland-4 {
  animation-delay: 0.6s;
}

.garland-5 {
  animation-delay: 0.8s;
}

@keyframes garlandBounce {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-10px) scale(1.1);
  }
}

.victory-level-text {
  font-size: 24px;
  font-weight: 700;
  color: #5d4037;
  margin-bottom: 15px;
}

#victory-level-number {
  color: #5d4037;
}

.victory-excellent {
  font-size: 42px;
  font-weight: 800;
  color: #5d4037;
  margin-bottom: 30px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
  animation: excellentPulse 1.5s ease-in-out infinite;
}

@keyframes excellentPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.victory-cards-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
  position: relative;
  min-height: 200px;
}

.victory-card-image {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.victory-card-img {
  width: 300px;
  height: auto;
  object-fit: contain;
  position: relative;
  z-index: 2;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

.btn-reshuffle-deck {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-reshuffle-deck img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.btn-reshuffle-deck:active {
  transform: scale(0.95);
}

.card-glow {
  position: absolute;
  inset: -20px;
  border-radius: 12px;
  background: transparent;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5), 0 0 90px rgba(255, 215, 0, 0.3);
  animation: cardGlow 2s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.victory-card-center .card-glow {
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5), 0 0 90px rgba(255, 215, 0, 0.3);
}

@keyframes cardGlow {
  0%, 100% {
    opacity: 0.7;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5), 0 0 90px rgba(255, 215, 0, 0.3);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 80px rgba(255, 215, 0, 0.7), 0 0 120px rgba(255, 215, 0, 0.5);
  }
}

.card-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.star-particle {
  position: absolute;
  font-size: 20px;
  color: #ffd700;
  pointer-events: none;
  animation: starFly 1.5s ease-out forwards;
}

@keyframes starFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--star-x), var(--star-y)) scale(0.3) rotate(720deg);
  }
}

/* Лучи света от карт */
.victory-card {
  position: relative;
}

.card-light-rays {
  display: none;
}

.card-coins-text {
  position: absolute;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  font-weight: 800;
  color: #5d4037;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-coins-text::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background-image: url('./monet.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.btn-continue {
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 482px !important;
  min-width: 482px !important;
  position: relative;
  margin: 0 auto;
}

.btn-continue img {
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 60px;
  position: relative;
  z-index: 1;
}

.btn-continue-text {
  position: absolute;
  font-size: 22px;
  font-weight: 700;
  color: #5d4037;
  z-index: 10;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.btn-continue:active {
  transform: scale(0.95);
}

.flying-coin {
  position: fixed;
  pointer-events: none;
  z-index: 20000;
  font-size: 30px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.spark-particle {
  position: fixed;
  width: 4px;
  height: 4px;
  background: #ffd700;
  border-radius: 50%;
  pointer-events: none;
  z-index: 20001;
  animation: sparkFade 0.5s ease-out forwards;
}

@keyframes sparkFade {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0);
  }
}

@keyframes coinsPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* Анимация уничтожения категории */
@keyframes categoryDestroy {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  30% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes categoryGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.8);
  }
  50% {
    box-shadow: 0 0 30px 15px rgba(255, 215, 0, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
  }
}

@keyframes categoryStars {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(2) rotate(180deg);
    opacity: 0;
  }
}

.category-destroying {
  animation: categoryGlow 0.4s ease-out, categoryDestroy 0.6s ease-in forwards;
  animation-delay: 0s, 0.3s;
  pointer-events: none;
}

.category-destroy-particle {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  animation: categoryStars 0.8s ease-out forwards;
  z-index: 1000;
}

/* Магазин */
.shop-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 20px;
  padding: 25px;
  width: 420px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.1);
}

.shop-title {
  font-size: 32px;
  font-weight: bold;
  color: white;
  text-align: center;
  margin-bottom: 20px;
}

.shop-item {
  width: 100%;
  background: #ffffff;
  border: 2px solid #27ae60;
  border-radius: 15px;
  padding: 18px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
  font-family: 'Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.shop-item:hover {
  border-color: #2ecc71;
  box-shadow: 0 0 8px rgba(39, 174, 96, 0.4);
}

.shop-item:active {
  transform: scale(0.98);
}

.shop-item-premium {
  min-height: 110px;
  background: #ffffff;
  flex-direction: row;
  position: relative;
}

.shop-item-premium .shop-item-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  flex: 1;
}

.shop-item-premium .shop-item-name {
  color: #333;
  text-align: center;
  margin-bottom: 12px;
  font-size: 18px;
}

.shop-item-premium .shop-item-desc {
  color: #666;
  text-align: center;
  margin-top: auto;
  font-size: 14px;
}

.shop-item-premium .premium-sprite {
  width: 69px;
  height: 69px;
  object-fit: contain;
  margin-right: 15px;
}

.shop-item-noads {
  min-height: 65px;
  background: #ffffff;
}

.shop-item-noads .shop-item-name {
  color: #333;
}

.shop-item-info {
  flex: 1;
  text-align: left;
}

.shop-item-name {
  color: #333;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 6px;
}

.shop-item-desc {
  color: #666;
  font-size: 13px;
}

.shop-item-price-btn {
  position: relative;
  width: 95px;
  height: 42px;
}

.shop-price-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.shop-price-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  white-space: nowrap;
}

.shop-section-title {
  color: #ffd700;
  font-size: 22px;
  font-weight: bold;
  margin: 20px 0 15px 0;
  text-align: center;
}

/* Система подсказок */
.game-hint-message {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  z-index: 20000;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  animation: hintFadeIn 0.3s ease-out forwards;
}

.game-hint-message.fade-out {
  animation: hintFadeOut 0.3s ease-out forwards;
}

.game-hint-message.instant-show {
  opacity: 1;
  animation: none;
}

@keyframes hintFadeIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes hintFadeOut {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

.shop-coins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.shop-coin-item {
  background: #ffffff;
  border: 2px solid #27ae60;
  border-radius: 12px;
  padding: 15px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
  font-family: 'Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.shop-coin-item:hover {
  border-color: #2ecc71;
  box-shadow: 0 0 8px rgba(39, 174, 96, 0.4);
}

.shop-coin-item:active {
  transform: scale(0.95);
}

.shop-coin-icon {
  font-size: 28px;
}

.shop-coin-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.shop-coin-amount {
  color: #333;
  font-size: 15px;
  font-weight: bold;
}

.shop-coin-price {
  color: white;
  font-size: 12px;
  background: #27ae60;
  padding: 3px 8px;
  border-radius: 5px;
}


/* Расширенное окно настроек */
.settings-content-expanded {
  min-width: 300px;
  max-width: 380px;
}

/* Кнопка "Другие игры" */
.btn-other-games {
  width: 100%;
  position: relative;
  margin-top: 15px;
}

.btn-other-games img {
  width: 100%;
  height: 70px;
  object-fit: contain;
}

.btn-other-games-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* Кнопки в окне победы - вертикальное расположение */
.victory-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
}

/* Кнопка утроения награды (x3) */
.btn-triple-reward {
  position: relative;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.btn-triple-reward img {
  width: 170px;
  height: auto;
  display: block;
}

.btn-triple-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-triple-reward:active {
  transform: scale(0.95);
}


/* ========================================
   МОБИЛЬНЫЕ СТИЛИ (только для touch-устройств)
   ======================================== */

/* Определяем мобильные устройства через touch и ориентацию */
@media (hover: none) and (pointer: coarse) {
  /* Улучшаем кликабельность кнопок */
  button, .btn-image, .clickable-box, .shop-item, .shop-coin-item, .sound-toggle, .card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }
  
  /* Увеличиваем область нажатия для кнопок закрытия */
  .btn-close-settings {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}

/* Мобильные устройства в ландшафтном режиме (не портретный) */
@media (hover: none) and (pointer: coarse) {
  /* Базовые стили для мобильных в ландшафте - применяются только если нет класса mobile-portrait */
  body:not(.mobile-portrait) .card {
    width: 89px;  /* 77 * 1.15 */
    height: 117px; /* 102 * 1.15 */
  }
  
  body:not(.mobile-portrait) .deck-pile .card,
  body:not(.mobile-portrait) .deck-pile--discard .card,
  body:not(.mobile-portrait) .card--deck {
    width: 77px !important;
    height: 102px !important;
  }
  
  body:not(.mobile-portrait) .pile .card {
    width: 98px;  /* 85 * 1.15 */
  }
  
  body:not(.mobile-portrait) .category-slot {
    flex: 0 0 108px; /* 94 * 1.15 */
    width: 108px;
    min-height: 138px; /* 120 * 1.15 */
  }
  
  body:not(.mobile-portrait) .card--in-slot {
    width: 98px; /* 85 * 1.15 */
    min-height: 117px;
  }
  
  body:not(.mobile-portrait) .pile {
    flex: 0 0 98px; /* 85 * 1.15 */
    width: 98px;
    min-height: 117px;
  }
  
  body:not(.mobile-portrait) .empty-pile {
    width: 98px;
    height: 117px;
  }
  
  body:not(.mobile-portrait) .deck-pile {
    width: 77px;
    height: 102px;
  }
}

/* ========================================
   Стили для мобильного портретного режима
   ======================================== */

/* Портретный режим на мобильных (720x1152) */
/* Масштаб: 720/720 = 1.0 (без изменений по ширине) */
/* Итоговый множитель: 1.44 */
body.mobile-portrait {
  --mp-card-width: 110px;   /* 77 * 1.44 */
  --mp-card-height: 147px;  /* 102 * 1.44 */
  --mp-pile-card-width: 122px; /* 85 * 1.44 */
  --mp-slot-width: 135px;   /* 94 * 1.44 */
  --mp-slot-height: 173px;  /* 120 * 1.44 */
}

/* Все карты одинакового размера (кроме фантомов) */
body.mobile-portrait .card:not(.card--drag-phantom):not(.card--hint-phantom) {
  width: var(--mp-card-width) !important;
  height: var(--mp-card-height) !important;
}

/* Карты в стопках чуть шире (кроме фантомов) */
body.mobile-portrait .pile .card:not(.card--drag-phantom):not(.card--hint-phantom) {
  width: var(--mp-pile-card-width) !important;
}

/* Карты в слотах (кроме фантомов) */
body.mobile-portrait .card--in-slot:not(.card--drag-phantom):not(.card--hint-phantom) {
  width: var(--mp-pile-card-width) !important;
  min-height: var(--mp-card-height) !important;
  height: 100% !important;
}

/* Слоты категорий */
body.mobile-portrait .category-slot {
  flex: 0 0 var(--mp-slot-width) !important;
  width: var(--mp-slot-width) !important;
  min-height: var(--mp-slot-height) !important;
}

/* Стопки карт */
body.mobile-portrait .pile {
  flex: 0 0 var(--mp-pile-card-width) !important;
  width: var(--mp-pile-card-width) !important;
  min-height: var(--mp-card-height) !important;
}

body.mobile-portrait .empty-pile {
  width: var(--mp-pile-card-width) !important;
  height: var(--mp-card-height) !important;
}

/* Колода - такой же размер как карты */
body.mobile-portrait .deck-pile {
  width: var(--mp-card-width) !important;
  height: var(--mp-card-height) !important;
}

/* Карты в колоде и сбросе (кроме фантомов) */
body.mobile-portrait .deck-pile .card:not(.card--drag-phantom):not(.card--hint-phantom),
body.mobile-portrait .deck-pile--discard .card:not(.card--drag-phantom):not(.card--hint-phantom),
body.mobile-portrait #deck .card:not(.card--drag-phantom):not(.card--hint-phantom),
body.mobile-portrait .card--deck:not(.card--drag-phantom):not(.card--hint-phantom) {
  width: 100% !important;
  height: 100% !important;
}

/* Emoji увеличены на 50% на мобильных в портретной ориентации */
body.mobile-portrait .card-emoji:not(.card--drag-phantom):not(.card--hint-phantom) {
  font-size: 47.25px !important; /* 31.5 * 1.5 */
}

/* Счётчик вместимости категории - увеличиваем на мобильных */
body.mobile-portrait .card-capacity-badge {
  font-size: 12px !important;
  top: 10px !important;
  left: 10px !important;
}

/* Emoji в закрытых картах (в стопках) - вернём к исходному размеру без увеличения на 50% */
body.mobile-portrait .card--covered .card-emoji:not(.card--drag-phantom):not(.card--hint-phantom) {
  font-size: 18.9px !important; /* 18 * 1.05 - без увеличения на 50% */
}

/* Прогресс в категориях - увеличиваем в 2 раза */
body.mobile-portrait .card-progress:not(.card--drag-phantom):not(.card--hint-phantom) {
  font-size: 18.9px !important; /* 9.45 * 2 */
}

/* Кнопки подсказок увеличены в 1.5 раза */
body.mobile-portrait #bottom-bar {
  gap: 37px; /* 25 + 12 */
}

body.mobile-portrait #bottom-bar button {
  transform: scale(1.5);
  transform-origin: center center;
}

body.mobile-portrait #bottom-bar button:active {
  transform: scale(1.425); /* 1.5 * 0.95 */
}

/* Счётчики подсказок - корректируем позицию для увеличенных кнопок */
body.mobile-portrait .hint-counter {
  top: -8px;
  right: -8px;
  font-size: 14px;
  width: 24px;
  height: 24px;
}

/* Магазин в портретном режиме - увеличенный, без прокрутки */
body.mobile-portrait .shop-content {
  width: 548px;
  max-width: 95%;
  padding: 32px 24px 40px 24px;
  border-radius: 24px;
  overflow: hidden;
}

body.mobile-portrait .shop-title {
  font-size: 39px;
  margin-bottom: 18px;
}

body.mobile-portrait .shop-item {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 17px;
  border-width: 2px;
}

body.mobile-portrait .shop-item-premium {
  min-height: 100px;
}

body.mobile-portrait .shop-item-premium .shop-item-name {
  font-size: 22px;
  margin-bottom: 10px;
}

body.mobile-portrait .shop-item-premium .shop-item-desc {
  font-size: 15px;
}

body.mobile-portrait .shop-item-premium .premium-sprite {
  width: 77px;
  height: 77px;
  margin-right: 18px;
}

body.mobile-portrait .shop-item-noads {
  min-height: 70px;
}

body.mobile-portrait .shop-item-noads .shop-item-name {
  font-size: 20px;
}

body.mobile-portrait .shop-item-info .shop-item-name {
  font-size: 20px;
  margin-bottom: 6px;
}

body.mobile-portrait .shop-item-price-btn {
  width: 105px;
  height: 46px;
}

body.mobile-portrait .shop-price-text {
  font-size: 15px;
}

body.mobile-portrait .shop-section-title {
  font-size: 28px;
  margin: 16px 0 12px 0;
}

body.mobile-portrait .shop-coins-grid {
  gap: 10px;
}

body.mobile-portrait .shop-coin-item {
  padding: 12px 10px;
  border-radius: 14px;
  border-width: 2px;
}

body.mobile-portrait .shop-coin-img {
  width: 50px;
  height: 50px;
}

body.mobile-portrait .shop-coin-amount {
  font-size: 18px;
}

body.mobile-portrait .shop-coin-price {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
}

body.mobile-portrait .btn-close-settings {
  width: 50px;
  height: 50px;
  font-size: 28px;
  top: 15px;
  right: 15px;
}

/* Фантомы при перетаскивании и подсказке - размеры внутренних элементов устанавливаются через JavaScript
   пропорционально визуальному размеру карты */
