/* ============================================
   CSS Variables - Glassmorphism Design System
   ============================================ */
:root {
    /* Brand Colors */
    --brand-primary: #667eea;
    --brand-secondary: #764ba2;
    --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Glassmorphism Base */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-bg-hover: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-blur: 10px;

    /* Shadows - Soft & Layered */
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.5);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-smooth: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

html {
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    background: #f5f5f5;
    /* Prevent browser zoom and bounce scrolling on iOS */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ========================================
   상단 중앙 컨트롤 (랭킹, 상점)
   ======================================== */

#top-center-controls {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    
    display: flex;
    gap: 12px;
}

.top-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    
    transition: all 0.2s ease;
}

.top-btn:hover {
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.top-btn:active {
    transform: translateY(0);
}

.top-btn-icon {
    font-size: 16px;
}

.top-btn-label {
    font-size: 13px;
}

/* 모바일 반응형 */
@media (max-width: 600px) {
    #top-center-controls {
        top: 12px;
        gap: 8px;
    }
    
    .top-btn {
        padding: 8px 14px;
    }
    
    .top-btn-icon {
        font-size: 14px;
    }
    
    .top-btn-label {
        font-size: 12px;
    }
}

/* ========================================
   우상단 정보 바 (좌표, 온라인, 배율)
   ======================================== */

#top-right-info {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 3px 6px;
    cursor: pointer;

    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);

    font-size: 9px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
}

.info-coords {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 9px;
    font-weight: 500;
    color: #333;
}

.info-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: color 0.2s ease;
    line-height: 1;
}

.info-share-btn .material-symbols-outlined {
    font-size: 16px;
}

.info-share-btn:hover {
    color: #667eea;
}

.info-share-btn:active {
    color: #4caf50;
}

.info-share-btn.copied {
    color: #4caf50;
}

.info-label {
    font-size: 12px;
    opacity: 0.8;
}

/* 중복 제거됨 - 위의 .info-coords 규칙 사용 */

.info-online {
    font-size: 11px;
    color: #666;
}

.info-online #info-online-count {
    font-weight: 600;
    color: #34a853;
}

/* 우상단 버튼 (국경선 등) */
.top-info-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.top-info-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.top-info-btn.active {
    background: rgba(76, 175, 80, 0.8);
    color: white;
}

/* 우상단 버튼 (좌표 아래 - 국경선 등) */
.top-right-btn {
    position: fixed;
    top: 55px;
    right: 10px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.9);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.top-right-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.top-right-btn.active {
    background: rgba(76, 175, 80, 0.9);
    color: white;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

/* 비활성 상태 명확히 */
.top-right-btn:not(.active) {
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
}

.top-right-btn:not(.active):hover {
    background: rgba(0, 0, 0, 0.7);
    color: white;
}

/* 월드 전체 보기 버튼 */
#world-view-btn {
    top: 100px;
}

/* 내 위치 찾기 버튼 (월드보기 아래) */
#gps-btn {
    top: 145px;
}

#world-view-btn.active {
    background: rgba(76, 175, 80, 0.9);
    color: white;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

#tool-borders-btn.active {
    background: rgba(76, 175, 80, 0.9);
    color: white;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

/* 복사 피드백 - share 버튼에 적용 */

@media (max-width: 600px) {
    #top-right-info {
        top: 6px;
        right: 6px;
        padding: 2px 4px;
    }
    
    .info-coords {
        font-size: 8px;
    }
}

/* ========================================
   우하단 GPS 버튼
   ======================================== */

.gps-floating-btn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    z-index: 1400 !important;
    
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gps-floating-btn:hover {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.gps-floating-btn:active {
    transform: scale(0.95);
}

@media (max-width: 600px) {
    .gps-floating-btn {
        bottom: 15px !important;
        right: 15px !important;
        left: auto !important;
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

#canvas-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    /* White background for canvas area */
    background-color: #ffffff;
    /* Prevent default touch behaviors */
    touch-action: none;
    -webkit-overflow-scrolling: touch;
}

#pixel-canvas,
#vector-canvas,
#label-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    /* Handle touch events directly */
    touch-action: none;
}

#pixel-canvas.dragging {
    cursor: grabbing !important;
}

#pixel-canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 1;
}

#tile-canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#vector-canvas,
#label-canvas {
    pointer-events: none;
    z-index: 1;
}

#label-canvas {
    z-index: 2;
}

/* Controls Overlay - Right side (좌표 바 아래) */
#controls {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}


/* Hamburger Menu - Left side */
#menu-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 15000;
    /* Highest z-index for menu container */
}

#menu-toggle {
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 24px;
    color: #333;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft), var(--shadow-inset);
    display: flex;
    align-items: center;
    justify-content: center;
}

#menu-toggle:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.05);
    box-shadow: var(--shadow-medium), var(--shadow-inset);
}

#menu-dropdown {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100%;
    background: #fff;
    border-right: 1px solid #eee;
    padding: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 15001;
    display: flex;
    flex-direction: column;
}

#menu-dropdown.open {
    left: 0;
}

/* 메뉴 헤더 */
.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
}

.menu-brand-text {
    display: flex;
    flex-direction: column;
}

.menu-brand-title {
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.menu-brand-subtitle {
    font-size: 11px;
    color: #888;
}

#menu-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

#menu-close:hover {
    background: #f5f5f5;
    color: #333;
}

/* 메뉴 콘텐츠 (스크롤) */
.menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* 로그인 카드 */
.menu-login-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    margin-bottom: 8px;
}

.menu-login-text {
    color: #666;
    font-size: 12px;
    margin-bottom: 8px;
}

.menu-login-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

/* 프로필 카드 */
.menu-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-profile-card:hover {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8efff 100%);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.profile-avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
}

.profile-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.rank-badge {
    font-size: 11px;
    color: #888;
}

/* 스탯 카드 - 2열 상단 + Purple 하단 */
.menu-stats-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 6px 6px;
    transition: all 0.2s ease;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.stat-label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

/* Purple 행 - 작고 압축된 디자인 */
.stat-purple-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-purple-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.stat-purple-row .purple-icon {
    font-size: 14px;
}

.stat-purple-row .stat-value {
    font-size: 15px;
    font-weight: 700;
    color: white;
}

.stat-purple-row .stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    margin-right: auto;
}

.stat-purple-row .purple-arrow {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
}

.stat-value {
    font-size: 15px;
    font-weight: 700;
    color: #333;
}

/* 메뉴 아이템 */
.menu-items {
    margin-top: 8px;
}

/* 메뉴 아이템들 컨테이너 */
.menu-items {
    padding: 0 10px;
    margin-top: 4px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-item:hover {
    background: #f5f5f5;
}

.menu-item-icon {
    width: 26px;
    height: 26px;
    background: #f0f0f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.menu-item-content {
    flex: 1;
}

.menu-item-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

.menu-item-subtitle {
    display: block;
    font-size: 10px;
    color: #888;
    line-height: 1.2;
}

.menu-item-action {
    display: flex;
    align-items: center;
}

.menu-item-arrow {
    font-size: 18px;
    color: #ccc;
}

/* 테마 스위치 */
.theme-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ddd;
    border-radius: 24px;
    transition: 0.3s;
}

.theme-slider:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-switch input:checked + .theme-slider {
    background: #4285f4;
}

.theme-switch input:checked + .theme-slider:before {
    transform: translateX(20px);
}

/* 언어 선택 드롭다운 */
.menu-select {
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

/* 로그아웃 버튼 */
#logout-section {
    padding: 16px;
}

.menu-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: transparent;
    border: 2px solid #ea4335;
    border-radius: 12px;
    color: #ea4335;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-logout-btn:hover {
    background: #fef0ef;
}

.logout-icon {
    font-size: 16px;
}

/* 법적 링크 */
.menu-legal-links {
    padding: 12px 16px;
    text-align: center;
    font-size: 11px;
    color: #888;
}

.menu-legal-links a {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.menu-legal-links a:hover {
    color: #4285f4;
    text-decoration: underline;
}

.legal-separator {
    margin: 0 8px;
    color: #ccc;
}

/* 새 푸터 */
.menu-footer-new {
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    text-align: center;
    font-size: 11px;
    color: #888;
}

.online-status-new {
    margin-bottom: 4px;
}

.copyright-link {
    color: #aaa;
    text-decoration: none;
}

.copyright-link:hover {
    color: #4285f4;
}

/* Custom Scrollbar for Menu */
.menu-content::-webkit-scrollbar {
    width: 6px;
}

.menu-content::-webkit-scrollbar-track {
    background: transparent;
}

.menu-content::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* Legacy scrollbar */
#menu-dropdown::-webkit-scrollbar {
    width: 6px;
}

#menu-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

#menu-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#menu-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Menu Header */
#menu-dropdown h3 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    padding: 24px 20px 16px;
    letter-spacing: -0.5px;
}

/* Menu Content Wrapper */
#menu-dropdown > *:not(#menu-close):not(h3) {
    margin-left: 16px;
    margin-right: 16px;
}

/* Menu Section Cards */
#auth-section {
    padding: 0 16px;
}

#menu-dropdown .menu-text {
    background: #fff;
    border-radius: 14px;
    margin: 12px 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 13px;
    line-height: 1.8;
    color: #555;
}

