@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');

*, ::before, ::after{
  --tw-border-spacing-x: 0;
  --tw-border-spacing-y: 0;
  --tw-translate-x: 0;
  --tw-translate-y: 0;
  --tw-rotate: 0;
  --tw-skew-x: 0;
  --tw-skew-y: 0;
  --tw-scale-x: 1;
  --tw-scale-y: 1;
  --tw-pan-x:  ;
  --tw-pan-y:  ;
  --tw-pinch-zoom:  ;
  --tw-scroll-snap-strictness: proximity;
  --tw-gradient-from-position:  ;
  --tw-gradient-via-position:  ;
  --tw-gradient-to-position:  ;
  --tw-ordinal:  ;
  --tw-slashed-zero:  ;
  --tw-numeric-figure:  ;
  --tw-numeric-spacing:  ;
  --tw-numeric-fraction:  ;
  --tw-ring-inset:  ;
  --tw-ring-offset-width: 0px;
  --tw-ring-offset-color: #fff;
  --tw-ring-color: rgb(59 130 246 / 0.5);
  --tw-ring-offset-shadow: 0 0 #0000;
  --tw-ring-shadow: 0 0 #0000;
  --tw-shadow: 0 0 #0000;
  --tw-shadow-colored: 0 0 #0000;
  --tw-blur:  ;
  --tw-brightness:  ;
  --tw-contrast:  ;
  --tw-grayscale:  ;
  --tw-hue-rotate:  ;
  --tw-invert:  ;
  --tw-saturate:  ;
  --tw-sepia:  ;
  --tw-drop-shadow:  ;
  --tw-backdrop-blur:  ;
  --tw-backdrop-brightness:  ;
  --tw-backdrop-contrast:  ;
  --tw-backdrop-grayscale:  ;
  --tw-backdrop-hue-rotate:  ;
  --tw-backdrop-invert:  ;
  --tw-backdrop-opacity:  ;
  --tw-backdrop-saturate:  ;
  --tw-backdrop-sepia:  ;
  --tw-contain-size:  ;
  --tw-contain-layout:  ;
  --tw-contain-paint:  ;
  --tw-contain-style:  ;
}

::backdrop{
  --tw-border-spacing-x: 0;
  --tw-border-spacing-y: 0;
  --tw-translate-x: 0;
  --tw-translate-y: 0;
  --tw-rotate: 0;
  --tw-skew-x: 0;
  --tw-skew-y: 0;
  --tw-scale-x: 1;
  --tw-scale-y: 1;
  --tw-pan-x:  ;
  --tw-pan-y:  ;
  --tw-pinch-zoom:  ;
  --tw-scroll-snap-strictness: proximity;
  --tw-gradient-from-position:  ;
  --tw-gradient-via-position:  ;
  --tw-gradient-to-position:  ;
  --tw-ordinal:  ;
  --tw-slashed-zero:  ;
  --tw-numeric-figure:  ;
  --tw-numeric-spacing:  ;
  --tw-numeric-fraction:  ;
  --tw-ring-inset:  ;
  --tw-ring-offset-width: 0px;
  --tw-ring-offset-color: #fff;
  --tw-ring-color: rgb(59 130 246 / 0.5);
  --tw-ring-offset-shadow: 0 0 #0000;
  --tw-ring-shadow: 0 0 #0000;
  --tw-shadow: 0 0 #0000;
  --tw-shadow-colored: 0 0 #0000;
  --tw-blur:  ;
  --tw-brightness:  ;
  --tw-contrast:  ;
  --tw-grayscale:  ;
  --tw-hue-rotate:  ;
  --tw-invert:  ;
  --tw-saturate:  ;
  --tw-sepia:  ;
  --tw-drop-shadow:  ;
  --tw-backdrop-blur:  ;
  --tw-backdrop-brightness:  ;
  --tw-backdrop-contrast:  ;
  --tw-backdrop-grayscale:  ;
  --tw-backdrop-hue-rotate:  ;
  --tw-backdrop-invert:  ;
  --tw-backdrop-opacity:  ;
  --tw-backdrop-saturate:  ;
  --tw-backdrop-sepia:  ;
  --tw-contain-size:  ;
  --tw-contain-layout:  ;
  --tw-contain-paint:  ;
  --tw-contain-style:  ;
}

