* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #1a1a1a;
    color: white;
    font-family: system-ui, -apple-system, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    overflow: hidden;
/* overflow-y: scroll; */
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    /* width: 100vw; */
    /* height: 100vh; */
    /* height: 100dvh; */
    width: 100%;
    height: 100%;
    background: #111;
    position: relative;
}

@media (min-width: 600px) {
    #game-wrapper {
        width: 520px;
        border-left: 2px solid #333;
        border-right: 2px solid #333;
        height: 96vh;
        border-radius: 16px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    }
    #controls-wrapper {
        display: none !important;
    }
}

/* Modal Overlay Layer */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

#overlay.hidden {
    display: none !important;
}

#overlay-content {
    text-align: center;
    padding: 20px;
    width: 85%;
    max-width: 320px;
}

#overlay-title {
    font-size: 36px;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: #ff0d72;
}

#overlay-subtitle {
    font-size: 15px;
    color: #fff;
    font-weight: bold;
    margin-bottom: 20px;
}

/* Leaderboard Specific Overlay Styling Rules */
#leaderboard-container {
    margin: 15px 0 25px 0;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 15px;
}

#leaderboard-container h3 {
    font-size: 14px;
    letter-spacing: 1px;
    color: #ffe138;
    margin-bottom: 12px;
}

#leaderboard-list {
    list-style-position: inside;
    text-align: left;
    font-size: 16px;
    color: #ddd;
}

#leaderboard-list li {
    padding: 4px 10px;
    border-bottom: 1px solid #2a2a2a;
}

#leaderboard-list li > div {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

#leaderboard-list li.current-run {
    color: #0dc2ff;
    font-weight: bold;
    background: rgba(13, 194, 255, 0.1);
    border-radius: 4px;
}

#status-board {
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    padding: 12px 14px;
    background: #111;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #222;
}

#main-play-container {
    flex: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    background: #090909;
    padding: 4px;
    overflow: hidden;
}

#canvas-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

#tetris {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111;
}

.side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    flex-shrink: 0;
    background: transparent;
    z-index: 5;
}

.panel-label {
    font-size: 11px;
    font-weight: 900;
    color: #888;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.canvas-box {
    background: #111;
    border: 1px solid #252525;
    border-radius: 6px;
    padding: 4px;
}

.canvas-box canvas {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

@media (max-width: 599px) {
    .side-panel { width: 70px; }
    .canvas-box canvas { width: 50px; height: 50px; }
}

#controls-wrapper {
    width: 100%;
    padding: 8px 12px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #111;
    z-index: 10;
    flex-shrink: 0;
    border-top: 1px solid #222;
}

.control-row {
    display: flex;
    width: 100%;
    gap: 8px;
}

.action-row .btn-hold { flex: 0.9; background: #37474f; border: 1px solid #455a64; }
.action-row .btn-rotate { flex: 1.1; background: #444; border: 1px solid #666; }
.action-row .btn-hard-drop { flex: 1.2; background: #2e7d32; border: 1px solid #4caf50; }

.nav-row .btn-wide { flex: 1.3; }
.nav-row .btn-narrow { flex: 0.9; }

.btn {
    color: white;
    padding: 15px 0;
    font-size: 15px;
    font-weight: bold;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    border: none;
    outline: none;
    touch-action: manipulation;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: background 0.1s, transform 0.05s;
}

.btn-nav { background: #2a2a2a; border: 1px solid #444; font-size: 20px; }
.btn-pause-top { background: #222; border: 1px solid #444; color: white; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 15px; }
#btn-restart { background: #ff8e0d; padding: 12px 30px; display: inline-block; }

.btn:active { transform: scale(0.96); background: #555; }
.btn-hard-drop:active { background: #1b5e20; }
#btn-restart:active { background: #e65100; }

.hidden { display: none !important; }