#menu-dropdown .menu-text strong {
    color: #333;
    font-size: 13px;
    display: block;
    margin-bottom: 8px;
}

/* Language Section */
.menu-language-section {
    background: #fff;
    border-radius: 14px;
    margin: 12px 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* Warning Box */
#menu-dropdown > div[style*="background: rgba(255, 0, 0"] {
    border-radius: 14px !important;
    margin: 12px 16px !important;
    padding: 14px 16px !important;
    background: linear-gradient(135deg, rgba(255, 100, 100, 0.08) 0%, rgba(255, 50, 50, 0.05) 100%) !important;
    border: 1px solid rgba(255, 100, 100, 0.2) !important;
}

/* Build Info */
#menu-dropdown > div[style*="padding: 10px"][style*="font-size: 11px"] {
    margin: 8px 16px 12px !important;
    padding: 12px 16px !important;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
    font-size: 11px !important;
    color: #888 !important;
}

#menu-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    color: #888;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

#menu-close:hover {
    background: rgba(255, 100, 100, 0.1);
    color: #e55;
    transform: rotate(90deg) scale(1.1);
}

.menu-item {
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    /* 터치 접근성: 최소 44px 높이 보장 */
    min-height: 44px;
}

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

.menu-item.active {
    background: rgba(102, 126, 234, 0.2);
}

.menu-separator {
    height: 1px;
    background: transparent;
    margin: 4px 0;
}

.menu-toggle-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    font-size: 14px;
    gap: 10px;
}

.menu-toggle-item span:first-child {
    width: 24px;
    text-align: center;
}

.menu-toggle-item span:nth-child(2) {
    flex: 1;
}

/* Toggle switch */
/* 터치 접근성: 최소 44px 높이 보장 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 44px;
}

.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: #ccc;
    border-radius: 34px;
    transition: .3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 36px;
    width: 36px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .3s;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

.menu-text {
    padding: 10px;
    /* 색상 대비 개선: WCAG AA 기준 4.5:1 이상 */
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

/* Control buttons - circular design with glassmorphism */
/* 터치 접근성: 최소 44x44px (WCAG 2.1 기준) */
.control-btn {
    width: 48px;
    height: 48px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    /* Make buttons circular */
    font-size: 20px;
    color: #333;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-soft), var(--shadow-inset);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    /* 터치 영역 확보 */
    min-width: 44px;
    min-height: 44px;
}

.control-btn:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.1);
    box-shadow: var(--shadow-medium), var(--shadow-inset);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn:focus-visible {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

/* Special styling for borders toggle button */
#borders-toggle-container {
    border-radius: 12px !important;
    width: auto !important;
    height: auto !important;
    padding: 8px 10px !important;
    min-width: 50px;
}

.control-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* GPS Button - top-right-btn 스타일 상속, 위치는 위에서 정의 */
#gps-btn svg {
    width: 20px;
    height: 20px;
}

#gps-btn.locating {
    animation: pulse-gps 1s infinite;
    color: #4285f4;
}

#gps-btn.located {
    color: #4285f4;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

/* Location Marker */
.location-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #4285f4;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.5);
    animation: pulse-location 2s infinite;
    z-index: 10;
    pointer-events: none;
}

@keyframes pulse-location {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

@keyframes pulse-gps {
    0% {
        box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(66, 133, 244, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(66, 133, 244, 0);
    }
}

/* Color Palette - Premium Design */
#color-palette {
    position: fixed !important;
    bottom: 15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: auto !important;

    /* Glassmorphism Background */
    background: rgba(20, 20, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    padding: 0;
    border-radius: 16px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;

    z-index: 10000;
    width: auto;
    min-width: 280px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
}

/* Header Section */
.palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.palette-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Palette Selector (Segmented Control) */
#palette-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.palette-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    stroke: rgba(0, 0, 0, 0.1);
    /* Subtle separator */
    stroke-width: 1px;
    transform-origin: center;
    opacity: 0.9;
}

.color-sector:hover {
    stroke: rgba(255, 255, 255, 0.8);
    stroke-width: 1.5px;
}

.color-sector.selected {
    stroke: #fff;
    stroke-width: 2px;
}

/* Color Container (SVG Wrapper) */
#color-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 10px;
}

/* SVG Sector Styles - Simple thin border, no animations */
.color-sector {
    cursor: pointer;
    stroke: rgba(0, 0, 0, 0.15);
    stroke-width: 0.5px;
    opacity: 1;
    transition: stroke 0.1s ease, stroke-width 0.1s ease;
}

.color-sector:hover {
    stroke: rgba(255, 255, 255, 0.9);
    stroke-width: 1.5px;
}

.color-sector.selected {
    stroke: #fff;
    stroke-width: 2px;
}

/* Responsive SVG Sizing */
svg {
    max-width: 200px;
    max-height: 200px;
}

/* Current color preview + collapse button */
#current-color-wrapper {
    display: flex; /* Show on both desktop and mobile */
    align-items: center;
    gap: 8px;
}

/* Hide collapse button on desktop (only show color preview) */
#palette-collapse-btn {
    display: none;
}

@media (min-width: 701px) {
    #current-color-preview {
        width: 44px;
        height: 44px;
    }
}

/* 터치 접근성: 최소 44px 크기 보장 */
#current-color-preview {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: #000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 터치 접근성: 최소 44px 크기 보장 */
#palette-collapse-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

#palette-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#palette-collapse-btn:active {
    transform: scale(0.95);
}

.collapse-arrow {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    transition: transform 0.3s ease;
}

/* Collapsed state */
#color-palette.collapsed .collapse-arrow {
    transform: rotate(180deg);
}

#color-palette.collapsed #palette-body {
    display: none;
}

#color-palette.collapsed #palette-selector {
    display: none;
}

/* Mobile Adjustments */
@media (max-width: 700px) {
    #color-palette {
        /* Move to bottom-right corner */
        left: auto !important;
        right: 10px !important;
        bottom: 10px !important;
        transform: none !important;
        
        /* Smaller size - roughly 1/4 of desktop */
        width: auto !important;
        min-width: 140px !important;
        max-width: 180px !important;
        
        /* Adjust padding */
        border-radius: 12px;
    }

    /* Show collapse button on mobile */
    #palette-collapse-btn {
        display: flex;
    }

    .palette-header {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .palette-title {
        font-size: 11px;
    }

    #palette-selector {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .palette-btn {
        padding: 3px 8px;
        font-size: 10px;
    }

    #palette-body {
        padding: 8px;
    }

    #color-container {
        padding: 4px;
    }

    svg {
        max-width: 120px;
        max-height: 120px;
    }

    /* Grid layout adjustments for mobile */
    .palette-16 #color-container {
        grid-template-columns: repeat(4, 1fr);
        width: 100%;
        gap: 3px;
    }

    .palette-16 .color-cell {
        aspect-ratio: 1;
        width: auto !important;
        height: auto !important;
    }

    /* 32 Colors on Mobile */
    .palette-32 #color-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }

    .palette-32 .color-cell {
        aspect-ratio: 1;
        width: auto !important;
        height: auto !important;
    }

    /* 256 Colors on Mobile */
    .palette-256 #color-container {
        grid-template-columns: repeat(8, 1fr);
        gap: 1px;
    }

    .palette-256 .color-cell {
        aspect-ratio: 1;
        width: auto !important;
        height: auto !important;
    }

    /* Collapsed state on mobile - compact mini version */
    #color-palette.collapsed {
        min-width: auto !important;
        width: auto !important;
    }

    #color-palette.collapsed .palette-header {
        padding: 8px 10px;
    }

    #color-palette.collapsed .palette-title {
        display: none;
    }
}

.color-cell:hover {
    outline: 1.5px solid rgba(255, 255, 255, 0.9);
    outline-offset: -1px;
}

.color-cell.selected {
    outline: 2px solid #fff;
    outline-offset: -1px;
}

.color-cell:focus-visible {
    outline: 2.5px solid #667eea;
    outline-offset: 1px;
}

/* Pulse animation removed for flat design */

.color-cell.locked {
    opacity: 0.3;
    cursor: not-allowed;
    position: relative;
}

.color-cell.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
}

/* Cooldown Popup */
#cooldown-popup {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: white;
    border: 2px solid #e0e0e0;
    color: #333;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    z-index: 20000;
    /* Higher than palette and menu */
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#cooldown-popup.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

#cooldown-timer {
    font-size: 28px;
    text-align: center;
    margin-top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
}

#watch-ad-btn-popup {
    margin-top: 15px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

#watch-ad-btn-popup:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#watch-ad-btn-popup:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: scale(1);
}

/* Coordinates Display */
#coords-display {
    display: none;
    /* Hidden - coordinates not needed */
    position: fixed;
    top: 30px;
    left: 80px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 12px;
    font-family: monospace;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Online Users Counter */
#online-users {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 12px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    color: #333;
}

#online-users .count {
    color: #667eea;
    font-size: 18px;
}

/* User Info */
#user-info {
    display: none;
}

.user-type {
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-align: center;
}

.user-type.registered {
    background: #718096;
}

.user-type.premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Tile Progress */
#tile-progress {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: none;
}

#tile-progress.active {
    display: block;
}

.progress-bar {
    width: 200px;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

/* Loading Screen */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.5s;
}

/* Pixel art loading screen */
.pixel-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pixel-text {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 380px;
}

