@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&display=swap');
body {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
}
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  color: white;
  width: 100%;
  box-sizing: border-box;
  touch-action: none; /* Prevent unwanted scrolling on mobile */
  position: relative;
}

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin-bottom: 1rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  padding: 0 0.5rem;
}

.score, .timer, .game-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.game-controls {
  display: flex;
  gap: 0.5rem;
}

.hints, .shuffles {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.hint-icon, .shuffle-icon {
  width: clamp(24px, 6vw, 32px);
  height: clamp(24px, 6vw, 32px);
  cursor: pointer;
  transition: all 0.3s ease;
  color: #FFD700;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3));
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint-icon:hover:not(.disabled), .shuffle-icon:hover:not(.disabled) {
  transform: scale(1.1);
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

.hint-icon.disabled, .shuffle-icon.disabled {
  cursor: not-allowed;
  filter: grayscale(1) opacity(0.5);
}

.hint-icon .icon, .shuffle-icon .icon {
  color: #FFD700;
}

.hints-count, .shuffles-count {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.game-board {
  background-image: url('../assets/board.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 10px rgba(0, 0, 0, 0.5));
  padding: 1.2rem;
  padding-right: 1.8rem;
  perspective: 1000px;
  width: min(95vw, 450px);
  height: min(95vw, 450px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

.board-row {
  display: flex;
  justify-content: space-between;
  height: 12.5%;
}

.jewel {
  width: 12.5%;
  height: 100%;
  aspect-ratio: 1;
  margin: 1px;
  border-radius: 8px;
  cursor: pointer;
  filter: drop-shadow(0 2px rgba(0, 0, 0, 0.5));
  position: relative;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform, filter, opacity;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              filter 0.2s ease-in-out;
}

/* Random size classes - very subtle variations */
.size-1 { --size-scale: 0.96; }
.size-2 { --size-scale: 0.98; }
.size-3 { --size-scale: 1.0; }
.size-4 { --size-scale: 1.02; }
.size-5 { --size-scale: 1.04; }

/* Rotation classes */
.rotate-1 { --rotation-angle: -5deg; }
.rotate-2 { --rotation-angle: -3deg; }
.rotate-3 { --rotation-angle: -1deg; }
.rotate-4 { --rotation-angle: 1deg; }
.rotate-5 { --rotation-angle: 3deg; }
.rotate-6 { --rotation-angle: 5deg; }

/* Apply combined transforms */
.jewel {
  transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
}

.jewel.swapping {
  z-index: 2;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.jewel.swap-failed {
  z-index: 2;
  animation: swapFailed 0.5s cubic-bezier(0.36, 0, 0.66, -0.56);
}

.jewel:hover {
  --size-scale: 1.1;
  --rotation-angle: 0deg;
  z-index: 1;
  filter: brightness(1.2);
}

.jewel.selected {
  --size-scale: 1.1;
  --rotation-angle: 0deg;
  animation: shake 0.5s ease infinite;
  filter: brightness(1.3);
  z-index: 2;
}

.jewel.adjacent {
  animation: adjacentShake 1.2s ease-in-out infinite;
  filter: brightness(1.1);
  z-index: 1;
}

.jewel.matched {
  animation: explode 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  z-index: 2;
}

.jewel.falling {
  animation: fall 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  z-index: 1;
}

/* Ensure board-shake doesn't override rotation */
.jewel.board-shake:not(.matched):not(.falling) {
  animation: boardShake 0.5s ease;
}

/* Ensure hint doesn't override rotation */
.jewel.hint:not(.matched):not(.falling) {
  animation: pulse 1s infinite;
}

.red {
  background-image: url('../assets/jewels/one.png');
}

.blue {
  background-image: url('../assets/jewels/two.png');
}

.green {
  background-image: url('../assets/jewels/three.png');
}

.yellow {
  background-image: url('../assets/jewels/four.png');
}

.purple {
  background-image: url('../assets/jewels/five.png');
}

.orange {
  background-image: url('../assets/jewels/six.png');
}

.pink {
  background-image: url('../assets/jewels/seven.png');
}

/* Neocat mode jewels */
.neocat-mode .red {
  background-image: url('../assets/jewels/neocat/one.png');
}

.neocat-mode .blue {
  background-image: url('../assets/jewels/neocat/two.png');
}

.neocat-mode .green {
  background-image: url('../assets/jewels/neocat/three.png');
}

.neocat-mode .yellow {
  background-image: url('../assets/jewels/neocat/four.png');
}

.neocat-mode .purple {
  background-image: url('../assets/jewels/neocat/five.png');
}

.neocat-mode .orange {
  background-image: url('../assets/jewels/neocat/six.png');
}

.neocat-mode .pink {
  background-image: url('../assets/jewels/neocat/seven.png');
}

.hint-button {
  display: none;
}

.game-over {
  background-color: white;
  padding: 1.5rem;
  border-radius: 16px;
  text-align: center;
  animation: fadeIn 0.5s ease;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
  width: 90%;
  max-width: 400px;
}

.game-over h2 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  margin-bottom: 0;
  color: #ff4d4d;
}

.game-over p {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  margin: 0;
  color: #0099ff;
}

.share-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 90%;
  max-width: 300px;
  margin-top: 1rem;
}

.share-section h3 {
  color: #0099ff;
  margin: 0;
  font-size: 1.2rem;
}

.share-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.instance-input {
  flex: 1;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: 2px solid #4CAF50;
  border-radius: 4px;
  background: rgb(88 185 92);
  color: white;
  font-family: inherit;
}

.instance-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.instance-input:focus {
  outline: none;
  border-color: #45a049;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.share-button {
  padding: 0.8rem 1.5rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  background: linear-gradient(135deg, #4CAF50, #45a049);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-weight: 600;
  min-height: 44px; /* Minimum touch target size */
}

.share-button:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

.share-button:active {
  transform: scale(0.95);
}

.reset-button {
  padding: 0.8rem 1.5rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  background: linear-gradient(135deg, #4CAF50, #45a049);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: transform 0.3s ease;
  min-height: 44px; /* Minimum touch target size */
}

.reset-button:hover {
  transform: scale(1.1);
}

.timer {
  font-family: monospace;
  font-size: clamp(1.2rem, 3vw, 1.4rem);
}

@keyframes shake {
  0%, 100% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(0, 0, 0);
  }
  25% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(-3px, 0, 0);
  }
  75% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(3px, 0, 0);
  }
}

@keyframes explode {
  0% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    opacity: 1;
    filter: brightness(1.5) drop-shadow(0 0 10px currentColor);
  }
  50% {
    transform: scale(calc(var(--size-scale, 1) * 1.8)) rotate(calc(var(--rotation-angle, 0deg) + 180deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    opacity: 0.8;
    filter: brightness(2) drop-shadow(0 0 20px currentColor);
  }
  100% {
    transform: scale(0) rotate(calc(var(--rotation-angle, 0deg) + 360deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    opacity: 0;
    filter: brightness(3) drop-shadow(0 0 30px currentColor);
  }
}

@keyframes fall {
  0% {
    transform: scale(var(--size-scale, 1)) translate3d(0, var(--fall-distance, -50px), 0) rotate(var(--rotation-angle, 0deg));
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(var(--size-scale, 1)) translate3d(0, 0, 0) rotate(var(--rotation-angle, 0deg));
    opacity: 1;
  }
}

@keyframes boardShake {
  0%, 100% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(0, 0, 0);
  }
  20% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(-2px, 0, 0);
  }
  40% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(2px, 0, 0);
  }
  60% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(-1px, 0, 0);
  }
  80% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(1px, 0, 0);
  }
}

@keyframes swapFailed {
  0%, 100% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
  25% {
    transform: scale(var(--size-scale, 1)) rotate(calc(var(--rotation-angle, 0deg) - 5deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
  75% {
    transform: scale(var(--size-scale, 1)) rotate(calc(var(--rotation-angle, 0deg) + 5deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    filter: brightness(1) drop-shadow(0 0 5px currentColor);
  }
  70% {
    transform: scale(calc(var(--size-scale, 1) * 1.1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    filter: brightness(1.3) drop-shadow(0 0 15px currentColor);
  }
  100% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
    filter: brightness(1) drop-shadow(0 0 5px currentColor);
  }
}

@keyframes adjacentShake {
  0%, 100% {
    transform: scale(var(--size-scale, 1)) rotate(calc(var(--rotation-angle, 0deg) - 1deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
  50% {
    transform: scale(var(--size-scale, 1)) rotate(calc(var(--rotation-angle, 0deg) + 1deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
}

.jewel.dragging {
  opacity: 0.6;
  --size-scale: 1.2;
  --rotation-angle: 0deg;
  z-index: 1000;
  cursor: grabbing;
  filter: brightness(1.3) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.jewel.drag-target {
  --size-scale: 1.1;
  --rotation-angle: 0deg;
  z-index: 999;
  filter: brightness(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  animation: dragTargetPulse 1s ease-in-out infinite;
}

@keyframes dragTargetPulse {
  0%, 100% {
    filter: brightness(1.2) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  }
  50% {
    filter: brightness(1.4) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) rotate(var(--initial-rotation, 0deg)) translate3d(0, 0, 0);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(var(--initial-rotation, 0deg)) translate3d(0, 0, 0);
  }
}

/* Media query for very small screens */
@media screen and (max-width: 350px) {
  .game-info {
    flex-direction: column;
    gap: 1rem;
  }
  
  .game-controls {
    width: 100%;
    justify-content: center;
  }
}

/* Prevent text selection during gameplay */
* {
  user-select: none;
  -webkit-user-select: none;
}

.notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.2rem;
  text-align: center;
  z-index: 1000;
  animation: fadeInOut 2s ease-in-out;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.end-game-button {
  margin-top: 1rem;
  padding: 0.8rem 1.5rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  background: linear-gradient(135deg, #ff4d4d, #cc0000);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: transform 0.3s ease;
  font-family: inherit;
  font-weight: 600;
  min-height: 44px;
}

.end-game-button:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}

.end-game-button:active {
  transform: scale(0.95);
}

.hypercube {
  background-image: url('../assets/jewels/hypercube.png') !important;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
  animation: hypercubeGlow 2s ease-in-out infinite;
  position: relative;
}

.hypercube::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
  animation: hypercubeAura 3s ease-in-out infinite;
  border-radius: 8px;
  pointer-events: none;
}

.hypercube-target {
  animation: hypercubeExplode 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  z-index: 3;
}

.hypercube-flash {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  pointer-events: none;
  z-index: 1000;
  animation: hypercubeFlash 0.6s ease-in-out forwards;
}

@keyframes hypercubeGlow {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 1)) brightness(1.2);
    transform: scale(calc(var(--size-scale, 1) * 1.1)) rotate(var(--rotation-angle, 0deg)) translate3d(var(--offset-x, 0), var(--offset-y, 0), 0);
  }
}

@keyframes hypercubeAura {
  0%, 100% {
    opacity: 0.5;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2);
  }
}

@keyframes hypercubeExplode {
  0% {
    transform: scale(var(--size-scale, 1)) rotate(var(--rotation-angle, 0deg));
    opacity: 1;
    filter: brightness(2) saturate(2) drop-shadow(0 0 15px currentColor);
  }
  50% {
    transform: scale(2.5) rotate(calc(var(--rotation-angle, 0deg) + 180deg));
    opacity: 0.8;
    filter: brightness(3) saturate(3) drop-shadow(0 0 30px currentColor);
  }
  100% {
    transform: scale(0) rotate(calc(var(--rotation-angle, 0deg) + 360deg));
    opacity: 0;
    filter: brightness(4) saturate(4) drop-shadow(0 0 45px currentColor);
  }
}

@keyframes hypercubeFlash {
  0% {
    background: transparent;
    backdrop-filter: brightness(1) saturate(1);
  }
  25% {
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: brightness(1.5) saturate(1.5);
  }
  50% {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: brightness(2) saturate(2);
  }
  75% {
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: brightness(1.5) saturate(1.5);
  }
  100% {
    background: transparent;
    backdrop-filter: brightness(1) saturate(1);
  }
}

.neocat-mode .hypercube {
  background-image: url('../assets/jewels/neocat/hypercube.png') !important;
} 