/*
! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com
*/

/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/

*,
::before,
::after {
  box-sizing: border-box; /* 1 */
  border-width: 0; /* 2 */
  border-style: solid; /* 2 */
  border-color: #e5e7eb; /* 2 */
}

::before,
::after {
  --tw-content: '';
}

/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
5. Use the user's configured `sans` font-feature-settings by default.
6. Use the user's configured `sans` font-variation-settings by default.
7. Disable tap highlights on iOS
*/

html,
:host {
  line-height: 1.5; /* 1 */
  -webkit-text-size-adjust: 100%; /* 2 */
  -moz-tab-size: 4; /* 3 */
  -o-tab-size: 4;
     tab-size: 4; /* 3 */
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
  font-feature-settings: normal; /* 5 */
  font-variation-settings: normal; /* 6 */
  -webkit-tap-highlight-color: transparent; /* 7 */
}

/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/

body {
  margin: 0; /* 1 */
  line-height: inherit; /* 2 */
}

/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/

hr {
  height: 0; /* 1 */
  color: inherit; /* 2 */
  border-top-width: 1px; /* 3 */
}

/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/

abbr:where([title]) {
  -webkit-text-decoration: underline dotted;
          text-decoration: underline dotted;
}

/*
Remove the default font size and weight for headings.
*/

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
}

/*
Reset links to optimize for opt-in styling instead of opt-out.
*/

a {
  color: inherit;
  text-decoration: inherit;
}

/*
Add the correct font weight in Edge and Safari.
*/

b,
strong {
  font-weight: bolder;
}

/*
1. Use the user's configured `mono` font-family by default.
2. Use the user's configured `mono` font-feature-settings by default.
3. Use the user's configured `mono` font-variation-settings by default.
4. Correct the odd `em` font sizing in all browsers.
*/

code,
kbd,
samp,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
  font-feature-settings: normal; /* 2 */
  font-variation-settings: normal; /* 3 */
  font-size: 1em; /* 4 */
}

/*
Add the correct font size in all browsers.
*/

small {
  font-size: 80%;
}

/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/

table {
  text-indent: 0; /* 1 */
  border-color: inherit; /* 2 */
  border-collapse: collapse; /* 3 */
}

/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/

button,
input,
optgroup,
select,
textarea {
  font-family: inherit; /* 1 */
  font-feature-settings: inherit; /* 1 */
  font-variation-settings: inherit; /* 1 */
  font-size: 100%; /* 1 */
  font-weight: inherit; /* 1 */
  line-height: inherit; /* 1 */
  letter-spacing: inherit; /* 1 */
  color: inherit; /* 1 */
  margin: 0; /* 2 */
  padding: 0; /* 3 */
}

/*
Remove the inheritance of text transform in Edge and Firefox.
*/

button,
select {
  text-transform: none;
}

/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/

button,
input:where([type='button']),
input:where([type='reset']),
input:where([type='submit']) {
  -webkit-appearance: button; /* 1 */
  background-color: transparent; /* 2 */
  background-image: none; /* 2 */
}

/*
Use the modern Firefox focus style for all focusable elements.
*/

:-moz-focusring {
  outline: auto;
}

/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/

:-moz-ui-invalid {
  box-shadow: none;
}

/*
Add the correct vertical alignment in Chrome and Firefox.
*/

progress {
  vertical-align: baseline;
}

/*
Correct the cursor style of increment and decrement buttons in Safari.
*/

::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
  height: auto;
}

/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/

[type='search'] {
  -webkit-appearance: textfield; /* 1 */
  outline-offset: -2px; /* 2 */
}

/*
Remove the inner padding in Chrome and Safari on macOS.
*/

::-webkit-search-decoration {
  -webkit-appearance: none;
}

/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/

::-webkit-file-upload-button {
  -webkit-appearance: button; /* 1 */
  font: inherit; /* 2 */
}

/*
Add the correct display in Chrome and Safari.
*/

summary {
  display: list-item;
}

/*
Removes the default spacing and border for appropriate elements.
*/

blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

ol,
ul,
menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/*
Reset default styling for dialogs.
*/

dialog {
  padding: 0;
}

/*
Prevent resizing textareas horizontally by default.
*/

textarea {
  resize: vertical;
}

/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/

