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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    pointer-events: auto;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0 0 20px 0;
    position: relative;
    pointer-events: auto;
}

.main-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 16px 32px 40px 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 450px;
    width: 100%;
    position: relative;
    overflow: hidden;
    z-index: 1;
    margin-top: 16px;
}

.main-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

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

/* PWA 설치 버튼: 원형 아이콘 버튼(📲) */
.qr-pwa-btn {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    color: #333;
}

.qr-pwa-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.logo {
    font-size: 2.5rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.5)); }
    to { filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.8)); }
}

.title {
    font-size: 1.8rem;
    color: #333;
    font-weight: 600;
    text-align: center;
}

.qr-input-section {
    margin-bottom: 20px;
    pointer-events: auto;
}

.qr-input-group {
    margin-bottom: 15px;
    pointer-events: auto;
}

.qr-options-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.qr-options-row .qr-input-group {
    flex: 1;
    margin-bottom: 0;
}

.qr-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    text-align: left;
    pointer-events: auto;
}

.qr-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    pointer-events: auto;
}

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

.qr-textarea {
    height: 45px;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}

.qr-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 10px 10px 0;
    pointer-events: auto;
}

.qr-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

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

.qr-button.secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.qr-result-section {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    border: 2px dashed #e2e8f0;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.qr-result-section.has-content {
    border-color: #667eea;
    background: white;
}

.qr-code-placeholder {
    color: #a0aec0;
    font-size: 1.1rem;
}

.qr-download-section {
    margin-top: 20px;
    display: none;
    pointer-events: auto;
}

.qr-download-section.show {
    display: block;
}

.qr-error {
    color: #e53e3e;
    background: #fed7d7;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    display: none;
}

.qr-success {
    color: #38a169;
    background: #c6f6d5;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    display: none;
}

/* 플로팅 버튼 스타일 */
.qr-back-btn:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) !important;
}

.lang-option:hover {
    background: rgba(102, 126, 234, 0.1) !important;
    color: #667eea !important;
}

.lang-option.selected {
    background: rgba(102, 126, 234, 0.15) !important;
    color: #667eea !important;
    font-weight: bold;
}

.lang-dropdown.show {
    display: block !important;
}

.qr-lang-btn {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.qr-lang-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .qr-lang-btn {
        width: 40px;
        height: 40px;
        font-size: 0.8rem;
        font-weight: bold;
        border-radius: 50%;
    }
}

.lang-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-option {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-option:last-child {
    border-bottom: none;
}

/* 뒤로가기 버튼 */
.qr-back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    margin-left: 0;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #667eea;
}

/* 광고 영역 스타일 */
.elegant-spacer {
    height: 32px;
    pointer-events: none;
}

@media (max-width: 768px) {
    .elegant-spacer {
        height: 20px;
    }
}

@media (max-width: 480px) {
    .elegant-spacer {
        height: 12px;
    }
}

/* 우아한 디스플레이 매니저를 위한 동적 클래스 */
.elegant-display {
    margin-bottom: 2.5vh;
    text-align: center;
    pointer-events: none;
}

.elegant-display * {
    pointer-events: none;
}

.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -10;
}

.floating-element {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float-element 8s infinite linear;
    pointer-events: none;
}

.floating-element:nth-child(1) { top: 10%; left: 10%; animation-delay: 0s; }
.floating-element:nth-child(2) { top: 20%; right: 15%; animation-delay: 2s; }
.floating-element:nth-child(3) { bottom: 30%; left: 20%; animation-delay: 4s; }
.floating-element:nth-child(4) { bottom: 20%; right: 10%; animation-delay: 6s; }

@keyframes float-element {
    0% { transform: translateY(0px) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

@media (max-width: 768px) {
    .main-content {
        padding: 10px 8px 20px 8px;
        margin: 10px;
        max-width: 400px;
    }
    .container { justify-content: flex-start; }

    .header-section { flex-direction: row; gap: 8px; }

    /* 모바일 버튼 크기만 조정 (위치: 내부 플로우) */
    .main-content .qr-back-btn { width: 42px !important; height: 42px !important; font-size: 20px !important; }
    .main-content .qr-lang-btn { width: 42px !important; height: 42px !important; font-size: 0.8rem !important; font-weight: bold !important; border-radius: 50% !important; }
    .main-content .qr-pwa-btn { width: 42px !important; height: 42px !important; font-size: 20px !important; }
    .header-section .qr-pwa-btn { margin-left: -5px; }

    .lang-dropdown { top: 52px !important; min-width: 180px !important; max-height: 250px !important; }
    #qr-toolbar { margin-top: 16px; margin-bottom: 20px; }
    .main-content { margin-top: 20px; }
}

@media (max-width: 480px) {
    .main-content { max-width: 360px; }

    /* 작은 모바일: 버튼 크기만 축소 */
    .main-content .qr-back-btn { width: 40px !important; height: 40px !important; font-size: 18px !important; }
    .main-content .qr-lang-btn { width: 40px !important; height: 40px !important; font-size: 0.8rem !important; font-weight: bold !important; border-radius: 50% !important; }
    .main-content .qr-pwa-btn { width: 40px !important; height: 40px !important; font-size: 18px !important; }
    .header-section .qr-pwa-btn { margin-left: -4px; }

    .lang-dropdown { top: 52px !important; min-width: 160px !important; max-height: 200px !important; }
    #qr-toolbar { margin-top: 18px; margin-bottom: 22px; }
    .main-content { margin-top: 22px; }
}

/* 안드로이드 전용 스타일 */
.android-device .qr-back-btn, .android-device .qr-lang-btn { box-sizing: border-box !important; }

@media (max-width: 768px) {
    /* 안드로이드 태블릿 전용 버튼 조정 */
    .android-device .qr-back-btn { left: calc(50vw - 200px) !important; }
    .android-device .qr-lang-btn { right: calc(50vw - 200px) !important; }
}

@media (max-width: 480px) {
    /* 안드로이드 작은 모바일 전용 버튼 조정 */
    .android-device .qr-back-btn { left: calc(50vw - 160px) !important; }
    .android-device .qr-lang-btn { right: calc(50vw - 160px) !important; }
}

/* 클릭 가능한 모든 요소 강제 설정 */
input, select, button, label, .qr-input, .qr-button, .qr-result-section, .qr-download-section { pointer-events: auto !important; }

/* 클릭 방지 요소들 */
.floating-elements, .floating-element, .elegant-spacer, .elegant-display, .elegant-display * { pointer-events: none !important; }

#center-area {
    min-height: 170px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

@media (max-width: 768px) {
    #center-area { min-height: 130px; height: 130px; justify-content: center; }
}

@media (max-width: 480px) {
    #center-area { min-height: 90px; height: 90px; justify-content: center; }
}

/* 추가: 상단 툴바 및 프레임별 위치 지정 */
#qr-toolbar {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0 24px;
    box-sizing: border-box;
    margin-top: 12px;
    margin-bottom: 16px;
}

.qr-frame { position: relative; width: 100%; }

/* 카드 내부: 버튼은 플로우에 따라 헤더 좌우에 위치 */
.main-content .qr-back-btn { position: static; color: #667eea; }
.main-content .qr-pwa-btn { position: static; margin-left: 0; }
.header-section .qr-pwa-btn { margin-left: -6px; }
.main-content .lang-selector { position: relative; }
/* 드롭다운은 언어 버튼 기준으로 펼쳐짐 */
.main-content .lang-dropdown { right: 0; }
