* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    background: #000;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
}

.game-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0px 0px 0px 0px;
    gap: 8px
}

/* Верхняя панель — всё в одном ряду */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
}

/* Крестик слева */
.close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.close-btn img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

/* SCORE по центру */
.score-box {
    text-align: center;
}
.score-label {
    font-size: 7px;
    color: #a84d6b;
    margin-bottom: 2px;
}
.score-value {
    font-size: 14px;
    color: #fff;
}

/* NEXT справа */
.next-box {
    text-align: center;
}
.next-label {
    font-size: 7px;
    color: #a84d6b;
    margin-bottom: 2px;
}
#next-piece-canvas {
    width: 40px;
    height: 40px;
    display: block;
    background: #000;
    border: 1px solid #5a2a3a;
}

.game-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}
#tetris-canvas {
    background: #000;
    border: 2px solid #5a2a3a;
    box-shadow: 0 0 10px rgba(90, 42, 58, 0.4);
    display: block;
    width: 100%;
    height: auto;
    image-rendering: crisp-edges;
}

.control-bar {
    display: flex;
    justify-content: center;
    gap: 35px;
    width: 100%;
    padding: 20px 0 40px 0;
}
.control-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: 0.05s linear;
}
.control-btn:active {
    transform: scale(0.9);
}
.control-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

@media (min-width: 768px) {
    .control-btn { width: 80px; height: 80px; }
    .control-bar { gap: 45px; }
}
@media (max-width: 767px) {
    .control-btn { width: 70px; height: 70px; }
    .control-bar { gap: 35px; }
}
@media (max-width: 550px) {
    .control-btn { width: 65px; height: 65px; }
    .control-bar { gap: 30px; }
}
@media (max-width: 450px) {
    .control-btn { width: 60px; height: 60px; }
    .control-bar { gap: 25px; }
}
@media (max-width: 380px) {
    .control-btn { width: 55px; height: 55px; }
    .control-bar { gap: 20px; }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.score-modal {
    background: #a27791;
    border: 4px solid #b97272;
    box-shadow: inset 0 0 0 2px #000, 0 0 0 2px #000;
    max-width: 320px;
    width: 90%;
    position: relative;
}
.modal-header {
    background: #79434a;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
}
.modal-title-text {
    font-size: 9px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}
.modal-close-btn {
    background: #000;
    color: #fff;
    border: 2px solid #b97272;
    width: 28px;
    height: 28px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.modal-inner {
    padding: 15px;
    text-align: center;
}
.modal-inner p {
    font-size: 11px;
    color: #000;
    margin-bottom: 12px;
}
.modal-inner input {
    background: #000;
    border: 2px solid #a84d6b;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 8px;
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
}
.modal-inner button {
    background: #000;
    color: #a84d6b;
    border: 2px solid #b97272;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 8px 16px;
    cursor: pointer;
}