.pixel-text .pixel-char {
    display: grid;
    gap: 0px;
    margin: 0 1px;
}

.pixel-text .pixel-char .px {
    width: 5px;
    height: 5px;
    transition: background-color 0.15s;
}

.pixel-text .pixel-char .px.on {
    background-color: #E0E0E0;
}

.pixel-text .pixel-char .px.on.lit {
    background-color: #667eea;
}

.pixel-text .pixel-space {
    width: 12px;
}

.pixel-progress-track {
    width: 260px;
    height: 6px;
    background: #F0F0F0;
    display: flex;
    gap: 2px;
}

.pixel-progress-fill {
    height: 100%;
    background: #667eea;
    width: 0%;
    transition: width 0.3s;
}

/* Legacy loader fallback */
.loader {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(102, 126, 234, 0.1);
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#user-display {
    display: none;
    font-size: 14px;
    color: #666;
}

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    top: 70px; /* Below top-center-controls (ranking/shop buttons) */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Don't block clicks on anything below */
}

.toast {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 400px;
    animation: slideDown 0.3s ease-out;
    pointer-events: none; /* Toasts never block clicks */
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Toast color swatch */
.toast-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* UI Popup (custom alert/confirm) - must be above .modal (z-index: 99999) */
.ui-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ui-popup-overlay.active {
    background: rgba(0, 0, 0, 0.5);
}

.ui-popup {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    min-width: 280px;
    max-width: 360px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ui-popup-overlay.active .ui-popup {
    transform: scale(1);
    opacity: 1;
}

.ui-popup-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.ui-popup-message {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 20px;
    word-break: keep-all;
}

.ui-popup-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ui-popup-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ui-popup-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.ui-popup-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

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

.ui-popup-btn-cancel {
    background: #f0f0f0;
    color: #555;
}

.ui-popup-btn-cancel:hover {
    background: #e0e0e0;
}

/* Auth Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 0;
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    text-align: center;
    position: relative;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.modal-body {
    padding: 30px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.auth-tab.active {
    color: #667eea;
    border-bottom: 2px solid #667eea;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border 0.3s;
}

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

.auth-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.auth-button:hover {
    transform: translateY(-2px);
}

.auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.google-signin-button {
    width: 100%;
    padding: 10px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
}

.google-signin-button:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
}

.error-message {
    color: #ff4444;
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

.success-message {
    color: #4CAF50;
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    color: white;
    font-size: 28px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    padding: 0;
    /* 터치 접근성: 최소 44x44px */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    font-weight: bold;
    z-index: 1000;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.user-info {
    display: none;
    padding: 10px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    margin: 10px 20px;
}

.user-info.active {
    display: block;
}

.user-email {
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
}

.logout-button {
    background: #ff4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

/* Ad Modal Styles - Removed (no ads in this service) */

/* Subscription Info */
.subscription-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 20px;
    text-align: center;
}

.subscription-info h3 {
    margin: 0 0 10px 0;
}

.subscription-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 5px;
}

/* Pixel Popup - Always on top of everything */
.pixel-popup {
    position: fixed !important;
    z-index: 999999 !important;
    pointer-events: auto !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ============================================
   Google OAuth Login Modal Styles
   ============================================ */

/* Enhanced Modal for Google Auth */
.auth-modal-google {
    max-width: 380px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    background: #1a1a2e; /* 전체 배경색 통일 */
}

.auth-modal-google .modal-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 24px 24px 16px;
    text-align: center;
}

.auth-modal-google .modal-header h2 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
}

.auth-modal-google .modal-body {
    background: #1a1a2e;
    padding: 16px 24px 24px;
}

.auth-welcome {
    text-align: center;
    margin-bottom: 20px;
}

.auth-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 0;
}

/* Google Sign In Button - Enhanced */
.google-signin-button {
    width: 100%;
    padding: 14px 20px;
    background: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.google-signin-button:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.google-signin-button:active {
    transform: translateY(0);
}

.google-signin-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.google-signin-button img {
    width: 20px;
    height: 20px;
}

/* Loading spinner */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Auth Benefits */
.auth-benefits {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 20px 0 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.benefit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    /* 색상 대비 개선: WCAG AA 기준 */
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
}

.benefit-icon {
    font-size: 20px;
}

/* Auth Terms */
.auth-terms {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0;
}

.auth-terms small {
    /* 색상 대비 개선: WCAG AA 기준 */
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.auth-terms a {
    color: #667eea;
    text-decoration: none;
}

.auth-terms a:hover {
    text-decoration: underline;
}

.auth-terms a:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Error Message in Modal */
.auth-modal-google .error-message {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: #ff4757;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
}

/* ============================================
   Menu Login / User Profile Styles
   ============================================ */

/* Login Prompt Box */
.login-prompt-box {
    padding: 12px;
    text-align: center;
}

/* 메뉴의 로그인 버튼 */
.login-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35);
    position: relative;
    overflow: hidden;
}

.login-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.login-btn:hover::before {
    left: 100%;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.45);
}

.login-btn:active {
    transform: translateY(0) scale(0.98);
}

/* User Profile in Menu */
.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.06) 0%, rgba(118, 75, 162, 0.04) 100%);
    border-radius: 12px;
    margin: 4px;
    transition: all 0.2s;
}

.user-profile-menu:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.08) 100%);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #667eea;
}

.user-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-info-text .username {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    line-height: 1.2;
}

.user-info-text .user-email {
    font-size: 11px;
    color: #888;
    line-height: 1.2;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User Currency (Purple) */
.user-currency {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 4px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.08) 0%, rgba(102, 126, 234, 0.06) 100%);
    border: none;
    border-radius: 10px;
}

.user-currency .currency-icon {
    font-size: 18px;
}

.user-currency .currency-amount {
    flex: 1;
    text-align: right;
    font-weight: 700;
    font-size: 16px;
    color: #7c3aed;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Logout Button */
.logout-btn {
    width: calc(100% - 8px);
    padding: 10px;
    margin: 8px 4px 4px;
    background: rgba(0, 0, 0, 0.03);
    border: none;
    border-radius: 10px;
    color: #888;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 80, 80, 0.1);
    color: #e55;
}

/* Tier Badges */
.tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.tier-badge.tier-free {
    background: #e3f2fd;
    color: #1976d2;
}

.tier-badge.tier-pro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tier-badge.tier-premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

/* Login Required Banner */
.login-required-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 9000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.login-required-banner p {
    margin: 0;
    font-size: 14px;
}

.login-required-banner button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-required-banner button:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

/* Mobile Responsive for Auth Modal */
@media (max-width: 480px) {
    .auth-modal-google {
        margin: 16px;
        max-width: calc(100% - 32px);
        width: calc(100% - 32px);
    }
    
    .auth-modal-google .modal-header {
        padding: 20px 20px 12px;
    }
    
    .auth-modal-google .modal-header h2 {
        font-size: 22px;
    }
    
    .auth-modal-google .modal-body {
        padding: 12px 20px 20px;
    }
    
    .auth-welcome {
        margin-bottom: 16px;
    }
    
    .auth-subtitle {
        font-size: 13px;
    }
    
    .auth-benefits {
        gap: 12px;
        padding: 12px;
        margin: 16px 0 12px;
    }
    
    .benefit-item {
        font-size: 10px;
    }
    
    .benefit-icon {
        font-size: 18px;
    }
    
    .auth-terms {
        padding-top: 12px;
    }
    
    .auth-terms small {
        font-size: 10px;
    }
}

/* ========================================
   Ranking Modal Styles
   ======================================== */

.ranking-modal-content {
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.ranking-header {
    background: #fff;
    color: #333;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}

.ranking-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    text-shadow: none;
}

.ranking-header .close-modal {
    color: #888;
    font-size: 24px;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f5f5f5;
}

.ranking-header .close-modal:hover {
    background: #eee;
    color: #333;
    transform: none;
}

.ranking-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 300px;
    max-height: 400px;
    background: #fafafa;
}

.ranking-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #aaa;
}

.ranking-loading .loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 215, 0, 0.2);
    border-top: 3px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ranking-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #888;
    text-align: center;
    padding: 20px;
}

.ranking-empty p {
    margin: 5px 0;
}

.ranking-list {
    padding: 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    background: #fff;
}

.ranking-item:hover {
    background: #f8f9fa;
}

.ranking-item.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15) 0%, #fff 100%);
}

.ranking-item.top-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.15) 0%, #fff 100%);
}

.ranking-item.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.12) 0%, #fff 100%);
}

