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

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Arial', sans-serif;
    background-color: #2c3e50;
    color: #ecf0f1;
    overflow: hidden;
    position: fixed;
}

.game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 10px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.score-container, .level-container, .lines-container {
    text-align: center;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 5px 10px;
    flex: 1;
    margin: 0 5px;
}

.score-label, .level-label, .lines-label {
    font-size: 0.8rem;
    margin-bottom: 2px;
}

#score, #level, #lines {
    font-size: 1.2rem;
    font-weight: bold;
}

.game-area-container {
    display: flex;
    flex: 1;
    margin-bottom: 10px;
}

#game-canvas {
    flex: 3;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

.next-piece-container {
    flex: 1;
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.next-label {
    margin-bottom: 5px;
    text-align: center;
}

#next-piece-canvas {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    width: 100%;
    height: 80px;
}

.controls-container {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
}

.d-pad {
    display: flex;
    flex-direction: column;
    flex: 3;
}

#rotate-btn {
    margin-bottom: 5px;
    height: 50px;
}

.d-pad-middle {
    display: flex;
    justify-content: space-between;
    height: 60px;
}

#left-btn, #down-btn, #right-btn {
    flex: 1;
    margin: 0 2px;
}

/* Enhanced d-pad layout */
.d-pad {
    position: relative;
}

.d-pad-middle {
    margin-top: 5px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-left: 10px;
}

#pause-btn, #drop-btn {
    flex: 1;
    margin: 2px 0;
}

button {
    border: none;
    background-color: rgba(52, 152, 219, 0.8);
    color: white;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

button:active {
    background-color: rgba(41, 128, 185, 0.8);
}

.button-icon {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Make the d-pad buttons larger */
#rotate-btn .button-icon {
    width: 32px;
    height: 32px;
}

.d-pad-middle button .button-icon {
    width: 28px;
    height: 28px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background-color: #34495e;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    width: 80%;
    max-width: 300px;
}

.modal h2 {
    margin-bottom: 20px;
}

.modal button {
    padding: 10px 20px;
    margin: 10px 0;
    width: 100%;
    justify-content: center;
    text-align: center;
}

.final-score {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.hidden {
    display: none;
}