* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a2e 100%);
  color: white;
  font-family: system-ui, sans-serif;
  text-align: center;
  overflow-y: auto;
  overflow-x: hidden;
  transition: background 3s ease-in-out;
}

.header {
  background: linear-gradient(135deg, #054179 0%, #151d2a 100%);
  padding: 12px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-bottom: 3px solid #0c1724;
  transition: background 3s ease-in-out, border-bottom-color 3s ease-in-out, box-shadow 3s ease-in-out;
  position: sticky;
  top: 0;
  z-index: 999;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  height: 60px;
}

.logo-placeholder {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  flex-shrink: 0;
}

.logo-image {
  width: 70px;
  height: 70px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

.collection-title {
  position: absolute;
  left: 5%;
  top: 40%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  letter-spacing: 1px;
  transition: color 3s ease-in-out, text-shadow 3s ease-in-out;
}

.powered-by {
  position: absolute;
  left: 5%;
  bottom: 5px;
  font-size: 0.75rem;
  color: #e8f0fe;
  opacity: 0.8;
  transition: color 3s ease-in-out, opacity 3s ease-in-out;
}

.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
  padding: 0;
  margin: 0;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  aspect-ratio: 1;
  background: #1a1a2e;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transition: background 3s ease-in-out, box-shadow 3s ease-in-out, border-color 3s ease-in-out;
}

.image-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-footer {
  background: rgba(0, 0, 0, 0.6);
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(74, 144, 226, 0.3);
  transition: background 3s ease-in-out, border-top-color 3s ease-in-out;
}

.like-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  transition: color 3s ease-in-out, all 0.2s ease;
  padding: 0;
}

.like-button:hover {
  transform: scale(1.2);
}

.like-button.liked {
  color: #ff6b6b;
}

.like-count {
  color: #e8f0fe;
  font-weight: bold;
  font-size: 0.95rem;
}

.loading {
  padding: 40px 20px;
  font-size: 1.2rem;
  text-align: center;
  color: #4a90e2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-height: 150px;
  transition: color 3s ease-in-out;
}

.loading-gif {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.loading-text {
  margin: 0;
  font-size: 0.9rem;
  color: #e8f0fe;
  font-weight: 300;
}

@media (max-width: 1024px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 600px) {
  .gallery {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .header {
    padding: 15px;
  }
  
  .header-content {
    flex-direction: column;
    justify-content: center;
    height: auto;
    gap: 10px;
  }
  
  .logo-image {
    width: 50px;
    height: 50px;
  }
  
  .collection-title {
    position: static;
    transform: none;
    font-size: 1rem;
    margin: 0;
    margin-top: 5px;
  }
  
  .powered-by {
    position: static;
    font-size: 0.65rem;
    margin: 0;
    margin-top: 3px;
  }
}

.loading-error {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: #ff6b6b;
  font-size: 1.2rem;
  font-weight: 500;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .modal-image {
    max-height: 85vh;
  }
  
  .close-button {
    top: 10px;
    right: 20px;
    font-size: 30px;
  }
}

body.game-mode {
  background: linear-gradient(to top, 
    transparent 0%, 
    rgba(74, 0, 0, 0.3) 25%,
    rgba(74, 0, 0, 0.8) 100%),
    linear-gradient(135deg, #0f0f0f 0%, #1a1a2e 100%);
  background-size: 100% 200%, 100% 100%;
  background-position: 0 100%, 0 0;
  position: relative;
  animation: fillBgRed 10s ease-in-out forwards;
}

@keyframes fillBgRed {
  0% {
    background-position: 0 100%, 0 0;
  }
  100% {
    background-position: 0 0%, 0 0;
  }
}

body.game-mode .header {
  background: linear-gradient(135deg, #8b0000 0%, #4a0000 100%);
  transition: background 10s ease-in-out, box-shadow 10s ease-in-out, border-bottom-color 10s ease-in-out;
  box-shadow: 0 8px 32px rgba(255, 0, 0, 0.3);
}

body.game-mode .gallery-item {
  background: #2d0000;
  box-shadow: 0 8px 16px rgba(255, 0, 0, 0.2);
  transition: all 10s ease-in-out;
  border: 2px solid rgba(255, 0, 0, 0.3);
}

body.game-mode .gallery-item.game-active {
  cursor: crosshair;
  transform: scale(1);
  transition: all 0.2s ease;
}

body.game-mode .gallery-item.game-active:hover {
  border-color: #ff3333;
  box-shadow: 0 8px 24px rgba(255, 0, 0, 0.5);
  transform: scale(1.02);
}

body.game-mode .gallery-item.destroyed {
  animation: destroyEffect 0.4s ease-out forwards;
}

@keyframes destroyEffect {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.1) rotate(15deg);
    filter: brightness(1.5) hue-rotate(10deg);
  }
  100% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
    filter: brightness(0);
  }
}

.destroy-fragment {
  position: fixed;
  pointer-events: none;
  z-index: 1001;
  animation: fragmentFall 1.2s ease-in forwards;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
  filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 0, 0, 0.8));
  border-radius: 4px;
}