.ranking-item.is-me {
    background: linear-gradient(90deg, rgba(66, 133, 244, 0.15) 0%, #fff 100%);
    border: 1px solid rgba(66, 133, 244, 0.3);
    border-radius: 12px;
    margin: 4px 12px;
}

.ranking-rank {
    width: 45px;
    font-size: 18px;
    font-weight: 700;
    color: #888;
    text-align: center;
    color: #888;
}

.ranking-item.top-1 .ranking-rank {
    color: #f59e0b;
    font-size: 22px;
}

.ranking-item.top-2 .ranking-rank {
    color: #9ca3af;
    font-size: 20px;
}

.ranking-item.top-3 .ranking-rank {
    color: #d97706;
    font-size: 18px;
}

.ranking-medal {
    font-size: 20px;
    margin-right: 8px;
}

.ranking-name {
    flex: 1;
    font-size: 15px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 10px;
}

.ranking-item.top-1 .ranking-name,
.ranking-item.top-2 .ranking-name,
.ranking-item.top-3 .ranking-name {
    font-weight: 600;
    color: #333;
}

.ranking-score {
    font-size: 13px;
    font-weight: 600;
    color: #4285f4;
    background: rgba(66, 133, 244, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    min-width: 60px;
    text-align: center;
}

.ranking-footer {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.my-ranking-info {
    font-size: 14px;
    color: #666;
}

.my-rank {
    color: #4285f4;
    font-weight: 700;
}

.my-pixels {
    color: #34a853;
    font-weight: 600;
}

.ranking-refresh-btn {
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ranking-refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.ranking-refresh-btn:active {
    transform: translateY(0);
}

/* Ranking Modal Mobile Responsive */
@media (max-width: 480px) {
    .ranking-modal-content {
        width: 95%;
        max-height: 85vh;
        margin: 10px;
    }
    
    .ranking-header {
        padding: 16px 20px;
    }
    
    .ranking-header h2 {
        font-size: 18px;
    }
    
    .ranking-item {
        padding: 10px 16px;
    }
    
    .ranking-rank {
        width: 35px;
        font-size: 16px;
    }
    
    .ranking-item.top-1 .ranking-rank {
        font-size: 20px;
    }
    
    .ranking-name {
        font-size: 14px;
    }
    
    .ranking-score {
        font-size: 12px;
        padding: 3px 10px;
        min-width: 50px;
    }
    
    .ranking-footer {
        flex-direction: column;
        gap: 12px;
    }
    
    .ranking-refresh-btn {
        width: 100%;
    }
}

/* Old Language Selector Styles (Removed - moved to menu) */

/* ========================================
   Menu Language Selector Styles
   ======================================== */

.menu-language-section {
    padding: 10px 15px;
}

.menu-language-label {
    font-size: 11px;
    color: #777;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-language-dropdown {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.02);
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: all 0.2s ease;
    font-weight: 500;
}

.menu-language-dropdown:hover {
    border-color: rgba(102, 126, 234, 0.3);
    background-color: rgba(102, 126, 234, 0.04);
}

.menu-language-dropdown:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    outline: none;
}

.menu-language-dropdown option {
    background: #fff;
    color: #333;
    padding: 12px;
}

/* ========================================
   Menu Legal Links
   ======================================== */
.menu-legal-links {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 15px;
    font-size: 11px;
    color: rgba(150, 150, 150, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.menu-legal-links a {
    color: rgba(150, 150, 150, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

.menu-legal-links a:hover {
    color: #8a2be2;
    text-decoration: underline;
}

.menu-legal-links a:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}

.menu-legal-links .legal-separator {
    color: rgba(100, 100, 100, 0.5);
    margin: 0 2px;
}

/* ========================================
   Menu Footer (Online Status & Copyright)
   ======================================== */
.menu-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-top: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.menu-footer .online-status {
    font-weight: 600;
    color: #F44336;
}

.menu-footer .copyright-link {
    color: rgba(150, 150, 150, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

.menu-footer .copyright-link:hover {
    color: #8a2be2;
}

.menu-footer .copyright-link:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ========================================
   Paint Mode Styles (색칠 모드 - 팔레트 내부)
   ======================================== */

/* 픽셀 한도 섹션 (항상 표시) */
#pixel-quota-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(60, 60, 60, 0.5) 0%, rgba(40, 40, 40, 0.5) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 회복 타이머 */
#pixel-recharge-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #888;
    justify-content: flex-end;
}

#pixel-recharge-timer.hidden {
    display: none;
}

#recharge-icon {
    font-size: 14px;
}

#recharge-countdown {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-weight: 600;
    color: #4CAF50;
    min-width: 35px;
}

#pixel-recharge-timer.urgent #recharge-countdown {
    color: #FF9800;
}

/* 팔레트 내부 페인트 모드 섹션 (색칠 모드 전용) */
#paint-mode-section {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
    }
}

body.paint-mode #paint-mode-section {
    display: flex;
}

/* 색칠 모드일 때 팔레트 강조 */
body.paint-mode #color-palette {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    border: 2px solid rgba(102, 126, 234, 0.5);
}

/* 픽셀 한도 표시 */
#pixel-quota-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

#pixel-quota-label {
    font-weight: 500;
    color: #aaa;
    white-space: nowrap;
}

#pixel-quota-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
    min-width: 60px;
}

#pixel-quota-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

#pixel-quota-text {
    font-weight: 600;
    color: #fff;
    min-width: 55px;
    text-align: right;
    font-size: 12px;
}

/* 채우기/취소 버튼 */
#paint-mode-buttons {
    display: flex;
    gap: 8px;
}

#fill-btn {
    flex: 1;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#fill-btn:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

#fill-btn:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

#cancel-paint-btn {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#cancel-paint-btn:hover {
    background: rgba(255, 100, 100, 0.3);
    border-color: rgba(255, 100, 100, 0.5);
    color: #ff8888;
}

/* 색칠 모드 시 캔버스 커서 변경 */
body.paint-mode #pixel-canvas {
    cursor: cell !important;
}

/* 색칠 모드 시 팔레트 타이틀 변경 표시 */
body.paint-mode .palette-title::after {
    content: ' 🎨';
}

/* 모바일 대응 */
@media (max-width: 768px) {
    #paint-mode-section {
        padding: 10px 12px;
        gap: 8px;
    }
    
    #pixel-quota-display {
        flex-wrap: wrap;
    }
    
    #pixel-quota-bar-container {
        width: 100%;
        order: 3;
    }
    
    #paint-mode-buttons {
        flex-direction: row;
    }
    
    #fill-btn, #cancel-paint-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ========================================
   새로운 하단 툴바 스타일 (2026 리디자인)
   ======================================== */

/* 하단 툴바 숨김 - paint-floating-btn으로 대체 */
#bottom-toolbar {
    display: none !important;
}

/* 툴바 그룹 */
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-left {
    padding-right: 8px;
}

.toolbar-center {
    padding: 0 4px;
}

.toolbar-right {
    padding-left: 8px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* 툴바 구분선 */
.toolbar-separator {
    width: 1px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

/* 툴바 버튼 공통 스타일 */
.toolbar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #555;
}

.toolbar-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

.toolbar-btn:active {
    transform: scale(0.95);
}

.toolbar-btn.active {
    background: #4285f4;
    color: white;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.4);
}

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

.toolbar-btn:disabled:hover {
    background: transparent;
    transform: none;
}

.toolbar-btn svg {
    width: 22px;
    height: 22px;
}

/* 색상 선택 버튼 */
.toolbar-btn.color-btn {
    width: auto;
    height: 40px;
    padding: 4px 10px 4px 4px;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 24px;
}

.toolbar-btn.color-btn:hover {
    border-color: #4285f4;
    box-shadow: 0 2px 12px rgba(66, 133, 244, 0.3);
}

.toolbar-btn.color-btn.active {
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}

.toolbar-btn.color-btn.active .color-btn-arrow {
    transform: rotate(180deg);
}

#current-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #FFD700;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.color-btn-arrow {
    font-size: 10px;
    color: #888;
    transition: transform 0.2s ease;
}

/* 픽셀 게이지 컨테이너 */
.pixel-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
}

/* 픽셀 게이지 */
.pixel-gauge {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

#pixel-gauge-current {
    min-width: 20px;
    text-align: right;
}

.gauge-separator {
    color: #999;
    font-weight: 400;
}

#pixel-gauge-max {
    color: #666;
    font-weight: 500;
}

.gauge-bar {
    width: 50px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-left: 8px;
}

.gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, #4285f4, #34a853);
    border-radius: 3px;
    width: 100%;
    transition: width 0.3s ease;
}

/* 게이지 타이머 */
.gauge-timer {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

.gauge-timer:empty {
    display: none;
}

/* 색상 팔레트 바 - 하단에서 올라오는 디자인 */
#color-palette-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    
    /* Safari 호환성을 위한 명시적 배경색 */
    background-color: #ffffff;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    padding: 10px 16px 12px;
    
    max-height: 60vh;
    overflow: hidden;
    
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: bottom center;
    
    /* 다크모드 무시 - 항상 밝은 테마 */
    color-scheme: light;
}

#color-palette-popup.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* 팔레트 닫기 버튼 */
#color-palette-popup .palette-close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: #666;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

#color-palette-popup .palette-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
}

/* 확장된 팔레트 - 3줄 표시 */
/* 확장 시: 3줄 표시 */
#color-palette-popup.expanded #color-grid-wrapper {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(36px * 3 + 4px * 2 + 8px) !important; /* 3행 높이 */
    -webkit-overflow-scrolling: touch;
}

#color-palette-popup.expanded #color-grid-container {
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
    max-height: none !important;
    overflow: visible !important;
    gap: 4px;
    padding: 4px 8px;
}

/* 팔레트 헤더 */
#color-palette-popup .palette-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 4px 0;
    margin-bottom: 0;
    border-bottom: none;
}

#color-palette-popup .palette-tools-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

/* 팔레트 내 Paint 버튼 */
#color-palette-popup .palette-paint-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
}

#color-palette-popup .palette-paint-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#color-palette-popup .palette-paint-btn:disabled {
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    opacity: 0.7;
    cursor: not-allowed;
}

