body {
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    background-color: #2a2a2a;
    color: #69d2e7;
    margin: 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    position: relative;
    height: 100vh;
}

.container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    /* Reduced padding to allow field expansion, d-pad sits on top */
    padding-bottom: 20px; 
}

header {
    margin-bottom: 10px;
    color: #a7dbd8;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link {
    text-decoration: none;
    font-weight: bold;
    color: #ff6b6b;
    font-size: 18px;
}

h1 {
    margin: 0;
    font-size: 32px;
    color: #ff6b6b;
}

.score-board {
    background: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    color: #ff6b6b;
    font-weight: bold;
    display: flex;
    gap: 15px;
}

.game-area {
    flex: 1;
    position: relative;
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 10px; /* Reduced margin */
}

canvas {
    background: #1a1a1a;
    border-radius: 5px;
    cursor: pointer;
    display: block;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Ensure canvas fits within container if screen is small */
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 250px;
    z-index: 100;
}

.hidden {
    display: none !important;
}

h2 {
    margin: 0;
    color: #ff6b6b;
    font-size: 36px;
}

p {
    margin: 0;
    color: #776e65;
    font-size: 18px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.95);
}

.twitter {
    background: #1da1f2;
}

.tutorial-text {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: white;
    font-weight: bold;
    pointer-events: none;
    opacity: 0.8;
    font-size: 18px;
    text-shadow: 1px 1px 2px black;
}

@media screen and (max-width: 520px) {
    .header-top {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 10px;
        align-items: center;
    }

    .back-link {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    h1 {
        grid-column: 2;
        grid-row: 1;
        text-align: right;
        font-size: 24px;
        margin: 0;
    }

    .score-board {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
    }
    
    .container {
        padding-bottom: 220px; /* Space for D-pad on mobile */
    }
}

/* Virtual D-pad styles */
#virtual-dpad {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: block;
}

/* Hide D-pad on desktop */
@media (hover: hover) and (pointer: fine) {
    #virtual-dpad {
        display: none;
    }
    
    .container {
        padding-bottom: 10px;
    }
}

.dpad-container {
    position: relative;
    width: 200px;
    height: 200px;
}

.dpad-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(105, 210, 231, 0.8);
    border: 2px solid #69d2e7;
    border-radius: 10px;
    color: white;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    background: rgba(105, 210, 231, 1);
    transform: scale(0.95);
}

.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-left {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-right {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}