* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

h1 {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #666;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.label {
    font-weight: 600;
    color: #555;
}

#difficulty {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

#difficulty:hover {
    background: #f0f0ff;
}

#attempts {
    font-weight: 700;
    font-size: 1.2rem;
    color: #667eea;
}

.examples-section {
    margin-bottom: 30px;
}

.examples-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #333;
}

.examples-grid {
    display: grid;
    gap: 15px;
    margin-bottom: 15px;
}

.example-item {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease-out;
}

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

.example-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.example-content {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.3rem;
    color: white;
}

.example-input, .example-output {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.arrow {
    font-size: 1.5rem;
    font-weight: bold;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #f0f0ff;
}

.btn-link {
    background: transparent;
    color: #667eea;
    text-decoration: underline;
    padding: 8px 16px;
}

.guess-section {
    margin-bottom: 30px;
}

.guess-section h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.hint {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

#guessInput {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

#guessInput:focus {
    outline: none;
    border-color: #667eea;
}

#guessInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.feedback {
    margin-bottom: 20px;
}

.feedback-correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    animation: celebrate 0.6s ease-out;
}

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

.feedback-incorrect {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1rem;
    animation: shake 0.5s ease-out;
}

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

.history {
    margin-bottom: 30px;
}

.history h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #333;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: #f8f9fa;
}

.history-item.incorrect {
    border-left: 4px solid #f5576c;
}

.history-item.correct {
    border-left: 4px solid #38ef7d;
    background: #e8f5e9;
}

.history-number {
    font-weight: 700;
    color: #666;
    min-width: 25px;
}

.history-guess {
    flex: 1;
    font-family: 'Courier New', monospace;
}

.history-result {
    font-size: 1.3rem;
}

.game-over {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
}

.game-over h2 {
    font-size: 2rem;
    margin-bottom: 20px;
}

.rule-reveal {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.rule-reveal h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

#actualRule {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: block;
}

.example-explanation {
    margin-top: 15px;
}

.example-explanation p {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.attempts-info {
    font-size: 0.95rem;
    opacity: 0.9;
}

.hidden {
    display: none !important;
}

.help-section {
    margin-top: 30px;
    text-align: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
    z-index: 1001;
    user-select: none;
    line-height: 1;
}

.close:hover {
    color: #333;
}

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

.modal-content ul {
    list-style-position: inside;
    line-height: 1.8;
    color: #555;
}

.modal-content li {
    margin-bottom: 10px;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .game-info {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .info-item {
        justify-content: space-between;
    }

    .example-content {
        font-size: 1.1rem;
        gap: 10px;
    }

    .example-input, .example-output {
        padding: 6px 12px;
    }
}
