@import url('https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@100;200;300;400;500;600;700;800;900&display=swap');

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

body {
    font-family: 'Lexend Deca', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    overflow: hidden;
    height: 100vh;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
}

/* Coordinate Display */
.coords-display {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    gap: 20px;
    z-index: 1000;
    font-family: 'Lexend Deca', 'Consolas', monospace;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.coord-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.coord-item .label {
    color: #7d8590;
    font-size: 12px;
}

.coord-item .value {
    color: #58a6ff;
    font-size: 14px;
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

.coord-item .editable-coord {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 2px 4px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.coord-item .editable-coord:hover {
    border-color: #30363d;
    background: rgba(48, 54, 61, 0.3);
}

.coord-item .editable-coord:focus {
    outline: none;
    border-color: #58a6ff;
    background: rgba(88, 166, 255, 0.1);
    cursor: text;
}

.coord-item .editable-coord::selection {
    background: rgba(88, 166, 255, 0.3);
}

/* Controls */
.controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.controls button {
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    padding: 10px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Lexend Deca', sans-serif;
    transition: all 0.2s ease;
}

.controls button:hover {
    background: rgba(48, 54, 61, 0.9);
    border-color: #58a6ff;
    transform: translateY(-1px);
}

/* Viewport */
.svg-viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    position: relative;
}

.svg-viewport:active {
    cursor: grabbing;
}

/* Canvas */
.render-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: transparent;
    
    /* Prevent drag/selection issues */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-drag: none;
    -khtml-user-select: none;
    -webkit-touch-callout: none;
}

.svg-container {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 0;
}

/* Loading and Error States */
.loading, .placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.loading {
    color: #58a6ff;
    font-size: 18px;
}

.placeholder {
    background: rgba(22, 27, 34, 0.8);
    border: 2px dashed #30363d;
    border-radius: 12px;
    padding: 40px;
}

.placeholder h2 {
    color: #58a6ff;
    margin-bottom: 16px;
    font-size: 24px;
}

.placeholder p {
    color: #7d8590;
    font-size: 16px;
}

/* Instructions */
.instructions {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(13, 17, 23, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 12px 16px;
    z-index: 1000;
    font-size: 12px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    color: #7d8590;
}

kbd {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: 'Lexend Deca', 'Consolas', monospace;
    color: #c9d1d9;
    min-width: 70px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .coords-display {
        display: none; /* Hide on mobile */
    }
    
    .instructions {
        display: none;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        padding: 20px;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(88, 166, 255, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: translateY(-5px);
    transition: all 0.3s ease;
}

.modal-content h2 {
    color: #58a6ff;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.3);
}

.close-button {
    color: #7d8590;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
}

.close-button:hover,
.close-button:focus {
    color: #58a6ff;
    background: rgba(88, 166, 255, 0.1);
    transform: scale(1.1);
    text-decoration: none;
    cursor: pointer;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    color: #c9d1d9;
    font-size: 16px;
    font-family: 'Lexend Deca', sans-serif;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.modal-content input[type="text"]::placeholder {
    color: #7d8590;
    font-weight: 300;
}

.modal-content input[type="text"]:focus {
    border-color: #58a6ff;
    background: rgba(13, 17, 23, 0.95);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25), inset 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.modal-content .user-results-list {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.modal-content .user-results-list:focus-within {
    border-color: #58a6ff;
    background: rgba(13, 17, 23, 0.95);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25), inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.modal-content .user-results-list .user-item {
    padding: 12px 16px;
    cursor: pointer;
    color: #c9d1d9;
    font-size: 16px;
    font-family: 'Lexend Deca', sans-serif;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(48, 54, 61, 0.3);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.modal-content .user-results-list .user-item:last-child {
    border-bottom: none;
}

.modal-content .user-results-list .user-item:hover {
    background: rgba(48, 54, 61, 0.3);
    color: #58a6ff;
}

.modal-content .user-results-list .user-item.selected {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(68, 149, 237, 0.2));
    color: #58a6ff;
    font-weight: 500;
    border-color: rgba(88, 166, 255, 0.3);
}

.modal-content .user-results-list .user-item:active {
    background: rgba(88, 166, 255, 0.1);
    transform: translateX(2px);
}

.modal-content .user-results-list::-webkit-scrollbar {
    width: 8px;
}

.modal-content .user-results-list::-webkit-scrollbar-track {
    background: rgba(13, 17, 23, 0.5);
    border-radius: 4px;
}

.modal-content .user-results-list::-webkit-scrollbar-thumb {
    background: rgba(125, 133, 144, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.modal-content .user-results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(125, 133, 144, 0.5);
}

.modal-content button {
    background: linear-gradient(135deg, #58a6ff, #4495ed);
    border: none;
    border-radius: 8px;
    color: #0d1117;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 500;
    font-family: 'Lexend Deca', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
}

.modal-content button:hover {
    background: linear-gradient(135deg, #4495ed, #3182ce);
    box-shadow: 0 6px 16px rgba(88, 166, 255, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.modal-content button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(88, 166, 255, 0.2);
}

.modal-content button:disabled {
    background: #30363d;
    color: #7d8590;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Side Modal */
.side-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Changed from auto */
    /* Removed background-color and backdrop-filter */
}

.side-modal-content {
    position: fixed;
    top: 20px; /* Fixed padding from the top */
    left: -500px; /* Start off-screen, slightly more than max-width */
    max-width: 450px; /* Max width for desktop */
    width: 90%; /* Responsive width, but capped by max-width */
    height: calc(100% - 40px); /* Maximize height with 20px top + 20px bottom padding */
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #30363d; /* Border on all sides */
    border-radius: 12px; /* Rounded corners */
    padding: 30px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
    /* Removed transform: translateY(-50%); as it's no longer needed with fixed top */
}

.side-modal.open .side-modal-content {
    left: 20px; /* Open position with margin from left */
    /* top and transform remain for vertical centering */
}

#user-info {
    color: #c9d1d9;
}

#user-info .profile-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 20px;
    flex-shrink: 0;
}

#user-info .user-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

#user-info .user-details {
    display: flex;
    flex-direction: column;
}

.badge-container {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.badge {
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    display: inline-block;
}

.creation-badge {
    background: #21262d;
    border: 1px solid #30363d;
    color: #7d8590;
}

.lifesteal-badge {
    background: #4d1a1a;
    border: 1px solid #8b0000;
    color: #ffc1c1;
}

.communities-section {
    margin-top: 25px;
}

.communities-section h3 {
    color: #58a6ff;
    font-size: 18px;
    margin-bottom: 15px;
    border-bottom: 1px solid #30363d;
    padding-bottom: 10px;
}

.communities-list {
    list-style: none;
    padding: 0;
}

.community-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 5px;
    border-bottom: 1px solid #21262d;
    gap: 15px;
}

.community-item:last-child {
    border-bottom: none;
}

.community-name {
    font-weight: 500;
    flex-grow: 1;
}

.community-messages {
    color: #7d8590;
    font-size: 12px;
    text-align: right;
    min-width: 80px;
}

.rank-badge {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 5px;
    white-space: nowrap;
}

.rank-gold {
    background-color: #b8860b20;
    border: 1px solid #b8860b;
    color: #ffd700;
}

.rank-silver {
    background-color: #c0c0c020;
    border: 1px solid #c0c0c0;
    color: #f0f0f0;
}

.rank-bronze {
    background-color: #cd7f3220;
    border: 1px solid #cd7f32;
    color: #e6a864;
}

.rank-default {
    background-color: #30363d20;
    border: 1px solid #30363d;
    color: #7d8590;
}

@media (max-width: 1200px) {
    #user-info .user-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

#user-info h2 {
    color: #58a6ff;
    font-size: 24px;
    margin-bottom: 10px;
}

#user-info p {
    font-size: 16px;
    line-height: 1.6;
    max-width: 60ch;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .side-modal-content {
        width: 95%;
        left: -100%;
    }

    .side-modal.open .side-modal-content {
        left: 2.5%;
        top: 2.5%;
        height: 95%;
        border-radius: 12px;
        border: 1px solid #30363d;
    }
}

/* Watermark */
.watermark {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    font-weight: 300;
    color: #c9d1d9;
    background: rgba(13, 17, 23, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #30363d;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
}

.watermark:hover {
    opacity: 0.8;
}