/* Tetris - Retro Arcade Theme */

* { 
    box-sizing: border-box; 
}

html, body { 
    height: 100%; 
    margin: 0;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #0a0a0a;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 0, 150, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 0, 0.05) 0%, transparent 50%);
    color: #00ffff;
    position: relative;
}

/* Animated scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
    animation: scanline 8s linear infinite;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

.wrap { 
    max-width: 1000px; 
    margin: 0 auto; 
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Retro Topbar */
.topbar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 24px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    border-radius: 0;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    position: relative;
}

.topbar::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ff00ff, #00ffff, #ff00ff, #00ffff);
    background-size: 400% 400%;
    animation: borderGlow 3s ease infinite;
    z-index: -1;
    filter: blur(8px);
}

@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.topbar h1 { 
  margin: 0;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #00ffff;
    text-shadow: 
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        0 0 30px #00ffff;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { 
        text-shadow: 
            0 0 10px #00ffff,
            0 0 20px #00ffff,
            0 0 30px #00ffff;
    }
    50% { 
        text-shadow: 
            0 0 15px #00ffff,
            0 0 30px #00ffff,
            0 0 45px #00ffff,
            0 0 60px rgba(0, 255, 255, 0.5);
    }
}

.settings-btn {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ffff;
    border-radius: 0;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
    color: #00ffff;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.settings-btn:hover { 
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
    transform: scale(1.05);
}

.settings-btn i { 
    font-size: 20px;
    text-shadow: 0 0 5px #00ffff;
}

.home {
    color: #00ffff;
    text-decoration: none;
    border: 2px solid #00ffff;
    padding: 10px 16px;
    border-radius: 0;
    transition: all 0.3s ease;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
  font-size: 14px;
}

.home:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
    transform: translateY(-2px);
}

/* Board Container - Retro Grid Layout */
.board-container { 
    display: grid; 
    grid-template-columns: 160px 1fr 160px; 
    gap: 24px; 
    align-items: start;
}

/* Stats Display - Retro Style */
.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    border-radius: 0;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.stats div {
    font-size: 18px;
    font-weight: 700;
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff;
}

.stats span {
    color: #ff00ff;
    text-shadow: 0 0 8px #ff00ff;
    font-size: 20px;
}

/* Canvas - Retro Game Board */
canvas { 
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #00ffff;
    border-radius: 0;
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
}

#game {
    display: block;
    margin: 0 auto;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
    flex-direction: column;
  align-items: center;
  justify-content: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.95);
    border: 4px solid #00ffff;
    color: #00ffff;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, border-color 0.3s ease;
    z-index: 100;
    box-shadow: 
        0 0 40px rgba(0, 255, 255, 0.8),
        inset 0 0 40px rgba(0, 255, 255, 0.2);
}

.overlay.visible {
  opacity: 1;
    pointer-events: all;
}

.overlay-backdrop {
  position: absolute;
  top: 0;
  left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
}

.overlay-content {
  position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    text-shadow: 
        0 0 15px currentColor,
        0 0 30px currentColor,
        0 0 45px currentColor;
    animation: overlayPulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Paused state */
.overlay.visible.paused {
    border-color: #ff00ff;
    box-shadow: 
        0 0 40px rgba(255, 0, 255, 0.8),
        inset 0 0 40px rgba(255, 0, 255, 0.2);
}

.overlay.visible.paused .overlay-content {
    color: #ff00ff;
    text-shadow: 
        0 0 15px #ff00ff,
        0 0 30px #ff00ff,
        0 0 45px #ff00ff;
    animation: overlayPulsePaused 1.5s ease-in-out infinite;
}

/* Restarting state */
.overlay.visible.restarting {
    border-color: #ffff00;
    box-shadow: 
        0 0 40px rgba(255, 255, 0, 0.8),
        inset 0 0 40px rgba(255, 255, 0, 0.2);
}

.overlay.visible.restarting .overlay-content {
    color: #ffff00;
    text-shadow: 
        0 0 15px #ffff00,
        0 0 30px #ffff00,
        0 0 45px #ffff00;
    animation: overlayPulseRestart 1s ease-in-out infinite;
}

@keyframes overlayPulse {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(0, 255, 255, 0.8),
            inset 0 0 40px rgba(0, 255, 255, 0.2);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(0, 255, 255, 1),
            inset 0 0 60px rgba(0, 255, 255, 0.3);
    }
}

@keyframes overlayPulsePaused {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(255, 0, 255, 0.8),
            inset 0 0 40px rgba(255, 0, 255, 0.2);
        transform: scale(1);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(255, 0, 255, 1),
            inset 0 0 60px rgba(255, 0, 255, 0.3);
        transform: scale(1.02);
    }
}

