* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #ff69b4 30%, #32ff7e 70%, #ff1493 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(44, 62, 80, 0.4);
    padding: 20px;
    margin: 20px;
}

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

.game-header h1 {
    color: #ff1493;
    font-size: 2em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(255, 105, 180, 0.3);
}

.score-container {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(45deg, #ff69b4, #32ff7e);
    padding: 10px;
    border-radius: 15px;
    color: #2c3e50;
    font-weight: bold;
    flex-wrap: wrap;
    gap: 5px;
}

.highscore {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    padding: 5px 10px;
    border-radius: 10px;
    color: #2c3e50;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-gap: 5px;
    background: rgba(255, 182, 217, 0.2);
    padding: 10px;
    border-radius: 15px;
    margin-bottom: 20px;
    aspect-ratio: 1;
}

.tile {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    position: relative;
    border: 2px solid transparent;
}

/* Custom icon tiles - override emoji */
.tile-custom-icon {
    background-size: 90% 90%;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 0; /* Hide emoji completely when custom image is used */
}

/* Custom icon tiles - override emoji */
.tile-custom-icon {
    font-size: 0; /* Hide emoji fallback */
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(50, 255, 126, 0.4);
}

.tile.selected {
    outline: 3px solid #32ff7e;
    outline-offset: -2px;
    box-shadow: 0 0 15px rgba(50, 255, 126, 0.8);
}

.tile.matching {
    animation: matchPulse 0.6s ease-out;
}

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

.tile.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.tile.falling {
    animation: fallIn 0.5s ease-out;
}

@keyframes fallIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tile.family-match {
    animation: familyGlow 0.8s ease-in-out;
}

.tile.square-match {
    animation: squarePulse 0.6s ease-out;
}

@keyframes squarePulse {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(90deg); }
    50% { transform: scale(1.3) rotate(180deg); }
    75% { transform: scale(1.1) rotate(270deg); }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

@keyframes familyGlow {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.3); filter: brightness(2) hue-rotate(180deg); }
    100% { transform: scale(0); opacity: 0; filter: brightness(3); }
}

.tile.family-clear {
    animation: familyClear 0.6s ease-out;
}

@keyframes familyClear {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.5) rotate(180deg); }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

.family-particle {
    font-size: 24px !important;
    text-shadow: 0 0 10px rgba(255, 105, 180, 0.8);
}

.family-swap-particle {
    font-size: 18px !important;
    text-shadow: 0 0 8px rgba(255, 105, 180, 0.6);
}

.match-particle {
    font-size: 16px !important;
    text-shadow: 0 0 5px rgba(255, 105, 180, 0.5);
}

