:root {
    --bg-color: #F5F7FA;
    --text-color: #2C3E50;
    --accent-color: #81C784;
    --font-family: 'Nunito', 'Segoe UI', 'Verdana', sans-serif;
    --grid-cell-size: 40px;
}

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

body {
    background-color: #2c3e50;
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
}

#game-container {
    width: 1280px;
    height: 700px;
    background: url('../assets/backgrounds/Fundo.png') no-repeat center center;
    background-size: cover;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.5);
    transition: opacity 0.3s;
}

.end-screen {
    background-color: rgba(255, 255, 255, 0.8);
}

.end-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    display: none;
}

.screen h1 {
    font-size: 3rem;
    color: var(--text-color);
    margin-bottom: 2rem;
}

.screen p {
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 2rem;
    text-align: center;
    max-width: 800px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.95);
}

.btn:hover {
    filter: brightness(1.1);
}

/* Gameplay Layout */
#game-ui {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: transparent;
}

#intro-screen {
    background-color: rgba(255, 255, 255, 0);
    animation: intro-backdrop 0.5s ease forwards;
    animation-delay: 0.6s;
}

#intro-screen h1,
#intro-screen p,
#intro-screen #level-selection {
    opacity: 0;
    transform: translateY(6px);
    animation: intro-content 0.5s ease forwards;
    animation-delay: 0.75s;
}

@keyframes intro-backdrop {
    from {
        background-color: rgba(255, 255, 255, 0);
    }

    to {
        background-color: rgba(255, 255, 255, 0.8);
    }
}

@keyframes intro-content {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

#header {
    height: auto;
    position: absolute;
    top: 20px;
    left: 20px;
    width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 5;
}

#time-display {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--text-color);
    margin-right: 20px;
}

#time-display.warning {
    color: #e74c3c;
    animation: pulse 1s infinite;
}

#controls {
    display: flex;
    gap: 20px;
}

#sidebar-container {
    position: absolute;
    top: 100px;
    left: 20px;
    width: 400px;
    height: 580px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 5;
}

#teams-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 10px;
    padding-right: 5px;
    /* Space for scrollbar */
}

/* Custom Scrollbar for sidebar */
#teams-list::-webkit-scrollbar {
    width: 8px;
}

#teams-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#teams-list::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

#teams-list::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

#main-area {
    /* Removed flex layout */
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    background: transparent;
}

#office-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    /* Let clicks pass through to desks */
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Desk Grids */
.desk {
    display: grid;
    /* grid-template-columns set via JS */
    gap: 2px;
    background-color: rgba(255, 255, 255, 0.0);
    padding: 34px 10px 10px;
    border-radius: 8px;
    position: absolute;
    width: 118px;
    height: 550px;
    pointer-events: auto;
    justify-content: center;
    align-content: center;
    justify-items: center;
    /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); */
}

/* Specific Desk Positions */
.desk[data-id="desk-1"] {
    left: 445px;
    top: 38px;
}

.desk[data-id="desk-2"] {
    left: 645px;
    top: 38px;
}

.desk[data-id="desk-3"] {
    left: 848px;
    top: 38px;
}

.desk[data-id="desk-4"] {
    left: 1050px;
    top: 38px;
}

.desk h3 {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    text-align: center;
    color: #34495e;
    font-size: 1rem;
    margin: 0;
    pointer-events: none;
}

.cell {
    width: var(--grid-cell-size);
    height: var(--grid-cell-size);
    background-color: #fff;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.cell.occupied {
    /* Color set inline */
}

.cell.blocked {
    background-color: #555;
    background-image: repeating-linear-gradient(45deg,
            #606dbc,
            #606dbc 5px,
            #465298 5px,
            #465298 10px);
    cursor: not-allowed;
    border: 1px solid #999;
}

.cell.drag-over {
    background-color: #e0f7fa;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.cell.invalid-drop {
    background-color: #ffebee;
}

.cell.preview-valid {
    background-color: rgba(46, 204, 113, 0.5) !important;
    box-shadow: inset 0 0 0 2px #27ae60;
}

.cell.preview-invalid {
    background-color: rgba(231, 76, 60, 0.5) !important;
    box-shadow: inset 0 0 0 2px #c0392b;
}

/* Off-screen container for generating drag images */
#drag-ghost-container {
    position: absolute;
    top: -9999px;
    left: -9999px;
}

.ghost-shape {
    display: grid;
    gap: 2px;
    background: transparent;
}

.ghost-cell {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.team-card {
    background-color: #fff;
    border: 2px solid #eee;
    padding: 10px;
    border-radius: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
}

.team-card:hover {
    border-color: var(--accent-color);
    transform: translateX(5px);
}

.team-card.dragging {
    opacity: 0.5;
}

.team-shape-preview {
    display: grid;
    gap: 1px;
}

.preview-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.team-info {
    flex: 1;
}

.flex-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background-color: #f1f3f5;
    color: #2c3e50;
    font-size: 0.85rem;
}

.flex-btn:hover {
    filter: brightness(0.98);
}

.team-name {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Flex Button */
#flex-btn {
    display: flex;
    align-items: center;
    gap: 10px;
}

#flex-btn svg {
    width: 24px;
    height: 24px;
}

#flex-btn.active {
    background-color: #2ecc71;
}

/* Toast */
#toast {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #e74c3c;
    color: white;
    padding: 10px 30px;
    border-radius: 50px;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 100;
}

#toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}