#color-palette-popup .palette-paint-btn.ready-to-paint {
    background: linear-gradient(135deg, #34a853 0%, #1e8e3e 100%);
    box-shadow: 0 4px 16px rgba(52, 168, 83, 0.4);
}

#color-palette-popup .palette-paint-btn .paint-icon {
    font-size: 16px;
}

#color-palette-popup .palette-paint-btn .paint-quota-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

#color-palette-popup .palette-paint-btn .paint-quota {
    background: rgba(255, 255, 255, 0.25);
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 12px;
}

#color-palette-popup .palette-paint-btn .paint-timer {
    font-size: 10px;
    opacity: 0.85;
    white-space: nowrap;
}

#color-palette-popup .palette-close-btn {
    position: static;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    color: #666;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-header-left {
    flex-shrink: 0;
}

.palette-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.palette-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.palette-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 26px;
    transition: all 0.2s ease;
}

.palette-tool-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.palette-tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.palette-tool-btn.active {
    background: #4285f4;
    color: white;
}

.palette-divider {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

/* 헤더 내 닫기 버튼 (빨간 X) */
#palette-close-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
    border: none !important;
    background: #ff5f57 !important;
    cursor: pointer;
    font-size: 18px !important;
    font-weight: bold;
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(255, 95, 87, 0.4);
}

#palette-close-btn:hover {
    background: #ff3b30 !important;
    transform: scale(1.05);
}

#palette-close-btn:active {
    transform: scale(0.95);
}

/* 빨간색 닫기 버튼 */
.palette-close-btn-red {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: #e53935;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.3);
}

.palette-close-btn-red:hover {
    background: #c62828;
    transform: scale(1.05);
}

.palette-close-btn-red:active {
    transform: scale(0.95);
}

/* 팔레트 위 플로팅 컨트롤 (최근색상 + 닫기버튼) */
/* 헤더 내 최근 색상 스타일 */
#color-palette-popup .recent-colors-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

#color-palette-popup .recent-colors-label {
    font-size: 10px;
    color: #888;
    font-weight: 600;
}

#color-palette-popup #recent-colors-container {
    display: flex;
    gap: 3px;
}

#color-palette-popup .recent-color-cell {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#color-palette-popup .recent-color-cell:hover {
    transform: scale(1.1);
}

/* 팔레트가 열려있을 때 플로팅 컨트롤 표시 */
/* :has() 사용으로 팔레트 상태에 따라 자동 표시/숨김 */
body:has(#color-palette-popup:not(.hidden)) .palette-floating-controls {
    display: flex;
}

/* 팔레트가 확장되었을 때 플로팅 컨트롤 - 팔레트 바로 위에 붙임 */
body:has(#color-palette-popup.expanded:not(.hidden)) .palette-floating-controls {
    bottom: 230px; /* 확장된 팔레트 바로 위 */
}

@media (max-width: 768px) {
    body:has(#color-palette-popup.expanded:not(.hidden)) .palette-floating-controls {
        bottom: 240px; /* 모바일에서 확장된 팔레트 바로 위 */
    }
}

.palette-floating-controls .recent-colors-row {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.palette-floating-controls .recent-colors-label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.palette-floating-controls #recent-colors-container {
    display: flex;
    gap: 4px;
}

.palette-floating-controls .recent-color-cell {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.palette-floating-controls .recent-color-cell:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.palette-floating-controls .recent-color-cell.selected {
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.5);
}

.recent-color-cell {
    position: relative;
}

.recent-color-cell.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.recent-color-cell.locked {
    opacity: 0.5;
}

.recent-color-cell.locked::before {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    pointer-events: none;
    z-index: 1;
}

/* 팔레트 위 플로팅 닫기 버튼 (빨간 X 버튼) */
.palette-close-btn-floating {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: #ff5f57;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 95, 87, 0.5);
    pointer-events: auto;
}

.palette-close-btn-floating:hover {
    background: #ff3b30;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.6);
}

.palette-close-btn-floating:active {
    transform: scale(0.95);
}

/* 팔레트 위 플로팅 컨트롤 */
.palette-controls-floating {
    position: fixed;
    bottom: 180px;
    right: 20px;
    z-index: 10000;
    display: flex;
    gap: 8px;
}

.palette-controls-floating.hidden {
    display: none;
}

.palette-mini-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.palette-mini-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mini-btn-icon {
    font-size: 14px;
}

.mini-btn-label {
    font-weight: 600;
    color: #4CAF50;
}

.mini-btn-label.off {
    color: #999;
}

/* 팔레트 푸터 - 제거됨 */

.palette-tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.palette-tool-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.palette-tool-btn.active {
    background: #4285f4;
    color: white;
}

.palette-footer-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
}

.palette-footer-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* 구 스타일 호환 */
.palette-popup-header { display: none; }
.palette-popup-title { display: none; }
.palette-popup-close { display: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.palette-popup-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* 팔레트 그리드 행 */
.palette-grid-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding-right: 0;
}

/* 헤더 인라인 확장 버튼 */
.palette-expand-btn-inline {
    font-size: 24px !important;
}

/* 팔레트 확장 버튼 */
.palette-expand-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.05);
    color: #666;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.palette-expand-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

#color-palette-popup.expanded .palette-expand-btn {
    transform: rotate(180deg);
}

/* 팔레트 팝업 내 색상 그리드 - 기본 1줄 */
#color-palette-popup #color-grid-wrapper {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    max-height: 44px !important; /* 1줄 높이 강제 */
}

/* 기본 상태: 1줄 표시 */
#color-palette-popup #color-grid-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    justify-content: center;
    min-width: max-content;
    padding: 4px 8px;
}


#color-palette-popup .color-bar-cell {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* 팔레트 하단 푸터 */
.palette-popup-footer {
    display: flex;
    justify-content: center;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.palette-paint-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.4);
    transition: all 0.2s ease;
}

.palette-paint-btn:hover:not(:disabled) {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.5);
}

.palette-paint-btn:disabled {
    background: linear-gradient(135deg, #9fc5f8 0%, #a4c2f4 100%);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.2);
    cursor: not-allowed;
    opacity: 0.7;
}

.palette-paint-btn.ready-to-paint {
    background: linear-gradient(135deg, #34a853 0%, #1e8e3e 100%);
    box-shadow: 0 4px 16px rgba(52, 168, 83, 0.4);
}

.palette-paint-btn .paint-icon {
    font-size: 16px;
}

.palette-paint-btn .paint-quota {
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
}

/* 채우기 플로팅 버튼 */
#paint-floating-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    transition: bottom 0.2s ease;
}

/* 팔레트 열릴 때 플로팅 버튼을 팔레트 바로 위에 붙임 */
/* :has() 사용으로 palette-open 클래스 없이도 팔레트 상태에 따라 자동 위치 조정 */
body:has(#color-palette-popup:not(.hidden)) #paint-floating-btn {
    position: fixed;
    bottom: 108px; /* 1줄 팔레트 위 (동일 간격) */
    z-index: 10003;
}

/* 팔레트 확장 시 (3줄) 더 위로 - 동일 간격 유지 */
body:has(#color-palette-popup.expanded:not(.hidden)) #paint-floating-btn {
    bottom: 200px; /* 3줄 팔레트 위 (동일 간격) */
}

body:has(#color-palette-popup:not(.hidden)) #paint-submit-floating {
    padding: 8px 16px;
    font-size: 14px;
}

/* 플로팅 닫기 버튼 */
.floating-close-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #ff5f57;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 8px;
    box-shadow: 0 2px 8px rgba(255, 95, 87, 0.4);
    transition: all 0.2s ease;
}

.floating-close-btn:hover {
    background: #ff3b30;
    transform: scale(1.1);
}

/* 팔레트 열릴 때 닫기 버튼 표시 */
body:has(#color-palette-popup:not(.hidden)) .floating-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 드래그 잠금 버튼 */
.paint-lock-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    background: rgba(50, 50, 80, 0.85);
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-right: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
}
.paint-lock-btn:hover {
    transform: scale(1.1);
    background: rgba(80, 80, 120, 0.95);
}
.paint-lock-btn.locked {
    background: rgba(255, 140, 0, 0.9);
    border-color: rgba(255, 200, 50, 0.7);
    box-shadow: 0 0 12px rgba(255, 140, 0, 0.6);
    animation: lock-pulse 1.2s ease-in-out infinite;
}
@keyframes lock-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 140, 0, 0.5); }
    50% { box-shadow: 0 0 18px rgba(255, 140, 0, 0.9); }
}
/* 그리기 모드에서 자물쇠 버튼 표시 */
body.paint-mode .paint-lock-btn {
    display: flex;
}
/* 잠금 상태에서 캔버스 커서 */
body.paint-lock canvas {
    cursor: crosshair !important;
}
/* 잠금 상태에서 내 위치 / 지구본 버튼 숨김 */
body.paint-lock #gps-btn,
body.paint-lock #world-view-btn {
    display: none !important;
}

/* 플로팅 버튼 컨테이너 flexbox */
#paint-floating-btn {
    display: flex;
    align-items: center;
    gap: 0;
}

#paint-submit-floating {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap; /* 텍스트 줄바꿈 방지 */
    min-width: max-content; /* 내용에 맞게 너비 확보 */
}

#paint-submit-floating:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

