/* ===== CSS 변수 정의 ===== */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-primary: #2c3e50;
    --text-secondary: #555;
    --text-light: #888;
    --bg-main: #f4f7f9;
    --bg-card: #ffffff;
    --bg-secondary: #f0f2f5;
    --border-color: #e0e6ed;
    --shadow-color: rgba(44, 62, 80, 0.1);
    --success-color: #4CAF50;
    --error-color: #ff6b6b;
    --delete-color: #f44336;
    --delete-hover: #d32f2f;
    --border-radius: 0.75rem; /* 12px */
    --sidebar-width-pc: 17.5rem; /* 280px */
    --sidebar-width-mobile: 17.5rem; /* 280px */
}

/* ===== 다크모드 변수 ===== */
body.dark-mode {
    --primary-color: #7c8ff5;
    --secondary-color: #9370db;
    --text-primary: #e4e6eb;
    --text-secondary: #b8bcc8;
    --text-light: #8a8d96;
    --bg-main: #18191a;
    --bg-card: #242526;
    --bg-secondary: #3a3b3c;
    --border-color: #3a3b3c;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --success-color: #4caf50;
    --error-color: #f44336;
    --delete-color: #f44336;
    --delete-hover: #d32f2f;
}

/* 다크모드 전환 애니메이션 */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== 기본 및 레이아웃 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { 
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 16px; /* rem 단위의 기준 */
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
}
.page.active { display: block; }
.hidden { display: none !important; }

/* ===== 모바일 기본 레이아웃 ===== */
.main-layout {
    max-width: 105rem; /* 1680px */
    margin: 0 auto;
}
.main-content {
    padding: 1rem; /* 16px */
    width: 100%;
}

/* ===== 인증 화면 ===== */
#auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    height: 100vh;
}
#auth-container h1 {
    font-size: 2rem;
    color: var(--primary-color);
}
#auth-container p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}
.google-login-btn {
    background-color: #fff;
    color: #444;
    font-size: 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem; /* 12px */
    padding: 0.75rem 1.25rem; /* 12px 20px */
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.1); /* 2px 4px */
    border: 1px solid var(--border-color);
    cursor: pointer;
}
.google-login-btn:hover {
    background-color: #f9f9f9;
}
.auth-notice {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.5;
}


/* ===== 헤더 ===== */
#page-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; }
#header-title {
    font-size: 1.1em; /* 모바일 기본 크기 조정 */
    font-weight: 700;
    line-height: 1.3;
}
#header-title #user-nickname-line1 {
    display: block; /* 줄바꿈 */
    font-size: 1.1em; /* 닉네임 강조 */
}
#header-title #header-subtitle {
    display: inline-flex; /* 게임 카운트와 같은 줄에 */
    align-items: center;
    font-size: 0.9em;
    font-weight: 600;
}

.game-count-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.8em;
    font-weight: 600;
    padding: 0.2rem 0.4rem; /* 모바일 크기 조정 */
    border-radius: 0.75rem;
    margin-left: 0.4rem;
}
.header-controls { display: flex; gap: 0.5rem; align-items: center; }
.action-icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    text-decoration: none;
}
.action-icon-btn:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}
.action-icon-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.view-icon { display: none; } /* Initially hide both */
.view-icon.active { display: block; } /* Show only the active one */


/* ===== 필터 사이드바 (모바일) ===== */
.filter-sidebar { 
    position: fixed; 
    top: 0; 
    right: -100%; 
    width: var(--sidebar-width-mobile); 
    max-width: 90%; 
    height: 100%; 
    background-color: var(--bg-card); 
    box-shadow: -0.3125rem 0 1.5625rem rgba(0,0,0,0.3);
    z-index: 1100; 
    transition: right 0.3s ease-in-out; 
    display: flex; 
    flex-direction: column;
    border-left: 1px solid var(--border-color);
}
.filter-sidebar.open { right: 0; }
.filter-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); }
.filter-header h3 { font-size: 1.2em; }
.filter-header .close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); }
.filter-sidebar .controls { padding: 1.25rem; overflow-y: auto; flex: 1; position: relative; }
/* 필터 로딩 스피너 */
.filter-sidebar .controls.loading-details::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-card);
    opacity: 0.7;
    z-index: 10;
}
.filter-sidebar .controls.loading-details::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 3rem; height: 3rem;
    margin-left: -1.5rem;
    margin-top: -1.5rem;
    border: 0.25rem solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

.filter-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); z-index: 1050; opacity: 1; transition: opacity 0.3s ease; }
.filter-overlay.hidden { opacity: 0; pointer-events: none; }

