* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 10px;
}

.guide-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.guide-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.guide-btn svg {
    width: 20px;
    height: 20px;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    align-items: start;
}

.game-section {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.game-board {
    margin-bottom: 30px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 3px;
    width: 400px;
    height: 400px;
    margin: 0 auto 20px;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 8px;
}

.grid-cell {
    background: #333333;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #404040;
    will-change: transform, background-color;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.grid-cell:hover {
    background: #404040;
    transform: scale(1.02) translateZ(0);
}

.grid-cell.filled {
    background: #4a90e2;
    border-color: #5ba0f2;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
    transform: translateZ(0);
}

.grid-cell.suggestion {
    background: #ff3b30 !important;
    border-color: #ff453a !important;
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.6) !important;
    animation: pulse 1s infinite;
    will-change: transform, opacity;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.board-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

.clear-btn, .restore-btn {
    background: #333333;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 100px;
    max-width: 140px;
}

.clear-btn:hover, .restore-btn:hover {
    background: #404040;
    transform: translateY(-1px);
}

.restore-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.restore-btn:hover {
    background: linear-gradient(135deg, #218838, #1e7e34);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.restore-btn:disabled {
    background: #555555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-blocks {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.block-slot {
    width: 80px;
    height: 80px;
    background: #333333;
    border-radius: 12px;
    border: 2px solid #404040;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    touch-action: none; /* Prevent default touch behaviors */
}

.block-slot.has-block {
    border-color: #4a90e2;
    background: #1a3a5c;
}

.block-slot.dragging {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.game-block-preview {
    cursor: grab;
    transition: all 0.2s ease;
    touch-action: none; /* Prevent default touch behaviors */
    user-select: none;
}

.game-block-preview:active {
    cursor: grabbing;
}

.game-block-preview.dragging {
    opacity: 0.8;
    transform: scale(1.2);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

/* Touch-and-click selection styles */
.selected-for-placement {
    border: 3px solid #4CAF50 !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6) !important;
    transform: scale(1.05);
    z-index: 100;
}

.block-slot.selected-for-placement {
    background: rgba(76, 175, 80, 0.2) !important;
}

.game-block-preview.selected-for-placement {
    animation: selected-pulse 1.5s infinite;
}

@keyframes selected-pulse {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
    }
    50% { 
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.9);
    }
}

/* Long-press feedback for mobile */
.block-slot.long-press-active {
    border: 2px solid #ff6b6b !important;
    background: rgba(255, 107, 107, 0.1) !important;
    animation: long-press-pulse 0.8s ease-out;
}

@keyframes long-press-pulse {
    0% { 
        border-color: #ff6b6b;
        box-shadow: 0 0 0 rgba(255, 107, 107, 0.4);
    }
    100% { 
        border-color: #ff6b6b;
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
    }
}

.drag-block {
    display: grid;
    gap: 2px;
    pointer-events: none;
    padding: 2px;
    background: rgba(26, 26, 26, 0.9);
    border-radius: 6px;
}

.drag-cell {
    width: 18px;
    height: 18px;
    background: #4a90e2;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.4);
    border: 1px solid #5ba0f2;
}

.drag-cell-empty {
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.grid-cell.drop-valid {
    background: #28a745 !important;
    border-color: #34ce57 !important;
    animation: dropPulse 0.5s infinite alternate;
}

.grid-cell.drop-invalid {
    background: #dc3545 !important;
    border-color: #e74c3c !important;
    animation: invalidPulse 0.5s infinite alternate;
}

@keyframes dropPulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

@keyframes invalidPulse {
    from { opacity: 0.5; }
    to { opacity: 0.8; }
}

.blocks-panel {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.blocks-panel h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
    text-align: center;
}

.mini-grid {
    display: inline-grid;
    gap: 1px;
    align-items: center;
    justify-items: center;
}

.mini-grid.vertical {
    grid-template-columns: 1fr;
    gap: 1px;
}

.mini-grid.square2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
}

.mini-grid.square3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-grid.L2x2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
}

.mini-grid.L3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-grid.T3x2 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
}

.mini-grid.T2x3 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-grid.Z3x2 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1px;
}

.mini-grid.Z2x3 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-grid.plus3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-grid.corner3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
}

.mini-cell {
    width: 10px;
    height: 10px;
    background: #555555;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.mini-cell.filled {
    background: #4a90e2;
    box-shadow: 0 1px 3px rgba(74, 144, 226, 0.3);
}

.selected-blocks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.selected-block {
    background: #333333;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 2px solid #404040;
    transition: all 0.2s ease;
}

.selected-block.has-block {
    border-color: #4a90e2;
    background: #1a3a5c;
}

.selected-block span {
    font-weight: 500;
    color: #cccccc;
}

