/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container Utama */
.app-container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.95);
    position: relative;
}

/* Header */
.app-header {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content h1 {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Navigation Tabs */
.tabs-navigation {
    display: flex;
    background: white;
    border-bottom: 2px solid #e5e7eb;
    position: sticky;
    top: 84px;
    z-index: 90;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tab-btn.active {
    color: #4f46e5;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #4f46e5;
}

/* Tab Contents */
.tab-contents {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Game Info */
.game-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.info-box {
    flex: 1;
    min-width: 100px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 0.8rem;
    text-align: center;
    border: 2px solid #e5e7eb;
}

.info-label {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0.3rem;
}

.info-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #111827;
}

#pattern-name {
    font-size: 1.2rem;
    color: #4f46e5;
}

/* Sequence Display */
.sequence-display {
    background: #f0f9ff;
    border: 2px dashed #0ea5e9;
    border-radius: 10px;
    padding: 0.8rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #0369a1;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Game Board */
.game-board-container {
    margin-bottom: 1.5rem;
}

.game-board-container h3 {
    text-align: center;
    margin-bottom: 0.8rem;
    color: #374151;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-width: 400px;
    margin: 0 auto;
    touch-action: manipulation;
}

.cell {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #ffffff, #f3f4f6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #1f2937;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
}

.cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.cell.selected {
    background: linear-gradient(145deg, #10b981, #059669);
    color: white;
    transform: scale(0.95);
}

.cell.start-cell {
    animation: blink 1.2s infinite;
}

.cell.available {
    animation: pulse 1.8s infinite;
}

.cell.wrong {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: white;
    animation: shake 0.5s;
}

.cell.correct {
    background: linear-gradient(145deg, #10b981, #059669);
    color: white;
    animation: pop 0.4s;
}

@keyframes blink {
    0%, 100% { 
        background: linear-gradient(145deg, #fbbf24, #f59e0b); 
        box-shadow: 0 0 15px rgba(245, 158, 11, 0.7);
    }
    50% { 
        background: linear-gradient(145deg, #f97316, #ea580c); 
        box-shadow: 0 0 20px rgba(249, 115, 22, 0.9);
    }
}

@keyframes pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}

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

/* Controls */
.controls {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    flex: 1;
    min-width: 100px;
    max-width: 150px;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

#start-btn {
    background: linear-gradient(90deg, #10b981, #059669);
    color: white;
}

#reset-btn {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    color: white;
}

#hint-btn {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.control-btn:active {
    transform: translateY(1px);
}

.control-btn:disabled {
    background: linear-gradient(90deg, #d1d5db, #9ca3af);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Game Status */
.game-status {
    text-align: center;
    padding: 0.8rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-weight: bold;
}

.success {
    color: #059669;
    background-color: rgba(16, 185, 129, 0.1);
    border: 2px solid #10b981;
}

.error {
    color: #dc2626;
    background-color: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
}

.info {
    color: #2563eb;
    background-color: rgba(59, 130, 246, 0.1);
    border: 2px solid #3b82f6;
}

/* Patterns Tab */
.patterns-container {
    padding: 0.5rem;
}

.patterns-container h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: #374151;
}

.difficulty-selector {
    background: #f3f4f6;
    padding: 0.8rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: center;
}

.difficulty-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #4b5563;
}

.difficulty-selector select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: #1f2937;
}

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

.pattern-btn {
    padding: 0.8rem;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.pattern-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.pattern-btn.active {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.pattern-info {
    background: #f0f9ff;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #0ea5e9;
}

.pattern-info h4 {
    color: #0369a1;
    margin-bottom: 0.5rem;
}

#pattern-example {
    font-size: 1.1rem;
    font-weight: 600;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

.pattern-description {
    font-size: 0.9rem;
    color: #6b7280;
    font-style: italic;
}

/* Instructions Tab */
.instructions-container {
    padding: 0.5rem;
}

.instructions-container h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: #374151;
}

.instructions-list {
    background: #f3f4f6;
    padding: 1rem 1rem 1rem 2rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.instructions-list li {
    margin-bottom: 0.8rem;
    line-height: 1.5;
    color: #4b5563;
}

.tips {
    background: #fef3c7;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #f59e0b;
}

.tips h4 {
    color: #d97706;
    margin-bottom: 0.5rem;
}

.tips ul {
    padding-left: 1.5rem;
    color: #92400e;
}

.tips li {
    margin-bottom: 0.5rem;
}

/* Footer */
.app-footer {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    color: white;
    padding: 1rem;
    text-align: center;
    margin-top: auto;
}

.footer-content p {
    margin-bottom: 0.3rem;
}

.developer {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .tab-btn {
        padding: 0.8rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .info-value {
        font-size: 1.5rem;
    }
    
    #pattern-name {
        font-size: 1rem;
    }
    
    .cell {
        font-size: 1rem;
    }
    
    .patterns-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .control-btn {
        min-width: 90px;
        padding: 0.7rem;
        font-size: 0.9rem;
    }
}

@media (min-width: 768px) {
    .app-container {
        max-width: 768px;
        margin: 0 auto;
        min-height: 100vh;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }
    
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .game-board {
        max-width: 500px;
        gap: 10px;
    }
    
    .cell {
        font-size: 1.4rem;
    }
}

/* Swipe Support */
.tab-contents {
    overflow-x: hidden;
    touch-action: pan-y;
}

/* Loading State */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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