input::-moz-placeholder, textarea::-moz-placeholder {
  opacity: 1; /* 1 */
  color: #9ca3af; /* 2 */
}

input::placeholder,
textarea::placeholder {
  opacity: 1; /* 1 */
  color: #9ca3af; /* 2 */
}

/*
Set the default cursor for buttons.
*/

button,
[role="button"] {
  cursor: pointer;
}

/*
Make sure disabled buttons don't get the pointer cursor.
*/

:disabled {
  cursor: default;
}

/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
   This can trigger a poorly considered lint error in some tools but is included by design.
*/

img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block; /* 1 */
  vertical-align: middle; /* 2 */
}

/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/

img,
video {
  max-width: 100%;
  height: auto;
}

/* Make elements with the HTML hidden attribute stay hidden by default */

[hidden]:where(:not([hidden="until-found"])) {
  display: none;
}

.block{
  display: block;
}

.flex{
  display: flex;
}

.grid{
  display: grid;
}

.transform{
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.border{
  border-width: 1px;
}

.uppercase{
  text-transform: uppercase;
}

.filter{
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}

.transition{
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* ═══════════════════════════════════════════════════════════════
   BACKPACK HERO — Game Styles
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-deep: #0c0e1a;
    --bg-panel: #131627;
    --bg-cell: #1a1e35;
    --bg-cell-hover: #252a48;
    --border: #2a2e4a;
    --border-bright: #4a4e8a;
    --text: #e2e8f0;
    --text-dim: #64748b;
    --accent: #14b8a6;
    --accent-glow: rgba(20, 184, 166, 0.3);
    --energy: #f59e0b;
    --damage: #ef4444;
    --heal: #22c55e;
    --block: #3b82f6;
    --common: #94a3b8;
    --uncommon: #22d3ee;
    --rare: #a78bfa;
    --selected: rgba(20, 184, 166, 0.4);
}

/* ─── Root Layout ─────────────────────────────────────────────── */

.game-root {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-deep);
    font-family: 'Inter', 'Segoe UI', sans-serif;
    color: var(--text);
    position: relative;
    -webkit-user-select: none;
       -moz-user-select: none;
            user-select: none;
}

/* ─── Combat Panel ────────────────────────────────────────────── */

.combat-panel {
    flex-shrink: 0;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border);
}

.dungeon-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.floor-badge {
    color: var(--energy);
}

.room-badge {
    color: var(--text-dim);
}

/* Enemy */

.enemy-area {
    position: relative;
}

.enemy-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.75rem;
    padding: 0.4rem 0.6rem;
}

.enemy-emoji-large {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.enemy-info {
    flex: 1;
    min-width: 0;
}

.enemy-name {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.enemy-intent {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--damage);
    margin-top: 0.15rem;
}

.enemy-block {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--block);
    margin-top: 0.1rem;
}

.buffed-badge {
    color: var(--damage);
    font-weight: 900;
}

/* HP Bar */

.hp-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.hp-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
}

.player-hp {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.enemy-hp {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.55rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Player Stats */

.player-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-inline {
    gap: 0.75rem;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-dim);
    width: 40px;
    flex-shrink: 0;
}

.player-hp-section {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.energy-display {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 0.5rem;
    padding: 0.2rem 0.5rem;
}

.energy-icon {
    font-size: 0.9rem;
}

.energy-value {
    font-size: 0.9rem;
    font-weight: 900;
    color: var(--energy);
}

.block-display {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 800;
}

.block-value {
    color: var(--block);
}

/* End Turn Button */

.btn-end-turn {
    width: 100%;
    padding: 0.45rem;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-bottom: 3px solid #3730a3;
    border-radius: 0.6rem;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.15s;
}

.btn-end-turn:hover {
    filter: brightness(1.1);
}

.btn-end-turn:active {
    border-bottom-width: 0;
    transform: translateY(3px);
}

/* Floating Damage Numbers */

.float-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.floating-text {
    position: absolute;
    font-size: 1.1rem;
    font-weight: 900;
    animation: floatUp 1.2s ease-out forwards;
    white-space: nowrap;
}

.ft-damage {
    color: var(--damage);
}

.ft-block {
    color: var(--block);
}

.ft-heal {
    color: var(--heal);
}

.ft-player_damage {
    color: #ff6b6b;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-40px);
    }
}

/* Game Over */

.game-over-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.game-over-text {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--damage);
}

