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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #8b7355 0%, #a0826d 100%);
    color: #2c2416;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%23ffffff" opacity="0.05"/><circle cx="50" cy="50" r="2" fill="%23000000" opacity="0.1"/></svg>');
    pointer-events: none;
    z-index: 0;
}

/* ===========================================
   MOBILE-FIRST: BASE STYLES FOR MOBILE
=========================================== */

/* Language menu container */
.lang-menu {
    position: relative;
}

/* Hamburger icon */
.hamburger {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
    padding: 10px;
    -webkit-tap-highlight-color: transparent;
}

.hamburger span {
    width: 22px;
    height: 2.5px;
    background-color: #f4e4c1;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Dropdown menu */
.lang-dropdown {
    position: absolute;
    right: 0;
    top: 45px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column-reverse;
    min-width: 140px;
    z-index: 100;
}

.lang-dropdown button {
    background: none;
    border: none;
    padding: 14px 16px;
    cursor: pointer;
    text-align: center;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    border-radius: 6px;
    margin: 2px;
}

.lang-dropdown button:active {
    background-color: #e0e0e0;
}

.lang-dropdown.active {
    display: flex;
}

/* Navigation - Mobile First */
.navbar {
    background: rgba(44, 36, 22, 0.98);
    backdrop-filter: blur(10px);
    padding: 14px 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    direction: ltr;
    gap: 12px;
}

.nav-brand {
    font-size: 22px;
    font-weight: bold;
    color: #f4e4c1;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    width: 100%;
    order: 3;
}

[dir="rtl"] .nav-links {
    direction: rtl;
}

[dir="ltr"] .nav-links {
    direction: ltr;
}

.nav-link {
    color: #f4e4c1;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-link:active {
    background: rgba(244, 228, 193, 0.15);
    transform: scale(0.95);
}

.nav-link.active {
    background: #b39a6a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 16px;
    position: relative;
    z-index: 1;
}

/* Pages */
.page {
    display: none;
    animation: fadeIn 0.4s;
}

.page.active {
    display: block;
}

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

/* Hero Section - Mobile First */
#home {
    min-height: 45vh;
    background-image: url("images/archioHome.avif");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
    margin-bottom: 0;
}

#home.active {
    display: flex;
}

#home::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
}

.hero {
    text-align: center;
    position: relative;
    z-index: 2;
    padding: 0 20px;
}

.hero-title {
    font-size: 26px;
    color: #fcdeb8;
    margin-bottom: 12px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.3;
}

.hero-subtitle {
    font-size: 16px;
    color: #fef5e7;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}

/* Next Section - Mobile First */
.next-section {
    position: relative;
    width: 100%;
    background: none;
    padding: 20px 0;
    z-index: 3;
    margin-top: -40px;
}

#home.active .next-section {
    visibility: visible;
    opacity: 1;
}

.feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 20px 0;
    padding: 0 16px;
}

.feature-card {
    background: rgba(255, 225, 185, 0.95);
    padding: 24px 18px;
    border: solid 2.5px #5d4e37;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.feature-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.feature-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 20px;
    color: #2c2416;
    margin-bottom: 10px;
}

.feature-card p {
    color: #5d4e37;
    line-height: 1.5;
    font-size: 15px;
}

/* Why Section */
.why-section {
    background: rgba(255, 225, 185, 0.95);
    padding: 24px 18px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin: 16px 16px 0 16px;
}

.why-section h2 {
    font-size: 24px;
    color: #2c2416;
    margin-bottom: 14px;
}

.why-section p {
    font-size: 15px;
    color: #5d4e37;
    line-height: 1.6;
}

/* Page Titles */
.page-title {
    font-size: 26px;
    color: #f4e4c1;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    padding: 0 16px;
}

.page-subtitle {
    font-size: 16px;
    color: #fef5e7;
    text-align: center;
    margin-bottom: 24px;
    padding: 0 16px;
}

