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

body {
    font-family: 'Open Sans', Arial, sans-serif;
    background-color: #2c3e2d; /* Forest green background */
    background-image: url('https://www.transparenttextures.com/patterns/dark-wood.png');
    color: #3a3a3a;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background-color: #f8f3e2; /* Light parchment color */
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
    padding: 20px;
    border: 2px solid #725634; /* Brown border */
    max-height: calc(100vh - 40px); /* Prevent overflow beyond viewport */
    overflow-y: auto; /* Allow scrolling if needed */
}

/* Improved header layout for single-row button organization */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #725634;
    position: relative;
    gap: 20px;
    flex-wrap: wrap;
}

header::after {
    content: "";
    position: absolute;
    width: 90%;
    height: 1px;
    background-color: #a98e73;
    bottom: -5px;
    left: 5%;
}

.title-section {
    flex: 0 0 auto;
    min-width: 200px;
}

h1 {
    margin-bottom: 5px;
    color: #4a2b0f; /* Dark brown */
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

h1::after {
    content: "⚔️";
    font-size: 0.6em;
    margin-left: 10px;
    vertical-align: middle;
}

/* Add a subtle tagline for clarity */
.tagline {
    color: #8b6b43;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    font-style: italic;
    margin-top: 5px;
    font-weight: normal;
}

h3 {
    font-family: 'Cinzel', serif;
    color: #4a2b0f;
    margin-bottom: 15px;
    font-size: 1.1rem;
    position: relative;
    padding-bottom: 8px;
}

h3::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background-color: #8b6b43;
}

.controls, .mode-controls {
    margin-bottom: 10px;
}

/* Reorganized mode controls for single row */
.mode-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.mode-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-label {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: #4a2b0f;
    font-size: 14px;
    white-space: nowrap;
}

.controls-divider {
    width: 1px;
    height: 35px;
    background-color: #c9b38c;
    margin: 0 8px;
}

.action-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-section .quickstart-btn {
    order: -1; /* Put quickstart button first */
    margin-right: 4px;
}

/* Remove old mode-row and action-row styles */
.mode-row,
.action-row {
    display: none;
}

button {
    background-color: #546a3c; /* Moss green */
    color: #f8f3e2;
    border: 1px solid #3a4a29;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

button:hover {
    background-color: #3a4a29; /* Darker green */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#add-fencer-1 {
    background-color: #3f5fa0; /* Blue for team 1 */
    border: 1px solid #2c4270;
}

#add-fencer-1:hover {
    background-color: #2c4270;
}

#add-fencer-2 {
    background-color: #9e3030; /* Red for team 2 */
    border: 1px solid #7a2424;
}

#add-fencer-2:hover {
    background-color: #7a2424;
}

#clear-board {
    background-color: #8b6b43; /* Wood brown */
    border: 1px solid #64492c;
}

#clear-board:hover {
    background-color: #64492c;
}

#delete-selected {
    background-color: #9e3030; /* Red delete button */
    border: 1px solid #7a2424;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#delete-selected::before {
    content: "🗑️";
    margin-right: 5px;
    font-size: 14px;
}

#delete-selected:hover {
    background-color: #7a2424;
}

#delete-selected:disabled {
    background-color: #ccc;
    color: #666;
    border-color: #bbb;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #725634;
    background-color: #f8f3e2;
    font-family: 'Open Sans', sans-serif;
    color: #3a3a3a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.canvas-container {
    flex: 1;
    padding: 15px; /* Reduced from 20px */
    background-color: #e9e0cc; /* Lighter parchment */
    border-radius: 8px;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid #725634;
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap to eliminate space between canvas and caption */
    height: 100%; /* Take full available height */
    min-height: 700px; /* Set a reasonable minimum height */
}