.game-over-info {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* ─── Backpack Grid ───────────────────────────────────────────── */

.backpack-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.4rem;
    gap: 0.3rem;
    overflow-y: auto;
    position: relative;
}

.backpack-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.grid-size {
    color: var(--border-bright);
}

.backpack-grid {
    display: grid;
    gap: 3px;
    flex: 1;
    min-height: 0;
}

.grid-cell {
    aspect-ratio: 1;
    background: var(--bg-cell);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
}

.grid-cell.empty:hover {
    background: var(--bg-cell-hover);
    border-color: var(--border-bright);
}

.grid-cell.occupied {
    border-color: var(--border-bright);
}

.grid-cell.occupied:hover {
    transform: scale(1.05);
    z-index: 2;
}

.grid-cell.selected {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    background: var(--selected);
}

.grid-cell.drag-over {
    border-color: var(--accent);
    background: var(--selected);
}

.grid-cell.usable {
    cursor: pointer;
    animation: pulse-glow 2s ease-in-out infinite;
}

.grid-cell.passive {
    border-style: dashed;
    opacity: 0.85;
}

/* Rarity border colors */

.grid-cell.rarity-common.occupied {
    border-color: var(--common);
}

.grid-cell.rarity-uncommon.occupied {
    border-color: var(--uncommon);
}

.grid-cell.rarity-rare.occupied {
    border-color: var(--rare);
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 4px rgba(245, 158, 11, 0.1);
    }

    50% {
        box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
    }
}

.item-emoji {
    font-size: clamp(1rem, 4vw, 1.5rem);
    line-height: 1;
}

.cost-badge {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 0.5rem;
    font-weight: 800;
    color: var(--energy);
    background: rgba(0, 0, 0, 0.6);
    padding: 0 3px;
    border-radius: 3px;
}

.cost-badge.cost-reduced {
    color: var(--heal);
    text-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}

.bonus-indicator {
    position: absolute;
    top: 1px;
    right: 2px;
    font-size: 0.55rem;
    font-weight: 900;
    border-radius: 2px;
    padding: 0 2px;
}

.bonus-dmg {
    color: var(--damage);
}

.bonus-blk {
    color: var(--block);
}

/* ─── Tooltip (BUG-5 FIX: anchored below grid, not floating off-screen) ─── */

.item-tooltip {
    position: absolute;
    bottom: 35%;
    left: 5%;
    right: 5%;
    width: 90%;
    margin: auto;
    background: rgba(30, 41, 59, 0.98);
    border: 1px solid var(--border-bright);
    border-radius: 0.8rem;
    padding: 0.8rem;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 800;
    font-size: 0.7rem;
}

.rarity-tag {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

.rarity-tag.common {
    background: rgba(148, 163, 184, 0.2);
    color: var(--common);
}

.rarity-tag.uncommon {
    background: rgba(34, 211, 238, 0.2);
    color: var(--uncommon);
}

.rarity-tag.rare {
    background: rgba(167, 139, 250, 0.2);
    color: var(--rare);
}

.tooltip-desc {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin: 0 0 0.3rem 0;
}

.tooltip-stats {
    display: flex;
    gap: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
}

.stat-dmg {
    color: var(--damage);
}

.stat-blk {
    color: var(--block);
}

.stat-heal {
    color: var(--heal);
}

.stat-cost {
    color: var(--energy);
}

/* ─── Staging Area ────────────────────────────────────────────── */

.staging-area {
    flex-shrink: 0;
    border-top: 2px solid var(--border);
    padding-top: 0.3rem;
}

.staging-label {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--energy);
    margin-bottom: 0.25rem;
}

.staging-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.staging-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-cell);
    border: 2px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.25rem 0.5rem;
    cursor: grab;
    transition: all 0.15s;
    font-size: 0.7rem;
}

.staging-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.staging-item.rarity-common {
    border-color: var(--common);
}

.staging-item.rarity-uncommon {
    border-color: var(--uncommon);
}

.staging-item.rarity-rare {
    border-color: var(--rare);
}

.staging-name {
    font-weight: 700;
    font-size: 0.6rem;
    color: var(--text);
}

/* ─── Loot Screen ─────────────────────────────────────────────── */

.loot-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.3s ease;
    padding: 0.5rem;
}

