*{
    box-sizing: border-box;
}

body{
    margin: 0;
    background: #2d2218;
    color: white;
    font-family: Georgia, serif;

    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#game{
    width: 100%;
    height: 100vh;
    height: 100dvh;

    display: flex;
    flex-direction: column;

    padding: 20px;
}

header{
    text-align: center;
    margin-bottom: 20px;
}

/* ---------------------------------- */
/* Player panel                        */
/* ---------------------------------- */

#topPanel{
    display: flex;
    gap: 20px;
    height: 220px;
    margin-bottom: 30px;
}

#playerPanel{
    position: relative;
    flex: 1;

    background: #3d2d1f;
    border: 2px solid #9d7b48;
    border-radius: 12px;
    padding: 20px;
    overflow: hidden;
}

#healthBar{
    width: 320px;
    max-width: 100%;
    height: 24px;

    background: #333;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 10px;
}

#healthFill{
    height: 100%;
    width: 100%;
    background: #3bb143;
    transition: width .3s;
}

.weaponBadge{
    display: block;
    margin-top: 6px;
    padding: 2px 10px;
    border-radius: 20px;
    background: #9d7b48;
    color: #2d2218;
    font-size: 13px;
    font-weight: bold;
    width: fit-content;
}

@keyframes flashHeal{
    0%   { box-shadow: inset 0 0 0 999px rgba(59, 177, 67, .35); }
    100% { box-shadow: inset 0 0 0 999px rgba(59, 177, 67, 0); }
}

@keyframes flashDamage{
    0%   { box-shadow: inset 0 0 0 999px rgba(196, 32, 38, .4); }
    100% { box-shadow: inset 0 0 0 999px rgba(196, 32, 38, 0); }
}

.flashHeal{
    animation: flashHeal .6s ease-out;
}

.flashDamage{
    animation: flashDamage .6s ease-out;
}

.hpPopup{
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    animation: hpPopupRise .9s ease-out forwards;
}

.hpPopupHeal{
    color: #58d968;
}

.hpPopupDamage{
    color: #ff5c5c;
}

@keyframes hpPopupRise{
    0%   { opacity: 0; transform: translateY(0); }
    15%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-40px); }
}

/* ---------------------------------- */
/* Floor / cards                       */
/* ---------------------------------- */

#floor{
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 35px;
}

.card{
    position: relative;

    width: clamp(150px, 18vw, 250px);
    aspect-ratio: 5 / 6;

    background: white;
    border-radius: 14px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, .45);

    cursor: pointer;
    user-select: none;
    overflow: hidden;

    transition: transform .15s, box-shadow .15s;
}

.card:hover{
    transform: translateY(-12px) scale(1.04);
    box-shadow: 0 20px 35px rgba(0, 0, 0, .6);
}

.cardEnter{
    animation: cardEnter .35s ease-out backwards;
}

@keyframes cardEnter{
    0%   { opacity: 0; transform: translateY(18px) scale(.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.red{
    color: #c42026;
}

.black{
    color: #202020;
}

.cardCorner{
    position: absolute;
    font-size: 30px;
    font-weight: bold;
}

.topLeft{
    top: 12px;
    left: 14px;
}

.bottomRight{
    right: 14px;
    bottom: 12px;
    transform: rotate(180deg);
}

.cardCenter{
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
}

.cardType{
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
}

.cardLevel{
    margin-top: 12px;
    font-size: 42px;
    font-weight: bold;
}

/* ---------------------------------- */
/* Log                                 */
/* ---------------------------------- */

#log{
    flex: 2;
    background: #181818;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
}

.logEntry{
    margin: 0 0 10px 0;
    padding-left: 10px;
    border-left: 2px solid #444;
    color: #bbb;
    line-height: 1.4;
}

.logEntryLatest{
    border-left-color: #d4af37;
    color: #f1e6c8;
    font-weight: bold;
}

/* ---------------------------------- */
/* Buttons                             */
/* ---------------------------------- */

#endFloor{
    margin: 20px auto;
    display: block;

    padding: 12px 30px;
    font-size: 18px;
    font-family: inherit;

    color: #f1e6c8;
    background: #6b4a24;
    border: 2px solid #9d7b48;
    border-radius: 8px;

    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
}

#endFloor:hover:not(:disabled){
    background: #85602f;
    transform: translateY(-2px);
}

#endFloor:disabled,
#endFloor.disabled{
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* ---------------------------------- */
/* Modals (combat / game over / win)   */
/* ---------------------------------- */

#combatWindow,
#gameOverWindow,
#victoryWindow{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    display: flex;
    justify-content: center;
    align-items: center;

    background: rgba(0, 0, 0, .8);
    opacity: 1;
    transition: opacity .2s ease;
    z-index: 10;
}

#combatWindow.hidden,
#gameOverWindow.hidden,
#victoryWindow.hidden{
    display: flex !important;
    opacity: 0;
    pointer-events: none;
}

#combatBox,
#gameOverBox,
#victoryBox{
    background: #3d2d1f;
    border: 3px solid #9d7b48;
    border-radius: 15px;
    text-align: center;

    transform: scale(1);
    transition: transform .2s ease;
}

#combatWindow.hidden #combatBox,
#gameOverWindow.hidden #gameOverBox,
#victoryWindow.hidden #victoryBox{
    transform: scale(.92);
}

#combatBox{
    padding: 40px;
    width: min(400px, 90vw);
}

#combatBox button{
    margin: 10px;
    padding: 12px 20px;
    font-size: 18px;
    font-family: inherit;

    color: #f1e6c8;
    background: #6b4a24;
    border: 2px solid #9d7b48;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}

#combatBox button:hover{
    background: #85602f;
}

#gameOverBox,
#victoryBox{
    padding: 50px;
    width: min(420px, 90vw);
}

#gameOverBox h1{
    font-size: 50px;
    color: #c42026;
}

#victoryBox h1{
    font-size: 50px;
    color: #d4af37;
}

#gameOverBox button,
#victoryBox button{
    padding: 15px 35px;
    font-size: 22px;
    font-family: inherit;

    color: #f1e6c8;
    background: #6b4a24;
    border: 2px solid #9d7b48;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
}

#gameOverBox button:hover,
#victoryBox button:hover{
    background: #85602f;
}

/* ---------------------------------- */
/* Mobile layout                       */
/* ---------------------------------- */

@media (max-width: 700px){

    #game{
        padding: 12px;
    }

    header h1{
        font-size: 22px;
        margin: 4px 0 12px;
    }

    #topPanel{
        height: auto;
        margin-bottom: 16px;
    }

    #playerPanel{
        padding: 14px;
    }

    #healthBar{
        width: 100%;
    }

    #floor{
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        align-content: center;
    }

    .card{
        width: 100%;
    }

    .cardCorner{
        font-size: 20px;
    }

    .cardType{
        font-size: 16px;
    }

    .cardLevel{
        font-size: 30px;
        margin-top: 6px;
    }

    #endFloor{
        width: 100%;
        min-height: 48px;
        font-size: 16px;
    }

    #log{
        flex: 1.4;
        padding: 10px;
    }

    #combatBox,
    #gameOverBox,
    #victoryBox{
        padding: 24px;
    }

    #combatBox button,
    #gameOverBox button,
    #victoryBox button{
        width: 100%;
        min-height: 48px;
        margin: 8px 0;
    }
}
