html, body { height: 100%; }

body {
    background: #001a2d;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    overflow: hidden;
}

/* Табло шириной как корт, но не шире окна */
#ui {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: min(600px, 100vw);
    box-sizing: border-box;
    gap: 8px;
    background: linear-gradient(180deg, #004a77 0%, #003355 100%);
    padding: 8px 10px;
    border-bottom: 4px solid #00a3e0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10;
    flex-shrink: 0;
}

.score-box { text-align: center; min-width: 120px; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 5px; }

.points {
    font-size: 36px;
    font-weight: 900;
    color: #ccff00;
    display: block;
    text-shadow: 2px 2px 0 #000;
}

.games {
    font-size: 11px;
    color: #00a3e0;
    font-weight: bold;
    letter-spacing: 1px;
}

#match-log {
    font-weight: 900;
    text-transform: uppercase;
    color: #fff;
    text-align: center;
    flex-grow: 1;
    font-size: 16px;
}

/* Корт занимает всё оставшееся место и сохраняет пропорции 3:4 */
.court-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    box-sizing: border-box;
    container-type: size;
}

#speed-tag {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #ccff00;
    font-weight: bold;
    font-size: 22px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    font-style: italic;
    z-index: 5;
}

canvas {
    background: #0072b8;
    box-shadow: 0 0 50px rgba(0,0,0,0.6);
    cursor: crosshair;
    border: 6px solid #005187;
    /* корт вписывается в свободное место (единицы cq = размер .court-wrap) */
    width: min(100cqw - 12px, (100cqh - 16px) * 0.75);
    height: auto;
    aspect-ratio: 3 / 4;
    box-sizing: border-box;
    touch-action: none;   /* палец двигает игрока, а не прокручивает страницу */
}

/* Узкий телефон: табло компактнее */
@media (max-width: 480px) {
    .score-box { min-width: 0; flex: 1; }
    .points { font-size: 26px; }
    .games { font-size: 9px; letter-spacing: 0; }
    #match-log { font-size: 12px; }
    #speed-tag { font-size: 16px; top: 14px; right: 14px; }
}
