/**
 * style.css - AAA Professional Game Styling with Transitions
 * 
 * UPDATED: 
 * - Removed CSS scaling completely
 * - Dynamic canvas sizing support
 * - Clean centered positioning
 * - Mobile-first responsive design
 * - FIXED: Guide panel now centers in left space
 * - ADDED: Canvas transition support
 */

/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: #000;
    color: #fff;
    font-family: monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* Prevent mobile browser behaviors */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ============ CANVAS - CRYSTAL CLEAR ============ */
#bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#game {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    object-fit: contain;
    object-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    display: block;
    /* Smooth transitions for blur effects */
    transition: filter 0.3s ease-out;
}

/* ============ UI CONTAINER ============ */
#ui-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#ui-container > * {
    pointer-events: auto;
}

/* ============ TOUCH CONTROLS ============ */
#touch-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: none;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
}

/* Show touch controls ONLY when JavaScript adds the class */
body.touch-device #touch-controls {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
}

.touch-left,
.touch-center,
.touch-right {
    display: flex;
    gap: 10px;
}

.touch-bottom {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.touch-btn {
    background: rgba(138, 43, 226, 0.8);
    border: 2px solid #8A2BE2;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(155, 48, 255, 0.9);
    transform: scale(0.95);
}

/* Larger buttons for drop and hold */
.touch-bottom .touch-btn {
    width: 100px;
    height: 50px;
    font-size: 16px;
}

/* ============ ERROR MESSAGE ============ */
.error-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ff0000;
    color: #fff;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(255, 0, 0, 0.3);
    z-index: 9999;
    text-align: center;
}

.error-message button {
    margin-top: 15px;
    padding: 10px 20px;
    background: #fff;
    color: #ff0000;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.error-message button:hover {
    background: #ffcccc;
}

