:root {
    --primary: #55aa55;
    --primary-light: #6bc96b;
    --secondary: #8b5a2b;
    --accent: #55ffff;
    --dark: #111111;
    --light: #e0e0e0;
    --white: #FFFFFF;
    --success: #55aa55;
    --warning: #ffaa00;

    --shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
    --shadow-hover: 2px 2px 0px rgba(0, 0, 0, 0.5);
    --radius: 0px;

    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Press Start 2P', monospace;
}

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

body {
    font-family: var(--font-ar);
    background-color: #87CEEB;
    color: var(--dark);
    line-height: 1.6;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 30px 30px;
    min-height: 100vh;
}

/* Typography */
.en-text {
    font-family: var(--font-en);
    direction: ltr;
    display: inline-block;
    font-size: 0.8em;
}

/* Header */
.app-header {
    background-color: #8b5a2b;
    /* Dirt background */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid #333;
    box-shadow: 0 4px 0px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: #55ff55;
    /* Bright green */
    text-shadow: 2px 2px 0px #222;
}

.logo span {
    color: #fff;
    font-weight: 700;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.home-btn,
.back-btn {
    background-color: #c6c6c6;
    /* Stone button */
    color: #111;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 900;
    border: 2px solid #111;
    box-shadow:
        inset -3px -3px 0px 0px #555555,
        inset 3px 3px 0px 0px #ffffff;
    transition: all 0.1s;
    text-shadow: 1px 1px 0px #fff;
}

.home-btn:hover,
.back-btn:hover {
    background-color: #8faadd;
}

/* Main Container */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 5%;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard */
.main-title {
    text-align: center;
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    color: #ffff55;
    /* Yellow */
    text-shadow: 3px 3px 0px #333;
    font-weight: 900;
}

.subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 1px 1px 0px #333;
    margin-bottom: 3rem;
    font-weight: 700;
}

.book-selection-cards {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.book-card {
    width: 300px;
    padding: 3rem 2rem;
    text-align: center;
    background-color: #8b5a2b;
    /* Wooden planks */
    border: 3px solid #111;
    box-shadow:
        inset -5px -5px 0px 0px #5c3a21,
        inset 5px 5px 0px 0px #a67c52,
        4px 4px 0px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.1s ease;
}

.book-card:hover {
    transform: scale(1.02);
}

.card-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.book-card h2 {
    font-family: var(--font-en);
    color: #fff;
    text-shadow: 2px 2px 0px #333;
    margin-bottom: 0.5rem;
}

.book-card p {
    color: #ffff55;
    font-weight: 900;
    text-shadow: 1px 1px 0px #333;
}

/* Units View */
.view-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed #eee;
}

.units-container {
    display: block;
    width: 100%;
}

.units-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.unit-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.1s;
    border: 3px solid #000;
    border-right: 5px solid var(--primary);
}

.unit-card:hover {
    transform: translate(2px, 2px);
    box-shadow: var(--shadow-hover);
}

.unit-title {
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

/* Unit Grouping */
.unit-section-group {
    margin-bottom: 3rem;
    width: 100%;
    grid-column: 1 / -1;
}

.unit-main-title {
    font-size: 1.8rem;
    color: var(--primary);
    margin: 2rem 0 1.5rem 0;
    padding: 0.5rem 1.5rem;
    background: var(--white);
    border-radius: 15px;
    display: inline-block;
    box-shadow: var(--shadow);
    border-right: 8px solid var(--accent);
}

.lessons-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 2rem;
}

