/* 
 * Game Common Styles - "Simple & Solid" Theme (v3.2 - Layout Fixed)
 * Optimized for Cinsistency, Senior Accessibility, and Game-like Polish
 * STRICTLY NO GRADIENTS.
 */

:root {
    /* Color System - Solid & High Contrast */
    --primary-color: #2563eb;
    /* Royal Blue */
    --primary-dark: #1e3a8a;
    --primary-light: #eff6ff;

    --success-color: #16a34a;
    /* Green */
    --warning-color: #f59e0b;
    /* Amber */
    --danger-color: #dc2626;
    /* Red */

    --text-main: #111827;
    /* Near Black */
    --text-sub: #4b5563;
    /* Dark Gray */

    --bg-page: #f9fafb;
    /* Very light gray */
    --bg-card: #ffffff;
    /* Pure White */

    --border-color: #e5e7eb;

    /* Spacing & Sizing */
    --container-width: 1200px;
    --btn-height: 60px;

    --radius-lg: 24px;
    --radius-md: 12px;

    /* Shadows & Effects */
    --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-game: 3px solid #e2e8f0;
}

/* 공통 네비게이션 바 */
.learning-topnav {
    position: sticky; top: var(--header-height, 70px); z-index: 100;
    margin-top: var(--header-height, 70px);
    background: #fff; border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.learning-topnav-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    height: 56px; gap: 12px;
}
.learning-topnav-back {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
    color: #374151; text-decoration: none; background: #f3f4f6; transition: all 0.15s;
    white-space: nowrap;
}
.learning-topnav-back:hover { background: #e5e7eb; color: #111827; }
.learning-topnav-back i { font-size: 0.85rem; }
.learning-topnav-title {
    font-size: 1.05rem; font-weight: 700; color: #111827; margin: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; flex: 1;
}
.learning-topnav-right { display: flex; align-items: center; gap: 8px; }
.learning-topnav-hub {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; font-size: 0.9rem; font-weight: 600;
    color: #2563eb; text-decoration: none; background: #eff6ff; transition: all 0.15s;
    white-space: nowrap;
}
.learning-topnav-hub:hover { background: #dbeafe; }
@media (max-width: 600px) {
    .learning-topnav-inner { height: 48px; padding: 0 12px; }
    .learning-topnav-back span, .learning-topnav-hub span { display: none; }
    .learning-topnav-back, .learning-topnav-hub { padding: 8px 12px; }
    .learning-topnav-title { font-size: 0.95rem; }
}

/* Reset & Base */
body {
    background-color: var(--bg-page);
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
}

.learning-main {
    padding-top: 16px;
    padding-bottom: 2rem;
    padding-left: 1rem;
    padding-right: 1rem;
    min-height: calc(100vh - var(--header-height, 70px) - 56px);
    display: flex;
    justify-content: center;
    box-sizing: border-box;
}

/* Common Layout Containers */
.game-container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
}

/* Standard Card Wrapper */
.game-content-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    padding: 1.5rem 2rem;
    border: 2px solid #e2e8f0;
    position: relative;
    overflow: visible;
    transition: box-shadow 0.3s ease;
}
.game-content-wrapper:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

/* Standard Header Section */
.game-header {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Back Button (Standard Flow) */
.header-left-btn {
    align-self: flex-start;
    margin-bottom: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-sub);
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-left-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateX(-2px);
}

.game-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 0.3rem;
    letter-spacing: -0.02rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    line-height: 1.2;
    text-align: center;
}

.game-title i {
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 0.45rem;
    border-radius: 10px;
    font-size: 1.3rem;
    box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}

.game-subtitle {
    font-size: 0.95rem;
    color: var(--text-sub);
    margin: 0;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
}