/* Sites Grid */
.sites-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.site-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    -webkit-tap-highlight-color: transparent;
}

.site-card:active {
    transform: scale(0.98);
}

.site-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.site-info {
    padding: 16px;
}

.site-info h3 {
    font-size: 20px;
    color: #2c2416;
    margin-bottom: 8px;
}

.site-info p {
    color: #5d4e37;
    line-height: 1.5;
    font-size: 15px;
}

/* History Cards */
.history-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.history-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.history-card h2 {
    font-size: 20px;
    color: #2c2416;
    margin-bottom: 12px;
}

.history-card p {
    font-size: 15px;
    color: #5d4e37;
    line-height: 1.6;
    margin-bottom: 12px;
}

/* Games */
.games-list {
    margin-bottom: 30px;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

.game-card {
    background: rgba(255, 225, 185, 0.95);
    padding: 28px 20px;
    border: solid 2px #5d4e37;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.game-card:active {
    transform: scale(0.98);
}

.game-card h3 {
    font-size: 22px;
    margin-bottom: 10px;
    color: #2c2416;
}

.game-card p {
    font-size: 15px;
    color: #5d4e37;
    line-height: 1.5;
}

.btn-back {
    background: #8b7355;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    display: inline-block;
    width: auto;
}

.btn-back:active {
    background: #6d5a43;
    transform: scale(0.95);
}

/* Quiz */
.quiz-container {
    max-width: 100%;
    margin: 0 auto;
}

.quiz-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.quiz-card h2 {
    font-size: 19px;
    color: #2c2416;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.4;
}

.answers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.answer-btn {
    padding: 14px 16px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    min-height: 50px;
    display: flex;
    align-items: center;
}

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

.answer-btn.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
}

.answer-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
}

.feedback {
    font-size: 17px;
    font-weight: bold;
    text-align: center;
    margin: 16px 0;
    min-height: 25px;
}

.quiz-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.btn-primary {
    padding: 14px 24px;
    background: #8b7355;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
}

.btn-primary:active {
    background: #6d5a43;
    transform: scale(0.98);
}

.score {
    font-size: 18px;
    font-weight: bold;
    color: #2c2416;
    text-align: center;
}

/* Memory Game */
.memory-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    animation: fadeIn 0.4s ease-in-out;
}

.memory-container .btn-back {
    align-self: flex-start;
    margin-bottom: 12px;
}

.memory-container h2 {
    width: 100%;
    text-align: center;
    margin: 0 0 16px 0;
    color: #f4e4c1;
    font-size: 22px;
}

.memory-container .btn-primary {
    margin-top: 16px;
    width: auto;
    min-width: 200px;
}

.memory-game {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}

.card {
    aspect-ratio: 1;
    perspective: 800px;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
}

.card.flip .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    backface-visibility: hidden;
}

.card-front {
    background: linear-gradient(135deg, #8b5a2b, #d4af37);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.card-back {
    transform: rotateY(180deg);
    background-size: cover;
    background-position: center;
    border: 2px solid #d4af37;
}

.card.matched .card-inner {
    transform: rotateY(180deg);
    cursor: default;
    opacity: 1;
    pointer-events: none;
}

/* Victory Overlay */
.victory-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    z-index: 60;
    padding: 20px;
}

.victory-card {
    background: #fff;
    padding: 24px 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    max-width: 90%;
    width: 100%;
    max-width: 400px;
}

.victory-card h2 {
    margin-bottom: 16px;
    color: #2c2416;
    font-size: 22px;
}

.victory-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.victory-controls button {
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
    background: #8b7355;
    color: #fff;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.victory-controls button:active {
    background: #6d5a43;
}

#memoryScore {
    font-weight: bold;
    color: #d4af37;
    font-size: 16px;
    margin-top: 8px;
}

/* Site Quiz */
.site-quiz-container {
    max-width: 100%;
    margin: 0 auto;
}

