@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 300; src: url('/fonts/inter-v20-latin-300.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 400; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 600; src: url('/fonts/inter-v20-latin-600.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 700; src: url('/fonts/inter-v20-latin-700.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Orbitron'; font-style: normal; font-weight: 400; src: url('/fonts/orbitron-v35-latin-regular.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Orbitron'; font-style: normal; font-weight: 600; src: url('/fonts/orbitron-v35-latin-600.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Orbitron'; font-style: normal; font-weight: 700; src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2');}

:root { 
    --menu-width: 200px; 
    --accent-color: #00C9FF; 
    --text-muted: #a0aec0;
    --gap-size: 12px;
}
html, body { height: 100vh; width: 100%; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background-color: #0f172a; margin: 0; padding: 0; box-sizing: border-box; color: #e2e8f0; display: flex; flex-direction: row; }
body::before { content: ''; position: absolute; top:0; left:0; width:100%; height:100%; background: radial-gradient(circle at center, rgba(0,201,255,0.05) 0%, transparent 70%); z-index: -1;}

.left-menu { width: var(--menu-width); min-width: var(--menu-width); height: 100vh; position: fixed; top: 0; left: 0; background: rgba(10, 10, 10, 0.9); box-shadow: 2px 0 15px rgba(0, 0, 0, 0.5); padding: 0 20px; box-sizing: border-box; z-index: 1001; font-family: 'Orbitron', sans-serif; font-weight: 600; display: flex; flex-direction: column; justify-content: center; overflow-y: auto; }
.left-menu ul { list-style: none; padding: 0; margin: 0; } .left-menu li { margin-bottom: 20px; }
.left-menu a { font-size: 26px; font-weight: normal; color: var(--accent-color); text-shadow: 0 0 2px var(--accent-color); text-decoration: none; display: block; padding: 8px 0; transition: all 0.3s ease; }
.left-menu a:hover, .left-menu a:focus { color: #fff; text-shadow: 0 0 8px #fff, 0 0 12px rgba(255, 255, 255, 0.5); outline: none; transform: translateX(5px);}
.left-menu a.active-page-link { color: #fff; text-shadow: 0 0 8px #fff, 0 0 12px rgba(255, 255, 255, 0.7); background-color: rgba(0, 190, 255, 0.15); border-radius: 8px; padding-left: 15px; padding-right: 15px; }

.main-content-wrapper { flex-grow: 1; margin-left: var(--menu-width); padding: 40px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; box-sizing: border-box; overflow-y: auto; }
.mobile-header, .menu-overlay { display: none; }

.breadcrumbs { width: 100%; max-width: 1200px; margin-bottom: 1rem; align-self: flex-start; } 
.breadcrumbs ol { display: flex; list-style: none; padding: 0; margin: 0; font-size: 0.9rem; color: var(--text-muted); } 
.breadcrumbs li:not(:last-child)::after { content: '>'; margin: 0 0.75rem; } 
.breadcrumbs a { color: var(--text-muted); text-decoration: none; transition: color 0.2s;} 
.breadcrumbs a:hover { color: var(--accent-color); }

.game-page-content { display: flex; flex-direction: column; align-items: center; gap: 30px; width: 100%; max-width: 600px; }
.game-2048-container { background-color: #1e293b; border-radius: 1.5rem; padding: 2rem; box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(0,201,255,0.05); border: 1px solid rgba(0,201,255,0.15); display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; max-width: 500px; box-sizing: border-box; }

.header-container { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 450px; margin-bottom: 10px; }
.game-2048-container h1 { font-family: 'Orbitron', sans-serif; font-size: 3.5rem; color: var(--accent-color); text-shadow: 0 0 10px rgba(0, 201, 255, 0.6); margin: 0; line-height: 1;}
.score-container { display: flex; gap: 10px; font-family: 'Inter', sans-serif; font-size: 0.9rem; color: #94a3b8; text-transform: uppercase; font-weight: 700; letter-spacing: 1px;}
.score-box { background-color: #0f172a; padding: 8px 15px; border-radius: 8px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); text-align: center; border: 1px solid #334155; }
.score-box span { display: block; font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: #fff; text-shadow: 0 0 5px var(--accent-color); margin-top: 3px; }

/* The Board */
.game-board { 
    position: relative;
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    grid-template-rows: repeat(4, 1fr); 
    gap: var(--gap-size); 
    width: 100%; 
    max-width: 450px; 
    aspect-ratio: 1 / 1; 
    background-color: #0f172a; 
    border-radius: 12px; 
    padding: var(--gap-size); 
    box-shadow: 0 0 20px rgba(0, 201, 255, 0.15), inset 0 0 15px rgba(0,0,0,0.8); 
    border: 2px solid #334155;
    box-sizing: border-box;
    user-select: none; 
    touch-action: none; 
}
.grid-cell { background-color: #1e293b; border-radius: 8px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }

/* The Tiles Layer */
.tile-container { position: absolute; top: var(--gap-size); left: var(--gap-size); right: var(--gap-size); bottom: var(--gap-size); z-index: 10; pointer-events: none; }
.tile { 
    position: absolute; 
    display: flex; justify-content: center; align-items: center; 
    font-family: 'Orbitron', sans-serif; font-size: 2.2rem; font-weight: 700; 
    border-radius: 8px; 
    transition: top 120ms ease-in-out, left 120ms ease-in-out, transform 120ms ease-in-out; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); 
    /* Size Calc: (100% container width - 3 gaps) / 4 tiles */
    width: calc((100% - (3 * var(--gap-size))) / 4);
    height: calc((100% - (3 * var(--gap-size))) / 4);
}

/* Position Classes for buttery sliding (Pure CSS Math) */
.col-1 { left: 0; }
.col-2 { left: calc(((100% - (3 * var(--gap-size))) / 4) * 1 + var(--gap-size) * 1); }
.col-3 { left: calc(((100% - (3 * var(--gap-size))) / 4) * 2 + var(--gap-size) * 2); }
.col-4 { left: calc(((100% - (3 * var(--gap-size))) / 4) * 3 + var(--gap-size) * 3); }

.row-1 { top: 0; }
.row-2 { top: calc(((100% - (3 * var(--gap-size))) / 4) * 1 + var(--gap-size) * 1); }
.row-3 { top: calc(((100% - (3 * var(--gap-size))) / 4) * 2 + var(--gap-size) * 2); }
.row-4 { top: calc(((100% - (3 * var(--gap-size))) / 4) * 3 + var(--gap-size) * 3); }

/* Value Classes */
.val-2 { background-color: #334155; color: #cbd5e1; }
.val-4 { background-color: #475569; color: #f1f5f9; }
.val-8 { background-color: #0284c7; color: #f0f9ff; }
.val-16 { background-color: #0369a1; color: #f0f9ff; }
.val-32 { background-color: #ea580c; color: #fff7ed; }
.val-64 { background-color: #c2410c; color: #fff7ed; }
.val-128 { background-color: #eab308; color: #0f172a; font-size: 2rem; box-shadow: 0 0 15px rgba(234, 179, 8, 0.4);}
.val-256 { background-color: #ca8a04; color: #0f172a; font-size: 2rem; box-shadow: 0 0 20px rgba(202, 138, 4, 0.5);}
.val-512 { background-color: #a16207; color: #f8fafc; font-size: 1.8rem; box-shadow: 0 0 25px rgba(161, 98, 7, 0.6);}
.val-1024 { background-color: #854d0e; color: #f8fafc; font-size: 1.6rem; box-shadow: 0 0 30px rgba(133, 77, 14, 0.7);}
.val-2048 { background-color: var(--accent-color); color: #0f172a; font-size: 1.6rem; box-shadow: 0 0 30px rgba(0, 201, 255, 0.8), inset 0 0 10px rgba(255,255,255,0.5); text-shadow: none;}
.tile-super { background-color: #f43f5e; color: #fff; box-shadow: 0 0 30px rgba(244, 63, 94, 0.9); font-size: 1.5rem; }

/* Animations */
.tile-new { animation: pop-in 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; } 
.tile-merged { animation: pulse 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; z-index: 20;}
@keyframes pop-in { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; } } 
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.15); box-shadow: 0 0 20px rgba(255,255,255,0.4); } 100% { transform: scale(1); } }

/* Game Messages */
.game-message { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(15, 23, 42, 0.85); backdrop-filter: blur(4px); display: none; flex-direction: column; justify-content: center; align-items: center; border-radius: 12px; z-index: 50; text-align: center; padding: 20px; box-sizing: border-box; animation: fade-in 300ms ease; }
.game-message.show { display: flex; }
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
.game-message h2 { font-family: 'Orbitron', sans-serif; font-size: 2.8rem; color: var(--accent-color); text-shadow: 0 0 10px var(--accent-color); margin: 0 0 10px; line-height: 1; }
.game-message p { font-size: 1.2rem; margin-bottom: 25px; color: #e2e8f0; font-weight: 600;}
.msg-btn-group { display: flex; gap: 15px; }

/* Buttons */
button { background: var(--accent-color); color: #0f172a; font-weight: 700; font-size: 1.1rem; padding: 0.8rem 1.8rem; border: none; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 4px 15px rgba(0, 201, 255, 0.3); font-family: 'Orbitron', sans-serif; }
button:hover { background-color: #38bdf8; transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 201, 255, 0.5); }
button:active { transform: translateY(1px); }
.btn-secondary { background: #334155; color: #fff; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
.btn-secondary:hover { background: #475569; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); }

.controls-2048 { display: flex; gap: 15px; margin-top: 5px; width: 100%; max-width: 450px; justify-content: center;}

/* Instructions */
.game-instructions { background-color: #1e293b; border-radius: 1.5rem; padding: 2rem; box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5); border: 1px solid #334155; width: 100%; box-sizing: border-box; text-align: left; }
.game-instructions h2 { font-family: 'Orbitron', sans-serif; font-size: 1.8rem; color: var(--accent-color); margin: 0 0 15px; text-align: center; border-bottom: 1px solid #334155; padding-bottom: 10px; }
.game-instructions p, .game-instructions ul { font-size: 1rem; line-height: 1.7; color: #cbd5e1; margin-bottom: 10px; }
.game-instructions ul { list-style: none; margin-left: 0; padding-left: 0; } 
.game-instructions ul li { margin-bottom: 12px; position: relative; padding-left: 20px; }
.game-instructions ul li::before { content: '▸'; color: var(--accent-color); position: absolute; left: 0; font-weight: bold; }

@media (min-width: 1100px) { .game-page-content { flex-direction: row; align-items: stretch; max-width: 1200px; gap: 40px; justify-content: center;} .game-2048-container { flex: 1.2; max-width: 500px; } .game-instructions { flex: 1; max-width: 450px; display: flex; flex-direction: column; justify-content: center;} }
@media (max-width: 992px) {
    html, body { height: auto; overflow: auto; }
    body { flex-direction: column; } body.menu-open { overflow: hidden; }
    .main-content-wrapper { padding: 80px 15px 40px; margin-left: 0; height: auto; overflow: visible; }
    .mobile-header { display: flex; align-items: center; justify-content: center; position: fixed; top: 0; left: 0; width: 100%; height: 65px; background-color: rgba(15, 23, 42, 0.95); backdrop-filter: blur(10px); border-bottom: 1px solid #334155; z-index: 1000; box-sizing: border-box; }
    .hamburger-btn { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); background: none; border: none; padding: 10px; cursor: pointer; z-index: 1002; box-shadow: none;} .hamburger-btn .line { display: block; width: 24px; height: 3px; background-color: #e2e8f0; margin: 5px 0; border-radius: 3px;}
    .hamburger-btn:hover { background: none; transform: translateY(-50%); box-shadow: none; }
    .mobile-title { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: var(--accent-color); font-weight: 700; text-shadow: 0 0 8px rgba(0, 201, 255, 0.5);}
    .left-menu { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); width: 260px; } .left-menu.menu-open { transform: translateX(0); }
    .menu-overlay { display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; } .menu-overlay.menu-open { opacity: 1; pointer-events: auto; }
    .game-page-content { max-width: 100%; gap: 20px; } 
    .game-2048-container { padding: 1.5rem 1rem; border-radius: 1rem;} 
    .header-container { max-width: 100%; }
    .game-2048-container h1 { font-size: 2.5rem; }
    .score-box { padding: 6px 12px; font-size: 0.8rem;} .score-box span { font-size: 1.2rem; }
    .game-board { --gap-size: 8px; max-width: 100%; }
    .tile { font-size: 1.8rem; } .val-128, .val-256, .val-512 { font-size: 1.4rem; } .val-1024, .val-2048, .tile-super { font-size: 1.1rem; }
    button { padding: 0.8rem 1rem; font-size: 1rem; flex: 1;}
    .game-instructions { padding: 1.5rem; }
    .breadcrumbs { padding-left: 5px; }
}