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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Container and layout */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    font-size: 1.1rem;
    color: #6c757d;
    font-weight: 400;
}

/* Main content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Form styling */
.treasure-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1rem;
}

.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: white;
}

.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-help {
    margin-left: 0.5rem;
    color: #6c757d;
    font-size: 0.9rem;
}

/* Class selection */
.class-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.class-checkbox {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.class-checkbox:hover {
    background: rgba(102, 126, 234, 0.1);
}

.class-checkbox input[type="checkbox"] {
    margin-right: 0.5rem;
    accent-color: #667eea;
}

.class-checkbox span {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    width: 100%;
    font-size: 1.1rem;
    padding: 1rem;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

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

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

.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

/* Results */
.results {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 700;
}

.results-content {
    line-height: 1.7;
}

/* Markdown styling in results */
.results-content h1 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    border-bottom: 3px solid #667eea;
    padding-bottom: 0.5rem;
}

.results-content h2 {
    color: #34495e;
    font-size: 1.4rem;
    margin: 1.5rem 0 1rem 0;
}

.results-content h3 {
    color: #34495e;
    font-size: 1.2rem;
    margin: 1.2rem 0 0.8rem 0;
}

.results-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.results-content li {
    margin: 0.3rem 0;
}

.results-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.results-content a:hover {
    border-bottom-color: #667eea;
}

.results-content strong {
    color: #2c3e50;
}

.results-content hr {
    border: none;
    border-top: 2px solid #e9ecef;
    margin: 2rem 0;
}

/* Error styling */
.error {
    background: rgba(220, 53, 69, 0.1);
    border: 2px solid rgba(220, 53, 69, 0.3);
    color: #721c24;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.error h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.error p {
    margin-bottom: 1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading state */
.btn-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .treasure-form,
    .results {
        padding: 1.5rem;
    }
    
    .class-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.3rem;
    }
    
    .class-checkbox {
        padding: 0.4rem;
    }
    
    .class-checkbox span {
        font-size: 0.85rem;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-content h1 {
        font-size: 1.5rem;
    }
    
    .results-content h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 0;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .class-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .btn-primary {
        font-size: 1rem;
        padding: 0.9rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .treasure-form,
    .results {
        border: 2px solid #2c3e50;
    }
    
    .form-group input[type="number"],
    .form-group select {
        border-color: #2c3e50;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}