/* === GRAVE JUMPER STYLES === */
.gj-wrapper, .gj-wrapper * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
.gj-wrapper {
    width: 100%;
    max-width: 900px;
    margin: 20px auto;
    font-family: Georgia, 'Times New Roman', serif;
    color: #e0c060;
}
.gj-wrap {
    position: relative;
    width: 100%;
    max-width: 900px;
    aspect-ratio: 900 / 560;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(180, 0, 0, 0.5), 0 0 100px rgba(80, 0, 0, 0.3);
    background: #06020d;
    overflow: hidden;
}
.gj-canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #06020d;
    touch-action: none;
}
.gj-ui {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
    color: #e0c060;
    font-size: 14px;
    text-shadow: 2px 2px 4px #000;
    gap: 6px;
    flex-wrap: wrap;
}
.gj-stat {
    background: rgba(0,0,0,0.55);
    padding: 4px 8px;
    border: 1px solid rgba(224, 192, 96, 0.5);
    border-radius: 3px;
    white-space: nowrap;
}
.gj-stat span { color: #ffcc00; font-weight: bold; }
.gj-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    padding: 20px;
    overflow-y: auto;
}
.gj-overlay.gj-hidden { display: none; }
.gj-overlay h1 {
    font-size: 54px;
    color: #c41e1e;
    text-shadow: 0 0 30px rgba(196, 30, 30, 0.8), 4px 4px 0 #000;
    margin-bottom: 8px;
    letter-spacing: 5px;
}
.gj-overlay h2 {
    font-size: 15px;
    color: #aaa;
    font-style: italic;
    font-weight: normal;
    margin-bottom: 18px;
    max-width: 480px;
    line-height: 1.4;
}
.gj-btn {
    background: linear-gradient(180deg, #5a0a0a 0%, #3a0505 100%);
    color: #f0d080;
    border: 2px solid #d4af37;
    padding: 14px 32px;
    font-size: 18px;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 3px;
    transition: all 0.2s;
    margin: 6px;
    touch-action: manipulation;
}
.gj-btn:hover {
    background: linear-gradient(180deg, #7a1010 0%, #5a0a0a 100%);
}
.gj-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.gj-controls-info {
    margin-top: 18px;
    color: #999;
    font-size: 13px;
    line-height: 1.8;
    background: rgba(0,0,0,0.5);
    padding: 12px 18px;
    border-left: 3px solid #c41e1e;
    max-width: 90%;
}
.gj-controls-info strong { color: #f0d080; }
.gj-key {
    display: inline-block;
    background: #2a2a2a;
    border: 1px solid #555;
    padding: 2px 6px;
    border-radius: 3px;
    margin: 0 2px;
    color: #fff;
    font-family: monospace;
    font-size: 11px;
}
.gj-err {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #4a0000;
    color: #fff;
    padding: 20px;
    border: 2px solid #ff4040;
    max-width: 80%;
    font-family: monospace;
    font-size: 13px;
    z-index: 100;
    display: none;
    white-space: pre-wrap;
}
.gj-flash {
    position: absolute;
    inset: 0;
    background: rgba(255, 0, 0, 0);
    pointer-events: none;
    z-index: 8;
}
.gj-sfx-toggle {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 6;
    pointer-events: auto;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(224, 192, 96, 0.5);
    color: #e0c060;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
    touch-action: manipulation;
}
.gj-sfx-toggle:hover { background: rgba(40,20,20,0.8); }

/* === TOUCH CONTROLS - DEFAULT (DESKTOP / NON-TOUCH) === */
.gj-touch-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 7;
    display: none;
}
.gj-touch-controls.gj-active { display: block; }
.gj-touch-btn {
    position: absolute;
    pointer-events: auto;
    border-radius: 50%;
    background: rgba(224, 192, 96, 0.15);
    border: 2px solid rgba(224, 192, 96, 0.45);
    color: #e0c060;
    font-family: inherit;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: background 0.05s, transform 0.05s;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.gj-touch-btn:active,
.gj-touch-btn.gj-pressed {
    background: rgba(224, 192, 96, 0.45);
    transform: scale(0.92);
}
.gj-btn-left, .gj-btn-right {
    width: 64px; height: 64px;
    bottom: 16px;
    font-size: 28px;
}
.gj-btn-left { left: 16px; }
.gj-btn-right { left: 92px; }
.gj-btn-jump {
    width: 76px; height: 76px;
    bottom: 22px; right: 22px;
    font-size: 14px;
    letter-spacing: 1px;
}
.gj-btn-torch {
    width: 70px; height: 70px;
    bottom: 110px; right: 25px;
    font-size: 26px;
}
.gj-touch-btn .gj-label {
    pointer-events: none;
    text-shadow: 1px 1px 2px #000;
}
@media (hover: hover) and (pointer: fine) {
    .gj-touch-controls { display: none !important; }
}
@media (pointer: coarse) {
    .gj-touch-controls.gj-active { display: block; }
}

/* === MOBILE LAYOUT - CONTROLS BELOW GAME === */
@media (max-width: 768px) {
    .gj-overlay h1 { font-size: 38px; letter-spacing: 3px; }
    .gj-overlay h2 { font-size: 13px; }
    .gj-btn { padding: 12px 24px; font-size: 16px; }
    .gj-controls-info { font-size: 12px; padding: 10px 12px; }
    .gj-ui { font-size: 12px; padding: 8px 10px; }
    .gj-stat { padding: 3px 6px; }

    /* Reshape the game wrapper as a vertical column on mobile */
    .gj-wrap {
        aspect-ratio: auto;
        display: flex;
        flex-direction: column;
    }

    /* Lock the canvas to its natural 900x560 aspect ratio */
    .gj-canvas {
        width: 100%;
        height: auto;
        aspect-ratio: 900 / 560;
        flex-shrink: 0;
    }

    /* The touch controls become a row below the canvas */
    .gj-touch-controls.gj-active {
        position: relative;
        inset: auto;
        width: 100%;
        height: 92px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 10px;
        background: rgba(0, 0, 0, 0.5);
        border-top: 1px solid rgba(224, 192, 96, 0.35);
        box-sizing: border-box;
    }

    /* Reset all absolute button positioning for mobile */
    .gj-btn-left, .gj-btn-right,
    .gj-btn-jump, .gj-btn-torch {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        top: auto;
    }

    .gj-btn-left, .gj-btn-right {
        width: 64px;
        height: 64px;
        font-size: 26px;
    }
    .gj-btn-left  { margin-right: 6px; }

    .gj-btn-torch {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }
    .gj-btn-jump {
        width: 72px;
        height: 72px;
        font-size: 13px;
        letter-spacing: 1px;
    }
    .gj-btn-torch { margin-right: 6px; }
}

/* === SMALL PHONES === */
@media (max-width: 480px) {
    .gj-touch-controls.gj-active {
        height: 84px;
        padding: 6px 8px;
    }
    .gj-btn-left, .gj-btn-right {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    .gj-btn-torch {
        width: 56px;
        height: 56px;
        font-size: 20px;
    }
    .gj-btn-jump {
        width: 64px;
        height: 64px;
        font-size: 12px;
    }
}

/* === SHORT LANDSCAPE (PHONES ROTATED) - KEEP OVERLAY === */
@media (max-height: 500px) and (orientation: landscape) {
    .gj-wrap {
        aspect-ratio: 900 / 560;
        display: block;
    }
    .gj-canvas {
        aspect-ratio: auto;
        height: 100%;
    }
    .gj-touch-controls.gj-active {
        position: absolute;
        inset: 0;
        display: block;
        width: auto;
        height: auto;
        padding: 0;
        background: none;
        border: none;
    }
    .gj-btn-left, .gj-btn-right {
        position: absolute;
        width: 50px; height: 50px;
        font-size: 22px;
        bottom: 10px;
    }
    .gj-btn-left  { left: 16px; }
    .gj-btn-right { left: 72px; }
    .gj-btn-jump {
        position: absolute;
        bottom: 10px; right: 14px;
        width: 60px; height: 60px;
    }
    .gj-btn-torch {
        position: absolute;
        bottom: 78px; right: 16px;
        width: 54px; height: 54px;
        font-size: 22px;
    }
}

.gj-leaderboard {
    margin-top: 16px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(212, 175, 55, 0.4);
    padding: 12px 16px;
    max-width: 420px;
    width: 100%;
}
.gj-leaderboard h3 {
    color: #d4af37;
    font-size: 16px;
    margin-bottom: 10px;
    letter-spacing: 2px;
    text-align: center;
}
.gj-leaderboard ol {
    list-style: none;
    padding: 0;
    margin: 0;
}
.gj-leaderboard li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px dotted rgba(224, 192, 96, 0.2);
    color: #ccc;
}
.gj-leaderboard li:last-child { border-bottom: none; }
.gj-leaderboard .gj-rank {
    color: #888;
    font-family: monospace;
    width: 26px;
    text-align: left;
}
.gj-leaderboard .gj-name {
    flex: 1;
    text-align: left;
    color: #e0c060;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}
.gj-leaderboard .gj-score {
    color: #ffcc00;
    font-weight: bold;
    font-family: monospace;
}
.gj-leaderboard .gj-rank-1 { color: #ffd700; font-weight: bold; }
.gj-leaderboard .gj-rank-2 { color: #c0c0c0; font-weight: bold; }
.gj-leaderboard .gj-rank-3 { color: #cd7f32; font-weight: bold; }
.gj-leaderboard-empty {
    color: #888;
    font-style: italic;
    font-size: 13px;
    text-align: center;
    padding: 8px 0;
}
.gj-name-input-wrap {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 300px;
}
.gj-name-input {
    width: 100%;
    padding: 8px 12px;
    background: #1a0a0a;
    border: 1px solid #d4af37;
    color: #f0d080;
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    letter-spacing: 1px;
}
.gj-name-input:focus {
    outline: none;
    border-color: #ffcc00;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.4);
}
.gj-saved-msg {
    color: #4aff4a;
    font-size: 12px;
    margin-top: 4px;
}
