body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.tabs {
    display: flex;
    border-bottom: 2px solid #ddd;
    background-color: #f8f8f8;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 16px;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab.active {
    background-color: white;
    border-bottom-color: #007bff;
    color: #007bff;
}

.tab:hover {
    background-color: #e8e8e8;
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

.map-view {
    text-align: center;
}

.canvas-container {
    position: relative;
    display: inline-block;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

#backgroundCanvas {
    position: relative;
    z-index: 2;
    pointer-events: none;
}

#memoryCanvas {
    position: absolute;
    top: calc(100% * 100 / (1024 + 100 + 100));
    /* Position based on: leftBorder(100) / (mapSize(1024) + leftBorder(100) + rightBorder(450)) */
    left: calc(100% * 100 / (1024 + 100 + 450));
    /* Width based on: mapSize(1024) / (mapSize(1024) + leftBorder(100) + rightBorder(450)) */
    width: calc(100% * 1024 / (1024 + 100 + 450));
    aspect-ratio: 1;
    z-index: 1;
    cursor: crosshair;
    transition: transform 0.8s cubic-bezier(0.23, 1, 0.320, 1);
    transform-origin: center center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#memoryCanvas.animating {
    cursor: wait;
    pointer-events: none;
}

.text-editor {
    display: flex;
    flex-direction: column;
    height: 800px;
}

.editor-toolbar {
    padding: 10px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 10px;
    align-items: center;
}

.editor-toolbar button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background-color: white;
    cursor: pointer;
    border-radius: 4px;
}

.editor-toolbar button:hover {
    background-color: #f0f0f0;
}

#textEditor {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
}

.tooltip {
    position: absolute;
    background: #f0f0f0;
    color: black;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: auto;
    z-index: 1000;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    margin-top: -10px;
    min-width: 200px;
}

.tooltip-close {
    position: absolute;
    top: 2px;
    right: 6px;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    font-size: 14px;
}

.tooltip-close:hover {
    color: #000;
}

.tooltip-nav {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    font-weight: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    line-height: 1;
    font-family: Arial, sans-serif;
    padding: 0;
    margin: 0;
    vertical-align: middle;
}

.tooltip-nav:hover {
    background: #0056b3;
}

.tooltip-nav:active {
    transform: scale(0.95);
}

/* Mobile responsive layout */
@media screen and (max-width: 768px) {
    .canvas-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    #backgroundCanvas {
        order: 1;
    }
    
    #memoryCanvas {
        /* Mobile positioning - inherit desktop top, adjust left for mobile */
        position: absolute !important;
        /* Mobile: leftBorder(100) / (mapSize(1024) + leftBorder(100) + rightBorderMobile(100)) */
        left: calc(100% * 100 / (1024 + 100 + 100)) !important;
        /* Mobile: mapSize(1024) / (mapSize(1024) + leftBorder(100) + rightBorderMobile(100)) */
        width: calc(100% * 1024 / (1024 + 100 + 100)) !important;
        aspect-ratio: 1 !important;
        order: 1;
        margin-top: 0;
    }
    
    .mobile-scale-info {
        display: block;
        background-color: #f8f8f8;
        padding: 15px;
        margin-top: 10px;
        border-radius: 4px;
        font-size: 14px;
        line-height: 1.4;
        order: 2;
        width: 100%;
        box-sizing: border-box;
    }
}

@media screen and (min-width: 769px) {
    .mobile-scale-info {
        display: none;
    }
    
    .mobile-instruction {
        display: none;
    }
    
    .desktop-instruction {
        display: inline;
    }
}

@media screen and (max-width: 768px) {
    .desktop-instruction {
        display: none;
    }
    
    .mobile-instruction {
        display: inline;
    }
}