.content-area {
    display: flex;
    gap: 20px;
    margin-bottom: 15px; /* Reduced from 20px */
    height: 700px; /* Fixed height to control overall layout */
    min-height: 700px; /* Ensure minimum height */
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background-color: #e9e0cc;
    border-radius: 8px;
    padding: 20px;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid #725634;
    height: 100%; /* Take full height of content-area (700px) */
    max-height: 700px; /* Match content-area height */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Hide horizontal overflow */
    
    /* Improved scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #8b6b43 #e9e0cc;
}

/* Enhanced scrollbar styling for webkit browsers */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #e9e0cc;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #8b6b43;
    border-radius: 4px;
    border: 1px solid #e9e0cc;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #64492c;
}

.sidebar-category {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(114, 86, 52, 0.2);
}

.sidebar-category:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.token-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 5px;
}

.terrain-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.token {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    border: 2px solid rgba(0, 0, 0, 0.15);
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.token[data-color="#3f5fa0"] {
    background-color: #3f5fa0; /* Flat blue */
}

.token[data-color="#9e3030"] {
    background-color: #9e3030; /* Flat red */
}

.token[data-color="#5a8c3e"] {
    background-color: #5a8c3e; /* Flat green */
}

.token[data-color="#9b722f"] {
    background-color: #9b722f; /* Flat gold */
}

.token[data-color="#7a3d99"] {
    background-color: #7a3d99; /* Flat purple */
}

.token[data-color="#e67e22"] {
    background-color: #e67e22; /* Flat orange (replacing black) */
}

.token.obstacle {
    background-color: #7a6c5c; /* Flat obstacle color */
}

.token.obstacle[data-shape="rect"] {
    border-radius: 5px;
    background-color: #83756a; /* Flat wall color */
}

.token span {
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); /* Darker shadow for better contrast */
    pointer-events: none;
}

.token:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.3);
}

.token:active {
    cursor: grabbing;
}

.token[data-color="#333333"] {
    display: none;
}

.token-selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ff6b35; /* Updated to match new arrow color */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.5);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(255, 107, 53, 0.8);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.5);
    }
}

canvas {
    width: 100%;
    height: calc(100% - 80px); /* Dynamic height based on container minus space for screenshot section */
    min-height: 450px; /* Ensure minimum height to prevent squishing */
    max-height: 580px; /* Maximum height to keep everything above fold */
    border: 2px solid #725634; /* Brown border */
    border-radius: 6px;
    cursor: crosshair;
    background-color: #f0eadc; /* Parchment color */
    background-image: url('https://www.transparenttextures.com/patterns/parchment.png');
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    flex: 1; /* Take available space */
}

.instructions {
    background-color: #e9e0cc;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #546a3c; /* Moss green */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.instructions h2 {
    margin-bottom: 10px;
    font-size: 1.2rem;
    font-family: 'Cinzel', serif;
    color: #4a2b0f; /* Dark brown */
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    line-height: 1.4;
    position: relative;
}

.instructions li::before {
    content: "➢";
    position: absolute;
    left: -18px;
    color: #546a3c;
    font-size: 12px;
}

.instructions strong {
    color: #4a2b0f;
    font-weight: 600;
}

/* Remove drawing tools specific styles */
.drawing-tools,
.tool-selector,
.tool-btn,
.brush-options,
.option-group,
#brush-size,
.color-palette,
.color-option,
.checkbox-option {
    /* These styles are no longer needed */
    display: none;
}

/* Improved mode buttons for single row layout */
.mode-buttons {
    display: flex;
    gap: 2px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #e9e0cc;
    border: none;
    border-right: 1px solid #c9b38c;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.2s;
    height: 50px;
    width: 70px;
    color: #4a2b0f;
    font-weight: 600;
    position: relative;
}

.mode-btn:last-child {
    border-right: none;
}

.mode-btn .icon {
    font-size: 16px;
    margin-bottom: 3px;
}

.mode-btn .label {
    font-size: 10px;
    line-height: 1;
}

.mode-btn:hover:not(.active) {
    background-color: #d9ceb8;
    transform: translateY(-1px);
}

