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

:root {
    --primary-color: #0052CC;
    --primary-hover: #0747A6;
    --secondary-color: #6B778C;
    --success-color: #00875A;
    --danger-color: #DE350B;
    --warning-color: #FFAB00;
    --background: #FAFBFC;
    --surface: #FFFFFF;
    --text-primary: #172B4D;
    --text-secondary: #5E6C84;
    --border-color: #DFE1E6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #0052CC 0%, #0747A6 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 1.5rem;
}

.language-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.lang-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.lang-btn.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
}

main {
    padding: 2rem;
}

.input-section {
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.help-text {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.data-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: 'Monaco', 'Courier New', monospace;
    resize: vertical;
    transition: var(--transition);
    background: var(--background);
}

.data-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.results-section {
    animation: fadeIn 0.5s ease-out;
}

.hidden {
    display: none;
}

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

.stat-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Monaco', 'Courier New', monospace;
}

.chart-container {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    margin-top: 2rem;
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

#histogram {
    max-height: 400px;
}

footer {
    background: var(--background);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

/* レスポンシブデザイン */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .container {
        border-radius: var(--radius);
    }
    
    header, main {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .language-selector {
        flex-direction: column;
    }
    
    .lang-btn {
        width: 100%;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1F2937;
        --surface: #111827;
        --text-primary: #F9FAFB;
        --text-secondary: #D1D5DB;
        --border-color: #374151;
    }
    
    body {
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    }
    
    .data-input {
        background: var(--surface);
        color: var(--text-primary);
    }
    
    .stat-card {
        background: var(--surface);
    }
    
    .chart-container {
        background: var(--surface);
    }
    
    footer {
        background: var(--surface);
    }
}