/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #2c2c2c;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: monospace;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* === Nokia 6110 Phone Body === */
#phone {
    background: linear-gradient(145deg, #3a3a4a, #2a2a38);
    border-radius: 28px 28px 32px 32px;
    padding: 18px 14px 22px;
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow:
        0 0 0 2px #1a1a24,
        0 8px 32px rgba(0, 0, 0, 0.6);
    position: relative;
}

#phone-top {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

#earpiece {
    width: 60px;
    height: 6px;
    background: #1a1a24;
    border-radius: 3px;
}

/* === Screen === */
#screen-frame {
    background: #1a1a24;
    border-radius: 4px;
    padding: 6px;
    width: 100%;
}

#screen {
    background: #9bbc0f;
    position: relative;
    width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* LCD pixel overlay effect */
#screen::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    ),
    repeating-linear-gradient(
        90deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 2;
}

#status-bar {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    font-size: 11px;
    color: #0f380f;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: monospace;
    border-bottom: 2px solid #8aad0e;
}

#game-canvas {
    display: block;
    width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* === Overlay (Start / Game Over) === */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3;
    pointer-events: none;
}

#overlay.hidden {
    display: none;
}

#overlay-text {
    color: #0f380f;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    line-height: 1.8;
    letter-spacing: 1px;
    white-space: pre-line;
}

/* === D-Pad === */
#controls {
    margin-top: 14px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

#dpad {
    display: grid;
    grid-template-columns: 52px 52px 52px;
    grid-template-rows: 52px 52px 52px;
    gap: 2px;
}

.dpad-btn {
    background: #4a4a5a;
    border: 1px solid #2a2a38;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dpad-btn:active {
    background: #3a3a48;
}

#btn-up    { grid-column: 2; grid-row: 1; border-radius: 6px 6px 2px 2px; }
#btn-left  { grid-column: 1; grid-row: 2; border-radius: 6px 2px 2px 6px; }
#btn-center {
    grid-column: 2;
    grid-row: 2;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    font-family: monospace;
    background: #555568;
}
#btn-right { grid-column: 3; grid-row: 2; border-radius: 2px 6px 6px 2px; }
#btn-down  { grid-column: 2; grid-row: 3; border-radius: 2px 2px 6px 6px; }

/* === Action Buttons === */
#action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn {
    background: #4a4a5a;
    border: 1px solid #2a2a38;
    color: #aaa;
    font-size: 10px;
    font-family: monospace;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 8px 12px;
    border-radius: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.action-btn:active {
    background: #3a3a48;
}

/* === Brand === */
#phone-bottom {
    margin-top: 16px;
    text-align: center;
}

#brand {
    color: #666;
    font-family: monospace;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 4px;
}

/* === Responsive === */
@media (max-width: 360px) {
    #phone {
        width: 100vw;
        border-radius: 0;
        padding: 12px 8px 16px;
    }
}

@media (min-width: 500px) {
    #phone {
        width: 360px;
        padding: 24px 20px 28px;
    }

    #dpad {
        grid-template-columns: 58px 58px 58px;
        grid-template-rows: 58px 58px 58px;
    }
}