.mode-btn.active {
    background-color: #8b6b43;
    color: #f8f3e2;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: none;
}

/* Compact action buttons for single row */
.action-btn {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    min-width: auto;
}

/* Specific styling for grid toggle to be more compact */
#toggle-grid {
    width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toggle-grid .icon {
    font-size: 14px;
}

/* Remove the "Grid" text for more compact layout */
#toggle-grid .label {
    display: none;
}

/* Make sure instructions support nested lists */
.instructions ul ul {
    margin-top: 5px;
    margin-bottom: 10px;
    padding-left: 15px;
}

.instructions ul ul li {
    margin-bottom: 3px;
    font-size: 0.95em;
}

.instructions ul ul li::before {
    content: "•";
    position: absolute;
    left: -12px;
    color: #8b6b43;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .content-area {
        flex-direction: column;
        height: auto; /* Allow natural height on mobile */
        min-height: auto;
    }
    
    .sidebar {
        width: 100%;
        height: auto; /* Allow natural height on mobile */
        max-height: 300px; /* Reasonable max height on mobile */
        margin-bottom: 20px;
        order: -1;
        overflow-y: auto; /* Ensure scrolling is maintained on mobile */
    }
    
    .canvas-container {
        min-height: auto; /* Reset min-height on mobile */
        height: auto;
        padding: 12px; /* Reduced padding on mobile */
        gap: 0; /* Keep no gap on mobile too */
    }
    
    canvas {
        height: 450px; /* Fixed height on mobile for proper proportions */
        min-height: 450px;
        max-height: 450px;
    }
    
    .screenshot-section {
        margin-top: 10px; /* Consistent small margin on mobile */
    }
    
    .token-container {
        grid-template-columns: repeat(4, 1fr);
    }
    
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .mode-controls {
        width: 100%;
        align-items: stretch;
    }
    
    .mode-row,
    .action-row {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    .token-container {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .mode-btn {
        width: 70px;
        height: 55px;
        padding: 8px 12px;
    }
    
    .mode-btn .icon {
        font-size: 18px;
    }
    
    .mode-btn .label {
        font-size: 10px;
    }
    
    .screenshot-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .screenshot-btn {
        min-width: auto;
    }
    
    canvas {
        height: 400px; /* Slightly smaller on very small screens */
        min-height: 400px;
        max-height: 400px;
    }
}

/* Better responsive behavior for single-row layout */
@media (max-width: 1000px) {
    .mode-controls {
        gap: 15px;
    }
    
    .mode-btn {
        width: 60px;
        height: 45px;
        padding: 6px 10px;
    }
    
    .mode-btn .icon {
        font-size: 14px;
    }
    
    .mode-btn .label {
        font-size: 9px;
    }
    
    .action-btn {
        height: 32px;
        padding: 0 10px;
        font-size: 11px;
    }
    
    .content-area {
        height: 680px; /* Intermediate size */
        min-height: 680px;
    }
    
    .canvas-container {
        min-height: 680px;
    }
    
    canvas {
        min-height: 420px;
        max-height: 550px;
    }
}

@media (max-width: 800px) {
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .title-section {
        text-align: center;
        min-width: auto;
    }
    
    .mode-controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .controls-divider {
        display: none;
    }
    
    .mode-section,
    .action-section {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .mode-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .mode-section {
        width: 100%;
        justify-content: center;
    }
    
    .action-section {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .mode-btn {
        flex: 1;
        min-width: 0;
    }
    
    .action-btn {
        flex: 1;
        min-width: 80px;
    }
    
    #toggle-grid {
        flex: 0 0 auto;
        width: 36px;
    }
}

@media (max-width: 700px) {
    .mode-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .mode-buttons {
        width: 100%;
    }
    
    .mode-btn {
        flex: 1;
    }
    
    .action-btn {
        width: 100%;
        margin-top: 5px;
    }
}

/* Updated styling for Combat Role tokens */
.token.role {
    /* Remove partial border/outline styling */
    background: var(--team-color, #3f5fa0); /* Use the selected team color as background */
    border: 2px solid rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Remove the ::before pseudo-element that was creating the partial color */
.token.role::before {
    display: none;
}

.role-symbol {
    font-size: 24px;
    line-height: 1;
    font-weight: bold;
    color: #ffffff; /* Make symbols white for better contrast on colored backgrounds */
    margin-bottom: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); /* Darker shadow for better contrast */
}

.role-name {
    font-size: 10px;
    color: #ffffff; /* White text for better contrast */
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* Individual styling for each role */
.token[data-role="linesman"] .role-symbol {
    transform: scale(1.4, 1);
}

.token[data-role="cavalry"] .role-symbol {
    transform: scale(1.2);
}

.token[data-role="harrier"] .role-symbol {
    transform: scale(1.2);
}

.token[data-role="shadow"] .role-symbol {
    opacity: 0.8;
}

.token[data-role="commander"] .role-symbol {
    color: #9b722f;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

.token[data-role="flank"] .role-symbol {
    transform: rotate(-15deg);
}

@media (max-width: 900px) {
    .token-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 500px) {
    .token-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Role color selector styling */
.role-color-selector {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(139, 107, 67, 0.2);
}

.role-color-label {
    font-size: 12px;
    color: #4a2b0f;
    font-weight: 600;
    margin-bottom: 8px;
    font-family: 'Open Sans', sans-serif;
}

.role-color-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    border-color: white;
    box-shadow: 0 0 0 1px #333;
    transform: scale(1.1);
}

/* Updated styling for Role and Rank tokens */
.token.role, .token.rank {
    background: var(--team-color, #3f5fa0); /* Use the selected team color as background */
    border: 2px solid rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Shared styles for role and rank symbols and names */
.role-symbol, .rank-symbol {
    font-size: 24px;
    line-height: 1;
    font-weight: bold;
    color: #ffffff; /* Make symbols white for better contrast on colored backgrounds */
    margin-bottom: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); /* Darker shadow for better contrast */
}

.role-name, .rank-name {
    font-size: 10px;
    color: #ffffff; /* White text for better contrast */
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* Specific styling for each rank symbol */
.token[data-rank="newcomer"] .rank-symbol {
    font-size: 18px;
}

.token[data-rank="initiate"] .rank-symbol {
    font-size: 16px;
    letter-spacing: -2px;
}

.token[data-rank="novice"] .rank-symbol {
    font-size: 22px;
}

.token[data-rank="swordsman"] .rank-symbol {
    font-size: 22px;
}

.token[data-rank="veteran"] .rank-symbol {
    font-size: 20px;
    letter-spacing: -2px;
}

.token[data-rank="master"] .rank-symbol {
    font-size: 20px;
    letter-spacing: -2px;
}

/* Add rank color selector styling */
.rank-color-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Styling for Terrain & Objectives tokens */
.token.terrain, .token.objective {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #e9e0cc;
    border: 2px solid rgba(0, 0, 0, 0.3);
    position: relative;
}

.terrain-icon, .objective-icon {
    font-size: 24px;
    line-height: 1;
    color: #4a2b0f;
    margin-bottom: 2px;
}

.terrain-name, .objective-name {
    font-size: 10px;
    color: #4a2b0f;
    font-weight: 600;
}

/* Special styling for specific terrain/objectives */
.token.tree .terrain-icon {
    font-size: 28px;
    color: #5a8c3e;
}

.token[data-terrain="wall"] {
    border-radius: 5px;
    background-color: #83756a;
}

.token[data-terrain="wall"] .terrain-icon {
    color: #ffffff;
}

.token[data-terrain="water"] {
    background-color: #a5c8e0;
}

.token[data-objective="rezpoint"] .objective-icon {
    color: #9e3030;
    font-weight: bold;
}

.token[data-objective="flag"] .objective-icon {
    color: #3f5fa0;
}

.token[data-objective="treasure"] .objective-icon {
    color: #9b722f;
}

/* Resize handles styling */
.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #ffffff;
    border: 2px solid #4a2b0f;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.resize-handle.tl {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.resize-handle.tr {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.resize-handle.bl {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.resize-handle.br {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

.resize-handle:hover {
    background-color: #e67e22;
    transform: scale(1.2);
}

/* Flag color selector */
.flag-color-selector {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(139, 107, 67, 0.2);
}

.flag-color-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Flag token customization */
.token.flag-token {
    --flag-color: #3f5fa0;
}

.token.flag-token .objective-icon {
    color: var(--flag-color);
}

/* Water combine hint styling */
.water-combine-hint {
    position: absolute;
    background-color: rgba(165, 200, 224, 0.3);
    border: 2px dashed #6a9cc8;
    pointer-events: none;
    z-index: 10;
}

/* Adding help tooltip for wall resizing */
.tooltip {
    position: absolute;
    background-color: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 200px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tooltip.visible {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Rotation handle for walls */
.rotation-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: #ffffff;
    border: 2px solid #4a2b0f;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
}

.rotation-handle::before {
    content: '↻';
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #4a2b0f;
}

.rotation-handle:hover {
    background-color: #e67e22;
    transform: translateX(-50%) scale(1.2);
}

/* Wall token hint text */
.wall-token .drag-hint {
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    font-size: 9px;
    color: #4a2b0f;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    font-style: italic;
}

.wall-token:hover .drag-hint {
    opacity: 1;
}

/* Rez point team color selector */
.rezpoint-color-selector {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(139, 107, 67, 0.2);
}

.rezpoint-color-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Rez point token customization */
.token.rezpoint-token {
    --rez-color: #9e3030;
}

.token.rezpoint-token .objective-icon {
    color: var(--rez-color);
}

/* Wall selection indicator (replaces resize handles) */
.wall-selected {
    outline: 3px solid #e67e22;
    outline-offset: 3px;
}

/* Updated tooltip for wall rotation */
.tooltip.wall-hint {
    background-color: #333;
    color: white;
    padding: 10px 15px;
    max-width: 250px;
    line-height: 1.4;
}

/* Grid Toggle Button */
#toggle-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background-color: #8b6b43;
}

#toggle-grid.grid-off {
    background-color: #a08364;
    color: #e0d8ca;
}

#toggle-grid .icon {
    font-size: 16px;
}

/* Wall token variations */
.token[data-orientation="horizontal"] .terrain-icon {
    transform: scale(1.2, 0.6);
    display: block;
}

.token[data-orientation="vertical"] .terrain-icon {
    transform: scale(0.6, 1.2);
    display: block;
}

.token[data-orientation="corner"] .terrain-icon {
    transform: scale(0.9);
    display: block;
}

/* Compact grid toggle button */
#toggle-grid {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toggle-grid .icon {
    font-size: 18px;
}

/* Remove global color selector styles */
.global-color-selector,
.color-selector-header,
.category-tabs,
.tab-btn,
.color-dots-container {
    display: none;
}

/* Restore dedicated color selector styles */
.role-color-selector,
.rank-color-selector,
.flag-color-selector,
.rezpoint-color-selector {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    padding: 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.3);
}

.role-color-label {
    font-size: 12px;
    color: #4a2b0f;
    font-weight: 600;
    margin-bottom: 6px;
}

.role-color-options,
.rank-color-options,
.flag-color-options,
.rezpoint-color-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.color-dot:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.color-dot.active {
    border-color: white;
    box-shadow: 0 0 0 1px #333;
    transform: scale(1.1);
}

/* Add these styles to your existing CSS file */

/* Arrow mode styling */
#mode-arrow .icon {
    font-weight: bold;
    font-size: 1.2em;
}

.mode-btn[data-mode="arrow"].active {
    background-color: #8e44ad;
    color: white;
}

/* Arrow hint text */
.arrow-hint {
    font-size: 11px;
    color: #8b6b43;
    margin: 8px 0 0 0;
    font-style: italic;
    line-height: 1.3;
}

/* Arrow color selector styling */
.arrow-color-selector {
    margin: 10px 0;
}

.arrow-color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

/* Temporary arrow styling while drawing */
.temp-arrow {
    position: absolute;
    pointer-events: none;
    z-index: 100;
}

/* Instructions drawer styling - updated for better UX */
.instructions-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #f8f3e2;
    border-top: 2px solid #725634;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

.instructions-toggle {
    width: 100%;
    background-color: #8b6b43;
    color: #f8f3e2;
    border: none;
    padding: 14px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 16px;
    transition: background-color 0.2s;
}

.instructions-toggle:hover {
    background-color: #64492c;
}

.toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.instructions-toggle.open .toggle-icon {
    transform: rotate(90deg);
}

.instructions-content {
    max-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: #8b6b43 #e9e0cc;
}

.instructions-content::-webkit-scrollbar {
    width: 8px;
}

.instructions-content::-webkit-scrollbar-track {
    background: #e9e0cc;
}

.instructions-content::-webkit-scrollbar-thumb {
    background: #8b6b43;
    border-radius: 4px;
}

.instructions-content.open {
    max-height: 70vh; /* Use viewport height for better responsiveness */
}

.instructions-drawer .instructions {
    background-color: transparent;
    padding: 30px 40px; /* Generous padding on all sides */
    border-radius: 0;
    border-left: none;
    box-shadow: none;
    margin: 0;
    line-height: 1.6; /* Better line spacing */
}

.instructions-drawer .instructions h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.instructions-drawer .instructions ul {
    padding-left: 25px;
}

.instructions-drawer .instructions li {
    margin-bottom: 12px; /* More space between items */
}

.instructions-drawer .instructions ul ul {
    margin-top: 8px;
    margin-bottom: 12px;
    padding-left: 20px;
}

.instructions-drawer .instructions ul ul li {
    margin-bottom: 6px;
}

/* Responsive adjustments for the drawer */
@media (max-width: 1200px) {
    .instructions-content.open {
        max-height: 60vh;
    }
}

@media (max-width: 900px) {
    .instructions-content.open {
        max-height: 50vh;
    }
    
    .instructions-drawer .instructions {
        padding: 25px 30px;
    }
}

@media (max-width: 600px) {
    .instructions-toggle {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .instructions-content.open {
        max-height: 40vh;
    }
    
    .instructions-drawer .instructions {
        padding: 20px 25px;
    }
    
    .instructions-drawer .instructions h2 {
        font-size: 1.1rem;
    }
}

/* Selection box styling */
.selection-box {
    position: absolute;
    border: 2px dashed #e67e22;
    background-color: rgba(230, 126, 34, 0.2);
    pointer-events: none;
    z-index: 50;
}

/* Screenshot capture section styling - improved alignment */
.screenshot-section {
    display: flex;
    align-items: center; /* Changed from stretch to center for more compact layout */
    gap: 10px; /* Reduced from 12px */
    padding: 8px 12px; /* Further reduced padding */
    background-color: #f5f0e6;
    border-radius: 6px; /* Slightly smaller border radius */
    border: 1px solid #d4c4a8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Reduced shadow */
    margin-top: 10px; /* Small controlled margin instead of auto */
    flex-shrink: 0; /* Don't shrink this section */
}

.caption-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px; /* Reduced gap */
    min-height: 0; /* Allow flex shrinking */
}

.caption-label {
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    color: #4a2b0f;
    font-size: 12px; /* Reduced from 13px */
    margin-bottom: 2px; /* Reduced spacing */
}

.caption-input {
    width: 100%;
    padding: 6px 8px; /* Further reduced padding */
    border: 1px solid #c9b38c;
    border-radius: 4px;
    background-color: #ffffff;
    font-family: 'Open Sans', sans-serif;
    font-size: 13px; /* Reduced from 14px */
    color: #3a3a3a;
    resize: vertical;
    min-height: 40px; /* Reduced from 50px */
    max-height: 60px; /* Reduced max height */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: border-color 0.2s ease;
    flex: 1; /* Take up available space */
}

.caption-counter {
    align-self: flex-end;
    font-size: 11px; /* Reduced from 12px */
    color: #666;
    font-family: 'Open Sans', sans-serif;
    margin-top: 2px; /* Reduced spacing */
}

.screenshot-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px; /* Further reduced gap */
    padding: 8px 12px; /* Further reduced padding */
    background-color: #2e8b57;
    color: white;
    border: none;
    border-radius: 4px; /* Smaller border radius */
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 13px; /* Reduced font size */
    min-width: 80px; /* Further reduced width */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: fit-content; /* Let button size naturally */
}

.screenshot-btn .icon {
    font-size: 16px; /* Further reduced icon size */
    line-height: 1;
}

.screenshot-btn .label {
    font-size: 10px; /* Further reduced text size */
    text-align: center;
    line-height: 1.1;
    font-weight: 600;
}

/* Responsive adjustments for screenshot section */
@media (max-width: 600px) {
    .screenshot-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .screenshot-btn {
        flex-direction: row; /* Horizontal layout on mobile */
        justify-content: center;
        gap: 8px;
        min-width: auto;
        padding: 14px 20px;
        align-self: auto; /* Reset stretch behavior on mobile */
    }
    
    .screenshot-btn .icon {
        font-size: 18px;
    }
    
    .screenshot-btn .label {
        font-size: 14px;
    }
}

/* Download notification styling */
.download-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #2e8b57;
    color: white;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    max-width: 300px;
}

