:root {
    --bg-color: #1e1e1e;
    --container-bg: linear-gradient(to bottom, #333, #222);
    --text-color: #ffffff;
    --control-bg: rgba(51, 51, 51, 0.85); /* Slightly more opaque */
    --button-bg: linear-gradient(to bottom, #666, #444);
    --button-hover: linear-gradient(to bottom, #777, #555);
    --button-active: linear-gradient(to bottom, #444, #222);
    --highlight-color: #007bff;
    --border-radius: 8px; /* Reduced border radius */
    --box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4); /* Slightly reduced shadow */
    --transition-duration: 0.2s; /* Faster transitions */
    --animation-duration: 0.5s; /* Faster animations */
    --panel-font-size: 10px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    background: url('https://i.imgur.com/bkKhA5t.png'); /* Replace with your URL */
    background-size: cover;
    background-position: center;
    animation: fadeIn var(--animation-duration) ease-in-out;
    margin: 0; /* Removes default body margins */
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full height */
    width: 100vw; /* Full width */
    max-width: none; /* Removes max-width limitation */
    padding: 5px; /* Reduced padding */
    background: var(--container-bg);
    border-radius: 0; /* Removes container border radius */
    box-shadow: none; /* Removes container shadow */
    animation: none; /* Removes container slide-in animation, can re-enable if needed */
}

.controls {
    display: flex;
    gap: 4px; /* Reduced gap */
    margin-bottom: 6px; /* Reduced margin */
    justify-content: center;
    flex-wrap: wrap;
    background-color: var(--control-bg);
    padding: 6px; /* Reduced padding */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    animation: pulse 3s infinite alternate;
}

@keyframes pulse {
    from {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }
    to {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    }
}

button {
    padding: 6px 12px; /* Reduced button padding */
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-duration) ease,
                transform 0.1s ease,
                box-shadow var(--transition-duration) ease;
    font-size: 12px; /* Reduced button font size */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

button:hover {
    background: var(--button-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

button:active {
    background: var(--button-active);
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#createAlliance {
    background: linear-gradient(to bottom, rgba(65, 124, 206, 0.5), rgba(65, 124, 206, 0.3));
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--container-bg);
    border-radius: var(--border-radius);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6); /* Reduced inset shadow */
}

canvas {
    image-rendering: pixelated;
}

#pixelCanvas {
    cursor: crosshair;
}

.info {
    margin-top: 6px; /* Reduced margin */
    text-align: center;
    font-size: 11px; /* Reduced font size */
    background-color: var(--control-bg);
    padding: 6px; /* Reduced padding */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.info p {
    margin: 3px 0;
}

.panelUser {
    position: fixed;
    z-index: 800;
    padding: 10px;
    left: 5px;
    bottom: 5px;
    background-color: rgba(0, 0, 0, 0.75);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    pointer-events: none;
    animation: none; /* Removed to reduce clutter and improve performance */
    font-size: var(--panel-font-size);
}

.panelUser p {
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(3px); /* Reduced blur */
}

.modal-content {
    position: relative;
    background: var(--container-bg);
    margin: 15% auto;
    padding: 15px; /* Reduced padding */
    border: 1px solid #555;
    width: 90%; /* Wider modal */
    max-width: 700px; /* Increased max width */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    animation: none; /* Removed, can re-enable if needed */
}

.close {
    color: #aaa;
    float: right;
    font-size: 24px; /* Reduced font size */
    font-weight: bold;
    cursor: pointer;
    transition: color var(--transition-duration) ease;
}

.close:hover,
.close:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

#cellInfo,
#pactUI,
#marketUI {
    font-size: smaller;
    width: 60%;
    height: 100%;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    overflow: auto;
}

#chatContainer {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 80%; /* Wider chat container */
    max-width: 350px;
    background-color: rgba(45, 45, 45, 0.95);
    border-radius: var(--border-radius);
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: slideInRight 0.3s ease-out; /* Faster animation */
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#chatHeader {
    padding: 8px; /* Reduced padding */
    background-color: var(--control-bg);
    cursor: pointer;
    text-align: center;
    border-bottom: 1px solid #444;
    transition: background-color var(--transition-duration) ease;
    font-size: 10px; /* Reduced font size */
}

#chatHeader:hover {
    background-color: rgba(60, 60, 60, 0.9);
}

#chatMessages {
    padding: 8px; /* Reduced padding */
    max-height: 120px; /* Reduced height */
    overflow-y: auto;
    font-size: 10px; /* Reduced font size */
}

#chatInputArea {
    display: flex;
    padding: 6px; /* Reduced padding */
    border-top: 1px solid #444;
}

#chatInput {
    flex: 1;
    padding: 5px; /* Reduced padding */
    border: none;
    border-radius: 4px;
    background-color: #444;
    color: var(--text-color);
    font-size: 10px; /* Reduced font size */
}

#chatSend {
    padding: 5px 10px; /* Reduced padding */
    margin-left: 3px; /* Reduced margin */
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-duration) ease;
    font-size: 10px; /* Reduced font size */
}

#chatSend:hover {
    background: var(--button-hover);
}

#chatContainer.hidden {
    display: none;
}

@media (max-width: 576px) {

    #cellInfo,
    #pactUI,
    #marketUI {
        font-size: x-small;
        width: 100%;
    }

    .container {
        padding: 2px;
    }

    button {
        padding: 5px 8px;
        font-size: 10px;
    }

    .info {
        font-size: 10px;
        padding: 5px;
    }

    .modal-content {
        margin: 20% auto;
        padding: 8px;
    }

    #chatContainer {
        width: 90%;
        right: 0;
    }

    .panelUser {
        left: 2px;
        bottom: 2px;
        font-size: 5.5px;
    }
}

#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 2001;
    pointer-events: none;
}

.notification {
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    margin-bottom: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s forwards, slideOut 0.5s forwards 3s;
    position: relative;
    pointer-events: auto;
}

.notification button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}