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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 'Hiragino Sans', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

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

/* Cards */
.upload-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.upload-card h2 {
    color: #4a5568;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

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

.form-group small {
    display: block;
    color: #718096;
    margin-top: 5px;
    font-size: 0.875rem;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #f7fafc;
}

.upload-area:hover, .upload-area.dragover {
    border-color: #667eea;
    background: #edf2f7;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.upload-text p {
    margin-bottom: 10px;
    color: #4a5568;
}

.upload-button {
    color: #667eea;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

/* File List */
.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #48bb78;
}

.file-name {
    font-weight: 500;
    color: #2d3748;
}

.file-size {
    color: #718096;
    font-size: 0.875rem;
}

.remove-file {
    background: #fed7d7;
    color: #e53e3e;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75rem;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

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

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: white;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Results Section */
.results-section {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.stat-card {
    text-align: center;
    color: white;
}

.stat-card h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Ranking Section */
.ranking-section, .distribution-section, .games-section {
    padding: 30px;
    border-bottom: 1px solid #e2e8f0;
}

.ranking-section:last-child, .distribution-section:last-child, .games-section:last-child {
    border-bottom: none;
}

.ranking-section h2, .distribution-section h2, .games-section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.ranking-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.ranking-table th {
    background: #f7fafc;
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
}

.ranking-table td {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.ranking-table tr:hover {
    background: #f7fafc;
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4a) !important;
    color: #744210;
    font-weight: 600;
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #e2e8f0) !important;
    color: #4a5568;
    font-weight: 600;
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #ed8936) !important;
    color: white;
    font-weight: 600;
}

.streak-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #667eea;
}

/* Distribution Chart */
#distributionChart {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.distribution-item {
    display: flex;
    align-items: center;
    background: #f7fafc;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    min-width: 200px;
}

.distribution-label {
    font-weight: 600;
    color: #4a5568;
    margin-right: 15px;
}

.distribution-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

/* Games List */
#gamesList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.game-item {
    background: #f7fafc;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #48bb78;
}

.game-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 5px;
}

.game-count {
    color: #718096;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-card {
        padding: 20px;
    }
    
    .upload-area {
        padding: 30px 20px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
        padding: 20px;
    }
    
    .ranking-section, .distribution-section, .games-section {
        padding: 20px;
    }
}