.download-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.download-notification .icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 16px;
}

/* Subtle help hints */
.help-hint {
    font-size: 11px;
    color: #8b6b43;
    font-style: italic;
    margin-top: 5px;
    line-height: 1.3;
}

.arrow-hint {
    font-size: 11px;
    color: #8b6b43;
    margin: 8px 0 0 0;
    font-style: italic;
    line-height: 1.3;
}

/* Ensure the canvas area uses available space efficiently */
@media (min-width: 1201px) {
    canvas {
        height: calc(100% - 70px); /* Optimal space usage on large screens */
        min-height: 500px;
        max-height: 600px;
    }
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .content-area {
        height: 650px; /* Slightly smaller on medium screens */
        min-height: 650px;
    }
    
    .canvas-container {
        min-height: 650px;
    }
    
    canvas {
        min-height: 400px;
        max-height: 520px;
    }
}

/* Updated facing indicator styling for the new arrow design */
.facing-indicator {
    position: absolute;
    width: 24px; /* Increased from 20px */
    height: 16px; /* Increased from 12px */
    background-color: #2d4a32; /* Updated to match new arrow color */
    border: none; /* Removed white border */
    border-radius: 2px;
    pointer-events: none;
    z-index: 150;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Subtle shadow instead of border */
}

.facing-indicator:hover {
    background-color: #1f3324; /* Darker green on hover */
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.facing-indicator.selected {
    background-color: #ff6b35; /* Bright orange-red for selected */
    border: none;
    box-shadow: 0 0 12px rgba(255, 107, 53, 0.6);
}

.facing-indicator.dragging {
    cursor: grabbing;
    background-color: #ff6b35;
    border: none;
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(255, 107, 53, 0.8);
}

/* Enhanced cursor states for better UX */
canvas.grabbing {
    cursor: grabbing !important;
}

canvas.rotating-facing {
    cursor: grabbing !important;
}

/* Add visual feedback for facing rotation */
.token-facing-rotation {
    animation: facingPulse 0.5s ease-in-out infinite alternate;
}

@keyframes facingPulse {
    0% { opacity: 0.8; }
    100% { opacity: 1.0; }
}

/* Enhanced help hint for facing indicators */
.facing-hint {
    background-color: #f0eadc;
    border: 1px solid #c9b38c;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
    font-size: 0.85em;
    color: #6b5a47;
    line-height: 1.3;
}

/* Update existing help hints to include facing information */
.help-hint {
    background-color: #f0eadc;
    border: 1px solid #c9b38c;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
    font-size: 0.85em;
    color: #6b5a47;
    line-height: 1.3;
}

/* Improve selection indicator visibility when facing arrows are present */
.token-selected {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(230, 126, 34, 0);
    }
}

