* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    font-family: 'Courier New', Courier, monospace, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(16, 16, 32, 0.85);
    border: 2px solid #00ffcc;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.3), inset 0 0 15px rgba(0, 255, 204, 0.1);
    padding: 15px;
    max-width: 480px;
    width: 100%;
    margin: 10px;
}

#game-header {
    text-align: center;
    margin-bottom: 12px;
    width: 100%;
}

#game-header h1 {
    font-size: 1.8rem;
    letter-spacing: 4px;
    color: #00ffcc;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.7);
    margin-bottom: 8px;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.stat-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333954;
    border-radius: 6px;
    padding: 4px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    color: #8892b0;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: bold;
    color: #64ffda;
}

#game-main {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    justify-content: center;
    position: relative;
}

#side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 110px;
}

.panel-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333954;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.panel-label {
    display: block;
    font-size: 0.7rem;
    color: #8892b0;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

#next-canvas {
    background: #05050a;
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}

.controls-info {
    font-size: 0.65rem;
    color: #a8b2d1;
    text-align: left;
    line-height: 1.4;
}

.controls-info p {
    margin-bottom: 3px;
}

#canvas-container {
    position: relative;
    border: 2px solid #333954;
    border-radius: 8px;
    background: #05050a;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    overflow: hidden;
}

#tetris-canvas {
    display: block;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    font-size: 1.8rem;
    color: #ff0055;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
    margin-bottom: 12px;
}

.overlay p {
    font-size: 1rem;
    margin-bottom: 15px;
    color: #ccd6f6;
}

.btn {
    background: #00ffcc;
    color: #05050a;
    border: none;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.4);
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.95);
    background: #00b38f;
}

#touch-controls {
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    margin-top: 15px;
}

.control-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.control-btn {
    background: rgba(25, 30, 56, 0.9);
    border: 1px solid #00ffcc;
    color: #00ffcc;
    font-size: 1.3rem;
    padding: 14px 0;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: background 0.1s, transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:active {
    background: #00ffcc;
    color: #05050a;
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

@media (max-width: 420px) {
    #game-wrapper {
        padding: 10px;
        margin: 5px;
    }
    #game-header h1 {
        font-size: 1.5rem;
    }
    .stat-value {
        font-size: 0.85rem;
    }
    .control-btn {
        padding: 12px 0;
        font-size: 1.1rem;
    }
}