@keyframes overlayPulseRestart {
    0%, 100% { 
        box-shadow: 
            0 0 40px rgba(255, 255, 0, 0.8),
            inset 0 0 40px rgba(255, 255, 0, 0.2);
        transform: scale(1);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(255, 255, 0, 1),
            inset 0 0 60px rgba(255, 255, 0, 0.3);
        transform: scale(1.05);
    }
}

/* Side Panels */
.left-side, .right-side {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    border-radius: 0;
    padding: 16px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.left-side h2, .right-side h2 { 
    margin: 0 0 12px 0; 
    font-size: 18px;
    font-weight: 700;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 8px #00ffff;
    text-align: center;
}

.next-pieces {
  display: flex;
  flex-direction: column;
    gap: 8px;
    align-items: center;
}

.next-piece {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #00ffff;
}

/* Modal - Retro Style */
.modal {
  position: fixed;
  inset: 0;
    z-index: 2000;
    display: flex;
  align-items: center;
  justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal[aria-hidden="false"] {
    opacity: 1;
    pointer-events: all;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
    background: #0a0a0a;
    border: 3px solid #00ffff;
    border-radius: 0;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.6),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    z-index: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #00ffff;
    background: rgba(0, 0, 0, 0.5);
}

.modal-header h2 {
    margin: 0;
    color: #00ffff;
    font-size: 24px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #00ffff;
}

.close-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 2px solid #00ffff;
    color: #00ffff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.modal-body {
    padding: 20px;
}

.modal-body h3 {
    color: #00ffff;
    font-size: 22px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0 0 20px 0;
    text-shadow: 
        0 0 10px #00ffff,
        0 0 20px #00ffff;
    padding-bottom: 12px;
    border-bottom: 2px solid #00ffff;
    box-shadow: 0 2px 8px rgba(0, 255, 255, 0.3);
}

/* Controls heading - left aligned */
section.controls h3 {
    text-align: left;
}

/* Handling heading - centered */
section.settings h3 {
    text-align: center;
}

.modal-body section {
    margin-bottom: 40px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
}

.modal-body section:last-child {
    margin-bottom: 0;
}

/* Keybind Controls */
.keybind-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    align-items: flex-start;
}

.keybind-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
}

.keybind-item label {
    width: 140px;
    text-align: right;
    color: #bcdcff;
    font-size: 14px;
    font-weight: 500;
}

.keybind-btn {
    min-width: 120px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ffff;
    border-radius: 0;
    color: #00ffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.3);
}

.keybind-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
    transform: translateY(-2px);
}

.keybind-btn.waiting {
    background: rgba(0, 255, 255, 0.3);
    border-color: #ff00ff;
    color: #ff00ff;
    animation: keybindPulse 1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.6);
}

@keyframes keybindPulse {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 30px rgba(255, 0, 255, 0.9);
        transform: scale(1.05);
    }
}

.keybind-key {
    display: inline-block;
}

.reset-btn {
    margin-top: 20px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #ff00ff;
    border-radius: 0;
    color: #ff00ff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

.reset-btn:hover {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.6);
    transform: translateY(-2px);
}

/* Settings Sliders */
.settings {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.setting {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 0;
    width: 100%;
    max-width: 400px;
}

.setting label {
    display: block;
    color: #00ffff;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 0 8px #00ffff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setting label span {
    color: #ff00ff;
    text-shadow: 0 0 8px #ff00ff;
    font-size: 18px;
}

.setting input[type="range"] {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ffff;
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.setting input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: #00ffff;
    border: 3px solid #0a0a0a;
    border-radius: 0;
  cursor: pointer;
    box-shadow: 
        0 0 15px rgba(0, 255, 255, 1),
        inset 0 0 5px rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.setting input[type="range"]::-webkit-slider-thumb:hover {
    background: #ff00ff;
    box-shadow: 
        0 0 20px rgba(255, 0, 255, 1),
        inset 0 0 5px rgba(255, 255, 255, 0.3);
    transform: scale(1.2);
}

.setting input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #00ffff;
    border: 3px solid #0a0a0a;
    border-radius: 0;
  cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 255, 255, 1);
}

.setting input[type="range"]::-moz-range-thumb:hover {
    background: #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 1);
}

/* Responsive */
@media (max-width: 768px) {
    .board-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .left-side, .right-side {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 16px;
    }
    
    .next-pieces {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .topbar h1 {
        font-size: 24px;
    }
    
    .stats {
        flex-direction: column;
        gap: 8px;
    }
}