.site-quiz-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.site-quiz-card img {
    max-width: 100%;
    border-radius: 10px;
    display: block;
    margin: 12px auto;
    height: auto;
    max-height: 200px;
    object-fit: cover;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    animation: fadeIn 0.3s;
    padding: 20px;
    overflow-y: auto;
}

.modal-content {
    background: white;
    margin: 40px auto;
    padding: 24px 20px;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    cursor: pointer;
    color: #2c2416;
    -webkit-tap-highlight-color: transparent;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:active {
    color: #8b7355;
}

.modal-content h2 {
    font-size: 22px;
    color: #2c2416;
    margin-bottom: 14px;
    padding-right: 32px;
}

.modal-content p {
    font-size: 15px;
    color: #5d4e37;
    line-height: 1.6;
}

/* Civilizations */
.civilizations-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
}

.civilization-card {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.civilization-card:active {
    transform: scale(0.98);
}

.civilization-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
}

.civilization-content {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
}

.civilization-content h2 {
    font-size: 20px;
    color: #8b7355;
    margin-bottom: 10px;
}

.civilization-content p {
    font-size: 15px;
    color: #2c2416;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* ========================================
   TABLET STYLES (min-width: 600px)
======================================== */

@media (min-width: 600px) {
    .navbar {
        padding: 16px 24px;
    }

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

    .nav-links {
        width: auto;
        order: initial;
        gap: 10px;
    }

    .nav-link {
        font-size: 16px;
        padding: 9px 16px;
    }

    #home {
        min-height: 50vh;
    }

    .hero-title {
        font-size: 32px;
    }

    .hero-subtitle {
        font-size: 18px;
    }

    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .feature-icon {
        font-size: 52px;
    }

    .feature-card h3 {
        font-size: 22px;
    }

    .why-section h2 {
        font-size: 28px;
    }

    .page-title {
        font-size: 32px;
    }

    .page-subtitle {
        font-size: 18px;
    }

    .sites-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .site-image {
        height: 200px;
    }

    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .memory-game {
        grid-template-columns: repeat(4, 1fr);
        max-width: 520px;
        gap: 14px;
    }

    .container {
        padding: 30px 24px;
    }

    .quiz-controls {
        flex-direction: row;
        justify-content: space-between;
    }

    .btn-primary {
        width: auto;
        min-width: 160px;
    }

    .civilization-image {
        height: 220px;
    }
}

/* ========================================
   DESKTOP STYLES (min-width: 900px)
======================================== */

