/* --- Root Variables --- */
:root {
    --console-bg: #2e1a26; /* Deep Pink/Purpleish console base */
    --console-darker-bg: #1f101a;
    --screen-bg: #180f15;
    --screen-bezel: #442c38;
    --button-main-color: #ff00cc; /* Neon Pink */
    --button-main-press-color: #b0008d;
    --button-dpad-color: #583b4e; 
    --button-dpad-press-color: #402a39;
    --text-color: #f0f0f0;
    --accent-color: #ff00cc;
    --highlight-color: #00d2ff; /* Cyan for selection/contrast */
    --pixel-font: 'Press Start 2P', cursive;
    
    /* Board Colors */
    --tile-bg: #3a2a35;
    --tile-border: #6a4a5e;
}

/* --- Body & Background --- */
html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; }
body {
    margin: 0; font-family: var(--pixel-font), sans-serif;
    background: linear-gradient(160deg, #180f15 0%, #2e1a26 30%, #442c38 70%, #1f101a 100%);
    background-size: 400% 400%; animation: cosmicShift 45s ease-in-out infinite alternate;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden; color: var(--text-color); position: relative;
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
@keyframes cosmicShift { 0% { background-position: 0% 0%; } 100% { background-position: 100% 100%; } }
#particles-js-match { position: absolute; width: 100%; height: 100%; top: 0; left: 0; z-index: 0; pointer-events: none; }

/* --- Background Decor --- */
.background-decor-match { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: 1; pointer-events: none; }
.decor-grid-pattern { position: absolute; top: 50%; left: 0; width: 100%; height: 50%; background-image: repeating-linear-gradient(var(--accent-color) 0 1px, transparent 1px 100%), repeating-linear-gradient(90deg, var(--accent-color) 0 1px, transparent 1px 100%); background-size: 50px 50px; opacity: 0.03; transform: perspective(300px) rotateX(45deg) scale(1.5); transform-origin: 50% 0; animation: scrollGrid 20s linear infinite; }
@keyframes scrollGrid { from { background-position-y: 0; } to { background-position-y: -50px; } }

/* --- Game Console Base Styles --- */
.game-console {
    width: 700px;
    min-height: 850px;
    max-height: 95vh;
    padding: 25px; border-width: 3px; position: relative; z-index: 2;
    background-color: var(--console-bg); border-radius: 25px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), inset 0 0 15px rgba(255,255,255,0.03), inset 0 5px 12px rgba(0,0,0,0.25);
    display: flex; flex-direction: column; align-items: center;
    border-style: solid; border-color: var(--console-darker-bg);
    font-family: var(--pixel-font), sans-serif;
    flex-shrink: 1; height: auto;
}

.console-top { width: 100%; margin-bottom: 20px; text-align: center; flex-shrink: 0; }
.brand { font-size: 2em; color: var(--accent-color); text-shadow: 0 0 5px var(--accent-color), 0 0 10px var(--accent-color), 2px 2px 2px #000; }

/* Screen Area */
.console-screen-area {
    display: flex; width: 100%; align-items: stretch; gap: 15px;
    flex-grow: 1; min-height: 0; flex-direction: row;
}

.game-screen-bezel {
    background-color: var(--screen-bezel); padding: 8px; border-radius: 6px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.6);
    flex: 1; display: flex; min-width: 0;
}

.game-screen {
    background-color: var(--screen-bg); position: relative;
    border: 2px solid var(--console-darker-bg); overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    flex: 1; border-radius: 4px; min-height: 400px;
}

#matchCanvas {
    display: block; image-rendering: pixelated;
    width: 100%; height: 100%;
}

/* Info Panel */
.info-panel {
    flex-grow: 0; flex-shrink: 0; width: 170px;
    display: flex; flex-direction: column; justify-content: space-around;
    padding: 15px 12px; background-color: var(--console-darker-bg);
    border-radius: 6px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    text-align: center; border: 2px solid #101018;
}
.info-section h4 { margin: 0 0 6px 0; font-size: 0.8em; color: var(--accent-color); text-transform: uppercase; letter-spacing: 1px; }
.info-section p { margin: 0; font-size: 1.1em; color: var(--text-color); line-height: 1.2; background-color: var(--screen-bg); padding: 7px 8px; border-radius: 3px; display: block; border: 1px solid var(--screen-bezel); }

