.game {
    display: block;
    width: -moz-fit-content;
    width: fit-content;
    margin: 0 auto; /* center the game block in the page */
    overflow: hidden;
    position: relative;
    /* keep space for the top UI so the canvas does not overlap it */
    padding-top: 80px;
}

.ui-bar {
    background-color: rgba(65, 88, 18, 0.61);
    border: solid 2px rgb(23, 90, 20);
    overflow: visible;
    padding: 10px;
    vertical-align: middle;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--game-width, 960px); /* match the canvas width when available */
    max-width: 100%;
    z-index: 9999;
}

/* position actions area at the right edge of the bar to avoid flex overlap */
.ui-bar .ui-bar-actions {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.ui-bar .ui-bar-actions .BUTTON_UWF {
    margin: 0;
}
.ui-bar {
    display: flex;
    align-items: center;
    min-height: 56px;
}

.ui-bar-items {
    list-style-type: none;
    margin: 0;
    padding: 0 12px; /* give some horizontal padding so items don't touch edges */
    display: flex;
    justify-content: space-between; /* keep badge and button separated */
    align-items: center;
    box-sizing: border-box;
}

.ui-bar-items .ui-bar-item:first-child {
    flex: 1 1 auto; /* let the left item take remaining space so it won't overlap */
}
.ui-bar-items .ui-bar-item:last-child {
    flex: 0 0 auto; /* keep the button size stable on the right */
}

.player-turn {
    z-index: 2; /* ensure badge sits above other inline elements */
}

.ui-bar-item {
    color: rgb(255, 255, 255);
    display: inline;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.player-turn {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
}

.turn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    border-radius: 8px;
    font-weight: 700;
    color: #fff;
    background: #8b0000; /* default P1 red */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    font-size: 15px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: visible;
}

@keyframes badge-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    }
}

.turn-badge {
    animation: badge-pulse 2.5s ease-in-out infinite;
}

.turn-text {
    color: #cfe3c1;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.player-1 .turn-badge {
    background: linear-gradient(180deg, #cc2222, #8b0000);
}

.player-2 .turn-badge {
    background: linear-gradient(180deg, #2a6eff, #1342a8);
}

.button {
    background-color: rgb(23, 90, 20);
    border: none;
    color: white;
    padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 2px 2px;
    transition-duration: 0.4s;
    cursor: pointer;
}

.button:hover {
    background-color: white;
    color: rgb(23, 90, 20);
}

.BUTTON_UWF {
    background: linear-gradient(to bottom, #557b25, #425913);
    border-radius: 10px;
    color: #c4d0b4;
    font-family: Arial;
    font-size: 20px;
    font-weight: 100;
    padding: 10px;
    box-shadow: 0px 6px 12px 0px #000000;
    text-shadow: 2px 3px 2px #4f661e;
    border: solid #425913 3px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    text-align: center;
}

.BUTTON_UWF {
    z-index: 1;
}

.BUTTON_UWF:hover {
    border: solid #425913 3px;
    background: linear-gradient(to bottom, #b4bf61, #314815);
    border-radius: 10px;
    text-decoration: none;
}

.context-menu {
    display: none;
    position: fixed;
    z-index: 100000;
    padding: 10px;
    width: 90px;
    max-width: 220px;
    background-color: rgba(65, 88, 18, 0.61);
    border: solid #425913 3px;
    box-shadow: 0px 6px 12px 0px #000000;
    border-radius: 10px;
}

.context-menu--active {
    display: block;
}

.context-menu-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu-item {
    display: block;
    margin-bottom: 4px;
}

.context-menu-link {
    display: block;
    padding: 4px 12px;
    color: #c4d0b4;
    font-family: Arial;
    font-size: 20px;
    font-weight: 100;
    text-decoration: none;
    float: right;
}

.context-menu-link:hover {
    color: rgba(65, 88, 18, 0.61);
    background-color: #c4d0b4;
}

.end-turn-banner {
    background-color: rgba(65, 88, 18, 0.61);
    position: absolute;

    height: 30%;
    top: 30%;
    right: 0;
    left: 100%;

    margin: 20px;
    z-index: 70;
    border: solid 2px #425913;
    overflow: hidden;
    justify-content: space-around;
    vertical-align: middle;
    transition: 0.5s;
}

.end-turn-banner.player-1 {
    background: linear-gradient(180deg, rgba(224, 75, 75, 0.95), rgba(139, 0, 0, 0.95));
    border-color: rgba(160, 20, 20, 0.9);
}

.end-turn-banner.player-2 {
    background: linear-gradient(180deg, rgba(74, 163, 255, 0.95), rgba(19, 66, 168, 0.95));
    border-color: rgba(20, 60, 160, 0.9);
}

.game canvas {
    display: block;
    position: relative;
    z-index: 0;
}

.hud {
    position: absolute; /* positioned within the .game container so it can sit on top or bottom of canvas */
    z-index: 9998;
    color: #ffffff;
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, rgba(16, 16, 16, 0.95), rgba(10, 10, 10, 0.9));
    padding: 10px 14px;
    border: 1px solid rgba(66, 89, 19, 0.9);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    transition:
        top 0.18s ease,
        left 0.18s ease;
    pointer-events: auto;
    min-width: 180px;
}

.hud.top {
    border-top: 2px solid rgba(100, 140, 40, 0.9);
}

.hud.bottom {
    border-bottom: 2px solid rgba(100, 140, 40, 0.9);
}

.hud img {
    display: block;
}
.hp-wrapper {
    width: 220px;
}
.hp-wrapper #hp-bar {
    width: 100%;
    max-width: 100%;
}

.end-turn-banner p {
    color: #c4d0b4;
    font-family: Arial;
    font-size: 40px;
    font-weight: 100;
    text-align: center;
}
