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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background: #ffffff;
    --surface: #f8f9fa;
    --surface-hover: #e9ecef;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --image-placeholder: #e5e7eb;
    --badge-bg: #374151;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.fixed-header {
    position: sticky;
    top: 0;
    background: var(--background);
    z-index: 100;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 20px 0 0 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.header-top h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin: 0;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    justify-content: flex-start;
    margin-left: 20px;
}

.header-right-top {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-section {
    margin-bottom: 0;
}

.search-bar {
    display: flex;
    gap: 10px;
    flex: 0 0 350px;
    max-width: 350px;
}

.filters-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-count {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.accordion-toggle {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.accordion-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
}

.accordion-icon {
    display: inline-block;
}

.accordion-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    width: auto;
    flex: 1;
}

.accordion-content.collapsed {
    display: none;
}

.main-content {
    padding-top: 30px;
}

#searchInput {
    flex: 1;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.controls-bar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}


.page-size-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-selector label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.page-size-selector select {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-size-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-selector label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.filter-selector select {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
    max-width: 300px;
    height: auto;
}


.filter-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-selector select option {
    padding: 8px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.game-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px var(--shadow);
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.game-image {
    width: 100%;
    height: 420px;
    background: var(--image-placeholder);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.game-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.game-image .placeholder-icon {
    font-size: 4rem;
    color: var(--text-light);
}

.game-badges {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    padding-top: 12px;
    gap: 12px;
}

.game-badges-left {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: flex-end;
}

.game-badges-right {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}

.release-date-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.storage-badge {
    display: inline-block;
    background: var(--badge-bg);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.size-badge {
    display: inline-block;
    background: var(--text-secondary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.size-score-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.metascore-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.metascore-high {
    background: #00ce7a;
}

.metascore-medium {
    background: #ffbd3f;
}

.metascore-low {
    background: #ff6874;
}

.metascore-tbd {
    background: white;
    color: #1f2937;
    border: 1px solid #1f2937;
}

.game-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.game-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
    line-height: 1.3;
}

.game-sub-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    min-height: 1.2em;
}

.game-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-light);
}

.game-genre {
    color: var(--text-light);
}

.game-size {
    color: var(--text-light);
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.loading-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    gap: 12px;
}

.spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-more p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.load-more {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
    padding: 20px 0;
}

.load-more-btn {
    padding: 12px 32px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.load-more-btn:hover {
    background: var(--primary-hover);
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: #e0e7ff;
    border: none;
    border-radius: 6px;
    font-size: 20px;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    line-height: 1;
    z-index: 1002;
}

.modal-close:hover {
    background: #c7d2fe;
}

.modal-header {
    margin-bottom: 20px;
    padding-right: 40px;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.modal-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

.modal-image {
    width: 100%;
    height: 600px;
    background: var(--image-placeholder);
    border-radius: 8px;
    margin-bottom: 24px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.modal-placeholder {
    color: var(--text-light);
    font-size: 1.5rem;
    text-align: center;
    padding: 40px;
}

.modal-info {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background: #e5e7eb;
    border-radius: 8px;
}

.modal-info-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    width: fit-content;
}

.modal-info-item.full-width {
    width: 100%;
}

.modal-info-item.full-width .modal-value {
    white-space: normal;
    word-wrap: break-word;
}

.modal-info-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.modal-info-item-inline {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    min-width: 150px;
}

.modal-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    min-width: 50px;
    flex-shrink: 0;
}

.modal-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-right {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-left: 0;
    }

    .search-bar {
        flex: 1;
        max-width: 100%;
        width: 100%;
    }

    .filters-row {
        width: 100%;
        flex-wrap: wrap;
    }


    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }

    .game-image {
        height: 320px;
    }

    .modal-image {
        height: 500px;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .fixed-header {
        padding: 15px 0 0 0;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-top h1 {
        font-size: 1.75rem;
        margin-bottom: 0;
    }

    .header-right {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-right-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .accordion-toggle {
        display: block;
        flex-shrink: 0;
    }

    .game-count {
        font-size: 0.85rem;
        margin-left: auto;
    }

    .accordion-content {
        width: 100%;
        flex-direction: column;
        gap: 12px;
    }

    .accordion-content.collapsed {
        display: none;
    }

    .search-bar {
        flex: 1;
        max-width: 100%;
        width: 100%;
    }

    .filters-row {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .filter-selector {
        width: 100%;
    }

    .filter-selector select {
        width: 100%;
        max-width: 100%;
    }

    .game-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .game-image {
        height: 300px;
    }

    .game-info {
        padding: 12px;
    }

    .game-title {
        font-size: 0.95rem;
    }

    .filter-selector {
        width: 100%;
    }

    .filter-selector select {
        width: 100%;
        max-width: 100%;
    }

    .modal-content {
        padding: 20px;
        max-width: 95%;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .modal-subtitle {
        font-size: 0.9rem;
    }

    .modal-image {
        height: 300px;
        margin-bottom: 20px;
    }

    .modal-info {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .modal-info-row {
        gap: 6px;
    }
}