/* ============ GUIDE PANEL - VISUAL THEME ONLY ============ */
.guide-panel {
    position: fixed;
    background: transparent;
    color: rgba(255, 255, 255, 0.1);
    font-family: monospace;
    font-size: 14px;
    line-height: 1.6;
    z-index: 5;
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    pointer-events: auto;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Hide scrollbar initially */
.guide-panel::-webkit-scrollbar {
    width: 0;
    transition: width 0.3s ease;
}

/* Initial state - just "GUIDE" visible */
.guide-panel .guide-header {
    font-size: 20px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

/* Rest of content invisible until hover */
.guide-panel .guide-section {
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

/* Hover state - VISUAL THEME ONLY */
.guide-panel.visible,
.guide-panel:hover {
    background: rgba(0, 0, 0, 0.9);
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 
        inset 0 0 50px rgba(255, 255, 255, 0.1),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 40px rgba(255, 255, 255, 0.1);
}

/* Show scrollbar on hover */
.guide-panel:hover::-webkit-scrollbar {
    width: 6px;
}

.guide-panel.visible .guide-header,
.guide-panel:hover .guide-header {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.guide-panel.visible .guide-section,
.guide-panel:hover .guide-section {
    opacity: 1;
    display: block;
}

/* Stagger the section animations */
.guide-panel .guide-section:nth-child(2) { transition-delay: 0.05s; }
.guide-panel .guide-section:nth-child(3) { transition-delay: 0.1s; }
.guide-panel .guide-section:nth-child(4) { transition-delay: 0.15s; }
.guide-panel .guide-section:nth-child(5) { transition-delay: 0.2s; }
.guide-panel .guide-section:nth-child(6) { transition-delay: 0.25s; }

.guide-section {
    margin-bottom: 20px;
}

.guide-section h3 {
    color: #8A2BE2;
    font-size: 14px;
}

.guide-panel:hover .guide-section h3 {
    color: #ffffff;
    text-shadow: 0 0 5px #8A2BE2;
}

.guide-section p {
    margin: 0 0 10px 0;
}

.guide-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-section li {
    margin-bottom: 5px;
    padding-left: 15px;
}

.guide-icon {
    display: inline-block;
    width: 20px;
    font-weight: bold;
    color: #FFD700;
}

.guide-key {
    display: inline-block;
    background: rgba(138, 43, 226, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.guide-panel:hover .guide-key {
    background: rgba(138, 43, 226, 0.5);
    box-shadow: 0 0 5px rgba(138, 43, 226, 0.5);
}

/* Hide guide panel on small screens */
@media (max-width: 1199px) {
    .guide-panel {
        display: none;
    }
}

/* ============ MOBILE GUIDE BUTTON ============ */
.guide-mobile-button {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(138, 43, 226, 0.9);
    border: 2px solid #8A2BE2;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 50;
    display: none;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(138, 43, 226, 0.3);
}

.guide-mobile-button:hover {
    background: #8A2BE2;
    transform: scale(1.1);
}

@media (max-width: 1199px) {
    .guide-mobile-button {
        display: block;
    }
}

/* ============ MOBILE GUIDE MODAL ============ */
.guide-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.guide-modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.guide-modal-content {
    background: #000;
    border: 2px solid #8A2BE2;
    border-radius: 10px;
    padding: 30px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 30px rgba(138, 43, 226, 0.5);
}

.guide-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #8A2BE2;
    font-size: 30px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.guide-modal-close:hover {
    color: #fff;
    transform: rotate(90deg);
}

/* Mobile modal uses same content styles */
.guide-modal .guide-section h3 {
    color: #fff;
}

.guide-modal .guide-key {
    background: rgba(138, 43, 226, 0.5);
}

/* ============ STATS PANEL ============ */
.stats-panel {
    position: fixed;
    background: transparent;
    color: rgba(255, 255, 255, 0.1);
    font-family: monospace;
    font-size: 14px;
    line-height: 1.6;
    z-index: 5;
    transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    pointer-events: auto;
    overflow-y: auto;
    overflow-x: hidden;
}

.stats-panel::-webkit-scrollbar {
    width: 0;
    transition: width 0.3s ease;
}

.stats-panel .stats-header {
    font-size: 20px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

.stats-panel .stats-section {
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.stats-panel.visible,
.stats-panel:hover {
    background: rgba(0, 0, 0, 0.9);
    color: rgba(255, 255, 255, 0.9);
    box-shadow: 
        inset 0 0 50px rgba(255, 255, 255, 0.1),
        0 0 20px rgba(255, 255, 255, 0.2),
        0 0 40px rgba(255, 255, 255, 0.1);
}

.stats-panel:hover::-webkit-scrollbar {
    width: 6px;
}

.stats-panel.visible .stats-header,
.stats-panel:hover .stats-header {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.stats-panel.visible .stats-section,
.stats-panel:hover .stats-section {
    opacity: 1;
    display: block;
}

.stats-section {
    margin-bottom: 20px;
}

.stats-section h3 {
    color: #8A2BE2;
    font-size: 14px;
}

.stats-panel:hover .stats-section h3 {
    color: #ffffff;
    text-shadow: 0 0 5px #8A2BE2;
}

.stats-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats-section li {
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.stat-value {
    color: #FFD700;
    font-weight: bold;
}

/* ============ ANIMATIONS ============ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ MOBILE RESPONSIVE ============ */
@media (max-width: 768px) {
    .guide-mobile-button {
        top: 10px;
        left: 10px;
    }
}

/* Touch control sizing for actual touch devices */
body.touch-device .touch-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
}

body.touch-device .touch-bottom .touch-btn {
    width: 80px;
    height: 45px;
    font-size: 14px;
}

/* Small phones */
@media (max-width: 480px) {
    body.touch-device #touch-controls {
        padding: 5px;
    }
    
    body.touch-device .touch-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    body.touch-device .touch-bottom .touch-btn {
        width: 70px;
        height: 40px;
        font-size: 12px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 600px) {
    body.touch-device #touch-controls {
        background: rgba(0, 0, 0, 0.3);
        padding: 5px;
    }
    
    body.touch-device .touch-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    body.touch-device .touch-bottom {
        margin-top: 5px;
    }
    
    body.touch-device .touch-bottom .touch-btn {
        width: 60px;
        height: 35px;
        font-size: 11px;
    }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #8A2BE2;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9A3BF2;
}

/* ============ SCROLLBAR FOR GUIDE ============ */
.guide-panel::-webkit-scrollbar,
.guide-modal-content::-webkit-scrollbar {
    width: 6px;
}

.guide-panel::-webkit-scrollbar-track,
.guide-modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.guide-panel::-webkit-scrollbar-thumb,
.guide-modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.guide-panel:hover::-webkit-scrollbar-thumb,
.guide-modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============ SCROLLBAR FOR STATS PANEL ============ */
.stats-panel::-webkit-scrollbar {
    width: 6px;
}

.stats-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.stats-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.stats-panel:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

/* ============ FOCUS STATES ============ */
button:focus,
input:focus {
    outline: 2px solid #8A2BE2;
    outline-offset: 2px;
}

/* ============ LOADING STATE ============ */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #8A2BE2;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* ============ DEBUG MODE ============ */
.debug-overlay {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    font-family: monospace;
    font-size: 12px;
    color: #0f0;
    pointer-events: none;
}

.debug-grid {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1;
    fill: none;
}

/* ============ PREVENT PULL-TO-REFRESH ============ */
body {
    overscroll-behavior-y: none;
}