#paint-submit-floating:disabled {
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    opacity: 0.7;
    cursor: not-allowed;
}

#paint-submit-floating .paint-icon {
    font-size: 18px;
}

#paint-submit-floating .paint-quota-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

#paint-submit-floating .paint-quota {
    background: rgba(255, 255, 255, 0.25);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
}

#paint-submit-floating .paint-timer {
    font-size: 10px;
    opacity: 0.85;
    white-space: nowrap;
}

/* 편집 모드 진입 버튼 스타일 */
#paint-submit-floating.edit-mode-enter {
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.4);
}

#paint-submit-floating.edit-mode-enter:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.5);
}

/* 저장 준비 상태 (픽셀 선택됨) */
#paint-submit-floating.ready-to-paint {
    background: linear-gradient(135deg, #34a853 0%, #1e8e3e 100%);
    box-shadow: 0 4px 16px rgba(52, 168, 83, 0.4);
}

#paint-submit-floating.ready-to-paint:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(52, 168, 83, 0.5);
}

#paint-cancel-floating {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: none; /* 기본 숨김 - 편집 모드일 때만 JS로 표시 */
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
    transition: all 0.2s ease;
}

#paint-cancel-floating:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* 모바일 반응형 */
@media (max-width: 600px) {
    #bottom-toolbar {
        bottom: 10px;
        padding: 6px 10px;
        gap: 4px;
    }
    
    .toolbar-btn {
        width: 40px;
        height: 40px;
    }
    
    .toolbar-btn.color-btn {
        width: 44px;
        height: 44px;
    }
    
    .toolbar-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .toolbar-separator {
        height: 20px;
    }
    
    .gauge-bar {
        width: 40px;
    }
    
    .pixel-gauge {
        font-size: 12px;
    }
    
    #color-palette-popup {
        padding: 10px 12px 14px;
    }
    
    #color-palette-popup .color-bar-cell {
        width: 32px;
        height: 32px;
        border-radius: 6px;
    }
    
    #paint-floating-btn {
        bottom: 15px;
    }
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark) {
    #bottom-toolbar {
        background: rgba(40, 40, 40, 0.95);
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    }
    
    .toolbar-btn {
        color: #ddd;
    }
    
    .toolbar-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .toolbar-btn.color-btn {
        background: #333;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .toolbar-separator,
    .toolbar-right {
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .pixel-gauge {
        color: #ddd;
    }
    
    .gauge-bar {
        background: rgba(255, 255, 255, 0.1);
    }
    
    /* 팔레트는 항상 밝은 배경 유지 */
    #color-palette-popup {
        background: rgba(255, 255, 255, 0.98);
    }
    
    .palette-popup-header {
        border-color: rgba(0, 0, 0, 0.1);
    }
    
    .palette-popup-title {
        color: #333;
    }
    
    .palette-popup-close {
        background: rgba(0, 0, 0, 0.1);
        color: #666;
    }
}

/* ========================================
   레거시 팔레트 바 (숨김 처리)
   ======================================== */

#color-palette-bar {
    display: none !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: -1;
    
    /* display: flex; */
    align-items: stretch;
    
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: none;
    
    width: 100%;
    
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 숨김 상태 */
#color-palette-bar.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* 확장 버튼 (헤더 내 배치 - 좌측) */
/* 터치 접근성: 최소 44px 크기 보장 */
#palette-expand-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 4px;
}

#palette-expand-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.1);
}

#palette-expand-btn:active {
    transform: scale(0.95);
}

.expand-icon {
    font-size: 12px;
    color: #666;
    transition: transform 0.3s ease;
}

#color-palette-bar.expanded .expand-icon {
    transform: rotate(180deg);
}

/* 메인 섹션 */
.palette-main-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* 헤더 바 */
.palette-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
}

.palette-title-area {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.palette-title,
.palette-count {
    color: #333;
}

.palette-icon {
    font-size: 14px;
}

.palette-count {
    font-weight: 400;
    color: #888;
}

.palette-tools {
    display: flex;
    align-items: center;
    gap: 8px; /* WCAG 2.5.5: Minimum 8px spacing between touch targets */
}

/* 터치 접근성: 최소 44px 크기 보장 */
.palette-tool-btn {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    color: #666;
}

.palette-tool-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
}

.palette-tool-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.palette-tool-btn:active {
    transform: scale(0.95);
}

.palette-tool-btn.active {
    background: rgba(66, 133, 244, 0.15);
    border-color: rgba(66, 133, 244, 0.3);
    color: #4285f4;
}

.tool-separator {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 4px;
}

/* 모바일용 채우기 버튼 (팔레트 헤더 내) - 컴팩트 스타일 */
/* 터치 접근성: 최소 44px 높이 보장 (Apple HIG, WCAG 2.1 Level AAA) */
#mobile-paint-btn {
    display: none; /* 기본적으로 숨김, 모바일에서만 표시 */
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    min-height: 44px; /* 터치 접근성 최소 크기 */
    border-radius: 14px;
    background: linear-gradient(135deg, #9575cd 0%, #7e57c2 100%);
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: white;
    box-shadow: 0 1px 4px rgba(149, 117, 205, 0.4);
    white-space: nowrap;
    transition: all 0.2s ease;
    margin-left: 4px;
    flex-shrink: 0;
}

#mobile-paint-btn:disabled {
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    opacity: 0.7;
    cursor: not-allowed;
}

#mobile-paint-btn:not(:disabled):active {
    transform: scale(0.95);
}

#mobile-paint-btn .paint-icon {
    font-size: 11px;
}

/* 모바일에서 "Paint" 라벨 작게 표시 */
#mobile-paint-btn .paint-label {
    display: inline;
    font-size: 10px;
}

/* 모바일 쿼터/타이머 - 컴팩트 스타일 */
#mobile-paint-btn .paint-quota {
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
}

#mobile-paint-btn .paint-timer {
    font-size: 9px;
    opacity: 0.85;
}

/* 모바일용 취소 버튼 (채우기 버튼 우측) */
/* 터치 접근성: 최소 44px 크기 보장 */
#mobile-cancel-btn {
    display: none; /* 기본적으로 숨김, 모바일 페인트 모드에서만 표시 */
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(244, 67, 54, 0.9);
    border: none;
    cursor: pointer;
    color: white;
    font-size: 14px;
    font-weight: bold;
    margin-left: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#mobile-cancel-btn:active {
    transform: scale(0.9);
    background: rgba(211, 47, 47, 1);
}

/* 비활성화된 버튼 스타일 */
.palette-tool-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.palette-tool-btn:disabled:hover {
    background: transparent;
    border-color: transparent;
}

/* 스포이드 SVG 아이콘 스타일 */
#tool-eyedropper .eyedropper-svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* 스포이드 활성화 스타일 */
.palette-tool-btn#tool-eyedropper.active {
    background: rgba(66, 133, 244, 0.2);
    border-color: #4285f4;
    color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.palette-tool-btn#tool-eyedropper.active .eyedropper-svg {
    fill: #4285f4;
}

/* 스포이드 모드일 때 캔버스 커서 */
body.eyedropper-mode #pixel-canvas {
    cursor: crosshair !important;
}

/* 색상 그리드 래퍼 */
#color-grid-wrapper {
    padding: 8px 12px 10px 12px; /* 하단 패딩 추가 */
    overflow-x: auto;
    overflow-y: hidden;
    /* 스크롤바 숨김 - 터치/드래그로만 스크롤 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#color-grid-wrapper::-webkit-scrollbar {
    display: none;
}

/* 색상 그리드 컨테이너 */
#color-grid-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    min-width: max-content;
    transition: all 0.3s ease;
    padding: 6px 0;
}

/* 확장 상태 - 여러 줄 표시 (꽉 채우기) */
#color-palette-bar.expanded #color-grid-container {
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
    /* 간격 줄여서 더 많은 색상 표시 */
    gap: 8px;
    justify-content: center;
}

#color-palette-bar.expanded #color-grid-wrapper {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 240px;
    padding: 8px 4px; /* 좌우 패딩 줄임 */
}

/* PC: 확장 시 색상 셀 - 직사각형 유지 */
/* 터치 접근성: 최소 44px 높이 보장 */
#color-palette-bar.expanded .color-bar-cell {
    width: 48px;
    height: 44px;
    border-radius: 8px;
}

/* 테두리 토글 버튼 스타일 */
/* 터치 접근성: 최소 44px 크기 보장 */
#toggle-border-btn {
    width: 44px;
    height: 44px;
    margin-right: 8px;
}

#toggle-border-btn .border-icon {
    font-size: 16px;
    font-weight: bold;
}

#toggle-border-btn.active {
    background: rgba(66, 133, 244, 0.15);
    border-color: rgba(66, 133, 244, 0.3);
    color: #4285f4;
}

#toggle-border-btn:not(.active) {
    background: rgba(0, 0, 0, 0.05);
    color: #999;
}

#toggle-border-btn:not(.active) .border-icon {
    opacity: 0.5;
}

