/* CSS Variables for theme colors */
:root {
    --bg-primary: #F5F5DC; /* Beige */
    --bg-secondary: #FFFEF7; /* Light cream */
    --color-primary: #8B4513; /* Warm brown */
    --color-accent: #FF6B6B; /* Soft coral */
    --color-text: #4A4A4A; /* Medium grey */
    --color-grid: #D3D3D3; /* Light grey */
    --color-white: #FFFFFF;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-piece: 0 4px 15px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Dark mode variables */
[data-theme="dark"] {
    --bg-primary: #2C2C2C; /* Charcoal */
    --bg-secondary: #3A3A3A;
    --color-primary: #D2B48C; /* Light brown */
    --color-accent: #FF8E8E; /* Light coral */
    --color-text: #E0E0E0; /* Light grey */
    --color-grid: #555555; /* Medium grey */
    --color-white: #1E1E1E;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

.game-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--color-grid);
    margin-bottom: 30px;
}

.game-title {
    font-family: 'Comfortaa', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.score-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--color-white);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
}

.score-label {
    font-weight: 600;
    color: var(--color-text);
}

.score-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-primary);
}

.header-right {
    display: flex;
    gap: 10px;
}

.toggle-btn, .menu-btn {
    background: var(--color-white);
    border: 2px solid var(--color-grid);
    color: var(--color-text);
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover, .menu-btn:hover {
    background: var(--color-accent);
    color: white;
    transform: translateY(-2px);
}

.toggle-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Main game area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    position: relative;
}

/* Paw decorations */
.paw-decoration {
    position: absolute;
    font-size: 3rem;
    opacity: 0.1;
    user-select: none;
    pointer-events: none;
    z-index: 1;
    animation: pawFloat 3s ease-in-out infinite;
}

.paw-left {
    left: 10%;
    top: 20%;
    animation-delay: 0s;
}

.paw-right {
    right: 10%;
    top: 60%;
    animation-delay: 1.5s;
}

/* Game board styles */
.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 2px;
    padding: 20px;
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    width: min(500px, 90vw);
    height: min(500px, 90vw);
    position: relative;
    z-index: 10;
}

/* 9x9 grid adjustments */
.game-board.grid-9x9 {
    width: min(600px, 95vw);
    height: min(600px, 95vw);
    padding: 15px;
    gap: 1px;
}

.grid-cell {
    background: var(--bg-secondary);
    border: 1px solid var(--color-grid);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition);
    cursor: pointer;
}

.grid-cell:hover {
    background: var(--color-accent);
    opacity: 0.8;
}

.grid-cell.valid-drop {
    background: rgba(255, 107, 107, 0.3);
    border-color: var(--color-accent);
}

.grid-cell.invalid-drop {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
}

/* Placement preview styles */
.placement-preview {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
}

.placement-preview .cat-symbol {
    font-size: 1.2rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Cat piece styles */
.cat-piece {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 4px;
    background: var(--color-white);
    box-shadow: var(--shadow-piece);
    transition: var(--transition);
    cursor: grab;
}

.cat-piece:active {
    cursor: grabbing;
}

.cat-piece.dragging {
    opacity: 0.8;
    transform: scale(1.1);
    z-index: 1000;
}

.cat-piece.matching {
    animation: matchPulse 0.5s ease-in-out;
}

/* Cat symbols */
.cat-symbol {
    font-size: 2rem;
    user-select: none;
}

.cat-type-1 { color: #FF6B6B; } /* Pink cat */
.cat-type-2 { color: #4ECDC4; } /* Teal cat */
.cat-type-3 { color: #45B7D1; } /* Blue cat */
.cat-type-4 { color: #96CEB4; } /* Green cat */
.cat-type-5 { color: #9B59B6; } /* Purple frog */

/* Next piece container */
.next-piece-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: var(--color-white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    min-width: 200px;
}

.next-piece-title {
    font-family: 'Comfortaa', sans-serif;
    color: var(--color-primary);
    margin: 0;
}

.next-piece {
    display: flex;
    gap: 5px;
    min-height: 80px;
    align-items: center;
    justify-content: center;
}

.domino-piece {
    display: flex;
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-piece);
    cursor: grab;
    transition: var(--transition);
}

.domino-piece:hover {
    transform: scale(1.05);
}

.domino-piece.horizontal {
    flex-direction: row;
}

.domino-piece.vertical {
    flex-direction: column;
}

.domino-half {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-grid);
    background: var(--bg-secondary);
}

.domino-half:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
}

.domino-half:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.domino-piece.vertical .domino-half:first-child {
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    border-bottom-left-radius: 0;
}

.domino-piece.vertical .domino-half:last-child {
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    border-top-right-radius: 0;
}

/* Action button */
.action-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.action-btn:hover {
    background: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-piece);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--color-white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-piece);
    text-align: center;
    max-width: 400px;
    margin: 20px;
}

.modal-content h2 {
    color: var(--color-primary);
    margin-bottom: 15px;
    font-family: 'Comfortaa', sans-serif;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-grid);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pawFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(5deg); }
    66% { transform: translateY(5px) rotate(-3deg); }
}

.score-update {
    animation: slideIn 0.3s ease;
}

/* Responsive design */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .header-right {
        order: -1;
    }

    .game-title {
        font-size: 1.5rem;
    }

    .game-board {
        width: min(350px, 90vw);
        height: min(350px, 90vw);
        padding: 15px;
    }

    .cat-symbol {
        font-size: 1.5rem;
    }

    .domino-half {
        width: 35px;
        height: 35px;
    }

    .next-piece-container {
        padding: 15px;
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .game-board {
        width: min(300px, 95vw);
        height: min(300px, 95vw);
        padding: 10px;
    }

    .cat-symbol {
        font-size: 1.2rem;
    }

    .domino-half {
        width: 30px;
        height: 30px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .grid-cell:hover {
        background: var(--bg-secondary);
    }

    .cat-piece:hover {
        transform: none;
    }

    .toggle-btn:hover, .menu-btn:hover {
        transform: none;
    }

    .action-btn:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .game-container {
        background: white;
        color: black;
    }
    
    .toggle-btn, .menu-btn, .action-btn {
        display: none;
    }
}