/* Info Bar (Score, Time, Level) */
.info-bar {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 0.6rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.info-item {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 1px solid #f1f5f9;
    min-width: 90px;
}

.info-item i {
    color: var(--primary-color);
    font-size: 1.05rem;
}

/* Buttons */
.btn-group {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.game-btn {
    height: var(--btn-height);
    padding: 0 2rem;
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    transition: all 0.1s ease;
    min-width: 150px;
    border-bottom: 4px solid rgba(0, 0, 0, 0.1);
}

.game-btn:hover {
    transform: translateY(-2px);
    filter: brightness(105%);
}

.game-btn:active {
    transform: translateY(2px);
    border-bottom-width: 0px;
    margin-bottom: 4px;
    /* Maintain layout on press */
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-bottom: 4px solid #1d4ed8;
}

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 2px solid var(--border-color);
    border-bottom: 4px solid #d1d5db;
}

.btn-large-start {
    width: 100%;
    max-width: 340px;
    height: 58px;
    font-size: 1.3rem;
    background-color: var(--success-color);
    color: white;
    border-bottom: 5px solid #14532d;
    margin: 0.5rem auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px rgba(22,163,74,0.25);
    transition: all 0.15s ease;
}
.btn-large-start:hover {
    box-shadow: 0 6px 24px rgba(22,163,74,0.35);
    background-color: #15803d;
}
.btn-large-start:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
    box-shadow: 0 2px 8px rgba(22,163,74,0.2);
}

/* Canvas Container */
.canvas-container {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
    position: relative;
    background: #f1f5f9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

#gameCanvas {
    display: block;
    max-width: 100%;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.common-modal {
    background: white;
    width: 90%;
    max-width: 450px;
    border-radius: 28px;
    padding: 3rem 2.5rem;
    text-align: center;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--primary-light);
    animation: modalBounce 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalBounce {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
    font-size: 4.5rem;
    display: block;
    margin-bottom: 1rem;
    animation: modalIconPop 0.5s 0.15s both;
}
@keyframes modalIconPop {
    from { transform: scale(0); }
    50% { transform: scale(1.2); }
    to { transform: scale(1); }
}

.modal-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.modal-message {
    font-size: 1.2rem;
    color: var(--text-sub);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Guide Box */
.guide-box {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1rem 1.2rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
}

.guide-box h4 {
    color: var(--primary-dark);
    font-size: 1rem;
    margin-bottom: 0.3rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.guide-box p {
    color: var(--text-sub);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Bottom Actions */
.bottom-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
}

.btn-back-bottom {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 2rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-sub);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.btn-back-bottom:hover {
    background: #f3f4f6;
    color: var(--text-main);
    border-color: #cbd5e1;
}

/* Responsive */
@media (max-width: 1024px) {
    .header-left-btn {
        position: static;
        transform: none;
        margin-bottom: 1rem;
        width: 100%;
        justify-content: center;
    }

    .game-header {
        align-items: stretch;
    }

    .game-title {
        font-size: 2rem;
    }
}

/* 게임 입장 애니메이션 */
.game-content-wrapper {
    animation: gameSlideIn 0.5s ease both;
}
@keyframes gameSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Info Bar 숫자 강조 */
.info-item span { color: var(--primary-color); }

/* 난이도 선택기 */
.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.difficulty-btn {
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-sub);
}
.difficulty-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
.difficulty-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}

@media (max-width: 600px) {
    .learning-main {
        padding-top: 16px;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .game-content-wrapper {
        padding: 1.5rem;
        border-radius: 16px;
    }

    .game-title {
        font-size: 1.6rem;
    }
    .game-subtitle {
        font-size: 1rem;
    }

    .header-left-btn {
        width: 100%;
        justify-content: center;
    }

    .btn-large-start {
        height: 62px;
        font-size: 1.3rem;
        max-width: 100%;
    }

    .info-bar {
        gap: 0.5rem;
    }

    .info-item {
        padding: 0.5rem 1rem;
        font-size: 1rem;
        min-width: auto;
        flex: 1;
    }

    .guide-box {
        padding: 1.2rem;
    }
}