*{
    font-family: "Press Start 2P",cursive;
    box-sizing: border-box;
}
body{
    background: #000;
    margin: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
h1{
    margin: 0;
}
button{
   border: 0;
   cursor: pointer;
   font-size: 16px; 
}
button:hover{
    background-color: #ddd;
}
.container{
    display: inline-block;
    position: relative;
    width: min(100vw, 1024px);
    height: min(100vh, 576px);
    max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px);
    overflow: hidden;
    box-shadow: none;
    background: transparent;
}
canvas{
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}
.overlappingDiv{
    background-color: black;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}
.characterDialogueBox{
    background-color: white;
    height: 140px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 4px black solid;
    display: none;
    padding: 12px;
}
.userInterface{
    display: none;
}
.enemyPanel{
    background: linear-gradient(180deg, #ffffff 0%, #f1f5fb 100%);
    width: clamp(180px, 28vw, 250px);
    position: absolute;
    top: clamp(20px, 4vw, 44px);
    left: clamp(20px, 4vw, 48px);
    border: 4px solid #1c2638;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(14, 21, 35, 0.25);
}

.draggle{
    font-size: 16px;
}
.healthTrack{
    position: relative;
}

.healthTrackBackground{
    height: 8px;
    background-color: #d6deea;
    margin-top: 10px;
    border-radius: 999px;
}
.enemyHealthBar{
    height: 8px;
    background: linear-gradient(90deg, #2dd26f 0%, #b7d841 55%, #e25d40 100%);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-radius: 999px;
}
.playerPanel{
    background: linear-gradient(180deg, #ffffff 0%, #f1f5fb 100%);
    width: clamp(220px, 32vw, 300px);
    position: absolute;
    bottom: clamp(230px, 29vw, 290px);
    right: clamp(16px, 4vw, 50px);
    border: 4px solid #1c2638;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(14, 21, 35, 0.25);
}
.emby{
    font-size: 16px;
}
.playerHealthBar{
    height: 8px;
    background: linear-gradient(90deg, #2dd26f 0%, #b7d841 55%, #e25d40 100%);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border-radius: 999px;
}
.battlePanel{
    background: linear-gradient(180deg, #f7f9fc 0%, #e7eef9 100%);
    height: clamp(170px, 24vw, 220px);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 4px solid #1c2638;
    display: flex;
    padding: 10px;
    gap: 10px;
}
.dialogueBox{
    position: absolute;
    top: 10px;
    right: auto;
    bottom: 10px;
    left: 10px;
    width: 42%;
    background:
        radial-gradient(circle at 14% 16%, rgba(255,255,255,0.72) 0 16%, transparent 17%),
        linear-gradient(180deg, #ffffff 0%, #ebf1fb 100%);
    border: 3px solid #667b99;
    border-radius: 16px;
    padding: 14px;
    display: none;
    cursor: pointer;
    color: #22344f;
    font-size: 11px;
    line-height: 1.7;
    letter-spacing: 0.2px;
    overflow-y: auto;
    z-index: 2;
    box-shadow:
        0 10px 24px rgba(30, 47, 78, 0.2),
        inset 0 -2px 0 rgba(92, 116, 148, 0.35);
}

.dialogueBox::after{
    content: 'Tap to continue';
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 8px;
    color: #60738f;
    letter-spacing: 0.3px;
    pointer-events: none;
}
.attackBox{
    width: 58%;
    margin-left: auto;
    display: grid;
    grid-template-columns: repeat(2,1fr);
    gap: 10px;
    padding: 0;
}

.attackBox button{
    border: 2px solid #314868;
    margin: 0;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.35;
    padding: 10px 9px;
    color: #172c49;
    background:
        linear-gradient(180deg, #ffffff 0%, #dbe9ff 100%);
    box-shadow:
        0 4px 0 #a8bfdc,
        inset 0 1px 0 rgba(255,255,255,0.8);
    letter-spacing: 0.3px;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, background 120ms ease;
}

.attackBox button:hover{
    background: linear-gradient(180deg, #fff9de 0%, #ffd56f 100%);
    transform: translateY(-1px);
}

.attackBox button:active{
    transform: translateY(1px);
    box-shadow: 0 2px 0 #9db9e6;
}

.attackBox button[data-attack-name="Run"]{
    background: linear-gradient(180deg, #ffe8e4 0%, #ffc4b6 100%);
    border-color: #8c3d2f;
    color: #5a1e14;
    box-shadow: 0 4px 0 #d89b8d;
}

body.is-in-battle #mobileControls{
    display: none !important;
}

.attackBox button:disabled{
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.3);
    box-shadow: 0 2px 0 #bcc8d8;
}

.attackTypePanel{
    display: flex;
    align-items:center;
    justify-content: center;
    width: 58%;
    margin-left: auto;
    border-left: 0;
    border-top: 3px solid #9cb2cf;
    border-radius: 10px;
    background: linear-gradient(180deg, #f2f7ff 0%, #e4ecf9 100%);
}
.attackType{
    font-size: 13px;
    color: #2a3f67;
    text-align: center;
    line-height: 1.3;
}

.mobileControls{
    display: none;
    width: min(280px, 90vw);
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 42px);
    grid-template-areas:
        ". up ."
        "left down right";
    gap: 8px;
    touch-action: none;
}

.controlButton{
    border: 3px solid #16243b;
    background: linear-gradient(180deg, #ffffff 0%, #deebff 100%);
    color: #0f1f39;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.controlButton.up{ grid-area: up; }
.controlButton.left{ grid-area: left; }
.controlButton.down{ grid-area: down; }
.controlButton.right{ grid-area: right; }

.controlButton.active{
    background: linear-gradient(180deg, #ffe38f 0%, #ffd257 100%);
}

.help-toggle{
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    border: 3px solid #f8fbff;
    border-radius: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg,#ff6b6b 0%, #ee5a6f 100%);
    color: #ffffff;
    font-size: 12px;
    box-shadow: 0 12px 22px rgba(238, 90, 111, 0.4);
}

.help-toggle:hover{
    background: linear-gradient(135deg,#ff7c7c 0%, #f06a80 100%);
}

.overlay-bg{
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
    background: rgba(0,0,0,0.7);
}

.help-panel{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 130;
    display: none;
    width: min(680px,92vw);
    max-height: 82vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #f2f6ff 100%);
    border: 4px solid #172741;
    padding: 18px;
    box-shadow: 0 24px 46px rgba(0,0,0,0.35);
}

.close-help{
    float: right;
    border: 3px solid #000000;
    border-radius: 6px;
    background: #f3f3f3;
    color: #000000;
    padding: 6px 10px;
    font-size: 10px;
}

.close-help:hover{
    background: #e2e2e2;
}

.help-panel h2{
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #1f3260;
}

.help-panel h3{
    margin: 14px 0 8px 0;
    font-size: 12px;
    color: #2b4479;
    border-bottom: 2px solid #bdd0f8;
    padding-bottom: 4px;
}
.help-panel p{
    margin: 6px 0;
    font-size: 10px;
    line-height: 1.6;
    color: #182742;
}

.key{
    display: inline-block;
    padding: 3px 8px;
    border: 2px solid #000000;
    border-radius: 4px;
    background: #111111;
    color: #ffe66d;
    font-size: 9px;
}
.help-inline-image{
    display: inline-block;
    vertical-align: middle;
    width: 82px;
    height: 40px;
    margin-left: 8px;
    border: 2px solid #000000;
    background: #ffffff;
    image-rendering: pixelated;
}

.battle-prompt-overlay{
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 16, 30, 0.72);
    z-index: 210;
    padding: 16px;
}

.battle-prompt-overlay.is-open{
    display: flex;
}

.battle-prompt-panel{
    width: min(420px, 92vw);
    border: 4px solid #16243b;
    border-radius: 12px;
    background: linear-gradient(180deg, #f6fbff 0%, #dfeeff 100%);
    box-shadow: 0 20px 42px rgba(0, 0, 0, 0.35);
    padding: 20px;
    color: #10203c;
}

.battle-prompt-panel h3{
    margin: 0 0 10px 0;
    font-size: 14px;
}

.battle-prompt-panel p{
    margin: 0 0 16px 0;
    font-size: 11px;
    line-height: 1.6;
}

.battle-prompt-actions{
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.battle-prompt-actions button{
    border: 3px solid #172741;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 11px;
    color: #0f1f39;
    background: linear-gradient(180deg, #ffffff 0%, #deebff 100%);
    min-height: 36px;
    cursor: pointer;
    flex: 1;
    transition: all 0.2s ease;
}

.battle-prompt-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.battle-prompt-actions button:active {
    transform: translateY(0);
}

.battle-prompt-actions button:last-child{
    color: #ffffff;
    background: linear-gradient(180deg, #275fbd 0%, #1a468f 100%);
    border-color: #0d2b5f;
}

@media (max-width: 900px){
    body{
        padding: 0;
        align-items: center;
        justify-content: center;
    }

    .container{
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
    }

    button{
        font-size: 12px;
    }

    .draggle,
    .emby,
    .attackType{
        font-size: 12px;
    }

    .enemyPanel,
    .playerPanel{
        width: clamp(170px, 34vw, 240px);
        padding: 10px;
        border-width: 3px;
    }

    .playerPanel{
        bottom: clamp(220px, 33vw, 270px);
    }

    .battlePanel{
        border-top-width: 3px;
        height: clamp(190px, 34vw, 250px);
        padding: 8px;
        gap: 8px;
    }

    .attackTypePanel{
        width: 62%;
        border-top-width: 2px;
    }

    .attackBox{
        width: 62%;
    }

    .attackBox button{
        font-size: 10px;
        padding: 8px 7px;
    }
}

@media (max-width: 560px){
    body {
        overflow: hidden;
    }

    .battlePanel{
        display: block;
        height: auto;
        min-height: 230px;
        padding: 8px;
        gap: 8px;
    }

    .enemyPanel,
    .playerPanel{
        width: min(48vw, 190px);
        border-width: 2px;
        padding: 8px;
    }

    .enemyPanel{
        top: 8px;
        left: 8px;
    }

    .playerPanel{
        right: 8px;
        bottom: 202px;
    }

    .draggle,
    .emby{
        font-size: 10px;
    }

    .attackBox,
    .attackTypePanel{
        width: 100%;
    }

    .dialogueBox{
        top: 8px;
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        font-size: 10px;
        padding: 10px;
    }

    .attackTypePanel{
        border-left: 0;
        border-top: 3px solid black;
        min-height: 52px;
    }

    .mobileControls{
        display: grid;
        position: fixed;
        left: 50%;
        bottom: 10px;
        transform: translateX(-50%);
        z-index: 140;
    }
}

@media (max-width: 640px){
    .help-toggle{
        right: 12px;
        font-size: 10px;
        padding: 8px 12px;
    }

    .help-panel{
        padding: 12px;
    }

    .help-panel h3{
        font-size: 10px;
        padding: 8px;
    }

    .help-panel p{
        font-size: 8px;
    }

    .attackBox button{
        font-size: 9px;
        padding: 8px 6px;
    }

    .battle-prompt-panel{
        padding: 14px;
    }
    
    .battle-prompt-panel h3{
        font-size: 12px;
        margin-bottom: 10px;
    }

    .battle-prompt-panel p{
        font-size: 10px;
        margin-bottom: 12px;
    }

    .battle-prompt-actions{
        flex-direction: column;
        gap: 10px;
    }
    
    .battle-prompt-actions button{
        font-size: 10px;
        padding: 10px 12px;
        min-height: 38px;
        width: 100%;
    }
}

.help-inlline-image{
    display: inline-block;
    vertical-align:middle;
    width: 82px;
    height: 40px;
    margin-left: 8px;
    border: 2px solid #000000;
    background: #ffffff;
    image-rendering: pixelated;
}