/* 필터 컨트롤 공통 스타일 */
.filter-sort-btn {
    width: 100%;
    background-color: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, border-color 0.2s;
}
.filter-sort-btn:hover { background-color: #e9eafc; border-color: var(--primary-color); }
.search-box, .filter-group { margin-bottom: 1.5rem; }
.search-box label, .filter-group label { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.5rem; display: block; }
.filter-input { 
    width: 100%;
    border: 1px solid var(--border-color); 
    background-color: var(--bg-main); 
    height: 2.75rem;
    font-size: 1rem;
    outline: none; 
    border-radius: 0.5rem;
    padding: 0 0.75rem;
    -webkit-appearance: none; /* Safari 그림자 제거 */
}
.filter-input:focus {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.toggle-group { display: flex; align-items: center; gap: 0.625rem; margin-top: 0.75rem; }
.toggle-group .toggle-label { font-size: 0.875rem; color: var(--text-secondary); cursor: pointer; }
.toggle-switch { position: relative; display: inline-block; width: 2.75rem; height: 1.5rem; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-color); transition: .4s; border-radius: 1.5rem; }
.toggle-slider:before { position: absolute; content: ""; height: 1.25rem; width: 1.25rem; left: 0.125rem; bottom: 0.125rem; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
input:checked + .toggle-slider { background-color: var(--primary-color); }
input:checked + .toggle-slider:before { transform: translateX(1.25rem); }
.slider-wrapper { position: relative; height: 1.5rem; }
.slider-wrapper .slider-track, .slider-wrapper .slider-range { position: absolute; left: 0; right: 0; top: 0.625rem; height: 0.25rem; border-radius: 0.125rem; }
.slider-wrapper .slider-track { background-color: var(--border-color); }
.slider-wrapper .slider-range { background-color: var(--primary-color); }
.slider-wrapper input[type="range"] { -webkit-appearance: none; appearance: none; position: absolute; width: 100%; height: 1.5rem; background: transparent; pointer-events: none; margin: 0; }
.slider-wrapper input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 1.5rem; height: 1.5rem; background-color: white; border: 2px solid var(--primary-color); border-radius: 50%; cursor: pointer; pointer-events: auto; box-shadow: 0 0 0.3125rem rgba(0,0,0,0.2); }
.slider-wrapper input[type="range"]::-moz-range-thumb { width: 1.25rem; height: 1.25rem; background-color: white; border: 2px solid var(--primary-color); border-radius: 50%; cursor: pointer; pointer-events: auto; box-shadow: 0 0 0.3125rem rgba(0,0,0,0.2); }
.slider-values { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-light); margin-top: 0.5rem; }

