﻿/* =========================================
   Vocabulary Express Train Game Styling
   ========================================= */

.train-game-wrapper {
    width: 100%;
    max-width: 1050px;
    margin: 10px auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

.train-card {
    background: #eef6ff;
    border: 3px solid #b3d8f8;
    border-radius: 20px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.train-hidden {
    display: none !important;
}

.category-selection {
    margin: 15px 0;
}

.category-dropdown {
    padding: 8px 16px;
    font-size: 16px;
    border-radius: 10px;
    border: 2px solid #0284c7;
    font-weight: 700;
}

/* Landscape Guard */
.landscape-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    color: #ffffff;
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    .landscape-overlay {
        display: flex;
    }
}

.warning-card {
    text-align: center;
    padding: 20px;
}

.rotate-icon {
    font-size: 50px;
    margin-bottom: 10px;
    animation: spin 2s infinite linear;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* HUD Header */
.train-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

.target-badge {
    background: #0284c7;
    color: #ffffff;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 15px;
}

.timer-display, .lives-display, .score-display {
    background: #ffffff;
    border: 2px solid #b3d8f8;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    color: #0f172a;
    font-size: 14px;
}

.lives-display {
    border-color: #ef4444;
    color: #dc2626;
}

.timer-display {
    border-color: #f59e0b;
    color: #b45309;
}

/* Dock Styling */
.crates-dock-wrapper {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 15px;
}

.dock-label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.crates-dock {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    min-height: 75px;
}

/* Pure Item Cards (NO Text, Images Only) */
.pure-item-card {
    position: relative;
    width: 65px;
    height: 65px;
    background: #ffffff;
    border: 2px solid #38bdf8;
    border-radius: 12px;
    cursor: grab;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    touch-action: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
    box-sizing: border-box;
    transition: transform 0.15s;
}

    .pure-item-card:hover {
        transform: scale(1.08);
    }

    .pure-item-card img {
        width: 52px;
        height: 52px;
        object-fit: contain;
        pointer-events: none;
    }

    .pure-item-card:active {
        cursor: grabbing;
        opacity: 0.8;
    }

    .pure-item-card.dragging {
        opacity: 0.3;
    }

/* Arena Tracks */
.train-arena {
    position: relative;
    width: 100%;
    height: 250px;
    background: linear-gradient(180deg, #bae6fd 0%, #e0f2fe 70%, #86efac 70%, #4ade80 100%);
    border: 3px solid #94a3b8;
    border-radius: 16px;
    overflow: hidden;
}

.rail-track {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    height: 8px;
    background: #475569;
    border-top: 3px dashed #1e293b;
}

/* Signal Post Fixed at Track Bottom */
.signal-container {
    position: absolute;
    bottom: 20px; /* Anchored to bottom of rail track */
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
}

    .signal-container.pos-right {
        right: 50px;
        left: auto;
    }

    .signal-container.pos-left {
        left: 50px;
        right: auto;
    }

.signal-post {
    width: 8px;
    height: 55px;
    background: #334155;
    border-radius: 2px;
}

.signal-light {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid #0f172a;
    color: #ffffff;
    font-weight: 900;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    margin-bottom: -2px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s, transform 0.1s;
    z-index: 2;
}

    .signal-light:active {
        transform: scale(0.9);
    }

.signal-green {
    background: #22c55e;
    box-shadow: 0 0 12px #22c55e;
}

.signal-red {
    background: #ef4444;
    box-shadow: 0 0 12px #ef4444;
}

/* Train Container */
.train-container {
    position: absolute;
    bottom: 25px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

    .train-container.dir-forward {
        flex-direction: row; /* Engine on Right */
    }

    .train-container.dir-reverse {
        flex-direction: row-reverse; /* Engine on Left */
    }

        .train-container.dir-reverse .locomotive {
            transform: scaleX(-1); /* Flip locomotive direction */
        }

/* Open Container Flatbed Cars with Wooden Slats Fence */
.flatbed-car {
    position: relative;
    width: 100px;
    height: 75px;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

/* Name Tag Label Above Cart */
.cart-label-tag {
    position: absolute;
    top: -18px;
    background: #fef08a;
    color: #854d0e;
    border: 2px solid #ca8a04;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 11px;
    text-transform: capitalize;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    white-space: nowrap;
    z-index: 10;
}

/* Back Fence Slat */
.fence-back {
    position: absolute;
    bottom: 15px;
    width: 96px;
    height: 45px;
    background: repeating-linear-gradient( 90deg, #a16207 0px, #a16207 10px, #78350f 10px, #78350f 14px );
    border-top: 3px solid #78350f;
    opacity: 0.7;
    z-index: 1;
}

.crate-slot {
    width: 90px;
    height: 55px;
    border: 2px dashed rgba(250, 204, 21, 0.8);
    border-radius: 6px;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    z-index: 3;
    transition: background 0.2s, border-color 0.2s;
}

    .crate-slot .pure-item-card {
        width: 52px;
        height: 52px;
        margin: 0;
        border-color: #0284c7;
    }

    .crate-slot.drag-over {
        background: rgba(250, 204, 21, 0.4);
        border-color: #ffffff;
    }

/* Front Fence Slat */
.fence-front {
    position: absolute;
    bottom: 12px;
    width: 98px;
    height: 25px;
    background: repeating-linear-gradient( 90deg, #ca8a04 0px, #ca8a04 12px, #a16207 12px, #a16207 16px );
    border-top: 3px solid #78350f;
    border-bottom: 4px solid #451a03;
    z-index: 4;
    pointer-events: none;
}

/* Dropped Wrong Item Animation to Ground */
.falling-ground {
    animation: dropToGround 0.8s forwards ease-in;
}

@keyframes dropToGround {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    70% {
        transform: translateY(110px) rotate(45deg);
        opacity: 0.9;
    }

    100% {
        transform: translateY(130px) rotate(90deg);
        opacity: 0;
    }
}

/* Locomotive */
.locomotive {
    position: relative;
    width: 110px;
    height: 75px;
    background: #0f172a;
    border-radius: 10px 25px 0 0;
    animation: engineBump 0.4s infinite alternate ease-in-out;
}

@keyframes engineBump {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-2px);
    }
}

.smoke-stack {
    position: absolute;
    top: -18px;
    right: 15px;
    width: 16px;
    height: 20px;
    background: #334155;
    border-radius: 3px;
}

.smoke-puff {
    position: absolute;
    background: rgba(241, 245, 249, 0.8);
    border-radius: 50%;
    opacity: 0;
}

.train-moving .smoke-puff.p1 {
    width: 12px;
    height: 12px;
    top: -10px;
    left: 2px;
    animation: puff 1.2s infinite;
}

.train-moving .smoke-puff.p2 {
    width: 18px;
    height: 18px;
    top: -20px;
    left: -5px;
    animation: puff 1.2s infinite 0.4s;
}

@keyframes puff {
    0% {
        opacity: 0.8;
        transform: translateY(0) scale(0.8);
    }

    100% {
        opacity: 0;
        transform: translateY(-30px) scale(2);
    }
}

.engine-body {
    position: absolute;
    bottom: 15px;
    left: 10px;
    width: 85px;
    height: 45px;
    background: #0284c7;
    border-radius: 6px;
}

.cabin-window {
    position: absolute;
    top: 6px;
    left: 10px;
    width: 22px;
    height: 20px;
    background: #fef08a;
    border-radius: 4px;
}

.cowcatcher {
    position: absolute;
    bottom: 0;
    right: -12px;
    width: 0;
    height: 0;
    border-bottom: 20px solid #475569;
    border-left: 15px solid transparent;
}

/* Wheels */
.wheel {
    position: absolute;
    bottom: -6px;
    width: 20px;
    height: 20px;
    background: #334155;
    border: 3px solid #94a3b8;
    border-radius: 50%;
    z-index: 5;
}

.train-moving .wheel {
    animation: spinWheel 0.6s infinite linear;
}

@keyframes spinWheel {
    100% {
        transform: rotate(360deg);
    }
}

.wheel.w1 {
    left: 15px;
}

.wheel.w2 {
    left: 55px;
}

.wheel.w-car1 {
    left: 12px;
}

.wheel.w-car2 {
    right: 12px;
}

/* Buttons & Overlays */
.btn-primary {
    background: #0284c7;
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
}

.btn-secondary {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
}

.btn-speech {
    background: #10b981;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 15px;
    font-weight: 700;
    cursor: pointer;
}

.game-over-title {
    color: #ef4444;
    font-size: 26px;
}

.final-score-box {
    font-size: 22px;
    font-weight: 800;
    color: #0284c7;
    margin: 15px 0;
}


/* =========================================
   Mobile Landscape Optimization
   ========================================= */

@media screen and (max-width: 900px) and (orientation: landscape) {

    .train-game-wrapper {
        margin: 5px auto;
        max-width: 100%;
    }

    .train-card {
        padding: 10px;
        border-width: 2px;
        border-radius: 14px;
    }

    /* Category */
    .category-selection {
        margin: 8px 0;
    }

    .category-dropdown {
        padding: 5px 10px;
        font-size: 13px;
        border-width: 1px;
    }

    /* HUD */
    .train-hud {
        margin-bottom: 7px;
        gap: 5px;
    }

    .target-badge {
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 15px;
    }

    .timer-display,
    .lives-display,
    .score-display {
        padding: 4px 8px;
        font-size: 11px;
        border-width: 1px;
        border-radius: 15px;
    }

    /* Dock */
    .crates-dock-wrapper {
        padding: 6px;
        margin-bottom: 8px;
        border-width: 1px;
        border-radius: 8px;
    }

    .dock-label {
        font-size: 9px;
        margin-bottom: 4px;
    }

    .crates-dock {
        gap: 5px;
        min-height: 50px;
    }

    /* Vocabulary item icons */
    .pure-item-card {
        width: 48px;
        height: 48px;
        padding: 3px;
        border-width: 1px;
        border-radius: 8px;
    }

        .pure-item-card img {
            width: 39px;
            height: 39px;
        }

    /* Arena */
    .train-arena {
        height: 180px;
        border-width: 2px;
        border-radius: 10px;
    }

    /* Rails */
    .rail-track {
        bottom: 15px;
        height: 6px;
    }

    /* Signals */
    .signal-container {
        bottom: 15px;
    }

        .signal-container.pos-right {
            right: 25px;
        }

        .signal-container.pos-left {
            left: 25px;
        }

    .signal-post {
        width: 6px;
        height: 42px;
    }

    .signal-light {
        width: 32px;
        height: 32px;
        border-width: 2px;
        font-size: 9px;
    }

    /* Train */
    .train-container {
        bottom: 20px;
        gap: 2px;
    }

    /* Flatbed cars */
    .flatbed-car {
        width: 72px;
        height: 58px;
    }

    .cart-label-tag {
        top: -14px;
        padding: 1px 5px;
        border-width: 1px;
        border-radius: 7px;
        font-size: 8px;
    }

    .fence-back {
        bottom: 11px;
        width: 69px;
        height: 34px;
    }

    .crate-slot {
        width: 65px;
        height: 42px;
        margin-bottom: 8px;
        border-width: 1px;
    }

        .crate-slot .pure-item-card {
            width: 40px;
            height: 40px;
        }

    .fence-front {
        bottom: 9px;
        width: 70px;
        height: 19px;
        border-top-width: 2px;
        border-bottom-width: 2px;
    }

    /* Locomotive */
    .locomotive {
        width: 78px;
        height: 55px;
        border-radius: 7px 17px 0 0;
    }

    .engine-body {
        bottom: 11px;
        left: 7px;
        width: 60px;
        height: 33px;
        border-radius: 4px;
    }

    .cabin-window {
        top: 4px;
        left: 7px;
        width: 16px;
        height: 15px;
        border-radius: 3px;
    }

    .smoke-stack {
        top: -13px;
        right: 11px;
        width: 12px;
        height: 15px;
    }

    .cowcatcher {
        right: -9px;
        border-bottom-width: 15px;
        border-left-width: 11px;
    }

    /* Wheels */
    .wheel {
        bottom: -5px;
        width: 15px;
        height: 15px;
        border-width: 2px;
    }

        .wheel.w1 {
            left: 11px;
        }

        .wheel.w2 {
            left: 40px;
        }

        .wheel.w-car1 {
            left: 9px;
        }

        .wheel.w-car2 {
            right: 9px;
        }

    /* Buttons */
    .btn-primary {
        padding: 8px 18px;
        font-size: 13px;
        border-radius: 15px;
    }

    .btn-secondary,
    .btn-speech {
        padding: 4px 10px;
        font-size: 11px;
        border-radius: 12px;
    }

    /* Game over */
    .game-over-title {
        font-size: 20px;
    }

    .final-score-box {
        font-size: 17px;
        margin: 8px 0;
    }
}