/* Skip to main content link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color, #4a90d9);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 14px;
    border-radius: 0 0 4px 0;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

:root {
    --primary-color: #8e44ad;
    --primary-dark: #6c2d8a;
    --primary-light: #b56edb;
    --secondary-color: #1a1a2e;
    --accent-color: #ff6b9d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --border-color: #2d2d3d;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;

    /* Animal Colors */
    --lion-color: #ff8c42;
    --eagle-color: #6b5b95;
    --wolf-color: #92a8d1;
    --dolphin-color: #00b4d8;
    --cat-color: #ffb703;
    --owl-color: #8b4513;
    --bear-color: #6b4423;
    --fox-color: #ff6b35;
    --rabbit-color: #ff99cc;
    --butterfly-color: #ee82ee;
    --dragon-color: #c70039;
    --unicorn-color: #ff1493;
}

/* Light Theme */
[data-theme="light"] {
    --secondary-color: #ffffff;
    --bg-dark: #f5f5fa;
    --bg-card: #ffffff;
    --border-color: #e0e0e0;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a70;
}

[data-theme="light"] body {
    background: var(--bg-dark);
    color: var(--text-primary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* 터치 최적화 */
button, a, input, [role="button"], [role="link"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

input[type="text"], textarea {
    -webkit-user-select: text;
    user-select: text;
}

html {
    font-size: 16px;
}

/* === App Loader === */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader-emoji {
    font-size: 48px;
    animation: loader-bounce 1s ease-in-out infinite;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 500;
}

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

@keyframes loader-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
}

/* === Theme Toggle === */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 56px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(142, 68, 173, 0.2);
    transform: scale(1.1);
}

[data-theme="light"] .theme-toggle {
    background: rgba(142, 68, 173, 0.1);
    border-color: rgba(142, 68, 173, 0.2);
}

[data-theme="light"] .theme-toggle:hover {
    background: rgba(142, 68, 173, 0.2);
}

/* === Language Selector === */
.language-selector {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
}

.lang-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(142, 68, 173, 0.2);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.lang-toggle:hover {
    background: rgba(142, 68, 173, 0.3);
    transform: scale(1.1);
}

.lang-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    min-width: 150px;
    overflow: hidden;
    z-index: 999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lang-menu.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.lang-option {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

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

.lang-option:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.lang-option.active {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
}

/* === Ads === */
.ad-banner {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    min-height: 90px;
    margin: 10px 0;
    padding: 5px 0;
}

.ad-top {
    border-bottom: 2px solid var(--border-color);
}

.ad-bottom {
    border-top: 2px solid var(--border-color);
    margin-top: auto;
}

/* === Screens === */
.screen {
    display: none;
    flex: 1;
    width: 100%;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Home Screen === */
.screen-home {
    justify-content: center;
    align-items: center;
    text-align: center;
    flex-direction: column;
    gap: 30px;
}

.home-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.home-emoji {
    font-size: 72px;
    animation: float 3s ease-in-out infinite;
}

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

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.app-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
}

.home-description {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    background: rgba(142, 68, 173, 0.1);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

/* === Quiz Screen === */
.screen-quiz {
    justify-content: flex-start;
    gap: 20px;
}

.quiz-header {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
}

.quiz-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 300px;
}

.question-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-btn {
    padding: 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.choice-btn:hover {
    border-color: var(--primary-color);
    background: rgba(142, 68, 173, 0.1);
    transform: translateX(4px);
}

.choice-btn.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.3);
}

.quiz-nav {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

/* === Result Screen === */
.screen-result {
    justify-content: flex-start;
    gap: 20px;
    padding-top: 30px;
}

.result-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-animal-icon {
    font-size: 80px;
    text-align: center;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.result-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.result-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.result-card {
    background: rgba(142, 68, 173, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    backdrop-filter: blur(20px);
}

.result-card.glassmorphic {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-text {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-primary);
}

.canvas-container {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

#resultCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-dark));
}

/* === Share Buttons === */
.share-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* === Buttons === */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(142, 68, 173, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(142, 68, 173, 0.1);
    border-color: var(--primary-color);
}

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

.btn-large {
    font-size: 16px;
    padding: 16px 32px;
    width: 100%;
    animation: cta-pulse 2s infinite;
}

@keyframes cta-pulse {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(142,68,173,0.3), 0 0 0 0 rgba(142,68,173,0.5); }
    50% { transform: scale(1.03); box-shadow: 0 6px 25px rgba(142,68,173,0.5), 0 0 0 12px rgba(142,68,173,0); }
    100% { transform: scale(1); box-shadow: 0 4px 15px rgba(142,68,173,0.3), 0 0 0 0 rgba(142,68,173,0); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-large {
        animation: none !important;
    }
}

.btn-share {
    background: var(--primary-color);
    color: #ffffff;
    font-size: 12px;
    padding: 10px 12px;
}

.btn-share:hover {
    background: var(--primary-light);
}

/* === Recommendation Section === */
.recommendation-section {
    padding: 30px 20px;
    background: var(--bg-card);
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

.rec-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.rec-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-primary);
    text-align: center;
    min-height: 120px;
    justify-content: center;
}

.rec-card:hover {
    border-color: var(--primary-color);
    background: rgba(142, 68, 173, 0.1);
    transform: translateY(-4px);
}

.rec-emoji {
    font-size: 32px;
}

.rec-name {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-secondary);
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Selection Color */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* === Accessibility === */
.hidden {
    display: none;
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* === Responsive === */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .app-container {
        max-width: 100%;
    }

    .screen {
        padding: 16px;
    }

    .app-title {
        font-size: 24px;
    }

    .share-buttons {
        grid-template-columns: 1fr;
    }

    .rec-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

@media (max-width: 360px) {
    .app-title {
        font-size: 20px;
    }

    .home-emoji {
        font-size: 64px;
    }

    .result-animal-icon {
        font-size: 64px;
    }

    .home-description {
        font-size: 12px;
        padding: 16px;
    }
}

/* === Print Styles === */
@media print {
    .language-selector,
    .ad-banner,
    .quiz-nav,
    .share-buttons,
    #startBtn,
    #retakeBtn {
        display: none;
    }

    .screen-result {
        background: white;
        color: black;
    }

    .result-card {
        background: #f5f5f5;
        border: 1px solid #ccc;
        color: black;
    }

    .result-text {
        color: black;
    }
}