/* Lesson Content Layout */
.lesson-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.lesson-section {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.section-title {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 25px;
    background: var(--accent);
    border-radius: 4px;
}

/* Clickable Text for TTS */
.clickable-text {
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: inline-block;
}

.clickable-text:hover {
    color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
    border-radius: 5px;
    padding: 0 5px;
}

.clickable-text::after {
    content: '🔊';
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.5;
}

/* Characters Section */
.characters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media(min-width: 768px) {
    .characters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.char-card {
    display: flex;
    background: var(--light);
    border-radius: 15px;
    padding: 1.5rem;
    gap: 1rem;
    border: 1px solid #eee;
}

.char-bubble {
    background: var(--white);
    padding: 1rem;
    border-radius: 15px;
    border-top-left-radius: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    flex: 1;
}

.char-text {
    font-family: var(--font-en);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

/* Vocabulary Grid */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.vocab-item {
    background: var(--primary-light);
    color: var(--white);
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.vocab-item:hover,
.vocab-item.clickable-text:hover {
    transform: scale(1.05);
    background: var(--primary);
    color: var(--white);
}

.vocab-en {
    font-family: var(--font-en);
    font-weight: 800;
}

.vocab-ar {
    font-weight: 700;
}

/* Grammar Tables */
.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.grammar-table th,
.grammar-table td {
    padding: 1rem;
    border: 1px solid #eee;
    text-align: right;
}

.grammar-table th {
    background: var(--secondary);
    color: var(--white);
}

.grammar-example {
    background: var(--light);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-right: 4px solid var(--accent);
}

/* Quiz Section */
.quiz-question {
    margin-bottom: 2rem;
    background: var(--light);
    padding: 1.5rem;
    border-radius: 10px;
}

.q-text {
    font-family: var(--font-en);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    direction: ltr;
}

.q-options {
    display: flex;
    gap: 1rem;
    direction: ltr;
}

.q-option {
    background: var(--white);
    border: 2px solid var(--primary-light);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-family: var(--font-en);
    font-weight: 700;
    color: var(--primary);
}

.q-option:hover {
    background: var(--primary-light);
    color: var(--white);
}

.q-option.correct {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.q-option.wrong {
    background: #FF7675;
    border-color: #FF7675;
    color: var(--white);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(45, 52, 54, 0.95);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.2rem;
    z-index: 1000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

    /* Games Menu */
    .game-card {
        background: #8b5a2b;
        border: 4px solid #333;
        box-shadow: inset -4px -4px 0px 0px #5c3a21, inset 4px 4px 0px 0px #a67c52;
        padding: 2rem;
        text-align: center;
        border-radius: 10px;
        cursor: pointer;
        transition: transform 0.2s;
        color: white;
    }

    .game-card:hover {
        transform: translateY(-5px);
    }

    .game-card h3 {
        color: #ffff55;
        text-shadow: 2px 2px 0px #222;
        margin-bottom: 1rem;
        font-size: 1.5rem;
    }

    .game-card .icon {
        font-size: 4rem;
    }

    /* Games Canvas UI */
    .game-area {
        background: #87CEEB;
        /* Sky blue */
        border: 6px solid #55aa55;
        border-radius: 10px;
        min-height: 400px;
        position: relative;
        overflow: hidden;
        padding: 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    }

    .game-hud {
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin-bottom: 2rem;
    }

    .game-hearts {
        color: #ff5555;
        font-size: 1.5rem;
        text-shadow: 2px 2px 0px #550000;
    }

    .game-diamonds {
        color: #55ffff;
        font-size: 1.5rem;
        text-shadow: 2px 2px 0px #005555;
    }

    .game-question {
        font-family: var(--font-en);
        font-size: 1.5rem;
        color: white;
        background: rgba(0, 0, 0, 0.7);
        padding: 1rem 2rem;
        border-radius: 10px;
        border: 3px solid #fff;
        text-align: center;
        margin-bottom: 3rem;
        direction: ltr;
    }
    /* Mining Game */
    .mining-blocks {
        display: flex;
        gap: 2rem;
        justify-content: center;
        position: relative;
    }

    .mine-block {
        width: 120px;
        height: 120px;
        background: #8b5a2b;
        border: 4px solid #333;
        box-shadow: inset -4px -4px 0px 0px #5c3a21, inset 4px 4px 0px 0px #55aa55;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ddd;
        font-family: 'Courier New', Courier, monospace;
        font-size: 1.5rem;
        font-weight: 900;
        text-shadow: -1px -1px 0 #333, 1px 1px 0 rgba(255,255,255,0.2);
        cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M2 28L14 16M14 16C12 12 14 6 18 2C22 6 28 8 30 14C26 18 20 20 14 16Z" stroke="black" stroke-width="2" fill="%23aaa"/></svg>'), pointer;
        transition: transform 0.1s, filter 0.1s;
        position: relative;
    }

    .mine-block:hover {
        transform: scale(1.05);
        filter: brightness(1.2);
    }

    .mine-block.broken {
        visibility: hidden;
    }

    .mine-particle {
        position: absolute;
        width: 20px;
        height: 20px;
        background: #8b5a2b;
        border: 2px solid #5c3a21;
        pointer-events: none;
        animation: flyOut 0.5s forwards cubic-bezier(0.25, 1, 0.5, 1);
    }

    @keyframes flyOut {
        0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
        100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0) rotate(var(--rot)); }
    }

    .mine-block.wrong-shake {
        animation: shake 0.3s;
        border-color: #ff0000;
        box-shadow: 0 0 15px red;
    }

    @keyframes shake {
        0%, 100% { transform: translateX(0); }
        25% { transform: translateX(-10px); }
        50% { transform: translateX(10px); }
        75% { transform: translateX(-10px); }
    }

    /* Archery Game */
    .creepers-container {
        display: flex;
        gap: 2rem;
        justify-content: space-around;
        width: 100%;
        position: relative;
        padding-top: 4rem;
    }

    .creeper {
        width: 90px;
        height: 130px;
        background: linear-gradient(135deg, #55ff55, #22aa22);
        border: 4px solid #111;
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        cursor: crosshair;
        animation: bobbing 2s infinite alternate ease-in-out;
        box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    }
    
    .creeper:nth-child(2) { animation-delay: 0.5s; }
    .creeper:nth-child(3) { animation-delay: 1s; }

    @keyframes bobbing {
        from { transform: translateY(0); }
        to { transform: translateY(-15px); }
    }

    .creeper-face {
        font-size: 3rem;
        margin-top: 10px;
        color: #111;
    }

    .creeper-option {
        position: absolute;
        top: -50px;
        background: rgba(255, 255, 255, 0.9);
        color: #000;
        font-family: 'Courier New', Courier, monospace;
        font-weight: bold;
        padding: 0.3rem 0.8rem;
        border: 2px solid #555;
        border-radius: 5px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    .creeper-option::after {
        content: '';
        position: absolute;
        bottom: -6px;
        left: 50%;
        transform: translateX(-50%);
        border-width: 6px 6px 0;
        border-style: solid;
        border-color: #555 transparent transparent transparent;
    }

    .creeper.hit {
        animation: explosionFlash 0.4s forwards;
        pointer-events: none;
    }
    
    @keyframes explosionFlash {
        0% { transform: scale(1); filter: brightness(1) sepia(0); background: #fff; }
        50% { transform: scale(1.5); filter: brightness(2) sepia(1) hue-rotate(-50deg) saturate(5); background: #fff; }
        100% { transform: scale(0); opacity: 0; }
    }
    
    .arrow-projectile {
        position: absolute;
        font-size: 2.5rem;
        z-index: 100;
        pointer-events: none;
        transition: left 0.3s linear, top 0.3s linear;
        transform-origin: center;
    }

    .player-bow {
        font-size: 4rem;
        text-align: center;
        margin-top: 1rem;
        transition: transform 0.1s;
    }
    .player-bow.pulling {
        transform: scale(1.2) translateY(5px);
    }

    /* Parkour Game */
    .parkour-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        height: 300px;
        position: relative;
        padding-bottom: 40px;
        overflow: hidden;
    }

    .lava-pool {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 50px;
        background: linear-gradient(to bottom, #ff5500, #cc2200);
        border-top: 4px solid #fffb00;
        overflow: hidden;
        z-index: 5;
    }

    .lava-bubble {
        position: absolute;
        bottom: -20px;
        width: 25px;
        height: 25px;
        background: #ffaa00;
        border-radius: 50%;
        animation: lavaBoil 2s infinite ease-in;
    }
    
    @keyframes lavaBoil {
        0% { transform: translateY(0) scale(1); opacity: 1; }
        100% { transform: translateY(-50px) scale(0); opacity: 0; }
    }

    .steve-player {
        font-size: 4rem;
        position: absolute;
        z-index: 10;
        transform-origin: bottom center;
        animation: breathe 1.5s infinite alternate;
    }

    @keyframes breathe {
        from { transform: scaleY(1); }
        to { transform: scaleY(0.95); }
    }

    .steve-player.jumping {
        animation: jumpRotate 0.5s forwards cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    @keyframes jumpRotate {
        0% { transform: rotate(0deg); }
        50% { transform: rotate(15deg); }
        100% { transform: rotate(0deg); }
    }

    .steve-player.sinking {
        animation: sinkLava 1s forwards;
    }

    @keyframes sinkLava {
        0% { opacity: 1; transform: translateY(0); filter: brightness(1); }
        100% { opacity: 0; transform: translateY(50px); filter: brightness(0.5) sepia(1) hue-rotate(-50deg) saturate(5); }
    }

    .parkour-floating-block {
        position: absolute;
        width: 60px;
        height: 40px;
        background: #8b5a2b;
        border: 2px solid #333;
        box-shadow: inset 0px 4px 0px 0px #55aa55;
        cursor: pointer;
        z-index: 8;
        transition: transform 0.1s;
    }
    
    .parkour-floating-block:hover {
        transform: scale(1.1);
        filter: brightness(1.2);
    }
    
    .wooden-sign {
        position: absolute;
        top: -45px;
        left: 50%;
        transform: translateX(-50%);
        background: #d2b48c;
        border: 2px solid #8b4513;
        padding: 5px 10px;
        font-family: 'Courier New', Courier, monospace;
        font-weight: bold;
        color: #3e2723;
        box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
        pointer-events: none;
        white-space: nowrap;
    }
    .wooden-sign::after {
        content: '';
        position: absolute;
        bottom: -15px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 15px;
        background: #8b4513;
    }

    .bridge-block {
        width: 60px;
        height: 40px;
        background: #8b5a2b;
        border: 2px solid #333;
        box-shadow: inset 0px 4px 0px 0px #55aa55;
        position: absolute;
        bottom: 50px;
        z-index: 7;
    }

    /* Fishing Game */
    .fishing-container {
        position: relative;
        width: 100%;
        height: 300px;
        background: linear-gradient(to bottom, #87CEEB 40%, #1E90FF 40%);
        border: 4px solid #333;
        overflow: hidden;
    }
    .player-fishing {
        position: absolute;
        top: 20px;
        left: 20px;
        font-size: 3rem;
    }
    .water-pool {
        position: absolute;
        top: 40%;
        width: 100%;
        height: 60%;
    }
    .fish-option {
        position: absolute;
        bottom: 20px;
        cursor: pointer;
        animation: swim 12s linear infinite;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .fish-sprite {
        font-size: 2rem;
        animation: swim-sprite 12s linear infinite;
        animation-delay: inherit;
    }
    .fish-text {
        background: rgba(255, 255, 255, 0.8);
        padding: 2px 5px;
        border-radius: 5px;
        font-weight: bold;
    }
    @keyframes swim {
        0% { left: 110%; }
        49% { left: -10%; }
        50% { left: -10%; }
        100% { left: 110%; }
    }
    @keyframes swim-sprite {
        0% { transform: scaleX(-1); }
        49% { transform: scaleX(-1); }
        50% { transform: scaleX(1); }
        100% { transform: scaleX(1); }
    }
    .fish-option.caught {
        animation: catchFish 1s forwards;
    }
    @keyframes catchFish {
        to { top: -100px; transform: rotate(720deg) scale(0); opacity: 0; }
    }

    /* Chest Game */
    .chest-container {
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 200px;
        background: #5c8a47; /* Grass green */
        border: 4px solid #333;
    }
    .chest-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .chest-label {
        background: rgba(0,0,0,0.7);
        color: white;
        padding: 5px 10px;
        margin-bottom: 10px;
        border-radius: 5px;
        font-family: 'Courier New', Courier, monospace;
    }
    .chest-block {
        font-size: 4rem;
        cursor: pointer;
        transition: transform 0.2s;
    }
    .chest-block:hover {
        transform: scale(1.1);
    }
    .chest-block.opened {
        animation: popDiamond 1s forwards;
    }
    @keyframes popDiamond {
        50% { transform: scale(1.3) translateY(-20px); }
        100% { transform: scale(1); }
    }
    .chest-loot {
        font-size: 3rem;
        animation: floatUp 1s ease-out forwards;
    }
    @keyframes floatUp {
        to { transform: translateY(-50px); opacity: 0; }
    }

    /* Crafting Game */
    .crafting-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        background: #8b8b8b;
        padding: 20px;
        border: 4px solid #555;
    }
    .crafting-table {
        display: flex;
        align-items: center;
        gap: 20px;
        background: #c6c6c6;
        padding: 10px;
        border: 2px solid #555;
    }
    .grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px;
        background: #8b8b8b;
    }
    .grid-slot {
        width: 50px;
        height: 50px;
        background: #c6c6c6;
        border: 2px inset #fff;
    }
    .arrow {
        font-size: 2rem;
    }
    .result-slot {
        width: 60px;
        height: 60px;
        background: #c6c6c6;
        border: 2px inset #fff;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 2rem;
    }
    .inventory-options {
        display: flex;
        gap: 15px;
    }
    .crafting-item {
        background: rgba(255,255,255,0.8);
        padding: 10px;
        border: 2px solid #333;
        cursor: pointer;
        text-align: center;
        transition: transform 0.2s;
    }
    .crafting-item:hover {
        transform: scale(1.1);
    }
    .crafting-item.crafted {
        opacity: 0.5;
        transform: scale(0.9);
    }

    /* Portal Game */
    .portal-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .portal-structure {
        width: 150px;
        height: 200px;
        border: 10px solid #2a0044; /* Dark purple/black for obsidian */
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #000;
        border-radius: 5px;
        box-shadow: 0 0 10px #000;
    }
    .portal-frame-block {
        width: 30px;
        height: 30px;
        background: #2a0044;
        position: absolute;
        opacity: 0;
        transition: opacity 0.5s;
    }
    .portal-frame-block.placed {
        opacity: 1;
        box-shadow: inset 0 0 5px #000;
    }
    .portal-frame-block:nth-child(1) { top: -10px; left: -10px; }
    .portal-frame-block:nth-child(2) { top: -10px; right: -10px; }
    .portal-frame-block:nth-child(3) { bottom: -10px; left: -10px; }

    .portal-vortex {
        width: 100%;
        height: 100%;
        background: radial-gradient(circle, #a800ff 0%, #4c0082 100%);
        opacity: 0;
        transition: opacity 1s;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 4rem;
    }
    .portal-vortex.ignited {
        opacity: 0.8;
        animation: swirl 2s infinite linear;
    }
    @keyframes swirl {
        100% { transform: rotate(360deg) scale(1.1); }
    }
    .portal-inventory-options {
        display: flex;
        gap: 15px;
    }
    .portal-item {
        background: #2a0044;
        padding: 10px;
        border: 2px solid #5c0099;
        cursor: pointer;
        text-align: center;
        width: 80px;
        height: 80px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        transition: transform 0.2s;
    }
    .portal-item:hover {
        transform: scale(1.1);
    }
    .portal-item.placed {
        opacity: 0.5;
        transform: scale(0.9);
        pointer-events: none;
    }
    .obsidian-texture {
        width: 100%;
        height: 30px;
        background: #110022;
        border: 1px solid #333;
        margin-bottom: 5px;
        background-image: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.05) 5px, rgba(255,255,255,0.05) 10px);
    }
    .portal-frame-block.drop-zone-active {
        border: 2px dashed #a800ff;
        background: rgba(168, 0, 255, 0.2);
        opacity: 1;
        box-shadow: 0 0 15px #a800ff;
    }

    /* Farming Game */
    .farming-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        background: #87CEEB; /* Sky */
        padding: 20px;
        border-radius: 10px;
    }
    .farmland {
        width: 100px;
        height: 50px;
        background: #5c4033; /* Dark brown dirt */
        border-top: 5px solid #3e2723;
        display: flex;
        justify-content: center;
        align-items: flex-end;
        position: relative;
    }
    .crop-sprite {
        font-size: 2rem;
        transform: translateY(10px);
        transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    .crop-sprite.grown {
        transform: translateY(-10px);
    }
    .farming-options-container {
        display: flex;
        gap: 15px;
    }
    .farming-option {
        background: rgba(255,255,255,0.9);
        padding: 10px;
        border: 2px solid #333;
        cursor: pointer;
        text-align: center;
        border-radius: 5px;
    }
    .seed-sprite { font-size: 1.5rem; }

    /* Potion Game */
    .potion-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .brewing-stand {
        width: 100px;
        height: 120px;
        background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 120" xmlns="http://www.w3.org/2000/svg"><rect x="45" y="10" width="10" height="90" fill="%23d4af37"/><rect x="20" y="100" width="60" height="10" fill="%23555"/></svg>') no-repeat center bottom;
        display: flex;
        justify-content: center;
        align-items: flex-end;
        padding-bottom: 20px;
    }
    .flask {
        font-size: 3rem;
        transition: transform 0.3s;
    }
    .flask.bubbling {
        animation: bubble 0.5s infinite alternate;
    }
    @keyframes bubble {
        0% { transform: scale(1) translateY(0); }
        100% { transform: scale(1.1) translateY(-5px); }
    }
    .potion-options-container {
        display: flex;
        gap: 15px;
    }
    .potion-option {
        background: rgba(255,255,255,0.9);
        padding: 10px;
        border: 2px solid #333;
        cursor: pointer;
        text-align: center;
        border-radius: 50%;
        width: 60px;
        height: 60px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

/* =========================================
   Translator Bot UI (Minecraft Style)
   ========================================= */

#translator-bot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: var(--font-ar);
}

#translator-fab {
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: var(--white);
    border: 3px solid var(--dark);
    box-shadow: 
        inset -3px -3px 0px rgba(0,0,0,0.3),
        inset 3px 3px 0px rgba(255,255,255,0.3),
        4px 4px 0px rgba(0,0,0,0.5);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
    outline: none;
}

#translator-fab:hover {
    transform: scale(1.1);
    background-color: var(--primary-light);
}

#translator-chat-window {
    width: 320px;
    height: 400px;
    background-color: #c6c6c6;
    border: 4px solid var(--dark);
    box-shadow: 
        inset -4px -4px 0px #8b8b8b,
        inset 4px 4px 0px #ffffff,
        8px 8px 0px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#translator-chat-window.hidden {
    display: none;
}

.chat-header {
    background-color: var(--secondary);
    color: var(--white);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--dark);
    font-weight: bold;
    font-size: 1rem;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}

.close-chat-btn {
    background: #ff5555;
    border: 2px solid var(--dark);
    color: white;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: inset -2px -2px 0 rgba(0,0,0,0.3);
}

.close-chat-btn:hover {
    background: #ff7777;
}

.chat-body {
    flex: 1;
    padding: 15px;
    background-color: #d9d9d9;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    padding: 10px;
    border: 2px solid var(--dark);
    font-size: 0.9rem;
    max-width: 85%;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.bot-message {
    background-color: var(--white);
    align-self: flex-start;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
    border-radius: 0 10px 10px 10px;
}

.user-message {
    background-color: var(--accent);
    align-self: flex-end;
    box-shadow: -3px 3px 0px rgba(0,0,0,0.2);
    border-radius: 10px 0 10px 10px;
    text-align: left;
    direction: ltr;
}

.chat-input-area {
    display: flex;
    padding: 10px;
    background-color: #a6a6a6;
    border-top: 3px solid var(--dark);
}

#translator-input {
    flex: 1;
    padding: 8px;
    border: 2px solid var(--dark);
    font-family: inherit;
    font-size: 0.9rem;
    direction: ltr; /* English input */
    outline: none;
    box-shadow: inset 2px 2px 0 rgba(0,0,0,0.2);
}

.chat-input-area .send-btn {
    background-color: var(--primary);
    color: white;
    border: 2px solid var(--dark);
    width: 40px;
    margin-right: 5px;
    cursor: pointer;
    box-shadow: inset -2px -2px 0 rgba(0,0,0,0.3);
    font-size: 1.2rem;
}

.chat-input-area .send-btn:hover {
    background-color: var(--primary-light);
}

.message-audio-btn {
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 5px;
    vertical-align: middle;
}
.message-audio-btn:hover {
    color: var(--primary);
}