:root {
    --bg-color: #1e1e1e;
    --container-bg: linear-gradient(to bottom, #333, #222);
    --text-color: #ffffff;
    --control-bg: rgba(51, 51, 51, 0.85);
    --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: 12px; /* Increased border radius for touch */
    --box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5); /* Enhanced shadow */
    --transition-duration: 0.15s; /* Faster transitions */
    --animation-duration: 0.4s; /* Faster animations */
    --panel-font-size: 12px; /* Increased for better readability */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Disable highlight on tap */
}

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;
    -webkit-user-select: none; /* Disable text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

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

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    max-width: none;
    padding: 8px; /* Increased padding */
    background: var(--container-bg);
    border-radius: 0;
    box-shadow: none;
    animation: none;
}

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

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

button {
    padding: 10px 16px; /* Increased button padding */
    background: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 8px; /* Increased border radius */
    cursor: pointer;
    transition: background var(--transition-duration) ease,
                transform 0.1s ease,
                box-shadow var(--transition-duration) ease;
    font-size: 16px; /* Increased button font size */
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

button:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
}

button:active {
    background: var(--button-active);
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

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

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

canvas {
    image-rendering: pixelated;
}

#pixelCanvas {
    cursor: crosshair;
}

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

.info p {
    margin: 5px 0;
}

.panelUser {
    position: fixed;
    z-index: 800;
    padding: 12px; /* Increased padding */
    left: 8px; /* Increased margin */
    bottom: 8px; /* Increased margin */
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    pointer-events: none;
    animation: none;
    font-size: var(--panel-font-size);
}

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

.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(4px); /* Increased blur */
}

.modal-content {
    position: relative;
    background: var(--container-bg);
    margin: 20% auto; /* Increased margin */
    padding: 20px; /* Increased padding */
    border: 1px solid #555;
    width: 95%; /* Further Wider modal */
    max-width: 800px; /* Further Increased max width */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    animation: none;
}

.close {
    color: #aaa;
    float: right;
    font-size: 30px; /* Increased 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: medium; /* Increased font size */
    width: 70%; /* Increased width */
    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: 90%; /* Even Wider chat container */
    max-width: 300px; /* Increased max width */
    background-color: rgba(45, 45, 45, 0.95);
    border-radius: var(--border-radius);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    animation: slideInRight 0.3s ease-out;
}

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

#chatHeader {
    padding: 10px; /* Increased 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: 14px; /* Increased font size */
}

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

#chatMessages {
    padding: 10px; /* Increased padding */
    max-height: 150px; /* Increased height */
    overflow-y: auto;
    font-size: 14px; /* Increased font size */
}

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

#chatInput {
    flex: 1;
    padding: 8px; /* Increased padding */
    border: none;
    border-radius: 6px; /* Increased border radius */
    background-color: #444;
    color: var(--text-color);
    font-size: 14px; /* Increased font size */
}

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

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

#chatContainer.hidden {
    display: none;
}

@media (max-width: 576px) {
    #cellInfo,
    #pactUI,
    #marketUI {
        font-size: small;
        width: 95%; /* Ensure full width */
    }

    .container {
        padding: 4px; /* Increased padding */
    }

    button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .info {
        font-size: 12px;
        padding: 8px;
    }

    .modal-content {
        margin: 25% auto; /* Adjust margin for smaller screens */
        padding: 12px;
    }

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

    .panelUser {
        left: 4px;
        bottom: 4px;
        font-size: 8px;
        bottom: 150px;
    }
}

#notification-container {
    position: fixed;
    top: 25px; /* Slightly lowered position */
    right: 25px; /* Slightly lowered position */
    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: 12px 24px; /* Increased padding */
    margin-bottom: 12px; /* Increased margin */
    border-radius: 8px; /* Increased border radius */
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4); /* Increased shadow */
    animation: slideIn 0.4s forwards, slideOut 0.4s forwards 3s;
    position: relative;
    pointer-events: auto;
    font-size: 14px; /* Increased font size */
}

.notification button {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px; /* Increased font size */
}

@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;
    }
}

/* Add some mobile specific resets */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Optional:  Disable zooming to improve performance, requires appropriate viewport meta tag */
/* html { touch-action: manipulation; } */