/* ===== 태그 필터 & 관리 ===== */
.tag-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.tag-filter-item {
    display: flex;
    align-items: center;
}
.tag-filter-item input[type="checkbox"] {
    display: none;
}
.tag-filter-item label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0;
}
.tag-filter-item input:checked + label {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.tag-color-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}
.filter-no-tags-info {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== 그리드 & 리스트 ===== */
/* Grid View */
#gameListContainer.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

.game-card-grid { 
    background: var(--bg-card); 
    border-radius: var(--border-radius); 
    box-shadow: 0 0.25rem 0.75rem var(--shadow-color); 
    overflow: hidden; 
    cursor: pointer; 
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
}
.game-card-grid:hover { 
    transform: translateY(-0.3125rem); 
    box-shadow: 0 0.5rem 1.25rem var(--shadow-color); 
}
.game-card-grid:active {
    transform: translateY(-0.125rem) scale(0.97);
    box-shadow: 0 0.25rem 0.5rem var(--shadow-color);
    transition-duration: 0.1s;
}
.game-image { width: 100%; padding-top: 100%; position: relative; background-color: var(--bg-secondary); }
.game-image img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.game-title-grid { padding: 0.625rem; text-align: center; }
.game-title-grid h3 { font-size: 0.9em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* List View */
#gameListContainer.game-list { display: flex; flex-direction: column; gap: 0.75rem; }
.game-list-item {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: 0 0.25rem 0.75rem var(--shadow-color);
    padding: 1rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Increased gap */
    transition: transform 0.2s ease, box-shadow 0.2s ease; 
}
.game-list-item:hover { 
    transform: translateY(-0.3125rem); 
    box-shadow: 0 0.5rem 1.25rem var(--shadow-color); 
}
.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.list-item-header h3 { font-size: 1.1em; font-weight: 700; margin-bottom: 0.25rem; }
.list-item-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.list-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem 1rem;
    font-size: 0.8em;
    color: var(--text-secondary);
}
.list-detail-item { display: flex; flex-direction: column; }
.list-detail-item strong { color: var(--text-primary); font-weight: 600; margin-bottom: 0.1rem; }
.list-detail-item span { word-break: break-all; } /* Allow long values to wrap */
.detail-loading-indicator {
    font-size: 0.8em;
    color: var(--text-light);
    font-style: italic;
    grid-column: 1 / -1; /* Span full width if details loading */
}

.empty-state-text { grid-column: 1 / -1; text-align: center; padding: 2.5rem; color: #888; }

/* 그리드 카드 태그 */
.card-tags-container {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.card-tag {
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}


/* ===== 모달, 로딩, 메시지 ===== */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 1rem; }
.modal-close-btn { position: absolute; top: 0.75rem; right: 0.75rem; background: rgba(0,0,0,0.3); color: white; border: none; border-radius: 50%; width: 2rem; height: 2rem; font-size: 1.125rem; cursor: pointer; z-index: 10; display:flex; align-items:center; justify-content:center; }
.modal-close-btn:hover { background: rgba(0,0,0,0.6); }

/* 상세 모달 */
.detail-content { background-color: var(--bg-card); border-radius: 1rem; width: 32.5rem; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 0.625rem 2.5rem rgba(0,0,0,0.5); position: relative; overflow: hidden; }
.modal-body-wrapper { display: flex; flex-direction: column; min-height: 0; flex-grow: 1; overflow: hidden; /* Prevent content overflow */}
.modal-image {
    position: relative;
    background-color: var(--bg-secondary);
    height: 40vh; /* 모바일 이미지 높이 고정 */
    max-height: 300px; /* 최대 높이 제한 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    flex-shrink: 0;
}
body.dark-mode .modal-image {
    background-color: #1a1a1a;
}
.modal-image img { 
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain; 
    border-radius: 0.5rem;
}
.detail-info {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}
.detail-info h2 { font-size: 1.6em; margin-bottom: 0.75rem; }
.detail-field { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border-color); font-size: 0.9em; gap: 1rem; }
.detail-field:last-of-type { border-bottom: none; }
.detail-field strong { color: var(--text-primary); flex-shrink: 0; }
.detail-field .value-span { color: var(--text-secondary); text-align: right; word-break: break-all; }
.edit-icon { cursor: pointer; color: var(--text-light); transition: color 0.2s; padding: 0.25rem; }
.edit-icon:hover { color: var(--primary-color); }
.detail-field .edit-input { height: 2.2rem; flex-grow: 1; }
.detail-field.edit-container { gap: 0.5rem; }
.detail-field.edit-container .key-input { flex-basis: 40%; }
.detail-field.edit-container .value-input { flex-basis: 60%; }
.field-actions { display: flex; align-items: center; }
.field-delete-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0 0.25rem;
    line-height: 1;
}
.field-delete-btn:hover { color: var(--delete-color); }


.detail-section { margin-top: 1.25rem; }
.detail-section h3 { font-size: 1.1em; }
.detail-section textarea { min-height: 80px; font-size: 0.9em; width: 100%; margin-top: 0.5rem; }
.detail-section-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s;
}
.detail-section-btn:hover { background-color: var(--secondary-color); }
.delete-btn { background-color: var(--delete-color); }
.delete-btn:hover { background-color: var(--delete-hover); }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    background: var(--bg-main);
    flex-shrink: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.detail-section-icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.detail-section-icon-btn:hover {
    background-color: var(--bg-main);
    color: var(--primary-color);
}


/* 태그 관리 */
.detail-tags-container { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 1.5rem; }
.tag-manage-modal { z-index: 2100; } /* Ensure tag modals are above detail modal */
.tag-manage-list { margin: 1rem 0; max-height: 40vh; overflow-y: auto; }
.tag-manage-item { padding: 0.5rem 0.75rem; border-radius: 1rem; border: 1px solid var(--border-color); cursor: pointer; transition: background-color 0.2s, border-color 0.2s; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.tag-manage-item:hover { background-color: #f0f2f5; }
.tag-manage-item.selected { background-color: var(--primary-color); border-color: var(--primary-color); color: white; }
.tag-manage-item-info { display: flex; align-items: center; gap: 0.5rem; }
.tag-delete-btn { background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 1.2rem; padding: 0 0.25rem; border-radius: 50%; width: 1.5rem; height: 1.5rem; display: flex; align-items: center; justify-content: center; }
.tag-delete-btn:hover { background-color: var(--delete-color); color: white; }
.tag-manage-item.selected .tag-delete-btn { color: white; }
.tag-manage-item.selected .tag-delete-btn:hover { background-color: rgba(255,255,255,0.2); }
.tag-color-picker-label {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative; /* Needed for positioning the input */
}
.tag-color-picker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    opacity: 0; /* Make it invisible but clickable */
    width: 100%;
    height: 100%;
    border: none;
    background: none;
    cursor: pointer;
    position: absolute;
    top: 0; left: 0;
}
.tag-name-edit-input {
    font-size: 0.9em;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--primary-color);
    border-radius: 0.25rem;
    outline: none;
    max-width: 100px;
}

.tag-create-form { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.tag-create-form #new-tag-name { flex-grow: 1; }
#new-tag-color-label {
    width: auto;
    padding: 0.5rem;
    height: 2.5rem;
    border-radius: 50px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-shrink: 0;
    position: relative; /* Needed for positioning the input */
}
#new-tag-color-label:hover {
    border-color: var(--primary-color);
}
.tag-create-form input[type="color"] {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    cursor: pointer;
}
.tag-create-form button { flex-shrink: 0; }
#new-tag-color-label span {
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
}
#new-tag-color-label svg {
    display: block;
    width: 1em; height: 1em;
}