/* 색상 셀 - 둥근 직사각형 버튼 스타일 */
/* 터치 접근성: 최소 44px 높이 보장 (PC 버전) */
.color-bar-cell {
    width: 48px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.color-bar-cell:hover {
    transform: scale(1.12);
    z-index: 1;
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.color-bar-cell.selected {
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.4), 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: scale(1.08);
}

.color-bar-cell.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.color-bar-cell.selected.light-color::after {
    color: #333;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* 잠긴 색상 - 원래 색상 유지, 자물쇠만 표시 */
.color-bar-cell.locked {
    cursor: pointer;
}

/* 한 줄 모드에서는 잠긴 색상 숨김 (해금된 색상만 표시) */
#color-palette-bar:not(.expanded) .color-bar-cell.locked {
    display: none;
}

.color-bar-cell.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    opacity: 0.95;
}

.color-bar-cell.locked:hover {
    transform: scale(1.08);
}


/* Paint 액션 버튼 - 팔레트 위에 떠있는 버튼 */
#paint-action-bar {
    position: fixed;
    /* 팔레트 높이 + 여백 (1줄: ~70px, 확장: ~280px) */
    bottom: calc(var(--palette-height, 70px) + 15px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: none !important; /* 새 하단 툴바 사용으로 숨김 */
    gap: 10px;
    align-items: center;
    transition: bottom 0.3s ease;
}

/* 페인트 모드가 아닐 때 취소 버튼 숨김 */
#paint-action-bar #paint-cancel-btn {
    display: none;
}

body.paint-mode #paint-action-bar #paint-cancel-btn {
    display: flex;
}

/* 모바일에서는 Paint 버튼 숨김 - 팔레트 헤더 내 버튼으로 대체 */
@media (max-width: 600px) {
    #paint-action-bar {
        display: none !important;
    }
}

/* ========================================
   스포이드 액션 바 스타일
   ======================================== */

#eyedropper-action-bar {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: none;
    gap: 10px;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.eyedropper-mode #eyedropper-action-bar {
    display: flex;
}

/* 스포이드 모드일 때 페인트 버튼 숨기기 */
body.eyedropper-mode #paint-action-bar {
    display: none !important;
}

@media (max-width: 600px) {
    #eyedropper-action-bar {
        top: 50px;
        padding: 8px 16px;
    }
}

/* 스포이드 취소 버튼 */
#eyedropper-cancel-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#eyedropper-cancel-btn:hover {
    background: rgba(255, 100, 100, 0.15);
    border-color: rgba(255, 100, 100, 0.4);
    color: #e53935;
    transform: scale(1.05);
}

#eyedropper-cancel-btn:active {
    transform: scale(0.95);
}

/* 스포이드 상태 버튼 (옅은 파란색) */
#eyedropper-status-btn {
    padding: 14px 32px;
    border-radius: 25px;
    background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%);
    border: none;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 16px rgba(66, 165, 245, 0.4);
    white-space: nowrap;
    animation: eyedropper-pulse 1.5s ease-in-out infinite;
}

@keyframes eyedropper-pulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(66, 165, 245, 0.4);
    }
    50% {
        box-shadow: 0 4px 24px rgba(66, 165, 245, 0.6);
    }
}

#eyedropper-status-btn .eyedropper-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

#eyedropper-status-btn .eyedropper-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

#eyedropper-status-btn .eyedropper-label {
    font-size: 15px;
}

/* 취소 버튼 */
#paint-cancel-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#paint-cancel-btn:hover {
    background: rgba(255, 100, 100, 0.15);
    border-color: rgba(255, 100, 100, 0.4);
    color: #e53935;
    transform: scale(1.05);
}

#paint-cancel-btn:active {
    transform: scale(0.95);
}

#paint-submit-btn {
    padding: 14px 32px;
    border-radius: 25px;
    background: linear-gradient(135deg, #9575cd 0%, #7e57c2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(149, 117, 205, 0.4);
    white-space: nowrap;
}

#paint-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(149, 117, 205, 0.5);
}

#paint-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

#paint-submit-btn:disabled {
    background: linear-gradient(135deg, #b39ddb 0%, #9575cd 100%);
    cursor: not-allowed;
    box-shadow: 0 2px 8px rgba(149, 117, 205, 0.3);
    opacity: 0.7;
}

#paint-submit-btn .paint-icon {
    font-size: 18px;
}

#paint-submit-btn .paint-quota {
    background: rgba(255, 255, 255, 0.25);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

#paint-submit-btn .paint-timer {
    font-size: 13px;
    opacity: 0.85;
}

/* 페인트 모드 활성화 시 강조 */
body.paint-mode #color-palette-bar {
    box-shadow: 0 -4px 24px rgba(66, 133, 244, 0.3);
    border-color: rgba(66, 133, 244, 0.3);
}

/* 모바일 반응형 */
@media (max-width: 600px) {
    #color-palette-bar {
        width: 100%;
        border-radius: 12px 12px 0 0;
    }
    
    #color-palette-bar.hidden {
        transform: translateY(100%);
    }
    
    /* 모바일: 선택 픽셀 텍스트와 카운트 숨기기 (버튼으로 대체) */
    .palette-title,
    .palette-count {
        display: none;
    }
    
    /* 모바일: 채우기 버튼 항상 표시 (쿨타임/쿼터 확인 가능하도록) */
    #mobile-paint-btn {
        display: flex;
    }
    
    /* 모바일: 페인트 모드일 때 취소 버튼 표시 */
    body.paint-mode #mobile-cancel-btn {
        display: flex;
    }
    
    /* 모바일: 색상 셀 정사각형으로 변경 - 터치 타겟 최소 44x44px (Apple HIG 권장) */
    .color-bar-cell {
        width: 44px;
        height: 44px;
        border-radius: 8px;
    }

    #color-grid-container {
        gap: 8px; /* WCAG 2.5.5: Minimum 8px spacing between touch targets */
    }
    
    /* 모바일: 확장 시 꽉 채우기 */
    #color-palette-bar.expanded #color-grid-container {
        gap: 8px; /* WCAG 2.5.5: Minimum 8px spacing between touch targets */
        justify-content: center;
    }
    
    /* 모바일: 확장 시 색상 셀 정사각형 유지 - 터치 타겟 최소 44x44px */
    #color-palette-bar.expanded .color-bar-cell {
        width: 44px;
        height: 44px;
        border-radius: 8px;
    }
    
    /* 모바일: 확장 시 좌우 패딩 최소화 */
    #color-palette-bar.expanded #color-grid-wrapper {
        padding: 6px 2px;
    }
    
    .palette-header-bar {
        padding: 6px 10px;
    }
    
    .palette-title-area {
        font-size: 12px;
    }
    
    /* 모바일: 터치 접근성을 위해 44px 유지 */
    .palette-tool-btn {
        width: 44px;
        height: 44px;
        font-size: 12px;
    }

    /* 모바일: 확장 버튼 크기 조정 - 터치 접근성 44px 유지 */
    #palette-expand-btn {
        width: 44px;
        height: 44px;
        margin-right: 2px;
    }
    
    #palette-expand-btn .expand-icon {
        font-size: 10px;
    }
    
    /* 모바일: 터치 접근성 44px 유지 */
    #toggle-border-btn {
        width: 44px;
        height: 44px;
        margin-right: 6px;
    }
    
    #toggle-border-btn .border-icon {
        font-size: 14px;
    }
    
    /* 모바일: 스포이드 SVG 아이콘 크기 조정 */
    #tool-eyedropper .eyedropper-svg {
        width: 14px;
        height: 14px;
    }
    
    #color-grid-wrapper {
        padding: 6px 10px;
    }
    
    #paint-submit-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    /* 모바일: 터치 접근성 44px 유지 */
    #paint-cancel-btn {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    #paint-action-bar {
        bottom: 70px;
        gap: 8px;
    }
    
    /* 확장 시 더 많은 색상 표시 */
    #color-palette-bar.expanded #color-grid-wrapper {
        max-height: 180px;
    }
}

/* ============================================
   Shop & Purple Charge Styles
   ============================================ */

/* Purple Balance Clickable */
.user-currency {
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-currency:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2) 0%, rgba(75, 0, 130, 0.2) 100%);
    transform: translateY(-1px);
}

.user-currency .currency-hint {
    font-size: 12px;
    color: #8a2be2;
    font-weight: bold;
    margin-left: 4px;
    opacity: 0.7;
}

/* ========================================
   새 상점 모달 스타일 (2026 리디자인)
   ======================================== */

.shop-modal-new {
    max-width: 420px;
    width: 90%;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
}

/* 상점 헤더 */
.shop-header-new {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #fff;
}

.shop-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shop-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.shop-header-text {
    display: flex;
    flex-direction: column;
}

.shop-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.shop-balance {
    font-size: 13px;
    color: #888;
}

.shop-balance span:last-child {
    color: #4285f4;
    font-weight: 600;
}

.shop-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 16px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shop-close:hover {
    background: #eee;
    color: #333;
}