.block-preview {
    min-width: 40px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.get-move-btn {
    width: 100%;
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: #ffffff;
    border: none;
    border-radius: 15px;
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.get-move-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.get-move-btn:active {
    transform: translateY(0);
}

.run-btn {
    width: 100%;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
    transform: translateZ(0);
    will-change: transform;
}

.run-btn:hover {
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
    background: linear-gradient(135deg, #e55a2b, #e6851a);
}

.run-btn:active {
    transform: translateY(0) translateZ(0);
}

.block-drawing-section {
    background: #333333;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.block-drawing-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #ffffff;
}

.drawing-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;
    width: 220px;
    height: 220px;
    margin: 0 auto 15px;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 8px;
}

.drawing-cell {
    background: #555555;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #666666;
    min-width: 22px;
    min-height: 22px;
}

.drawing-cell:hover {
    background: #666666;
    transform: scale(1.05);
}

.drawing-cell.filled {
    background: #4a90e2;
    border-color: #5ba0f2;
    box-shadow: 0 2px 6px rgba(74, 144, 226, 0.4);
    transform: scale(1.02);
}

.drawing-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.draw-btn {
    background: #555555;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.draw-btn:hover {
    background: #666666;
    transform: translateY(-1px);
}

.draw-btn.primary {
    background: #4a90e2;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.draw-btn.primary:hover {
    background: #357abd;
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.suggestions-section {
    margin-top: 25px;
    background: #333333;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    transform: translateZ(0);
    will-change: transform;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.suggestions-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    flex: 1;
}

.suggestions-header .get-move-btn {
    margin: 0;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 120px;
    max-width: 140px;
}

.moves-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

.moves-list::-webkit-scrollbar {
    width: 6px;
}

.moves-list::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 3px;
}

.moves-list::-webkit-scrollbar-thumb {
    background: #555555;
    border-radius: 3px;
}

.moves-list::-webkit-scrollbar-thumb:hover {
    background: #666666;
}

.no-moves {
    color: #888888;
    text-align: center;
    font-style: italic;
    margin: 40px 0;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 10px;
    border: 2px dashed #444444;
}

.move-suggestion {
    background: linear-gradient(135deg, #404040, #383838);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    transform: translateZ(0);
    will-change: transform, background;
}

.move-suggestion:hover {
    background: linear-gradient(135deg, #4a4a4a, #424242);
    transform: translateY(-3px) translateZ(0);
    border-color: #4a90e2;
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.2);
}

.move-suggestion.active {
    border-color: #ff3b30;
    background: linear-gradient(135deg, #2a1a1a, #3a1515);
    box-shadow: 0 8px 25px rgba(255, 59, 48, 0.3);
    transform: translateY(-2px) translateZ(0);
}

.move-score {
    font-size: 20px;
    font-weight: bold;
    color: #4a90e2;
    margin-bottom: 8px;
    text-shadow: 0 1px 3px rgba(74, 144, 226, 0.3);
}

.move-details {
    color: #cccccc;
    font-size: 14px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.move-block-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

.move-block-preview span {
    color: #888888;
    font-size: 12px;
    font-weight: 500;
}

.preview-mini {
    display: inline-grid;
    gap: 1px;
    margin: 2px;
}

.preview-mini.vertical {
    grid-template-columns: 1fr;
}

.preview-mini.grid2x2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.preview-mini.grid3x3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.preview-cell {
    width: 8px;
    height: 8px;
    background: #555555;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.preview-cell.filled {
    background: #4a90e2;
    box-shadow: 0 1px 2px rgba(74, 144, 226, 0.3);
}

.selected-block.used {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .grid {
        width: 320px;
        height: 320px;
    }
    
    .container {
        padding: 15px;
    }
    
    .block-selector {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-blocks {
        gap: 20px;
        margin-top: 30px;
    }
    
    .block-slot {
        width: 85px;
        height: 85px;
        /* Make blocks larger on mobile for easier touch interaction */
    }
}

/* Social Links */
.social-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #333;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.social-link:hover {
    transform: translateY(-2px);
    background: #4a90e2;
    border-color: #4a90e2;
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.4);
}

.social-link svg {
    transition: transform 0.3s ease;
}

.social-link:hover svg {
    transform: scale(1.1);
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 50px;
    border-top: 1px solid #333;
    background: #1a1a1a;
}

.footer p {
    font-size: 14px;
    color: #888;
    font-weight: 400;
}

.flash {
    color: #4a90e2;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    position: relative;
}

.flash::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: #4a90e2;
    transition: width 0.3s ease;
}

.flash:hover::after {
    width: 100%;
}

/* Responsive adjustments for social links */
@media (max-width: 768px) {
    .social-links {
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .social-link {
        width: 35px;
        height: 35px;
    }
    
    .social-link svg {
        width: 18px;
        height: 18px;
    }
    
    .footer {
        padding: 20px;
        margin-top: 30px;
    }
    
    .footer p {
        font-size: 12px;
    }
}

/* Guide Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #2a2a2a;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideInUp 0.3s ease;
}

.modal-header {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 20px 30px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.close-modal {
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.close-modal:hover {
    opacity: 1;
}

.modal-body {
    padding: 30px;
    color: #ffffff;
}

.guide-step {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: #3a3a3a;
    border-radius: 15px;
    transition: transform 0.2s ease;
}

.guide-step:hover {
    transform: translateY(-2px);
}

.step-number {
    background: #4CAF50;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    flex-shrink: 0;
}

.step-content h3 {
    margin: 0 0 10px 0;
    color: #4CAF50;
    font-size: 18px;
    font-weight: 600;
}

.step-content p {
    margin: 0;
    line-height: 1.6;
    color: #cccccc;
}

.step-content strong {
    color: #ffffff;
}

.modal-footer {
    padding: 20px 30px;
    text-align: center;
    border-top: 1px solid #444;
}

.guide-close-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.guide-close-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Guide Button */
@media (max-width: 768px) {
    .guide-btn {
        top: 10px;
        right: 10px;
        padding: 10px 16px;
        font-size: 12px;
    }
    
    .guide-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .modal-content {
        margin: 2% auto;
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .guide-step {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .step-number {
        align-self: center;
    }
}
