.speech-bubble {
    position: absolute;
    z-index: 900;
    max-width: min(260px, calc(100vw - 16px));
    padding: 8px 14px;
    border-radius: 14px;
    background-color: #ffffff;
    color: #222C37;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(6px) scale(0.9);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.speech-bubble.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Tail, pointing at the speaker. --tail-x is set from JS so it stays on target when the bubble is clamped. */
.speech-bubble::after {
    content: "";
    position: absolute;
    left: var(--tail-x, 50%);
    margin-left: -8px;
    border: 8px solid transparent;
}

.speech-bubble.is-above::after {
    top: 100%;
    border-top-color: #ffffff;
}

.speech-bubble.is-below::after {
    bottom: 100%;
    border-bottom-color: #ffffff;
}

.speech-target {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.speech-target img {
    transition: filter 0.4s ease;
    filter: var(--fury-filter, drop-shadow(0 0 0 transparent)) var(--poison-glow, drop-shadow(0 0 0 transparent)) var(--burn-glow, drop-shadow(0 0 0 transparent));
}

.speech-target.is-furious {
    --fury-filter: sepia(1) saturate(8) hue-rotate(-35deg) drop-shadow(0 0 6px rgba(255, 0, 0, 0.6));
}

.speech-target {
    position: relative;
}

.anger-mark {
    position: absolute;
    top: -4px;
    right: -4%;
    width: 34px;
    height: 34px;
    fill: #b00000;
    pointer-events: none;
    animation: anger-pulse 0.5s ease-in-out infinite alternate;
}

/* Once the logo stops shaking, the mark keeps throbbing, slower, swinging between -20 and +20 degrees */
.is-calm .anger-mark {
    animation: anger-throb 1.1s ease-in-out infinite alternate;
}

@keyframes anger-throb {
    from { transform: scale(0.92) rotate(-20deg); }
    to { transform: scale(1.1) rotate(20deg); }
}

@keyframes anger-pulse {
    from { transform: scale(0.85) rotate(-6deg); }
    to { transform: scale(1.15) rotate(6deg); }
}

/* Logos leaving the screen must not create a horizontal scrollbar */
#FavoritesGames {
    position: relative;
    overflow-x: hidden;
    overflow-x: clip;
}

.life-bar-wrapper {
    position: absolute;
    /* 50px above the image; the status icons are placed relative to the bar, so they follow */
    top: -50px;
    left: 4%;
    width: 82%;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.life-bar-wrapper.is-visible {
    opacity: 1;
}

.life-bar-level {
    position: relative;
    z-index: 1;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    margin-right: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background-color: #222C37;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.life-bar {
    position: relative;
    flex: 1 1 auto;
    height: 16px;
    border: 1px solid #ffffff;
    border-radius: 8px;
    background-color: #222C37;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.life-bar-damage,
.life-bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
}

/* Orange layer left behind by the fill, it shrinks to the fill's width shortly after a hit */
.life-bar-damage {
    background-color: #ffa31a;
    transition: width 0.3s ease-out;
}

.life-bar-fill {
    background-color: #3ddc4f;
}

.life-bar-label {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    padding-left: 8px;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 14px;
    text-align: center;
    -webkit-text-stroke: 3px #000000;
    paint-order: stroke fill;
}

.damage-text {
    position: absolute;
    z-index: 2;
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 800;
    -webkit-text-stroke: 4px #000000;
    paint-order: stroke fill;
    white-space: nowrap;
    pointer-events: none;
}

.damage-text.is-critical {
    color: #ffd400;
    font-size: 2.4rem;
}

/* Countdown ring on the left of the screen */
.fight-timer {
    position: absolute;
    left: 16px;
    z-index: 3;
    width: 72px;
    height: 72px;
    pointer-events: none;
}

.fight-timer svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.fight-timer-track,
.fight-timer-ring {
    fill: none;
    stroke-width: 7;
}

.fight-timer-track {
    stroke: rgba(34, 44, 55, 0.25);
}

.fight-timer-ring {
    stroke: #2d8cff;
    stroke-linecap: round;
}

.fight-timer.is-urgent .fight-timer-ring {
    stroke: #e8141c;
}

.fight-timer-seconds {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #222C37;
    font-size: 1.6rem;
    font-weight: 800;
}

.fight-timer.is-urgent .fight-timer-seconds {
    color: #e8141c;
}

.screen-message {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1100;
    color: #e8141c;
    font-size: clamp(2.2rem, 11vw, 8rem);
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
    /* long messages wrap instead of leaving the screen */
    width: max-content;
    max-width: 92vw;
    -webkit-text-stroke: 8px #000000;
    paint-order: stroke fill;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.screen-message.is-win {
    color: #ffd400;
}

/* Badges in the top right corner of a target: cactus hint (left) and skull of a beaten target */
.target-badges {
    position: absolute;
    top: 0;
    right: 6%;
    z-index: 1;
    display: flex;
    gap: 4px;
}

.target-badge {
    width: 26px;
    height: 26px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background-color: #222C37;
    color: #ffffff;
    font-size: 0.7rem;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    cursor: help;
}

/* the cactus is shown in black and white */
.target-badge.is-cactus {
    font-size: 0.8rem;
    filter: grayscale(1) brightness(1.4);
}

.speech-target.is-furious .target-badges {
    display: none;
}

/* Thrown when a target is beaten; can be picked up once it landed */
.loot-item {
    position: absolute;
    z-index: 2;
    font-size: 2.24rem;
    line-height: 1;
    pointer-events: none;
    /* Colored outline following the shape of the image, then a soft halo, then a shadow */
    filter: drop-shadow(0 0 1px var(--rarity-color, #ffffff)) drop-shadow(0 0 1px var(--rarity-color, #ffffff))
        drop-shadow(0 0 5px var(--rarity-color, #ffffff)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

/* Copy of a picked up item flying to the inventory bar */
.loot-item.is-flying {
    position: fixed;
    z-index: 1200;
}

/* A landed item pulses, to invite the player to take it. The independent `scale` property is used so that
   the transform placing the item is left alone. */
.loot-item.is-landed {
    cursor: pointer;
    pointer-events: auto;
    animation: loot-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes loot-pulse {
    from { scale: 1; }
    to { scale: 1.2; }
}

.loot-item.is-landed:hover {
    filter: drop-shadow(0 0 2px var(--rarity-color, #ffffff)) drop-shadow(0 0 2px var(--rarity-color, #ffffff))
        drop-shadow(0 0 10px var(--rarity-color, #ffffff)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

.loot-item img,
.inventory-slot-item img {
    display: block;
    width: 1em;
    height: 1em;
    object-fit: contain;
}

/* Inventory bar, at the bottom of the screen. The slots shrink with the screen so the whole bar always fits. */
.inventory-bar {
    position: fixed;
    bottom: 8px;
    left: 50%;
    z-index: 950;
    display: flex;
    flex-direction: column;
    max-width: calc(100vw - 8px);
    padding: 6px 8px;
    border-radius: 10px;
    background-color: rgba(34, 44, 55, 0.92);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.inventory-bar.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* First row of the bar: stats and slots (a second row, the skill tree, is styled in skills.css) */
.inventory-main {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Room for the bar at the very bottom of the page. It is added to the footer, not to the body: padding on the
   body would show the fixed animated header behind the page. */
body.has-inventory #footer {
    padding-bottom: 85px;
}

/* Power above the gold, on the left of the slots */
.inventory-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 50px;
    margin-right: 3px;
    padding-right: 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
    text-align: center;
}

.inventory-power {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #ffffff;
    cursor: pointer;
}

.inventory-power-main {
    text-align: center;
}

/* Counter of bonus items (cactus...), on the right of the power, on the line of the number (not of the whole
   block with its label above) */
.inventory-bonuses {
    align-self: flex-end;
    margin-bottom: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inventory-bonuses:empty {
    display: none;
}

.inventory-bonus {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 5px 0 3px;
    border: 1px solid var(--rarity-color, #ffffff);
    border-radius: 9px;
    background-color: rgba(255, 255, 255, 0.08);
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1.3;
}

.inventory-bonus-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.inventory-bonus-icon img {
    display: block;
    width: 1em;
    height: 1em;
}

.inventory-bar.has-bonus .inventory-slot {
    width: min(44px, calc((100vw - 165px) / 6));
    height: min(44px, calc((100vw - 165px) / 6));
}

.inventory-power-label {
    font-size: 0.5rem;
    text-transform: uppercase;
    opacity: 0.7;
}

.inventory-power-value {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    color: #ffd400;
}

.inventory-gold {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffd400;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
}

.inventory-gold-value {
    display: inline-block;
}

.gold-coin {
    display: inline-block;
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    box-sizing: border-box;
    border: 1px solid #8a6200;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff3a0, #ffd400 55%, #c79100);
}

.gold-coin.is-flying {
    position: fixed;
    z-index: 1200;
    width: 14px;
    height: 14px;
    pointer-events: none;
}

/* 6 slots plus the stats column: the slot size follows the screen width, up to 44px */
.inventory-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(44px, calc((100vw - 120px) / 6));
    height: min(44px, calc((100vw - 120px) / 6));
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 7px;
    background-color: rgba(255, 255, 255, 0.06);
}

.inventory-slot.is-filled {
    border-color: var(--rarity-color, #ffffff);
    box-shadow: 0 0 6px var(--rarity-color, #ffffff);
}

/* Faded icon of what the slot accepts */
.inventory-slot-ghost {
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.25;
    filter: grayscale(1);
}

.inventory-slot.is-filled .inventory-slot-ghost {
    display: none;
}

.inventory-slot-item {
    font-size: 1.3rem;
    line-height: 1;
}

.inventory-slot-bonus {
    position: absolute;
    right: 3px;
    bottom: 0;
    color: #ffd400;
    font-size: 0.6rem;
    font-weight: 800;
    -webkit-text-stroke: 3px #000000;
    paint-order: stroke fill;
}

/* Frame describing the item of an inventory slot */
.item-tooltip {
    position: fixed;
    z-index: 960;
    min-width: 170px;
    max-width: min(310px, calc(100vw - 16px));
    padding: 10px 28px 10px 14px;
    border: 2px solid var(--rarity-color, #ffffff);
    border-radius: 10px;
    background-color: rgba(34, 44, 55, 0.97);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease, visibility 0.15s;
    pointer-events: none;
}

.item-tooltip.is-visible {
    visibility: visible;
    opacity: 1;
}

.item-tooltip.is-pinned {
    pointer-events: auto;
}

/* Tail pointing down at the slot */
.item-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--tail-x, 50%);
    margin-left: -8px;
    border: 8px solid transparent;
    border-top-color: var(--rarity-color, #ffffff);
}

.item-tooltip-name {
    color: var(--rarity-color, #ffffff);
    font-weight: 800;
}

.item-tooltip-rarity {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.7;
}

.item-tooltip-skills {
    margin-top: 4px;
}

.item-tooltip-skill {
    color: #ffd400;
    font-size: 0.78rem;
    font-weight: 700;
}

.item-tooltip-close {
    position: absolute;
    top: 2px;
    right: 6px;
    display: none;
    padding: 0 4px;
    border: 0;
    background: none;
    color: #ffffff;
    font-size: 1.3rem;
    line-height: 1.2;
    opacity: 0.7;
    cursor: pointer;
}

.item-tooltip-close:hover {
    opacity: 1;
}

.item-tooltip.is-pinned .item-tooltip-close {
    display: block;
}

.inventory-slot.is-filled {
    cursor: pointer;
}

.damage-text.is-poison {
    color: #6bff4a;
}

/* A poisoned or burning target glows, on top of its fury tint */
.speech-target.is-poisoned {
    --poison-glow: drop-shadow(0 0 8px #3dff3d);
}

.speech-target.is-burning {
    --burn-glow: drop-shadow(0 0 8px #ff7a1a);
}

.status-indicator.is-poison {
    --status-color: #6bff4a;
}

.status-indicator.is-burn {
    --status-color: #ff8a1f;
}

.damage-text.is-pet {
    color: #4fd8ff;
}

.damage-text.is-burn {
    color: #ff3b30;
}

/* Companion fighting next to the target */
.fight-pet {
    position: absolute;
    bottom: -6px;
    left: 0;
    z-index: 1;
    font-size: 2rem;
    line-height: 1;
    pointer-events: none;
}

/* Give up button, under the fight timer */
.fight-giveup {
    position: absolute;
    left: 16px;
    z-index: 3;
    width: 72px;
    padding: 4px 0;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    background-color: rgba(34, 44, 55, 0.9);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.fight-giveup:hover {
    background-color: #e8141c;
}

/* Damage over time icons (poison, burn) in a row above the life bar, all the same size.
   Each has a ring emptying as the effect runs out. */
.status-row {
    position: absolute;
    bottom: calc(100% + 3px);
    left: 4px;
    display: flex;
    gap: 4px;
}

.status-indicator {
    position: relative;
    display: none;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.status-indicator.is-active {
    display: flex;
}

.status-indicator svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.status-indicator-track,
.status-indicator-ring {
    stroke-width: 2.5;
}

.status-indicator-track {
    fill: rgba(34, 44, 55, 0.9);
    stroke: rgba(255, 255, 255, 0.2);
}

.status-indicator-ring {
    fill: none;
    stroke: var(--status-color, #6bff4a);
    stroke-linecap: round;
}

.status-indicator-icon {
    position: relative;
    font-size: 0.65rem;
    line-height: 1;
}

.status-indicator-stacks {
    position: absolute;
    right: -6px;
    bottom: -4px;
    color: #ffffff;
    font-size: 0.55rem;
    font-weight: 800;
    -webkit-text-stroke: 3px #000000;
    paint-order: stroke fill;
}

/* Upgrade preview: the new values in green next to the current ones */
.item-tooltip-change {
    color: #6bff4a;
    font-weight: 700;
}

.item-tooltip-text {
    margin-bottom: 4px;
    font-size: 0.85rem;
    opacity: 0.9;
}

.item-tooltip-upgrade {
    display: none;
    width: 100%;
    margin-top: 8px;
    padding: 5px 10px;
    border: 0;
    border-radius: 6px;
    background-color: #ffd400;
    color: #222C37;
    font-weight: 800;
    cursor: pointer;
}

.item-tooltip-upgrade.is-available {
    display: block;
}

.item-tooltip-upgrade.is-confirming {
    background-color: #3ddc4f;
}

.item-tooltip-upgrade:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.item-tooltip-upgrade .gold-coin {
    margin-left: 2px;
    vertical-align: -2px;
}

/* Frozen fight timer: the ring and the seconds turn icy while the countdown is stopped */
.fight-timer.is-frozen {
    filter: drop-shadow(0 0 6px #7fdcff);
}

.fight-timer.is-frozen .fight-timer-ring {
    stroke: #7fdcff;
}

.fight-timer.is-frozen .fight-timer-seconds {
    color: #2b9cd8;
}

.damage-text.is-freeze {
    color: #7fdcff;
}

/* The boss only shows up once the other targets are beaten */
.best-games.is-boss-hidden {
    display: none;
}

.best-games.is-boss img {
    max-height: 82px;
}

.item-tooltip-buy {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 5px 10px;
    border: 0;
    border-radius: 6px;
    background-color: #ffd400;
    color: #222C37;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
}

.item-tooltip-buy:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.item-tooltip-buy .gold-coin {
    margin-left: 2px;
    vertical-align: -2px;
}

/* How to attack, under the image during a fight */
.fight-hint {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: min(280px, 90vw);
    transform: translateX(-50%);
    color: #222C37;
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.fight-hint.is-visible {
    opacity: 1;
}

.fight-hint-icon {
    display: inline-block;
    font-size: 1.1rem;
    animation: fight-hint-tap 0.9s ease-in-out infinite;
}

@keyframes fight-hint-tap {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(0.88); }
}

/* Button to enter the dungeon, shown once the boss is beaten */
.dungeon-entry {
    margin-top: 10px;
    text-align: center;
}

.dungeon-entry.is-hidden {
    display: none;
}

.dungeon-button {
    display: inline-block;
    padding: 14px 34px;
    border-radius: 10px;
    background-color: #222C37;
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.dungeon-button:hover {
    background-color: #e8141c;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-2px);
}

.damage-text.is-wind {
    color: #b980ff;
}

/* Smaller message, for the skill points */
.screen-message.is-small {
    font-size: clamp(1.3rem, 6vw, 3.2rem);
    -webkit-text-stroke: 5px #000000;
}

/* Label of the spell "Ctrl+C Ctrl+V" when it replays the clicks */
.damage-text.is-replay {
    color: #ffffff;
    font-size: 1.1rem;
    font-family: Consolas, monospace;
}

/* Bots (spell "Bot"): mouse cursors on the target */
.bot-cursor {
    position: absolute;
    z-index: 3;
    width: 18px;
    height: 25px;
    margin: -2px 0 0 -2px;
    transform-origin: 2px 2px;
    transition: left 0.24s ease-out, top 0.24s ease-out;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

.bot-cursor svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: var(--bot-color, #ffffff);
    stroke: #111111;
    stroke-width: 1.5;
    stroke-linejoin: round;
}

/* Ring spreading from the tip of a cursor when it clicks */
.bot-click {
    position: absolute;
    z-index: 2;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border: 2px solid var(--bot-color, #ffffff);
    border-radius: 50%;
    pointer-events: none;
}
