* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #85c256;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* dynamic viewport height for mobile browsers */
    overflow: hidden;
    user-select: none;
    touch-action: manipulation;
}

.stats {
    display: flex;
    justify-content: space-around;
    font-size: 1.2rem;
    font-weight: bold;
    background: #2c3e50;
    color: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.stats span {
    color: #f1c40f;
    font-size: 1.4rem;
}

.game-info {
    font-size: 0.95rem;
    color: #7f8c8d;
    text-align: center;
    font-weight: 600;
    padding: 0 10px;
}

.game-container {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
    overflow: auto;
    /* Allow scrolling for the whole container if needed */
}

@media (max-width: 1024px) {
    .game-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        min-width: unset;
        width: 100%;
        max-height: 400px;
    }

    .city-area {
        width: 100%;
        height: auto;
        aspect-ratio: 1200 / 1052;
    }
}

@media (max-width: 600px) {
    body {
        overflow-y: auto;
    }

    .game-container {
        padding: 10px;
        gap: 10px;
    }

    .sidebar {
        padding: 10px;
    }

    .icon-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats {
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding: 10px;
        font-size: 1rem;
    }

    .stats span {
        font-size: 1.1rem;
    }

    .toast {
        width: 80%;
        font-size: 1rem;
        padding: 10px 20px;
    }

    .modal-content {
        padding: 20px;
    }

    .question-text {
        font-size: 1.2rem;
    }

    .option-btn {
        padding: 12px;
        font-size: 1rem;
    }

    /* Small screen adjustments for city elements */
    /* Removed fixed resource bar sizes - now using responsive cqw sizes */
}

/* Sidebar / Construction Pool */
.sidebar {
    flex: 1;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    border: 3px solid #ecf0f1;
}

.sidebar h2 {
    margin: 0;
    color: #2980b9;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 2px solid #bdc3c7;
    padding-bottom: 10px;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.icon-item {
    background: white;
    border-radius: 10px;
    text-align: center;
    padding: 12px 5px;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #dfe6e9;
    user-select: none;
    touch-action: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
}

.icon-item:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: #3498db;
    background: #f0f8ff;
    box-shadow: 0 8px 15px rgba(52, 152, 219, 0.2);
}

.icon-item:active,
.icon-item.selected {
    cursor: grabbing;
    border-color: #e67e22;
    background: #fff3cd;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(230, 126, 34, 0.4);
}

.plot.can-receive {
    background: rgba(241, 196, 15, 0.2);
    border: 2px dashed #f1c40f;
}

.icon-item .building-img {
    width: 85px;
    height: 85px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    margin-bottom: 5px;
}

.icon-item .label {
    font-size: 1rem;
    font-weight: bold;
    color: #34495e;
    pointer-events: none;
}

.cost-badge {
    font-size: 0.85rem;
    color: #e67e22;
    margin-top: 5px;
    font-weight: bold;
    background: #fff3cd;
    padding: 2px 10px;
    border-radius: 12px;
    border: 1px solid #ffeaa7;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* City Area - City Plan Layout */
.city-area {
    height: 100%;
    aspect-ratio: 1200 / 1052;
    background-color: #85c256;
    /* Arka plan boşluklarını yeşil yapmak için */
    background-image: url('./assets/background.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 15px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2), 0 5px 20px rgba(0, 0, 0, 0.15);
    border: 6px solid #6c9e42;
    position: relative;
    /* Extremely important for absolute positioning of plots */
    overflow: hidden;
    /* Allows elements inside to scale dynamically based on city width */
    container-type: size;
    container-name: city;
}

/* River passing through */
.river {
    display: none;
}

.river::after {
    display: none;
}

/* Text Label Targets */
.plot {
    position: absolute;
    /* width and height are dynamically managed in script.js */
    background: transparent;
    border-radius: 40px;
    /* makes it a soft rounded patch */
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -50%) skewX(-5deg);
    /* adds a slight perspective slant */
    transition: all 0.3s ease;
    z-index: 1;
}

.plot.drag-over {
    background: rgba(255, 255, 255, 0.3);
    border: 3px dashed #f1c40f;
    transform: translate(-50%, -50%) skewX(-5deg) scale(1.05);
    /* maintain skew during pop in */
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6);
}

.plot.occupied {
    background: transparent;
    border: none;
    cursor: default;
}

