:root {
--bg-color: #1a1a1e;
--grid-bg: #0c0c0f;
--panel-bg: #2a2a32;
--accent: #e74c3c;
--btn-bg: #34343d;
--led-color: #00ffcc;
}

body {
background-color: var(--bg-color);
color: white;
font-family: 'Segoe UI', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
touch-action: none;
width: 100vw;
/* FIX: Prevents text selection globally */
user-select: none;
-webkit-user-select: none;
}

/* NEW: Neon Header */
.game-header {
font-size: 32px;
font-weight: 900;
text-transform: uppercase;
letter-spacing: 5px;
margin-bottom: 10px;
color: white;
text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 20px var(--accent), 0 0 40px var(--accent);
}

/* NEW: Footer */
.game-footer {
margin-top: 15px;
font-size: 10px;
color: #666;
letter-spacing: 2px;
text-transform: uppercase;
}

.container {
display: flex;
gap: 12px;
padding: 15px;
background: var(--panel-bg);
border-radius: 12px;
box-shadow: 0 20px 50px rgba(0,0,0,0.6);
position: relative;
border: 1px solid rgba(255, 255, 255, 0.05);
transform-origin: center;
}

@media screen and (max-width: 450px) { .container { transform: scale(0.85); } }
@media screen and (max-width: 380px) { .container { transform: scale(0.75); } }
@media screen and (max-height: 600px) { .container { transform: scale(0.7); } }

.side-panel {
display: flex;
flex-direction: column;
align-items: center;
width: 110px;
height: 400px;
}

.hold-section, .stat-box {
background: #1e1e24;
padding: 10px;
border-radius: 8px;
border: 1px solid #444;
box-shadow: inset 2px 2px 5px rgba(0,0,0,0.8), 1px 1px 0px rgba(255,255,255,0.05);
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
margin-bottom: 12px;
position: relative;
overflow: hidden;
}

.hold-section::after, .stat-box::after {
content: "";
position: absolute;
top: 0; left: 0;
width: 100%; height: 50%;
background: linear-gradient(rgba(255,255,255,0.03), transparent);
pointer-events: none;
}

.label {
font-size: 10px;
font-weight: bold;
margin-bottom: 5px;
color: #888;
letter-spacing: 1px;
text-transform: uppercase;
}

.stat-box span {
font-size: 16px;
font-weight: bold;
display: block;
color: var(--led-color);
text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
font-family: 'Courier New', Courier, monospace;
}

.grid-container {
position: relative;
width: 200px;
height: 400px;
}

.grid {
width: 100%;
height: 100%;
display: flex;
flex-wrap: wrap;
background-color: var(--grid-bg);
border: 4px solid #333;
box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
overflow: hidden;
}

.grid div, .mini-grid div, .hold-grid div {
height: 20px;
width: 20px;
box-sizing: border-box;
}

.tetromino {
border: 3px solid;
border-top-color: rgba(255,255,255,0.5);
border-left-color: rgba(255,255,255,0.3);
border-right-color: rgba(0,0,0,0.3);
border-bottom-color: rgba(0,0,0,0.5);
}

.mini-grid, .hold-grid {
width: 80px;
height: 80px;
display: flex;
flex-wrap: wrap;
background-color: var(--grid-bg);
border: 2px solid #111;
box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.game-info {
margin: 5px 0;
width: 100%;
display: flex;
flex-direction: column;
gap: 4px;
}

.stat-box p { font-size: 9px; margin: 0; color: #aaa; }

.side-controls {
margin-top: auto;
display: grid;
grid-template-areas:
". up ."
"left . right"
". down .";
gap: 4px;
background: rgba(0,0,0,0.4);
padding: 8px;
border-radius: 12px;
border: 1px solid rgba(255,255,255,0.05);
box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.control-btn, .mini-btn, #start-button {
color: white;
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.05s ease;
/* FIX: The following lines stop the copy/paste menu */
-webkit-touch-callout: none !important;
-webkit-tap-highlight-color: transparent;
outline: none;
}

.control-btn {
width: 30px;
height: 30px;
font-size: 12px;
background: var(--btn-bg);
border-radius: 4px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-left: 1px solid rgba(255, 255, 255, 0.05);
border-bottom: 3px solid rgba(0, 0, 0, 0.7);
border-right: 1px solid rgba(0, 0, 0, 0.4);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#rotate { grid-area: up; }
#left { grid-area: left; }
#right { grid-area: right; }
#down { grid-area: down; height: 30px; }

.control-btn:active, .mini-btn:active, #start-button:active {
transform: translateY(1.5px);
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
background: var(--accent);
color: white;
}

.mini-btn {
width: 100%;
height: 34px;
margin-top: 8px;
font-size: 11px;
font-weight: 800;
border-radius: 6px;
background: var(--btn-bg);
border-top: 1px solid rgba(255, 255, 255, 0.1);
border-bottom: 3px solid rgba(0, 0, 0, 0.6);
}

#start-button {
margin-top: 15px;
width: 100%;
padding: 12px 5px;
background: var(--accent);
border-radius: 4px;
font-weight: bold;
font-size: 11px;
text-transform: uppercase;
border-top: 1px solid rgba(255, 255, 255, 0.2);
border-bottom: 4px solid rgba(0, 0, 0, 0.5);
}

.speed-container {
margin: 10px 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}

.speed-bar-bg {
width: 14px;
height: 50px;
background: #111;
border: 1px solid #444;
border-radius: 3px;
position: relative;
overflow: hidden;
box-shadow: inset 0 0 5px #000;
}

#speed-fill {
position: absolute;
bottom: 0;
width: 100%;
height: 0%;
background: linear-gradient(to top, #00ffcc, #f1c40f, #e74c3c);
transition: height 0.3s ease;
}

#game-over-overlay {
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
width: 150px;
padding: 20px;
background: rgba(26, 26, 30, 0.98);
border: 2px solid var(--accent);
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.8);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
backdrop-filter: blur(4px);
text-align: center;
}

.blink {
animation: arcadeBlink 0.8s infinite;
color: var(--accent);
font-size: 14px;
font-weight: 900;
margin-bottom: 5px;
text-transform: uppercase;
}

#game-over-overlay p { font-size: 10px; margin: 4px 0; color: #888; }
#final-score { font-size: 22px; color: var(--led-color); font-family: 'Courier New', monospace; margin-bottom: 12px; }
#restart-btn { width: 100%; padding: 8px; font-size: 10px; background: var(--btn-bg); border-bottom: 2px solid #000; }

@keyframes arcadeBlink {
0%, 100% { opacity: 1; text-shadow: 0 0 10px var(--accent); }
50% { opacity: 0.3; text-shadow: none; }
}

.hidden { display: none !important; }

.particle {
position: absolute;
width: 6px; height: 6px;
pointer-events: none;
border-radius: 2px;
z-index: 100;
animation: particleBurst 0.6s cubic-bezier(0, .9, .57, 1) forwards;
}

@keyframes particleBurst {
0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; }
}

.clearing {
animation: lineClear 0.4s ease-in-out forwards;
pointer-events: none;
}

@keyframes lineClear {
0% { transform: scale(1); opacity: 1; filter: brightness(2); }
100% { transform: scale(0); opacity: 0; }
}

.floor { visibility: hidden; }