:root {
    --bg-color: #F5F5F7;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --accent-blue: #0071E3;
    --accent-blue-hover: #0077ED;
    --danger: #FF3B30;
    --success: #34C759;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius-lg: 20px;
    --radius-md: 12px;
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-color);
    background-image: radial-gradient(#e5e5e5 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 140px;
    /* Increased space for fixed navbar */
    padding-bottom: 60px;
}

#app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.glass-nav {
    position: fixed;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    height: 60px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 100px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    transition: all 0.3s ease;
}

.glass-nav.hidden {
    transform: translate(-50%, -100px);
    opacity: 0;
}

.nav-left,
.nav-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.nav-right {
    justify-content: flex-end;
    gap: 8px;
}

.nav-center {
    flex: 2;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-emoji {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.nav-xp-label {
    display: none;
}

.nav-xp-value {
    font-size: 14px;
    font-weight: 600;
    background: var(--text-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    display: inline-block;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 48px;
    margin-bottom: 16px;
    text-align: center;
}

p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Components */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    transition: transform 0.2s ease;
}

.btn {
    display: inline-block;
    background-color: var(--accent-blue);
    color: white;
    padding: 12px 24px;
    border-radius: 980px;
    /* Pill shape */
    font-size: 17px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: var(--accent-blue-hover);
    transform: scale(1.02);
}

.btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid #d2d2d7;
    font-size: 17px;
    font-family: var(--font-stack);
    background: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s ease;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Login View */
.login-container {
    max-width: 480px;
    margin: 0 auto;
    text-align: center;
}

.emoji-selection-container {
    position: relative;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #d2d2d7;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.5);
    overflow: hidden;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
    width: 100%;
    height: 300px;
    overflow-y: auto;
    padding: 12px;
}

.emoji-grid.hidden {
    display: none;
}

.emoji-option {
    font-size: 32px;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.emoji-option:hover {
    transform: scale(1.2);
    background: rgba(0, 0, 0, 0.05);
}

.emoji-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.emoji-preview.active {
    display: flex;
}

.emoji-large {
    font-size: 120px;
    margin-bottom: 20px;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-small {
    font-size: 14px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.btn-small:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

@keyframes popIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Dashboard View */
.dashboard-header {
    display: none;
    /* Hidden in favor of navbar */
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
}

.xp-badge {
    background: var(--text-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 60px;
}

.level-card {
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 250px;
    /* Ensure consistent height */
}

.level-card.centered-content {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.level-card.locked {
    opacity: 0.8;
    cursor: not-allowed;
    background: rgba(245, 245, 247, 0.8);
}

.level-card:hover:not(.locked) {
    transform: translateY(-5px);
}

.level-number {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.level-title {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.level-status-container {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.level-icon-large {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.level-icon-large.locked {
    color: var(--text-secondary);
}

.level-icon-large.completed {
    color: var(--success);
}

.level-status-large {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-secondary);
}

.review-btn-large {
    background: transparent;
    border: 2px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 12px 24px;
    border-radius: 980px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.review-btn-large:hover {
    background: var(--accent-blue);
    color: white;
}

.ranking-section {
    max-width: 800px;
    margin: 80px auto;
    /* Increased vertical margin */
}

.ranking-list {
    list-style: none;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-position {
    font-weight: 700;
    width: 30px;
    color: var(--text-secondary);
}

/* Level View */
.level-container {
    max-width: 800px;
    margin: 0 auto;
}

.back-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 0;
    margin-bottom: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover {
    background: transparent;
    color: var(--text-primary);
    transform: none;
}

.activity-content {
    margin-top: 30px;
}

.activity-step {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.activity-step:last-child {
    border-bottom: none;
}

.hidden {
    display: none !important;
}

/* Specific Activity Styles */
.classroom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.classroom-img {
    width: 100%;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s;
}

.classroom-img:hover {
    transform: scale(1.05);
}

.classroom-img.selected {
    outline: 4px solid var(--accent-blue);
}

.post-it-wall {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: #f0f0f0;
    padding: 20px;
    border-radius: var(--radius-md);
    min-height: 200px;
}

.post-it {
    background: #fff740;
    color: #333;
    padding: 16px;
    width: 150px;
    height: 150px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
    font-family: 'Marker Felt', sans-serif;
    transform: rotate(-2deg);
}

.post-it:nth-child(even) {
    transform: rotate(2deg);
    background: #ff7eb9;
}

/* Old Letter Style */
.old-letter {
    background-color: #f8f1e0;
    /* Aged paper color */
    background-image:
        radial-gradient(circle at 20% 30%, rgba(101, 67, 33, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(101, 67, 33, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.02) 0%, transparent 60%),
        linear-gradient(to bottom right, rgba(0, 0, 0, 0.05), transparent 30%);
    border: 1px solid #d4c4a0;
    box-shadow:
        1px 1px 3px rgba(0, 0, 0, 0.2),
        0 10px 20px rgba(0, 0, 0, 0.1);
    padding: 40px;
    margin: 30px auto;
    max-width: 600px;
    font-family: 'Courier New', Courier, serif;
    /* Typewriter/Handwritten feel */
    color: #4a3b2a;
    line-height: 1.8;
    font-size: 18px;
    position: relative;
    transform: rotate(-1deg);
    border-radius: 2px;
}

.old-letter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxmaWx0ZXIgaWQ9Im4iPjxmZVR1cmJ1bGVuY2UgdHlwZT0iZnJhY3RhbE5vaXNlIiBiYXNlRnJlcXVlbmN5PSIwLjUiIG51bW9jdGF2ZXM9IjMiIHN0aXRjaFRpbGVzPSJzdGl0Y2giLz48L2ZpbHRlcj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWx0ZXI9InVybCgjbikvb3BhY2l0eT0iMC4xIi8+PC9zdmc+');
    opacity: 0.3;
    pointer-events: none;
}

.old-letter p {
    color: #4a3b2a;
    margin-bottom: 20px;
}

.old-letter p:last-child {
    margin-bottom: 0;
    text-align: right;
    font-style: italic;
    font-weight: bold;
}

/* Traveler's Diary Styles */
.diary-section {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.diary-container {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: #5d4037;
    border-radius: 4px 12px 12px 4px;
    box-shadow:
        inset 4px 0 10px rgba(0, 0, 0, 0.5),
        5px 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #ffd700;
    font-family: serif;
    border: 2px solid #3e2723;
}

.diary-container:hover {
    transform: scale(1.05) rotate(-2deg);
}

.diary-container::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 0, 0, 0.2);
}

.diary-label {
    font-family: 'Courier New', Courier, serif;
    /* Typewriter/Handwritten feel */
    font-size: 32px;
    /* Much larger */
    padding: 10px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    color: white;
}

/* Diary Overlay & 3D Animation */
.diary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.diary-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.diary-scene {
    width: 120px;
    height: 160px;
    perspective: 2000px;
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.diary-scene.expanded {
    width: 35vw;
    /* Half of the open width (70vw) */
    height: 80vh;
    max-width: 500px;
    /* Half of max width */
    max-height: 800px;
}

/* Shift the scene to the right when opening to keep it centered */
.diary-scene.open {
    transform: translateX(17.5vw);
    /* Half of width */
}

@media (min-width: 1428px) {

    /* 1000px / 0.7 */
    .diary-scene.open {
        transform: translateX(250px);
    }
}

.book-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

/* Leaves */
.front-leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    z-index: 2;
}

.diary-scene.open .front-leaf {
    transform: rotateY(-180deg);
}

.back-leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Sides */
.front-side,
.back-side,
.page-right {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px 12px 12px 4px;
    box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.1);
}

/* Cover Design */
.front-side.cover-design {
    background: #5d4037;
    border: 2px solid #3e2723;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.front-side::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(0, 0, 0, 0.2);
}

/* Inner Pages */
/* Inner Pages */
.back-side.page-left {
    background: #f8f1e0;
    transform: rotateY(180deg);
    border: 1px solid #d4c4a0;
    padding: 20px;
    /* Normalized to 20px */
    overflow: hidden;
    /* Changed from auto to hidden to rely on inner scroll */
    border-radius: 12px 0 0 12px;
    /* Inverted radius */
    box-shadow: inset -10px 0 20px rgba(0, 0, 0, 0.1);
    /* Shadow near spine */
    box-sizing: border-box;
}

.page-right {
    background: #f8f1e0;
    border: 1px solid #d4c4a0;
    padding: 20px;
    /* Normalized to 20px */
    overflow: hidden;
    /* Changed from auto to hidden */
    box-shadow: inset 10px 0 20px rgba(0, 0, 0, 0.1);
    /* Shadow near spine */
    box-sizing: border-box;
}

/* Content Styles */
.book-cover-content {
    text-align: center;
    color: #ffd700;
    font-family: serif;
}

.open-book-btn {
    margin-top: 20px;
    padding: 10px 20px;
    background: #ffd700;
    color: #3e2723;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.open-book-btn:hover {
    transform: scale(1.1);
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.badge-item {
    text-align: center;
    padding: 10px;
    border: 1px dashed #d4c4a0;
    border-radius: 8px;
}

.badge-icon {
    font-size: 32px;
    display: block;
}

.badge-date {
    font-size: 11px;
    color: #666;
    font-style: italic;
    margin-top: 4px;
}

.close-diary-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    z-index: 2001;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.close-diary-btn:hover {
    transform: scale(1.1);
}

/* Interactive Globe Styles */
.globe-container {
    width: 300px;
    height: 300px;
    margin: 20px auto;
    position: relative;
    border-radius: 50%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.globe {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: url('https://upload.wikimedia.org/wikipedia/commons/thumb/2/23/Blue_Marble_2002.png/1024px-Blue_Marble_2002.png');
    background-color: #001f3f;
    /* Fallback color */
    background-size: cover;
    background-position: center;
    position: relative;
    transform: rotate(-5deg);
    transition: transform 0.5s ease;
}

.globe:hover {
    transform: rotate(0deg) scale(1.02);
}

.globe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2) 0%, rgba(0, 0, 0, 0.6) 90%);
    pointer-events: none;
    box-shadow: inset 10px 0 30px rgba(0, 0, 0, 0.5);
}

.continent-point {
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.continent-point:hover {
    background: #fff;
    transform: scale(1.3);
    box-shadow: 0 0 25px rgba(255, 255, 255, 1);
}

.continent-point::after {
    content: attr(data-label);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.continent-point:hover::after {
    opacity: 1;
}

/* Positions for static view */
.point-africa {
    top: 45%;
    left: 53%;
}

.point-europe {
    top: 25%;
    left: 50%;
}

.point-asia {
    top: 25%;
    left: 75%;
}

.point-america-n {
    top: 25%;
    left: 18%;
}

.point-america-s {
    top: 65%;
    left: 28%;
}

.point-oceania {
    top: 70%;
    left: 85%;
}

/* Globe Info Popup */
.globe-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.globe-popup-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.globe-popup-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    text-align: left;
}

.globe-popup-overlay.active .globe-popup-content {
    transform: scale(1);
}

.globe-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

.globe-popup-title {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
}

.globe-popup-close {
    background: #f0f0f0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
}

.globe-popup-close:hover {
    background: #e0e0e0;
}

.globe-info-item {
    margin-bottom: 15px;
}

.globe-info-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.globe-info-value {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Passport Styles */
.passport-container {
    background: #fdfbf7;
    border: 2px solid #d4c4a0;
    border-radius: 16px;
    padding: 30px;
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.05),
        0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-top: 20px;
    background-image:
        radial-gradient(#e6e6e6 1px, transparent 1px),
        radial-gradient(#e6e6e6 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

.passport-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

.passport-stamp {
    width: 60px;
    height: 60px;
    border: 3px double #d32f2f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d32f2f;
    font-weight: bold;
    font-size: 12px;
    transform: rotate(-15deg);
    text-transform: uppercase;
    text-align: center;
    opacity: 0.8;
}

.passport-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.passport-upload-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px dashed #ccc;
    text-align: center;
    transition: all 0.3s;
}

.passport-upload-section:hover {
    border-color: var(--accent-blue);
    background: #f8f9fa;
}

.photo-frame {
    width: 150px;
    height: 150px;
    background: #eee;
    margin: 15px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

.photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.photo-placeholder {
    font-size: 40px;
    color: #ccc;
}

.upload-label {
    display: inline-block;
    padding: 8px 16px;
    background: var(--accent-blue);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.upload-label:hover {
    background: var(--accent-blue-hover);
}

.passport-reflection {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
}

.reflection-textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', Courier, serif;
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
    background: #fffdf8;
}

.validation-message {
    font-size: 12px;
    margin-top: 5px;
    text-align: right;
}

.validation-message.error {
    color: #d32f2f;
}

.validation-message.success {
    color: var(--success);
}

/* Image Zoom Styles */
.photo-frame {
    cursor: pointer;
    position: relative;
}

.zoom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    /* Let clicks pass through to the frame */
}

.photo-frame:hover .zoom-overlay {
    opacity: 1;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 4000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s;
}

.lightbox-overlay.active .lightbox-img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
}

/* Lobby Tabs */
.lobby-tabs {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 5px;
    border-radius: 100px;
    width: fit-content;
    z-index: 999;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.lobby-tab {
    padding: 10px 24px;
    border-radius: 100px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
}

.lobby-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

.lobby-tab.active {
    background: white;
    color: var(--accent-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    margin-top: 80px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 20px;
}

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

/* Responsive Design */

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
    body {
        padding-top: 120px;
    }

    .glass-nav {
        width: 95%;
        max-width: none;
    }

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

    .diary-scene.expanded {
        width: 45vw;
        height: 70vh;
    }

    .diary-scene.open {
        transform: translateX(22.5vw);
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding-top: 100px;
        padding-bottom: 40px;
    }

    h1 {
        font-size: 32px;
    }

    .glass-nav {
        top: 20px;
        height: 50px;
        padding: 0 16px;
    }

    .nav-center {
        font-size: 16px;
    }

    .nav-emoji {
        font-size: 24px;
    }

    .card {
        padding: 24px;
    }

    .levels-grid {
        grid-template-columns: 1fr;
    }

    .level-card {
        min-height: 200px;
    }

    /* Diary Mobile */
    .diary-scene.expanded {
        width: 85vw;
        height: 60vh;
        max-width: none;
    }

    .diary-scene.open {
        transform: translateX(0);
        /* Center it on mobile, maybe stack pages if needed */
    }

    /* On mobile, maybe we don't do the full book opening animation or simplify it */
    .diary-scene.open .front-leaf {
        transform: rotateY(-180deg);
        /* Keep rotation but layout might need tweak */
    }

    /* Globe adjustments */
    #globeViz {
        height: 300px !important;
    }

    .globe-popup-content {
        width: 90%;
        max-height: 80vh;
        overflow-y: auto;
    }

    /* Old Letter */
    .old-letter {
        padding: 20px;
        font-size: 16px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .glass-nav {
        width: 92%;
    }

    .nav-xp-label {
        display: none;
    }

    .nav-center {
        display: none;
        /* Hide group name on very small screens to save space */
    }

    .nav-left,
    .nav-right {
        flex: 1;
        justify-content: center;
    }

    h1 {
        font-size: 28px;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    }
}

/* --- Enhanced Diary Styles --- */

.diary-controls {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    z-index: 10001;
    transition: left 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.diary-scene.open .diary-controls {
    left: 0;
}

.diary-nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diary-nav-btn:hover {
    background: white;
    color: #333;
    transform: scale(1.1);
}

.page-left,
.page-right {
    padding: 20px;
    box-sizing: border-box;
    /* Ensure padding doesn't affect width */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    overflow: hidden;
    /* Prevent spillover */
}

/* Badge Card Styles */
.badge-card {
    width: 100%;
    height: 100%;
    border: 2px solid #ccc;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    /* Ensure padding/border doesn't affect size */
}

.badge-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: #333;
    font-size: 14px;
    overflow-y: auto;
    /* Allow scrolling if content is too big */
    min-height: 0;
    /* Important for flex child scrolling */
}

.badge-card.locked {
    background: #f5f5f5;
    border-style: dashed;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
}

.badge-card.unlocked {
    border-width: 3px;
}

.badge-header {
    padding: 15px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-icon-large {
    font-size: 32px;
    background: rgba(255, 255, 255, 0.2);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-title {
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: #333;
    font-size: 14px;
}

.badge-meta {
    font-size: 12px;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.badge-desc {
    font-style: italic;
    line-height: 1.4;
}

.badge-skills {
    margin-top: auto;
    /* Push to bottom */
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.skill-tag {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-criteria {
    font-size: 11px;
    color: #999;
    text-align: center;
    margin-top: 10px;
}

/* Responsive adjustments for diary */
@media (max-width: 768px) {
    .diary-controls {
        bottom: -50px;
        gap: 20px;
    }

    .badge-title {
        font-size: 14px;
    }

    .badge-body {
        padding: 10px;
        font-size: 12px;
    }

    .badge-icon-large {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
}

/* --- Page Flip Animation Styles --- */

.flipping-leaf {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
    z-index: 100;
    /* Above everything */
    pointer-events: none;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.flipping-leaf .page-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: #f8f1e0;
    border: 1px solid #d4c4a0;
    /* Padding should match .page-left/.page-right */
    padding: 20px;
    box-sizing: border-box;
    /* Ensure padding doesn't affect width */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.flipping-leaf .page-front {
    /* Right Page Shape */
    border-radius: 4px 12px 12px 4px;
    box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 2;
}

.flipping-leaf .page-back {
    /* Left Page Shape */
    transform: rotateY(180deg);
    border-radius: 12px 4px 4px 12px;
    /* Inverted radius */
    box-shadow: inset -4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1;
}