:root {
    --primary-color: #FF006E;
    --secondary-color: #FB5607;
    --accent-color: #FFBE0B;
    --purple-color: #8338EC;
    --blue-color: #3A86FF;
    --dark-bg: #0a0a0a;
    --darker-bg: #050505;
    --card-bg: #1a1a1a;
    --text-light: #ffffff;
    --text-gray: #cccccc;
    --text-dark: #666666;
    --border-color: #333333;
    --success-color: #00ff88;
    --error-color: #ff4444;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
}

.app-header {
    background: linear-gradient(90deg, var(--primary-color), var(--purple-color));
    padding: 1rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(255, 0, 110, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.main-content {
    flex: 1;
    padding: 1rem;
    padding-bottom: 100px;
    max-width: 100%;
}

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

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

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

/* Game Area Styles */
.game-area {
    max-width: 100%;
}

.cipher-display {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.cipher-display h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.3rem;
}

.cipher-text, .solution-text {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.cipher-text {
    background: rgba(255, 0, 110, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    text-shadow: 0 0 5px rgba(255, 0, 110, 0.3);
}

.solution-text {
    background: rgba(58, 134, 255, 0.1);
    border: 1px solid var(--blue-color);
    color: var(--blue-color);
    min-height: 60px;
}

.substitution-panel {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.substitution-panel h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.substitution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.5rem;
    max-width: 100%;
}

.substitution-pair {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(131, 56, 236, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
    border: 1px solid var(--purple-color);
}

.cipher-letter {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.solution-input {
    width: 30px;
    height: 30px;
    text-align: center;
    background: rgba(58, 134, 255, 0.2);
    border: 1px solid var(--blue-color);
    border-radius: 5px;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
}

.solution-input:focus {
    outline: none;
    box-shadow: 0 0 10px var(--blue-color);
    border-color: var(--accent-color);
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    min-width: 120px;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--purple-color));
    color: white;
    box-shadow: 0 4px 15px rgba(255, 0, 110, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, var(--text-dark), var(--border-color));
    color: white;
    box-shadow: 0 4px 15px rgba(102, 102, 102, 0.4);
}

.btn-accent {
    background: linear-gradient(45deg, var(--accent-color), var(--secondary-color));
    color: var(--dark-bg);
    box-shadow: 0 4px 15px rgba(255, 190, 11, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 0, 110, 0.6);
}

.btn:active {
    transform: translateY(0);
}

.progress-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.progress-section h3 {
    color: var(--success-color);
    margin-bottom: 1rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--darker-bg);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--accent-color));
    width: 0%;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.progress-text {
    text-align: center;
    color: var(--text-gray);
    font-weight: 600;
}

/* Analysis Section */
.analysis-container {
    max-width: 100%;
}

.analysis-container h2 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 2rem;
}

.frequency-chart {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    min-height: 200px;
}

.frequency-bar {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.frequency-letter {
    font-weight: bold;
    color: var(--primary-color);
    width: 30px;
    text-align: center;
}

.frequency-bar-fill {
    flex: 1;
    height: 20px;
    background: var(--darker-bg);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.frequency-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue-color), var(--purple-color));
    transition: width 0.5s ease;
}

.frequency-count {
    color: var(--text-gray);
    font-size: 0.9rem;
    min-width: 40px;
    text-align: right;
}

.patterns-list, .suggestions-list {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.patterns-list h3, .suggestions-list h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.pattern-item, .suggestion-item {
    background: rgba(251, 86, 7, 0.1);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

/* Help Section */
.help-container {
    max-width: 100%;
}

.help-container h2 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 2rem;
}

.help-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.help-section h3 {
    color: var(--blue-color);
    margin-bottom: 1rem;
}

.help-section p, .help-section li {
    line-height: 1.6;
    color: var(--text-gray);
    margin-bottom: 0.5rem;
}

.help-section ol, .help-section ul {
    padding-left: 1.5rem;
}

/* FAQ Styles */
.faq-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    margin-top: 2rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.faq-section h2 {
    color: var(--purple-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

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

.faq-question:hover {
    color: var(--accent-color);
}

.faq-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

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

.faq-answer {
    padding: 0 0 1rem 0;
    color: var(--text-gray);
    line-height: 1.6;
    animation: slideDown 0.3s ease;
}

.faq-answer[hidden] {
    display: none;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 200px; }
}

/* Stats Section */
.stats-container {
    max-width: 100%;
}

.stats-container h2 {
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 2rem;
}

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

.stat-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

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

.achievements-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.achievements-section h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.achievement-item {
    background: rgba(131, 56, 236, 0.1);
    border: 1px solid var(--purple-color);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--success-color);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.achievement-title {
    font-weight: bold;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.achievement-description {
    font-size: 0.9rem;
    color: var(--text-gray);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, var(--dark-bg), var(--darker-bg));
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

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

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

.nav-item span {
    font-size: 0.8rem;
    font-weight: 500;
}

.nav-item.active {
    color: var(--primary-color);
    background: rgba(255, 0, 110, 0.1);
    transform: translateY(-2px);
}

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

/* Footer */
footer {
    background: var(--darker-bg);
    color: var(--text-gray);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-bottom: 80px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 0.5rem;
        padding-bottom: 100px;
    }
    
    .cipher-display, .substitution-panel, .progress-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .substitution-grid {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 0.25rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .app-header h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .cipher-text, .solution-text {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .substitution-grid {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    }
    
    .solution-input {
        width: 25px;
        height: 25px;
        font-size: 0.9rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations and Effects */
.glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 5px var(--primary-color); }
    to { box-shadow: 0 0 20px var(--primary-color), 0 0 30px var(--primary-color); }
}

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

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

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

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

.correct-letter {
    background: rgba(0, 255, 136, 0.3) !important;
    border-color: var(--success-color) !important;
    color: var(--success-color) !important;
}

.incorrect-letter {
    background: rgba(255, 68, 68, 0.3) !important;
    border-color: var(--error-color) !important;
    color: var(--error-color) !important;
}

/* Loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.hidden { display: none !important; }
.visible { display: block !important; }

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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