*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* verwijder blauwe highlight op mobiel */
    tap-highlight-color: transparent;
    user-select: none;
    /* voorkom tekst selectie */
    -webkit-user-select: none;
}

body {
    font-family: Arial, sans-serif;
    background-color: #0f1f4f;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    /* voorkom scrollen op mobiel */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
}

.container {
    width: 96vw;
    height: 92vh;
    border-radius: 28px;
    background: #162c66;
    box-shadow: 0 0 0 8px #131c50;
    display: flex;
    flex-direction: column;
    padding: 16px 24px;
    gap: 12px;
}

.top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    position: relative;
}

.top-bar button {
    width: 130px;
    height: 56px;
    border: none;
    border-radius: 14px;
    font-size: 20px;
    color: rgb(240, 240, 240);
    cursor: pointer;
    touch-action: manipulation;
    /* verwijder 300ms tap delay */
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.top-bar button:active {
    transform: scale(0.95);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.select-btn {
    background-color: #4da6ff;
}

.home-btn {
    background-color: #66cc66;
}

#status {
    color: #fff;
    font-size: 14px;
    margin: 0;
    min-width: 120px;
    text-align: center;
}

.fullscreen-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.75);
    font-size: 20px;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fullscreen-btn:active {
    background-color: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: translateY(-50%) scale(0.93);
}

.bottom-row {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 2vw 6% 2vw;
}

.left-side {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.right-side {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

/* ── D-pad ── */
.direction-section {
    display: grid;
    grid-template-columns: repeat(3, 62px);
    grid-template-rows: repeat(3, 62px);
    gap: 3px;
    border-radius: 22px;
    padding: 0;
    transform: translateY(-10%) translateX(-16px);
}

.direction-section button {
    width: 62px;
    height: 62px;
    border-radius: 12px;
    font-size: clamp(22px, 3vw, 38px);
    color: rgb(240, 240, 240);
    background-color: #371a45;
    cursor: pointer;
    touch-action: manipulation;
    /* verwijder 300ms tap delay */
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.direction-section button:active {
    transform: scale(0.93);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.up-btn {
    grid-area: 1 / 2;
}

.left-btn {
    grid-area: 2 / 1;
}

.center-btn {
    grid-area: 2 / 2;
}

.right-btn {
    grid-area: 2 / 3;
}

.down-btn {
    grid-area: 3 / 2;
}

.center-btn {
    border-radius: 50% !important;
    background: #ccc !important;
    color: #000 !important;
    font-size: clamp(24px, 3.5vw, 42px) !important;
}

/* ── YXBA face buttons ── */
.face-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    border-radius: 22px;
    padding: 0;
    transform: translateY(-10%);
}

.face-section button {
    width: 70px;
    height: 70px;
    border: none;
    border-radius: 50%;
    font-size: clamp(18px, 2.5vw, 28px);
    font-weight: bold;
    color: rgb(240, 240, 240);
    cursor: pointer;
    touch-action: manipulation;
    /* verwijder 300ms tap delay */
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.face-section button:active {
    transform: scale(0.93);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.y-btn {
    grid-area: 1 / 2;
    background-color: #4da6ff;
}

.x-btn {
    grid-area: 2 / 1;
    background-color: #cc66ff;
}

.b2-btn {
    grid-area: 2 / 3;
    background-color: #ff6699;
}

.a2-btn {
    grid-area: 3 / 2;
    background-color: #cc3333;
}

/* ── Joysticks ── */
.joystick-base {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 3px solid rgba(255, 255, 255, 0.15);
    position: relative;
    flex-shrink: 0;
    touch-action: none;
    cursor: pointer;
}

#joystickBase {
    transform: translateX(-20px);
}

.joystick-stick {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 1px 3px rgba(255, 255, 255, 0.15);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s ease;
    pointer-events: none;
}

/* ── Landscape short screens ── */
@media (max-height: 450px) {
    .direction-section button {
        width: 64px;
        height: 64px;
    }

    .face-section button {
        width: 50px;
        height: 50px;
    }

    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-stick {
        width: 50px;
        height: 50px;
    }

    .top-bar button {
        width: 100px;
        height: 46px;
        font-size: 17px;
    }
}