/* Game Overlays */
.game-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(24, 15, 21, 0.92); display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; text-align: center; padding: 20px; z-index: 10; font-family: var(--pixel-font), sans-serif; touch-action: none; }
.message-content { background-color: var(--console-darker-bg); border: 2px solid var(--accent-color); padding: 25px 30px; border-radius: 4px; box-shadow: 0 0 15px var(--accent-color), inset 0 0 10px rgba(255, 0, 204, 0.2); }
.game-overlay p { font-size: 1.2em; margin-top: 0; margin-bottom: 18px; line-height: 1.5; color: var(--text-color);}
.game-overlay p.controls-hint { font-size: 0.75em; color: #aaa; margin-bottom: 22px;}
.game-overlay button { padding: 12px 25px; font-family: var(--pixel-font); background-color: var(--button-main-color); color: #000; border: none; border-radius: 3px; cursor: pointer; font-size: 1em; text-shadow: none; box-shadow: 0 3px 0px var(--button-main-press-color), 0 0 8px rgba(255, 0, 204, 0.5); transition: all 0.1s ease-out; font-weight: bold; }
.game-overlay button:hover { background-color: #ff33db; box-shadow: 0 3px 0px var(--button-main-press-color), 0 0 12px rgba(255, 0, 204, 0.7); }
.game-overlay button:active { transform: translateY(2px); box-shadow: 0 1px 0px var(--button-main-press-color), 0 0 5px rgba(255, 0, 204, 0.4); }

/* --- Controls --- */
.console-controls {
    display: flex; justify-content: center; align-items: center;
    width: 100%; padding: 0 20px; margin-top: 20px; flex-shrink: 0;
}
.action-buttons { display: flex; gap: 20px; }

/* D-Pad Visualization */
.d-pad-visual {
    width: 100px; height: 100px; position: relative; opacity: 0.8;
}
.d-pad-btn {
    position: absolute; width: 30px; height: 30px; background-color: var(--button-dpad-color);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5); border-radius: 4px;
}
.d-pad-btn.up { top: 0; left: 35px; }
.d-pad-btn.down { bottom: 0; left: 35px; }
.d-pad-btn.left { top: 35px; left: 0; }
.d-pad-btn.right { top: 35px; right: 0; }
.d-pad-center { top: 35px; left: 35px; width: 30px; height: 30px; background-color: var(--button-dpad-color); position: absolute; }


.control-button.action-button {
    width: 80px; height: 80px; border-radius: 50%;
    background-color: var(--button-main-color);
    border: 4px solid var(--console-darker-bg);
    box-shadow: 0 6px 0 var(--button-main-press-color), 0 10px 10px rgba(0,0,0,0.3);
    cursor: pointer; position: relative; transition: all 0.1s;
    display: flex; justify-content: center; align-items: center;
}
.control-button.action-button:active, .control-button.action-button.active-touch {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--button-main-press-color), 0 5px 5px rgba(0,0,0,0.3);
}
.control-button.action-button i { font-size: 24px; color: #222; }

/* Console Bottom */
.console-bottom { width: 100%; margin-top: 20px; display: flex; justify-content: center; flex-shrink: 0; }
.speaker-grill { display: flex; gap: 6px; }
.speaker-grill span { width: 10px; height: 36px; background-color: var(--console-darker-bg); border-radius: 2px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.6); }

/* --- Mobile Optimizations --- */
@media (max-width: 768px) and (orientation: portrait) {
    body { height: 100svh; overflow: hidden; }
    .game-console {
        width: 100%; height: 100svh; border-radius: 0; border: none;
        padding: 10px; min-height: 0;
        display: flex; flex-direction: column; justify-content: flex-start;
    }
    .console-top { margin-bottom: 10px; }
    .brand { font-size: 1.5em; }
    .console-screen-area {
        flex-direction: column; width: 100%; flex-grow: 1;
        margin-bottom: 10px; overflow: hidden; min-height: 0; order: 1; gap: 0;
    }
    .game-screen-bezel { width: 100%; flex: 1; padding: 5px; margin-right: 0; }
    .game-screen { width: 100%; height: 100%; min-height: 0; }

    .info-panel {
        width: 100%; flex-direction: row; flex-wrap: wrap;
        justify-content: space-around; padding: 8px; gap: 5px 10px;
        flex-grow: 0; flex-shrink: 0; order: 2;
        border-radius: 4px; border-width: 1px;
    }
    .info-section { text-align: center; flex-basis: auto; }
    .info-section h4 { font-size: 0.7em; margin-bottom: 3px; }
    .info-section p { font-size: 0.9em; padding: 4px 6px; }

    .console-controls {
        width: 100%; padding: 10px 15px; margin-top: auto;
        order: 3; justify-content: space-between;
    }
    .console-bottom { margin-top: 15px; order: 4; padding-bottom: 10px;}
}