/* 상점 탭 */
.shop-tabs {
    display: flex;
    padding: 0 20px;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.shop-tab {
    flex: 1;
    padding: 14px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-radius: 25px;
    margin: 8px 4px;
    transition: all 0.2s ease;
}

.shop-tab:hover {
    color: #333;
}

.shop-tab.active {
    background: #fff;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 상점 콘텐츠 */
.shop-content {
    padding: 16px 20px;
    max-height: 400px;
    overflow-y: auto;
}

.shop-tab-content {
    display: none;
}

.shop-tab-content.active {
    display: block;
}

/* 상점 카드 */
.shop-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.shop-card:hover {
    border-color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.shop-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.shop-card-icon.blue {
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8fc 100%);
}

.shop-card-icon.green {
    background: linear-gradient(135deg, #e8fdf0 0%, #d0fce4 100%);
}

.shop-card-icon.purple {
    background: linear-gradient(135deg, #f3e8fd 0%, #e4d0fc 100%);
}

.shop-card-info {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.shop-card-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    word-break: keep-all;
}

.shop-card-desc {
    display: block;
    font-size: 11px;
    color: #888;
    line-height: 1.3;
    word-break: keep-all;
}

.shop-card-action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

/* 수량 컨트롤 */
.qty-control-new {
    display: flex;
    align-items: center;
    gap: 0;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.qty-btn-new {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qty-btn-new:hover {
    background: #e8e8e8;
    color: #333;
}

.qty-value-new {
    width: 32px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* 가격 버튼 */
.price-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.price-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

/* 가격 텍스트 */
.shop-card-price-text {
    text-align: right;
}

.price-text-value {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4285f4;
}

.price-text-unit {
    font-size: 11px;
    color: #888;
}

/* 상점 모달 모바일 반응형 */
@media (max-width: 480px) {
    .shop-modal-new {
        max-width: 95%;
        width: 95%;
    }
    
    .shop-content {
        padding: 12px 16px;
    }
    
    .shop-card {
        padding: 12px;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .shop-card-icon {
        width: 40px;
        height: 40px;
    }
    
    .shop-card-info {
        flex: 1 1 100px;
        min-width: 70px;
    }
    
    .shop-card-title {
        font-size: 12px;
        line-height: 1.4;
        white-space: normal;
    }
    
    .shop-card-desc {
        font-size: 10px;
        line-height: 1.3;
    }
    
    .shop-card-action {
        gap: 4px;
        flex-shrink: 1;
    }
    
    .qty-control-new {
        gap: 0;
    }
    
    .qty-btn-new {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .qty-value-new {
        width: 28px;
        font-size: 12px;
    }
    
    .buy-btn-new {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .price-text-value {
        font-size: 12px;
    }
    
    .charge-card {
        padding: 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
    
    .charge-card .charge-amount {
        font-size: 14px;
        margin-bottom: 0;
    }
    
    .charge-card .charge-price {
        font-size: 13px;
        margin-top: 0;
    }
    
    .charge-badge {
        position: static;
        transform: none;
        margin-left: 8px;
        padding: 3px 8px;
        font-size: 10px;
    }
}

/* 충전 그리드 - 기본 1열, 큰 화면에서 2열 */
.charge-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 600px) {
    .charge-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.charge-card {
    background: #f8f9fa;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    padding: 12px 10px;
    text-align: center;
    position: relative;
    transition: all 0.2s ease;
}

.charge-card:hover {
    border-color: #e0e0e0;
}

.charge-card.popular {
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8fc 100%);
    border-color: #4285f4;
}

.charge-badge {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.charge-amount {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 2px;
}

.charge-bonus {
    display: block;
    font-size: 12px;
    color: #4285f4;
    font-weight: 500;
    margin-bottom: 4px;
}

.charge-label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
}

.charge-buy-btn {
    width: auto;
    min-width: 80px;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.charge-buy-btn:hover {
    background: #f5f5f5;
}

.charge-buy-btn.highlight {
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: white;
    border: none;
}

.charge-buy-btn.highlight:hover {
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

/* 상점 모바일 반응형 */
@media (max-width: 600px) {
    .charge-buy-btn {
        padding: 8px;
        font-size: 12px;
    }
    
    .charge-card {
        padding: 12px;
    }
    
    .charge-amount {
        font-size: 18px;
    }
    
    .charge-label {
        font-size: 11px;
        margin-bottom: 8px;
    }
}

/* 상점 푸터 */
.shop-footer-new {
    padding: 16px 20px;
    text-align: center;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

/* ========================================
   레거시 상점 스타일 (호환성)
   ======================================== */

/* Shop Modal */
.shop-modal-content {
    max-width: 450px;
    width: 90%;
}

.shop-body {
    padding: 16px;
}

.shop-user-status {
    display: flex;
    gap: 16px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.1) 0%, rgba(75, 0, 130, 0.1) 100%);
    border-radius: 10px;
    margin-bottom: 16px;
}

.shop-user-status .status-item {
    flex: 1;
    text-align: center;
}

.shop-user-status .status-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.shop-user-status .status-value {
    font-size: 16px;
    font-weight: 700;
    color: #8a2be2;
}

/* Shop Purple Balance Row */
.purple-balance-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.charge-btn {
    background: linear-gradient(135deg, #8a2be2, #9932cc);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(138, 43, 226, 0.3);
}

.charge-btn:hover {
    background: linear-gradient(135deg, #7b1fa2, #8a2be2);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(138, 43, 226, 0.4);
}

.charge-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(138, 43, 226, 0.3);
}

/* Shop Item */
.shop-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.shop-item:hover {
    border-color: #8a2be2;
    box-shadow: 0 2px 8px rgba(138, 43, 226, 0.1);
}

.shop-item.shop-item-info {
    background: #f8f9fa;
    border-style: dashed;
}

.shop-item .item-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.shop-item .item-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 10px;
}

.shop-item .item-info {
    flex: 1;
}

.shop-item .item-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.shop-item .item-desc {
    display: block;
    font-size: 12px;
    color: #888;
}

.shop-item .item-purchase {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.shop-item .item-remaining {
    margin-top: 8px;
    font-size: 11px;
    color: #888;
    text-align: right;
}

/* Quantity Control */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 4px;
}

/* 터치 접근성: 최소 44px 크기 보장 */
.quantity-control .qty-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: white;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-control .qty-btn:hover {
    background: #667eea;
    color: white;
}

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

.quantity-control .qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
}

/* Price Info */
.price-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.price-info .price-label {
    font-size: 12px;
    color: #888;
}

.price-info .price-value {
    font-size: 14px;
    font-weight: 700;
    color: #8a2be2;
}

.discount-badge {
    padding: 2px 6px;
    background: #ff4757;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
}

/* Buy Button */
.buy-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.buy-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Purple Charge Modal */
.purple-charge-content {
    max-width: 400px;
    width: 90%;
}

.current-balance-display {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.1) 0%, rgba(75, 0, 130, 0.1) 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.current-balance-display span:last-child {
    font-size: 20px;
    font-weight: 700;
    color: #8a2be2;
    margin-left: 8px;
}

.charge-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.charge-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.charge-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.charge-option.popular {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.charge-option .charge-amount {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.charge-option .charge-price {
    font-size: 14px;
    font-weight: 700;
    color: #8a2be2;
}

.charge-option .charge-bonus {
    margin-left: 8px;
    padding: 3px 8px;
    background: #ff6b6b;
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
}

.charge-coming-soon {
    text-align: center;
    padding: 16px;
    margin-top: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    color: #888;
}

/* Purple 잔액 상세 표시 */
.balance-detail {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.balance-detail .paid-label {
    color: #8a2be2;
}

.balance-detail .free-label {
    color: #4caf50;
}

/* 충전 옵션 추가 스타일 */
.charge-option {
    position: relative;
}

.charge-option.selected {
    border-color: #8a2be2;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    box-shadow: 0 0 0 2px rgba(138, 43, 226, 0.3);
}

.charge-option .charge-option-main {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 12px;
}

.charge-option .popular-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
}

/* 충전 정보 */
.charge-info {
    margin-top: 16px;
    padding: 12px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 11px;
    color: #666;
}

.charge-info p {
    margin: 4px 0;
}

/* 로딩 상태 */
.loading-packages {
    text-align: center;
    padding: 40px;
    color: #888;
}

.charge-error {
    text-align: center;
    padding: 30px;
    color: #e74c3c;
}

.charge-error button {
    margin-top: 12px;
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.no-packages {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .shop-item {
        background: #2a2a2a;
        border-color: #444;
    }

    .shop-item .item-icon {
        background: #333;
    }

    .shop-item .item-name {
        color: #eee;
    }

    .quantity-control {
        background: #333;
    }

    .quantity-control .qty-btn {
        background: #444;
        color: #fff;
    }

    .charge-option {
        background: #2a2a2a;
        border-color: #444;
    }

    .charge-option:hover {
        background: #333;
    }

    .charge-option .charge-amount {
        color: #eee;
    }
}

/* ============================================
   Glassmorphism Fallback for Unsupported Browsers
   ============================================
   backdrop-filter가 지원되지 않는 브라우저에서
   불투명 배경으로 폴백하여 가독성 유지
   ============================================ */

@supports not (backdrop-filter: blur(10px)) {
    /* Menu toggle button fallback */
    #menu-toggle {
        background: #f5f5f5;
        border-color: #e0e0e0;
    }

    #menu-toggle:hover {
        background: #ffffff;
    }

    /* Menu dropdown fallback */
    #menu-dropdown {
        background: #ffffff;
        border-right-color: #e0e0e0;
    }

    /* Control buttons fallback */
    .control-btn {
        background: #f5f5f5;
        border-color: #e0e0e0;
    }

    .control-btn:hover {
        background: #ffffff;
    }

    .control-btn.active {
        /* Active state keeps gradient, no change needed */
    }

    /* Color palette fallback */
    #color-palette {
        background: rgba(20, 20, 25, 0.98);
    }
}