.placed-building-img {
    width: 130%;
    /* Let buildings stand slightly larger than their plots */
    height: 130%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.4));
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: skewX(5deg) translateY(-10%);
    /* Straighten building up & move it slightly up */
    pointer-events: none;
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }

    80% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #2ecc71;
    color: white;
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 1.3rem;
    font-weight: bold;
    display: none;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: dropDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes dropDown {
    0% {
        top: 0;
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }

    100% {
        top: 80px;
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

.toast.error {
    background: #e74c3c;
}

/* Resource progress bar styling */
.resource-bar-container {
    position: absolute;
    width: 140px;
    width: 11.6cqw;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #34495e;
    border: 0.25cqw solid #34495e;
    border-radius: 8px;
    border-radius: 0.6cqw;
    padding: 8px;
    padding: 0.5cqw;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    box-shadow: 0 0.4cqw 1.25cqw rgba(0, 0, 0, 0.3);
    z-index: 10;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translate(-50%, -50%);
    animation: breathing 3s infinite ease-in-out;
}

@keyframes breathing {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.03);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.resource-bar-container:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: #fff;
    border-color: #f1c40f;
    box-shadow: 0 0.66cqw 2cqw rgba(241, 196, 15, 0.4);
    animation: none;
    /* stop breathing on hover */
}

.resource-bar-container:active {
    transform: translate(-50%, -50%) scale(0.95);
    background: #f1f1f1;
    box-shadow: 0 0.16cqw 0.8cqw rgba(0, 0, 0, 0.2);
}

.resource-bar-label {
    font-size: 14px;
    font-size: 1.15cqw;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.3cqw;
    pointer-events: none;
}

.resource-bar-track {
    width: 100%;
    height: 12px;
    height: 1cqw;
    background: #bdc3c7;
    border-radius: 6px;
    border-radius: 0.5cqw;
    overflow: hidden;
    pointer-events: none;
}

.resource-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 1s linear, background-color 0.5s;
}

/* Glow effect around the Resource Bar containers */
.hotspot {
    position: absolute;
    width: 150px;
    width: 12cqw;
    /* Slightly larger than the container (11.6cqw) */
    height: 70px;
    height: 5.4cqw;
    /* Slightly larger than container height */
    background: transparent;
    border-radius: 12px;
    border-radius: 1cqw;
    transform: translate(-50%, -50%);
    z-index: 4;
    /* Behind the container */
    pointer-events: none;
    box-shadow: 0 0 1.25cqw 0.4cqw rgba(241, 196, 15, 0.6);
    animation: glowHotspot 2s infinite alternate ease-in-out;
}

@keyframes glowHotspot {
    0% {
        box-shadow: 0 0 0.8cqw 0.16cqw rgba(241, 196, 15, 0.4);
        opacity: 0.6;
    }

    100% {
        box-shadow: 0 0 2cqw 0.66cqw rgba(241, 196, 15, 0.8);
        opacity: 0.9;
    }
}

.hotspot.danger {
    box-shadow: 0 0 1.66cqw 0.66cqw rgba(231, 76, 60, 0.9);
    animation: dangerGlow 0.6s infinite alternate ease-in-out;
}

@keyframes dangerGlow {
    0% {
        box-shadow: 0 0 1.25cqw 0.4cqw rgba(231, 76, 60, 0.7);
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        box-shadow: 0 0 2.9cqw 1.25cqw rgba(231, 76, 60, 1);
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    width: 600px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    border: 8px solid #f1c40f;
    position: relative;
}

.modal-content h3 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 25px;
}

.question-text {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 30px;
    color: #2980b9;
    line-height: 1.4;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    padding: 15px 20px;
    font-size: 1.2rem;
    background: #f8f9fa;
    border: 2px solid #bdc3c7;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
    color: #34495e;
    text-align: left;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    background: #f1c40f;
    color: #2c3e50;
    border-color: #f39c12;
    transform: translateX(10px);
    box-shadow: -5px 5px 10px rgba(0, 0, 0, 0.1);
}

.option-btn.correct {
    background: #2ecc71 !important;
    color: white !important;
    border-color: #27ae60 !important;
}

.option-btn.wrong {
    background: #e74c3c !important;
    color: white !important;
    border-color: #c0392b !important;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #95a5a6;
    cursor: pointer;
    transition: 0.2s;
}

.close-modal-btn:hover {
    color: #e74c3c;
    transform: scale(1.1);
}