.square-particle {
    font-size: 20px !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* Custom icon backgrounds */
.tile-pomeranian { 
    background-image: url('/images/icons/pomeranian.png') !important;
    background-size: 80% 80% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}
.tile-baby { 
    background-image: url('/images/icons/baby.png') !important;
    background-size: 80% 80% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}
.tile-curly { 
    background-image: url('/images/icons/curly.png') !important;
    background-size: 80% 80% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}
.tile-asian { 
    background-image: url('/images/icons/asian.png') !important;
    background-size: 80% 80% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* Optional regular tile custom icons - commented out until you add them */
/* .tile-heart { background-image: url('/images/icons/heart.png'); }
.tile-ice { background-image: url('/images/icons/ice.png'); }
.tile-cookie { background-image: url('/images/icons/cookie.png'); }
.tile-coffee { background-image: url('/images/icons/coffee.png'); }
.tile-flower { background-image: url('/images/icons/flower.png'); } */

@keyframes fallIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Tile colors - themed to match icons */
.tile-type-0 { background: linear-gradient(45deg, #ffb6d9, #ffc0cb); } /* Heart */
.tile-type-1 { background: linear-gradient(45deg, #87ceeb, #add8e6); } /* Ice cube */
.tile-type-2 { background: linear-gradient(45deg, #deb887, #f4a460); } /* Cookie */
.tile-type-3 { background: linear-gradient(45deg, #ff69b4, #ff85c1); } /* Heart */
.tile-type-4 { background: linear-gradient(45deg, #8b4513, #a0522d); } /* Coffee */
.tile-type-5 { background: linear-gradient(45deg, #ffb6c1, #ffc0cb); } /* Flower */

/* Bonus tiles - transparent background for custom icons */
.tile-bonus {
    background: transparent;
    border: 2px solid transparent;
}

/* Regular bonus tiles (fallback when no custom image) */
.tile-bonus:not(.tile-pomeranian):not(.tile-baby):not(.tile-curly):not(.tile-asian) {
    background: linear-gradient(45deg, #ff69b4, #32ff7e, #2c3e50);
    border: 2px solid #ff1493;
}



.game-footer {
    display: flex;
    justify-content: space-around;
    gap: 10px;
}

#giveUpBtn {
    display: none !important;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    display: block;
    width: 100%;
    margin: 10px 0;
}

.btn-primary {
    background: linear-gradient(45deg, #ff1493, #ff69b4);
    box-shadow: 0 4px 15px rgba(255, 20, 147, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 20, 147, 0.6);
}

.btn-secondary {
    background: linear-gradient(45deg, #da70d6, #dda0dd);
    box-shadow: 0 4px 15px rgba(218, 112, 214, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(218, 112, 214, 0.6);
}

.modal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 105, 180, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(255, 105, 180, 0.5);
    max-width: 300px;
    position: relative;
    z-index: 10000;
}

.modal-content h2 {
    color: #ff1493;
    margin-bottom: 20px;
}

.modal-content p {
    color: #8b008b;
    margin-bottom: 20px;
    font-size: 1.2em;
    font-weight: bold;
}

.highscore-display {
    color: #ffd700 !important;
    font-size: 1.1em !important;
}

.new-highscore {
    color: #32ff7e;
    font-size: 1.3em;
    font-weight: bold;
    margin: 10px 0;
    animation: pulse 1s infinite;
}

/* Hide modals by default */
.modal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 105, 180, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* When modal should be visible */
.modal.visible {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 9999 !important;
}

/* Play Again button styling - hide by default, show in modal */
#playAgainBtn {
    display: none;
}

#gameOverModal.visible #playAgainBtn {
    display: block !important;
}

#highscoresSection[style*="display: block"] #playAgainBtn {
    display: block !important;
}

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

.name-input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
}

.name-input:focus {
    outline: none;
    border-color: #32ff7e;
    box-shadow: 0 0 10px rgba(50, 255, 126, 0.5);
}

.highscores-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-weight: bold;
}

.highscore-rank {
    color: #ffd700;
    margin-right: 10px;
    font-size: 1.2em;
}

.highscore-name {
    flex-grow: 1;
    color: #2c3e50;
}

.highscore-score {
    color: #ff69b4;
    font-size: 1.1em;
}

/* Slot Machine Styles */
.slot-machine-content {
    max-width: 450px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(44, 62, 80, 0.4);
    padding: 25px;
    border: 3px solid #ff69b4;
}

.slot-machine-content h2 {
    color: #ff1493;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(255, 105, 180, 0.3);
}

.slot-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff69b4, #32ff7e);
    padding: 12px 20px;
    border-radius: 15px;
    font-weight: bold;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(255, 105, 180, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.slot-score {
    color: #ffffff;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.slot-spins {
    color: #ffffff;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.slot-machine-container {
    position: relative;
    margin: 20px 0;
}

.slot-machine {
    display: flex;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 182, 217, 0.3), rgba(50, 255, 126, 0.2));
    padding: 15px;
    border-radius: 20px;
    height: 220px;
    overflow: hidden;
    position: relative;
    border: 4px solid #ff1493;
    box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.2);
}

.slot-machine-window {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Restore proper slot machine overlays */
.slot-window-top,
.slot-window-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(to bottom, 
        rgba(44, 62, 80, 0.6) 0%, 
        rgba(44, 62, 80, 0.3) 70%, 
        transparent 100%);
    z-index: 5;
}

.slot-window-top {
    top: 0;
}

.slot-window-bottom {
    bottom: 0;
    background: linear-gradient(to top, 
        rgba(44, 62, 80, 0.6) 0%, 
        rgba(44, 62, 80, 0.3) 70%, 
        transparent 100%);
}

/* Add a central viewing window 
.slot-machine::after {
    content: '';
    position: absolute;
    top: 75px;
    left: 0;
    right: 0;
    height: 60px;
    border: 3px solid #ffd700;
    border-left: none;
    border-right: none;
    background: rgba(255, 255, 255, 0.05);
    z-index: 4;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}
*/
/* Draw 2 horizontal lines at 1/3 and 2/3 */
.slot-machine::before,
.slot-machine::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;                 /* line thickness */
  background: #ffd700;         /* line color */
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.35);
}

.slot-machine::before {
  top: calc(100% / 3);
  transform: translateY(-50%); /* center the line on the 1/3 boundary */
}

.slot-machine::after {
  top: calc(2 * 100% / 3);
  transform: translateY(-50%); /* center the line on the 2/3 boundary */
}
.slot-reel {
    flex: 1;
    background: linear-gradient(45deg, #ffb6d9, #32ff7e);
    border-radius: 15px;
    border: 2px solid #ff1493;
    overflow: hidden;
    position: relative;
    transition: transform 0.05s ease-out;
    box-shadow: 
        inset 0 2px 8px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(255, 20, 147, 0.3);
    z-index: 3; /* Ensure reels are above overlays */
}

/* Custom icon support for slot machine */
.slot-reel .tile-pomeranian, 
.slot-reel .tile-baby, 
.slot-reel .tile-curly, 
.slot-reel .tile-asian {
    font-size: 0;
    background-size: 80% 80% !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: transparent !important;
}

.slot-icon {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8em;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

/* Individual icon colors matching main game */
.slot-icon:nth-child(6n+1) { background: linear-gradient(45deg, #ffb6d9, #ffc0cb); }
.slot-icon:nth-child(6n+2) { background: linear-gradient(45deg, #87ceeb, #add8e6); }
.slot-icon:nth-child(6n+3) { background: linear-gradient(45deg, #deb887, #f4a460); }
.slot-icon:nth-child(6n+4) { background: linear-gradient(45deg, #ff69b4, #ff85c1); }
.slot-icon:nth-child(6n+5) { background: linear-gradient(45deg, #8b4513, #a0522d); }
.slot-icon:nth-child(6n) { background: linear-gradient(45deg, #ffb6c1, #ffc0cb); }

.slot-reel.win-glow {
    animation: winGlow 0.5s ease-in-out infinite alternate;
}

@keyframes winGlow {
    0% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.8); }
    100% { box-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 50px rgba(50, 255, 126, 0.8); }
}

@keyframes bonusPop {
    0% { 
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

.slot-controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.slot-controls button {
    flex: 1;
}

.slot-win-display {
    background: rgba(255, 215, 0, 0.2);
    border: 2px solid #ffd700;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
    color: #ffffff;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Slot Machine Modal Specific */
#slotMachineModal.visible {
    display: flex !important;
}

#slotMachineModal {
    background: rgba(255, 105, 180, 0.9);
}

/* Responsive design for slot machine */
@media (max-width: 480px) {
    .game-container {
        margin: 10px;
        padding: 15px;
    }
    
    .game-board {
        grid-gap: 3px;
        padding: 5px;
    }
    
    .tile {
        font-size: 1.2em;
    }
    
    .slot-machine-content {
        padding: 20px;
        margin: 10px;
    }
    
    .slot-machine {
        height: 140px;
        padding: 10px;
    }
    
    .slot-icon {
        height: 45px;
        font-size: 2em;
    }
}