@media (min-width: 900px) {
    .navbar {
        padding: 20px 40px;
        flex-wrap: nowrap;
    }

    .nav-brand {
        font-size: 26px;
    }

    .nav-links {
        gap: 12px;
        margin-right: 40px;
    }

    .nav-link {
        font-size: 17px;
        padding: 10px 18px;
    }

    .nav-link:hover {
        background: rgba(244, 228, 193, 0.1);
        transform: translateY(-2px);
    }

    .nav-link::after {
        content: "";
        position: absolute;
        bottom: 5px;
        left: 50%;
        width: 0;
        height: 2px;
        background: #f4e4c1;
        transition: 0.3s;
        transform: translateX(-50%);
    }

    .nav-link:hover::after {
        width: 60%;
    }

    #home {
        min-height: 60vh;
        margin-bottom: 80px;
        padding-top: 0;
        align-items: center;
    }

    .hero-title {
        font-size: 48px;
    }

    .hero-subtitle {
        font-size: 22px;
    }

    .next-section {
        position: absolute;
        top: 280px;
        left: 50%;
        transform: translateX(-50%);
        width: 85%;
        max-width: 1200px;
        margin-top: 0;
        pointer-events: none;
        visibility: hidden;
        opacity: 0;
    }

    #home.active .next-section {
        pointer-events: auto;
        visibility: visible;
        opacity: 1;
    }

    .feature-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 30px;
        margin: 60px 0;
        padding: 0;
    }

    .feature-card {
        padding: 36px 28px;
    }

    .feature-card:hover {
        transform: translateY(-10px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    }

    .feature-icon {
        font-size: 60px;
    }

    .feature-card h3 {
        font-size: 24px;
    }

    .why-section {
        padding: 40px 36px;
        margin: 16px 0 0 0;
    }

    .why-section h2 {
        font-size: 34px;
    }

    .why-section p {
        font-size: 17px;
    }

    .container {
        max-width: 1200px;
        padding: 40px 20px;
    }

    .page-title {
        font-size: 44px;
        padding: 0;
    }

    .page-subtitle {
        font-size: 20px;
        padding: 0;
    }

    .sites-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }

    .site-card:hover {
        transform: translateY(-10px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    }

    .site-image {
        height: 220px;
    }

    .history-card {
        padding: 36px 32px;
    }

    .history-card h2 {
        font-size: 24px;
    }

    .history-card p {
        font-size: 16px;
    }

    .games-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 28px;
    }

    .game-card {
        padding: 36px 28px;
    }

    .game-card:hover {
        transform: translateY(-8px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    }

    .game-card h3 {
        font-size: 26px;
    }

    .quiz-container,
    .site-quiz-container {
        max-width: 800px;
    }

    .quiz-card,
    .site-quiz-card {
        padding: 36px 32px;
    }

    .quiz-card h2 {
        font-size: 23px;
    }

    .answer-btn {
        padding: 15px 20px;
        font-size: 16px;
    }

    .answer-btn:hover {
        background: #f0f0f0;
        transform: translateX(8px);
    }

    .site-quiz-card img {
        max-height: 280px;
    }

    .memory-container {
        padding: 24px;
    }

    .memory-container h2 {
        font-size: 30px;
    }

    .memory-game {
        grid-template-columns: repeat(4, 120px);
        gap: 16px;
        max-width: none;
    }

    .card-front {
        font-size: 28px;
    }

    .modal-content {
        padding: 36px 32px;
        max-width: 600px;
    }

    .modal-content h2 {
        font-size: 28px;
    }

    .modal-content p {
        font-size: 17px;
    }

    .civilization-card {
        flex-direction: row;
    }

    .civilization-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    }

    .civilization-image {
        width: 360px;
        height: 280px;
        order: 2;
    }

    .civilization-content {
        padding: 36px 32px;
        order: 1;
    }

    .civilization-content h2 {
        font-size: 28px;
    }

    .civilization-content p {
        font-size: 16px;
    }
}

/* ========================================
   LARGE DESKTOP (min-width: 1200px)
======================================== */

@media (min-width: 1200px) {
    .nav-brand {
        font-size: 28px;
    }

    .nav-links {
        gap: 15px;
        margin-right: 60px;
    }

    .nav-link {
        font-size: 18px;
        padding: 10px 20px;
    }

    .hero-title {
        font-size: 56px;
    }

    .hero-subtitle {
        font-size: 24px;
    }

    .feature-icon {
        font-size: 64px;
    }

    .why-section h2 {
        font-size: 36px;
    }

    .why-section p {
        font-size: 18px;
    }

    .page-title {
        font-size: 48px;
    }

    .history-card h2 {
        font-size: 26px;
    }

    .game-card h3 {
        font-size: 28px;
    }

    .quiz-card h2 {
        font-size: 24px;
    }

    .memory-container h2 {
        font-size: 32px;
    }

    .modal-content h2 {
        font-size: 32px;
    }

    .modal-content p {
        font-size: 18px;
    }

    .civilization-content h2 {
        font-size: 32px;
    }
}

/* Prevent text selection on tap targets */
.nav-link,
.feature-card,
.site-card,
.game-card,
.answer-btn,
.btn-primary,
.btn-back,
.civilization-card {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Fix for iOS Safari bottom bar */
@supports (-webkit-touch-callout: none) {
    #home {
        min-height: -webkit-fill-available;
    }
}
