/**
 * Game-specific styles - Canvas, game area, and game UI elements
 */

.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    min-height: 500px; /* Prevent layout from shrinking beyond this point */
    /* Footer now flows naturally, no extra padding needed */
}

.game-main {
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

.game-sidebar {
    flex: 0 0 240px; /* Reduced width sidebar */
    max-width: 240px;
}

/* Compact styling for sidebar instructions */
.game-sidebar .instructions-section {
    margin: 0;
    max-width: none;
}

.game-sidebar .instructions-container {
    font-size: 0.9em;
}

.game-sidebar .instructions-content {
    padding: 0;
}

.game-sidebar .instructions-content ul {
    margin: 12px;
}

.game-sidebar .instructions-content li {
    padding: 6px 0;
    padding-left: 18px;
    font-size: 0.95em;
    line-height: 1.4;
}

.game-area {
    margin-bottom: 15px;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: visible;
}

.canvas-status-icons {
    position: absolute;
    top: 0;
    left: -32px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    pointer-events: none; /* Don't block mouse events to canvas */
}

.status-icon {
    display: none;
    width: 16px;
    height: 16px;
}

.status-icon svg {
    width: 100%;
    height: 100%;
}

.status-icon svg path {
    fill: var(--text-primary);
}

.status-icon.active {
    display: block;
}

/* Direction arrow styling */
.direction-arrow {
    opacity: 0.7;
}

.direction-arrow.active {
    opacity: 1;
}

.direction-arrow svg {
    width: 14px;
    height: 14px;
}

#magnetIcon {
    transform: rotate(180deg);
}

.start-indicator {
    position: absolute;
    font-family: var(--font-primary);
    font-size: 10px;
    color: var(--success-color);
    white-space: nowrap;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Don't block mouse events to canvas */
}

/* Default: Left edge positioning */
.start-indicator.left {
    left: 0;
    top: 20px;
    transform: translateX(-100%);
    padding-right: 15px;
}

/* Right edge positioning */
.start-indicator.right {
    right: 0;
    top: 20px;
    transform: translateX(100%);
    padding-left: 15px;
}

/* Top edge positioning */
.start-indicator.top {
    top: 0;
    left: 50%;
    transform: translate(-50%, -100%);
    padding-bottom: 15px;
    text-align: center;
}

/* Bottom edge positioning */
.start-indicator.bottom {
    bottom: 0;
    left: 50%;
    transform: translate(-50%, 100%);
    padding-top: 15px;
    text-align: center;
}

.start-indicator.visible {
    opacity: 1;
}

#gameCanvas {
    border: 2px solid var(--border-color);
    border-radius: 0;
    display: block;
    cursor: crosshair;
    background: var(--bg-tertiary);
    /* Pure responsive sizing - no hardcoded constraints */
    max-width: 100%;
    height: auto;
    /* Removed min-width and min-height - dimensions calculated purely from viewport */
}

/* CRITICAL: Lock dimensions for games with stored canvas sizes to prevent coordinate corruption */
#gameCanvas.dimension-locked {
    max-width: none !important;
    max-height: none !important;
    width: var(--locked-canvas-width) !important;
    height: var(--locked-canvas-height) !important;
    min-width: unset !important;
    min-height: unset !important;
}

/* Cursor states for drawing */
/* Note: Dynamic cursor is now set by ThemeManager - removed hardcoded black cursor */

#gameCanvas:not(.drawing):not(.near-edge):not(.read-mode) {
    cursor: crosshair;
}

/* Canvas rotation classes */
#gameCanvas {
    transition: transform 0.3s ease;
}

#gameCanvas.rotate-left {
    transform: rotate(0deg);
}

#gameCanvas.rotate-right {
    transform: rotate(180deg);
}

#gameCanvas.rotate-top {
    transform: rotate(-90deg);
}

#gameCanvas.rotate-bottom {
    transform: rotate(90deg);
}

#gameCanvas.read-mode {
    cursor: default;
}

/* Magnifying glass cursor is now handled dynamically by ThemeManager */

/* Pinned mode cursors are now handled dynamically by ThemeManager */

.game-info {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    min-height: 60px; /* Ensure minimum height for game info buttons */
    position: relative;
    top: 0; /* Prevent from going above viewport when shrinking */
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.stat label {
    color: var(--text-secondary);
}

.stat span {
    color: var(--text-primary);
    font-weight: 600;
}

/* Game state indicators - Retro Style */
.game-area.drawing #gameCanvas {
    cursor: crosshair;
    border-color: var(--border-color);
}

.game-area.completed #gameCanvas {
    cursor: default;
    border-color: var(--border-color);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    #gameCanvas {
        cursor: default;
    }
}

/* Fixed Line Information Panel */
.line-info-panel {
    margin-top: 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    font-family: var(--font-primary);
}

.line-info-header {
    background: var(--bg-secondary);
    padding: 12px 15px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.line-info-header h3 {
    margin: 0;
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1em;
}

.line-info-panel .line-info-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    color: var(--text-secondary);
}

.line-info-panel .line-info-close:hover {
    opacity: 0.7;
}

.line-info-panel .line-info-close svg {
    width: 12px;
    height: 12px;
}

.line-info-panel .line-info-content {
    padding: 15px;
}

.line-info-panel .line-info-details {
    font-size: 0.9em;
    line-height: 1.4;
}

.line-info-panel .line-info-item {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.line-info-panel .line-info-item strong {
    color: var(--text-primary);
    font-weight: bold;
}

.line-info-panel.hover-mode {
    opacity: 0.95;
}

.line-info-panel.pinned-mode {
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Mobile responsive game area */
@media (max-width: 1024px) {
    .game-layout {
        flex-direction: column;
        gap: 15px;
        min-height: 450px; /* Reduced minimum height for tablets */
        /* Footer now flows naturally, no extra padding needed */
    }
    
    .game-sidebar {
        flex: none;
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .start-indicator {
        position: static;
        transform: none;
        padding: 10px 0;
        text-align: center;
        font-size: 12px;
    }
    
    .canvas-container {
        flex-direction: column;
        align-items: center;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }
    
    .stat {
        justify-content: space-between;
    }
    
    .game-layout {
        gap: 15px;
        /* Footer now flows naturally, no extra padding needed */
    }
}

@media (max-width: 600px) {
    .game-layout {
        min-height: 400px; /* Further reduced for mobile */
        padding-top: 5px; /* Less padding on mobile */
    }
    
    .game-info {
        flex-wrap: wrap;
        flex-direction: row;
        justify-content: space-around;
        gap: 8px;
        min-height: 50px; /* Smaller minimum height on mobile */
    }
    
    /* Canvas maintains dynamic sizing with minimum constraints on mobile */
    .canvas-container {
        overflow-x: auto; /* Allow horizontal scrolling if canvas exceeds viewport */
    }
    
    .stat {
        flex: 1 1 45%;
        min-width: 120px;
        justify-content: space-between;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .start-indicator {
        font-size: 11px;
        padding: 8px 0;
    }
    
    .game-info {
        padding: 10px;
    }
    
    .game-layout {
        gap: 10px;
        /* Footer now flows naturally, no extra padding needed */
    }
}