.pixel-fragment {
  position: fixed;
  pointer-events: none;
  z-index: 1001;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.4);
  border: 1px solid rgba(255, 0, 0, 0.2);
}

@keyframes fragmentFall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: 
      translate(var(--spreadX), var(--fallY)) 
      rotate(720deg) 
      scale(0.2);
  }
}

@keyframes pixelFall {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: 
      translate(var(--spreadX), var(--fallY)) 
      scale(0.3);
  }
}

#game-ui {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  pointer-events: none;
}

.game-header {
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.95) 0%, rgba(74, 0, 0, 0.95) 100%);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(255, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid #ff0000;
  pointer-events: auto;
  animation: slideDown 0.5s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.game-title {
  font-size: 2rem;
  color: #ff3333;
  font-weight: bold;
  text-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 0 40px rgba(255, 0, 0, 0.4);
  letter-spacing: 2px;
  animation: pulse 0.6s ease infinite;
}

@keyframes pulse {
  0%, 100% {
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 0 40px rgba(255, 0, 0, 0.4);
  }
  50% {
    text-shadow: 0 0 40px rgba(255, 100, 100, 1), 0 0 60px rgba(255, 0, 0, 0.6);
  }
}

.game-score {
  font-size: 1.5rem;
  color: #ffff00;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 255, 0, 0.6);
  flex: 1;
  text-align: center;
}

#score-value {
  color: #ff6666;
  font-size: 1.8rem;
  text-shadow: 0 0 10px rgba(255, 100, 100, 0.8);
}

.exit-button:hover {
  background: linear-gradient(135deg, #ff1313 0%, #ff0000 100%);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
}

.exit-button:active {
  transform: scale(0.95);
}

body.game-mode .collection-title,
body.game-mode .powered-by,
body.game-mode .loading,
body.game-mode .like-button {
  color: #ff0000;
  transition: color 10s ease-in-out;
}

body.game-mode .header {
  background: linear-gradient(135deg, #8b0000 0%, #4a0000 100%);
  border-bottom-color: #ff0000;
  transition: all 10s ease-in-out;
}

body.game-mode .card-footer {
  background: rgba(74, 0, 0, 0.8);
  border-top-color: rgba(255, 0, 0, 0.5);
  transition: background 10s ease-in-out, border-top-color 10s ease-in-out;
}

.exit-game-button {
  background: linear-gradient(135deg, #ff3333 0%, #cc0000 100%);
  color: white;
  border: 2px solid #ff0000;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s ease;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.4);
  box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
}

.exit-game-button:hover {
  background: linear-gradient(135deg, #ff6666 0%, #ff0000 100%);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
}

.exit-game-button:active {
  transform: scale(0.95);
}

.game-score-display {
  font-size: 1.2rem;
  color: #ff9999;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.6);
  margin-right: 15px;
  transition: color 2s ease;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#game-weapon {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  height: 300px;
  object-fit: contain;
  object-position: center bottom;
  animation: weaponAppear 1.5s ease-out forwards;
}

@keyframes weaponAppear {
  0% {
    bottom: -300px;
  }
  100% {
    bottom: 0;
  }
}