/* Add subtle glow effect for facing arrows when hovering */
canvas:hover .facing-indicator {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

/* Improve visibility of facing arrows on different backgrounds */
.facing-arrow-glow {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
}

/* Enhanced cursor states for better UX */
canvas.grabbing {
    cursor: grabbing !important;
}

canvas.rotating-facing {
    cursor: grab !important;
}

/* Add visual feedback for facing rotation */
.token-facing-rotation {
    animation: facingPulse 0.8s ease-in-out infinite alternate;
}

@keyframes facingPulse {
    0% {
        filter: brightness(1);
    }
    100% {
        filter: brightness(1.3); /* Increased brightness for better visibility */
    }
}

/* Enhanced help hint for facing indicators */
.facing-hint {
    font-size: 11px;
    color: #8b6b43;
    font-style: italic;
    margin-top: 5px;
    line-height: 1.3;
    text-align: center;
}

/* Update existing help hints to include facing information */
.help-hint {
    font-size: 11px;
    color: #8b6b43;
    font-style: italic;
    margin-top: 5px;
    line-height: 1.3;
}

/* Improve selection indicator visibility when facing arrows are present */
.token-selected {
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ff6b35; /* Updated to match new arrow color */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.5);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(255, 107, 53, 0.8);
    }
    100% {
        box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.5);
    }
}

