:root {
    --primary: #FF006E;
    --secondary: #FB5607;
    --accent: #FFBE0B;
    --purple: #8338EC;
    --blue: #3A86FF;
    --dark: #1a1a1a;
    --light: #f8f9fa;
    --gray: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--dark) 0%, #2d1b69 50%, var(--dark) 100%);
    color: var(--light);
    min-height: 100vh;
    padding-bottom: 80px;
    overflow-x: hidden;
}

header {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 20px rgba(255, 0, 110, 0.3);
}

header h1 {
    font-size: 1.8rem;
    font-weight: bold;
    text-shadow: 0 0 20px var(--primary);
    color: var(--light);
}

main {
    padding: 1rem;
    max-width: 100%;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.section.active {
    display: block;
}

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

.game-container {
    max-width: 600px;
    margin: 0 auto;
}

.game-header {
    margin-bottom: 1rem;
}

.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 15px;
    border: 2px solid var(--blue);
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.3);
}

#remaining-pieces {
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.hint-btn, .reset-btn {
    background: linear-gradient(45deg, var(--purple), var(--blue));
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(131, 56, 236, 0.4);
}

.hint-btn:hover, .reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(131, 56, 236, 0.6);
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 2px;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    border: 2px solid var(--primary);
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.4);
    max-width: 100%;
    aspect-ratio: 8/7;
}

.grid-cell {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 40px;
    position: relative;
}

.grid-cell:hover {
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.3), rgba(251, 86, 7, 0.3));
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.5);
}

.grid-cell.placed {
    background: linear-gradient(45deg, var(--success), #20c997);
    color: white;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.grid-cell.highlighted {
    background: linear-gradient(45deg, var(--accent), var(--secondary));
    animation: pulse 1s infinite;
}

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

.dominoes-panel {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 15px;
    margin-bottom: 1rem;
    border: 2px solid var(--secondary);
    box-shadow: 0 0 20px rgba(251, 86, 7, 0.3);
}

.dominoes-panel h3 {
    margin-bottom: 1rem;
    text-align: center;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.dominoes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
}

.domino-piece {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    color: var(--dark);
    border: 2px solid var(--blue);
    border-radius: 10px;
    padding: 0.5rem;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.domino-piece:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(58, 134, 255, 0.4);
}

.domino-piece.selected {
    background: linear-gradient(45deg, var(--primary), var(--purple));
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.6);
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 0, 110, 0.6); }
    50% { box-shadow: 0 0 30px rgba(255, 0, 110, 0.9); }
}

.domino-piece.used {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(108, 117, 125, 0.5);
}

.message-area {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1rem;
    border: 2px solid var(--accent);
    box-shadow: 0 0 20px rgba(255, 190, 11, 0.3);
}

.message {
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

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

.message.success {
    background: linear-gradient(45deg, var(--success), #20c997);
    color: white;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.message.error {
    background: linear-gradient(45deg, var(--danger), #e74c3c);
    color: white;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.5);
}

.message.info {
    background: linear-gradient(45deg, var(--blue), var(--purple));
    color: white;
    box-shadow: 0 0 15px rgba(58, 134, 255, 0.5);
}

.content-container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 20px;
    border: 2px solid var(--blue);
    box-shadow: 0 0 30px rgba(58, 134, 255, 0.3);
}

.content-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent);
    font-size: 2rem;
}

.instructions-content {
    display: grid;
    gap: 1.5rem;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.instruction-icon {
    font-size: 2rem;
    min-width: 60px;
    text-align: center;
    background: linear-gradient(45deg, var(--primary), var(--purple));
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.4);
}

.instruction-text h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.instruction-text p {
    color: var(--light);
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    border: 2px solid var(--purple);
    box-shadow: 0 0 20px rgba(131, 56, 236, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 25px rgba(131, 56, 236, 0.5);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--light);
    font-size: 0.9rem;
}

.reset-stats-btn {
    background: linear-gradient(45deg, var(--danger), #e74c3c);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
    display: block;
    margin: 0 auto;
}

.reset-stats-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.6);
}

.faq-container {
    display: grid;
    gap: 1rem;
}

.faq-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    color: var(--light);
    padding: 1.5rem;
    text-align: left;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
}

.faq-question[aria-expanded="true"] {
    background: linear-gradient(45deg, var(--primary), var(--purple));
    color: white;
}

.faq-icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 1.5rem 1.5rem;
    color: var(--light);
    line-height: 1.6;
    animation: slideDown 0.3s ease-out;
}

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

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95), rgba(45, 27, 105, 0.95));
    backdrop-filter: blur(20px);
    border-top: 2px solid var(--primary);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem;
    box-shadow: 0 -4px 20px rgba(255, 0, 110, 0.3);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray);
    padding: 0.5rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    min-width: 60px;
}

.nav-item:hover {
    color: var(--accent);
    transform: translateY(-2px);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(255, 0, 110, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.3);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: bold;
}

footer {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--gray);
    font-size: 0.8rem;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .puzzle-grid {
        font-size: 0.7rem;
    }
    
    .grid-cell {
        min-height: 35px;
    }
    
    .dominoes-list {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
    
    .domino-piece {
        min-height: 45px;
        font-size: 0.7rem;
    }
    
    .content-container {
        padding: 1rem;
    }
    
    .content-container h2 {
        font-size: 1.5rem;
    }
    
    .instruction-item {
        flex-direction: column;
        text-align: center;
    }
    
    .instruction-icon {
        margin: 0 auto 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .game-status {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .hint-btn, .reset-btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .puzzle-grid {
        gap: 1px;
        padding: 0.5rem;
    }
    
    .grid-cell {
        min-height: 30px;
        font-size: 0.6rem;
    }
    
    .dominoes-list {
        max-height: 150px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
}

.domino-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--success), #20c997);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    font-size: 0.7rem;
    z-index: 10;
}

.grid-cell.hint-highlight {
    background: linear-gradient(45deg, var(--accent), var(--secondary));
    animation: hintPulse 2s infinite;
}

@keyframes hintPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 190, 11, 0.5);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(255, 190, 11, 0.8);
    }
}