/* BGG 검색 모달 & 수동 추가 */
.search-panel-content {
    background-color: var(--bg-card);
    border-radius: 1rem;
    width: 30rem; /* 480px */
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0.625rem 2.5rem rgba(0,0,0,0.5);
    position: relative;
    padding: 1.5rem;
    overflow-y: auto; /* 스크롤 가능하게 */
}
#search-panel .search-box { display: flex; gap: 0.5rem; margin-top: 1rem; }
.add-options { text-align: center; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.add-options p { color: var(--text-light); margin-bottom: 0.5rem; font-size: 0.9em; }
.search-results-list { margin-top: 1rem; overflow-y: auto; min-height: 100px; }
.search-result-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--border-color); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item div { display: flex; flex-direction: column; }
.search-result-item .name { font-weight: 600; }
.search-result-item .year { font-size: 0.8em; color: var(--text-light); }
.search-result-item .add-btn { background-color: var(--primary-color); color: white; border: none; border-radius: 0.5rem; padding: 0.4rem 0.8rem; font-size: 0.9em; cursor: pointer; }
.search-result-item .add-btn:hover { background-color: var(--secondary-color); }
.search-result-item .add-btn:disabled { background-color: var(--border-color); cursor: not-allowed; }

#manual-add-form .manual-add-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-group.form-group-full { grid-column: 1 / -1; }
.form-group label { font-size: 0.9em; font-weight: 500; margin-bottom: 0.25rem; display: block; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    box-sizing: border-box;
}

/* BoardLife HTML/URL Modal */
#boardlife-add-form textarea, #boardlife-add-form input[type="url"] {
    width: 100%;
    min-height: 100px;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.9em;
    resize: vertical;
}
#boardlife-add-form input[type="url"] { min-height: 2.75rem; }


/* 로딩, 메시지 */
.loading { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-main); opacity: 0.8; display: flex; align-items: center; justify-content: center; z-index: 9999; }
.spinner { width: 3.125rem; height: 3.125rem; border: 0.25rem solid var(--border-color); border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.message-container { position: fixed; top: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 10000; width: calc(100% - 2rem); max-width: 31.25rem; }
.message { padding: 0.75rem 1.25rem; border-radius: 0.5rem; color: white; box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.15); margin-bottom: 0.625rem; }
.message.success { background-color: var(--success-color); }
.message.error { background-color: var(--error-color); }

/* 마이페이지 (전체 화면) */
.mypage-fullscreen-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
}
.mypage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.05);
}
.mypage-header h1 {
    font-size: 1.2em;
    font-weight: 700;
    margin: 0;
}

/* 탭 네비게이션 */
.mypage-tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}
.tab-btn {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover {
    color: var(--text-primary);
}
.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* 탭 컨텐츠 */
.mypage-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}
.tab-inner {
    max-width: 60rem;
    margin: 0 auto;
    padding: 1.5rem;
}