.loot-panel {
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.loot-title {
    font-size: 1rem;
    font-weight: 900;
    color: var(--energy);
    margin-bottom: 0.75rem;
}

.loot-choices {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.loot-card {
    background: var(--bg-panel);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    color: var(--text);
}

.loot-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.loot-card.rarity-common {
    border-color: var(--common);
}

.loot-card.rarity-uncommon {
    border-color: var(--uncommon);
}

.loot-card.rarity-rare {
    border-color: var(--rare);
}

.loot-emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.loot-name {
    font-size: 0.75rem;
    font-weight: 800;
}

.loot-rarity {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
}

.loot-rarity.common {
    color: var(--common);
}

.loot-rarity.uncommon {
    color: var(--uncommon);
}

.loot-rarity.rare {
    color: var(--rare);
}

.loot-desc {
    font-size: 0.6rem;
    color: var(--text-dim);
    flex: 1;
}

.loot-stats {
    display: flex;
    gap: 0.4rem;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.btn-skip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.35rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-skip:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* ─── Arrange Footer ──────────────────────────────────────────── */

.arrange-footer {
    flex-shrink: 0;
    padding: 0.4rem;
    text-align: center;
    border-top: 2px solid var(--border);
    background: var(--bg-panel);
}

.arrange-hint {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin: 0;
}

/* ─── Shared Buttons ──────────────────────────────────────────── */

.btn-primary {
    background: linear-gradient(135deg, #14b8a6, #0d9488);
    color: white;
    border: none;
    border-bottom: 3px solid #0f766e;
    border-radius: 0.6rem;
    padding: 0.5rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.15s;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:active {
    border-bottom-width: 0;
    transform: translateY(3px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════
   EVAL FIXES — New Visual States
   ═══════════════════════════════════════════════════════════════ */

/* UX-1: Energy flash on gain */

.energy-flash {
    animation: energyPulse 0.5s ease;
}

@keyframes energyPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.25);
        background: rgba(245, 158, 11, 0.3);
    }

    100% {
        transform: scale(1);
    }
}

/* UX-2: Activation flash */

.grid-cell.activated {
    animation: activateFlash 0.3s ease;
}

@keyframes activateFlash {
    0% {
        transform: scale(1);
        background: var(--bg-cell);
    }

    30% {
        transform: scale(0.9);
        background: rgba(245, 158, 11, 0.3);
    }

    100% {
        transform: scale(1);
        background: var(--bg-cell);
    }
}

/* UX-4: Shake on insufficient energy */

.grid-cell.shake {
    animation: shakeCell 0.4s ease;
}

@keyframes shakeCell {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    50% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-2px);
    }
}

/* UX-4: Cant-afford visual dimming */

.grid-cell.cant-afford {
    opacity: 0.6;
}

.cost-locked {
    color: var(--damage) !important;
    font-size: 0.45rem !important;
}

/* BUG-4: Discard button on staging items */

.discard-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--damage);
    font-size: 0.55rem;
    font-weight: 800;
    padding: 0 0.3rem;
    border-radius: 0.2rem;
    cursor: pointer;
    line-height: 1.2;
    transition: all 0.15s;
    margin-left: auto;
}

.discard-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--damage);
}

/* UX-3: Game over stats */

.game-over-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.3rem;
    width: 100%;
    max-width: 320px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.3rem 0.1rem;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--accent);
}

.stat-name {
    font-size: 0.45rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.best-run {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--energy);
    margin-top: 0.25rem;
}

/* UX-5: Combat interaction hint */

.combat-hint {
    flex-shrink: 0;
    text-align: center;
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-dim);
    padding: 0.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

/* HP bar warning colors */

.hp-bar.player-hp.hp-warning {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.hp-bar.player-hp.hp-critical {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    animation: hpPulse 1s ease-in-out infinite;
}

@keyframes hpPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Base Rarity Colors */

.rarity-common {
    border-color: var(--common);
}

.rarity-uncommon {
    border-color: var(--uncommon);
}

.rarity-rare {
    border-color: var(--rare);
}

.rarity-legendary {
    border-color: var(--legendary);
}

/* Events */

.event-panel {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    width: 90%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.event-emoji {
    font-size: 2.5rem;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.event-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.event-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.event-choice-btn {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.event-choice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    transform: translateY(-1px);
}