/* Add subtle glow effect for facing arrows when hovering */
canvas:hover .facing-indicator {
    filter: brightness(1.2);
}

/* Improve visibility of facing arrows on different backgrounds */
.facing-arrow-glow {
    filter: drop-shadow(0 0 4px rgba(45, 74, 50, 0.6)); /* Shadow matching arrow color */
}

/* Quickstart button styling */
.quickstart-btn {
    background-color: #8e44ad !important; /* Purple background for distinction */
    border-color: #732d91 !important;
    font-weight: 700 !important;
    position: relative;
}

.quickstart-btn:hover {
    background-color: #732d91 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2) !important;
}

.quickstart-btn .icon {
    font-size: 16px;
    animation: battlePulse 2s ease-in-out infinite;
}

.quickstart-btn .label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Subtle animation for the Line Battle icon */
@keyframes battlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Enhanced notification styling for Line Battle */
.line-battle-notification {
    background-color: #8e44ad !important; /* Match button color */
    border-left: 4px solid #732d91;
}

.line-battle-notification .icon {
    animation: battleSuccess 0.6s ease-out;
}

@keyframes battleSuccess {
    0% {
        transform: scale(0.5) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(5deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Responsive adjustments for quickstart button */
@media (max-width: 1000px) {
    .quickstart-btn {
        min-width: 70px;
    }
    
    .quickstart-btn .label {
        font-size: 10px;
    }
}

@media (max-width: 800px) {
    .quickstart-btn {
        flex: 1;
        min-width: 0;
        max-width: 120px;
    }
}

@media (max-width: 600px) {
    .quickstart-btn {
        min-width: 80px;
    }
    
    .quickstart-btn .icon {
        font-size: 18px;
    }
    
    .quickstart-btn .label {
        font-size: 11px;
    }
}

/* Ensure proper spacing in action section */
.action-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-section .quickstart-btn {
    order: -1; /* Put quickstart button first */
    margin-right: 4px;
}
