:root {
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --text-dark: #2c3e50;
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { 
    font-family: var(--font-main); 
    margin: 0; 
    overflow: hidden; 
    touch-action: none; 
    user-select: none; 
}

a { text-decoration: none; }

.game-environment { display: flex; flex-direction: column; width: 100vw; height: 100vh; position: relative; }

.game-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; z-index: 100; flex-shrink: 0; }
.glass-panel { background: var(--glass-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 2px solid var(--glass-border); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.back-btn { background: rgba(255, 255, 255, 0.85); color: var(--text-dark); font-weight: 900; padding: 10px 25px; border-radius: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: transform 0.2s, background 0.2s; text-transform: uppercase; letter-spacing: 1px; }
.back-btn:hover { background: white; transform: scale(1.05); }
.game-stats { display: flex; gap: 20px; }
.stat-box { background: white; padding: 8px 25px; border-radius: 25px; font-weight: 900; font-size: 1.3rem; box-shadow: 0 4px 10px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 8px; }
.stat-label { color: #546e7a; text-transform: uppercase; font-size: 1rem; letter-spacing: 0.5px; }
.text-blue { color: #0288d1; }
.text-purple { color: #9c27b0; }

.game-canvas { flex-grow: 1; position: relative; display: flex; justify-content: center; align-items: center; min-height: 0; overflow: hidden; padding: 20px; }

.pieces-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

.puzzle-board { position: relative; aspect-ratio: 4 / 3; width: 90%; max-width: 800px; max-height: calc(100vh - 120px); background-color: rgba(255, 255, 255, 0.3); border: 6px dashed rgba(255, 255, 255, 0.8); border-radius: 15px; box-shadow: inset 0 0 20px rgba(0,0,0,0.1); z-index: 1; }

.grid-cell { position: absolute; border: 1px solid rgba(255, 255, 255, 0.2); }

.puzzle-piece { position: absolute; background-repeat: no-repeat; cursor: grab; pointer-events: auto; box-shadow: 0 8px 15px rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.4); transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); touch-action: none; display: flex; align-items: center; justify-content: center; }
.puzzle-piece:active { cursor: grabbing; z-index: 50; }

.puzzle-piece.locked { pointer-events: none; box-shadow: none; border: 1px solid rgba(255,255,255,0.1); z-index: 1; }

.rotate-indicator { width: clamp(55px, 8vw, 80px); height: clamp(55px, 8vw, 80px); background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: clamp(32px, 5vw, 45px); font-weight: 900; color: #00bcd4; box-shadow: 0 4px 15px rgba(0,0,0,0.3); pointer-events: none; transition: opacity 0.3s ease; z-index: 5; animation: pulseRotate 2s infinite ease-in-out; }

@keyframes pulseRotate { 0% { transform: scale(1); box-shadow: 0 4px 15px rgba(0,0,0,0.3); } 50% { transform: scale(1.15); box-shadow: 0 8px 25px rgba(0, 188, 212, 0.6); border: 2px solid #00bcd4; } 100% { transform: scale(1); box-shadow: 0 4px 15px rgba(0,0,0,0.3); } }

.custom-modal { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); width: 90%; max-width: 600px; padding: 50px 30px; display: flex; align-items: center; justify-content: center; text-align: center; z-index: 200; opacity: 0; visibility: hidden; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); background-color: white; border-radius: 30px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); border: 8px solid #00bcd4; }
.custom-modal.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.modal-content { width: 100%; display: flex; flex-direction: column; align-items: center; }
.text-3d { font-size: 3.2rem; color: #2c3e50; margin-bottom: 20px; font-weight: 900; text-transform: uppercase; -webkit-text-stroke: 2px white; text-shadow: 0 6px 15px rgba(0,0,0,0.25); }
.game-instructions { font-size: 1.4rem; color: #546e7a; margin-bottom: 35px; font-weight: 800; line-height: 1.4; }

.btn-3d { background: linear-gradient(180deg, #00bcd4, #00838f); color: white; border: 4px solid white; padding: 15px 50px; border-radius: 40px; font-size: 1.5rem; font-weight: 900; cursor: pointer; text-transform: uppercase; box-shadow: 0 8px 0 #006064, 0 15px 25px rgba(0, 188, 212, 0.4); transition: all 0.15s ease; }
.btn-3d:active { transform: translateY(8px); box-shadow: 0 0 0 #006064, 0 5px 10px rgba(0, 188, 212, 0.4); }
.btn-3d-alt { background: linear-gradient(180deg, #ffffff, #e0e0e0); color: #2c3e50; border: 4px solid white; padding: 15px 40px; border-radius: 40px; font-size: 1.3rem; font-weight: 900; cursor: pointer; text-transform: uppercase; box-shadow: 0 8px 0 #9e9e9e, 0 15px 25px rgba(0, 0, 0, 0.2); transition: all 0.15s ease; }
.btn-3d-alt:active { transform: translateY(8px); box-shadow: 0 0 0 #9e9e9e, 0 5px 10px rgba(0, 0, 0, 0.2); }
.modal-actions { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

.confetti-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti-particle { position: absolute; width: 10px; height: 20px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(-10px) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }

@media (max-width: 768px) {
    .game-header { padding: 10px 15px; flex-direction: column; gap: 15px; }
    .game-stats { width: 100%; justify-content: space-between; }
    .puzzle-board { width: 95%; max-height: calc(100vh - 160px); border-width: 4px; }
    .custom-modal { padding: 40px 20px; border-width: 4px; }
    .text-3d { font-size: 2.2rem; }
    .btn-3d { font-size: 1.2rem; padding: 12px 30px; }
}