/* 폼 그룹 (마이페이지) */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}
.input-group {
    display: flex;
    gap: 0.5rem;
}
.input-group .filter-input {
    flex-grow: 1;
}
.input-group .action-icon-btn {
    flex-shrink: 0;
}
.filter-input.readonly {
    background-color: var(--bg-main);
    color: var(--text-secondary);
    cursor: default;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* 섹션 헤더 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.section-header h2 {
    font-size: 1.3em;
    font-weight: 700;
    margin: 0;
}

/* 통계 카드 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 0.125rem 0.5rem var(--shadow-color);
    text-align: center;
}
.stat-card h3 {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}
.stat-count {
    font-size: 0.9em;
    color: var(--text-light);
}

/* 플레이 기록 카드 */
.play-record-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: 0 0.125rem 0.5rem var(--shadow-color);
    padding: 1.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.play-record-card:hover {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.25rem 0.75rem var(--shadow-color);
}
.play-record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}
.play-record-date {
    font-size: 1.1em;
    font-weight: 700;
}
.play-record-games {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.play-record-preview {
    font-size: 0.85em;
    color: var(--text-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 최근 구매 리스트 */
.purchase-item {
    background: var(--bg-card);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.05);
}
.purchase-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.purchase-item-date {
    font-size: 0.85em;
    color: var(--text-light);
}
.purchase-item-price {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--primary-color);
}

/* 플레이 기록 모달 */
.play-record-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.play-record-modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    max-width: 50rem;
    width: 100%;
    margin: auto;
    position: relative;
    box-shadow: 0 0.625rem 2.5rem rgba(0,0,0,0.5);
}
.play-record-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.play-record-modal-header h2 {
    font-size: 1.4em;
    margin: 0;
}
.play-record-modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* 플레이 기록 폼 */
.play-game-entry {
    background: var(--bg-main);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}
.play-game-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.play-round {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}
.play-round-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.remove-btn {
    background: none;
    border: none;
    color: var(--delete-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
}
.remove-btn:hover {
    color: var(--delete-hover);
}

/* 이미지 그리드 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.image-grid-item {
    position: relative;
    padding-top: 100%;
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--bg-main);
}
.image-grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-remove-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.image-remove-btn:hover {
    background: rgba(244, 67, 54, 0.9);
}

/* 이미지 슬라이더 (게임 상세 모달용) */
.image-slider-container {
    position: relative;
    width: 100%;
    height: 100%;
}
.image-slider {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.slider-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
}
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}
.slider-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}
.slider-btn-prev {
    left: 0.5rem;
}
.slider-btn-next {
    right: 0.5rem;
}
.slider-indicator {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85em;
}

/* 프로그레스 인포 */
.progress-info {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}
.progress-info p {
    margin: 0.5rem 0;
}

/* 빈 상태 메시지 */
.empty-message {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

/* 모바일 최적화 */
@media (max-width: 62rem) {
    .mypage-tabs {
        justify-content: flex-start;
    }
    .tab-btn {
        flex: 0 0 auto;
        min-width: 6rem;
    }
    .stats-cards {
        grid-template-columns: 1fr;
    }
}


/* ===== PC/태블릿 화면용 미디어 쿼리 (992px 이상) ===== */
@media (min-width: 62rem) {
    .main-layout {
        display: grid;
        grid-template-columns: var(--sidebar-width-pc) 1fr;
        padding: 0 4rem;
        gap: 3rem;
    }

    .main-content {
        grid-column: 2 / 3;
        padding: 2rem 0;
    }
    
    .filter-sidebar {
        grid-column: 1 / 2;
        position: sticky;
        height: calc(100vh - 4rem);
        box-shadow: none;
        border: none;
        background: none;
        transition: none;
        display: flex;
        right: auto;
    }
    
    .filter-sidebar .controls {
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 1.5rem;
        height: 100%;
        margin-top: 2rem;
    }

    #header-title { font-size: 1.6em; line-height: normal; }
    #header-title #user-nickname-line1 { display: inline; }
    #header-title #header-subtitle { display: inline-flex; font-size: 1em; font-weight: 700; margin-left: 0.5rem; }

    .filter-header, #open-filter-btn, .filter-overlay { display: none; }
    
    /* PC Grid */
    #gameListContainer.game-grid {
        grid-template-columns: repeat(auto-fill, minmax(8.125rem, 1fr));
        gap: 1rem;
    }
    /* PC List */
     #gameListContainer.game-list .game-list-item {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
     #gameListContainer.game-list .list-item-header {
         flex-basis: 30%;
         min-width: 150px;
         margin-bottom: 0;
    }
     #gameListContainer.game-list .list-item-details {
         flex-grow: 1;
         grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }


    .detail-content {
        height: 75vh;
        max-height: 50rem;
        width: 60rem;
    }
    .modal-body-wrapper {
        flex-direction: row;
        overflow: hidden; /* Prevent inner scrollbars from interfering */
    }
    .modal-image {
        flex: 2;
        padding: 1.5rem;
        border-right: 1px solid var(--border-color);
        max-height: 100%;
        height: auto; /* PC에서는 고정 높이 제거 */
    }
    .detail-info {
        flex: 1;
        max-height: 100%;
        padding: 1.5rem 2rem;
        overflow-y: auto; /* Only info section scrolls */
    }
}

