.cm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.cm-modal-backdrop.is-open {
  display: flex;
}

.cm-modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  overflow-y: auto;
  overflow-x: hidden;
}

.cm-modal.cm-modal--skills {
  overflow: visible;
}

.cm-modal.cm-modal--skills .cm-panel__body {
  overflow: visible;
}

.cm-modal .cm-panel__body {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.cm-modal__actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.cm-modal-help p {
  margin: 0 0 10px;
}

.cm-modal-help p:last-child {
  margin-bottom: 0;
}

.cm-modal-devlog {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cm-modal-devlog__entry h4 {
  margin: 0 0 6px;
  color: var(--gold);
  font-family: var(--font-panel-title);
  font-size: 13px;
}

.cm-modal-devlog__entry ul {
  margin: 0;
  padding-left: 18px;
}

.cm-modal-devlog__entry li + li {
  margin-top: 4px;
}

.cm-skill-choice {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cm-skill-choice__grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.cm-skill-choice__grid.is-single {
  display: flex;
}

.cm-skill-choice-card {
  flex: 1 1 calc(50% - 5px);
  min-width: 0;
  border: 1px solid var(--bronze-dark);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.04), transparent 55%), var(--slot-inner);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: visible;
}

.cm-skill-choice-card.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(232, 212, 168, 0.28), 0 0 10px rgba(232, 212, 168, 0.22);
}

.cm-skill-choice-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cm-skill-choice-card__head-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cm-skill-choice-card h4 {
  margin: 0;
  color: var(--gold);
  font-family: var(--font-panel-title);
  font-size: 13px;
}

.cm-skill-choice-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.cm-skill-choice-card__copy {
  border: 1px solid rgba(196, 163, 90, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(15, 10, 8, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cm-skill-choice-card__lvl {
  font-size: 11px;
  color: var(--gold-dim);
}

.cm-skill-choice-card__mana-badge,
.cm-skill-choice-card__heal-badge,
.cm-skill-choice-card__damage-badge {
  border: 1px solid var(--bronze-dark);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.cm-skill-choice-card__mana-badge {
  color: #9fd3ff;
  background: rgba(11, 20, 30, 0.7);
}

.cm-skill-choice-card__heal-badge {
  color: #8fd88a;
  background: rgba(20, 30, 11, 0.7);
}

.cm-skill-choice-card__damage-badge {
  color: #ef4444;
  background: rgba(30, 11, 11, 0.7);
}

.cm-skill-choice-card__delta s {
  color: #b98383;
  margin-right: 4px;
  text-decoration: line-through;
}

.cm-skill-choice-card__delta strong {
  color: #8fd88a;
  font-weight: 700;
}

.cm-skill-choice__grid.is-single .cm-skill-choice-card {
  flex-basis: 100%;
}

.cm-start-placeholder {
  margin-top: 12px;
  font-size: 12px;
  color: var(--gold-dim);
  text-align: center;
}

/* Game screen: simple fixed right column sizing (5 inventory cells). */
.cm-app--game .cm-main {
  grid-template-columns: 260px minmax(320px, 1fr) 300px;
  max-height: 100vh;
}

.cm-app--game .cm-col--center {
  min-height: 0;
}

.cm-app--game .cm-field {
  min-height: 0;
}

.cm-app--game .cm-col--right .cm-panel__body {
  padding-left: 10px;
  padding-right: 10px;
}

.cm-app--game .cm-col--right .cm-panel--inventory .cm-panel__body,
.cm-app--game .cm-col--right .cm-panel--consumables .cm-panel__body {
  align-items: center;
}

.cm-app--game .cm-col--right .cm-panel--inventory .cm-inv-wrap {
  width: 276px;
  max-width: 276px;
  min-height: var(--inv-cell);
  padding-right: 0;
  scrollbar-gutter: auto;
}

.cm-app--game .cm-panel--consumables .cm-cons-wrap {
  width: 276px;
  max-width: 276px;
  padding-right: 0;
}

.cm-app--game .cm-equip-slot__box--drop-target {
  border-color: #e8d4a8;
  box-shadow: 0 0 0 2px rgba(232, 212, 168, 0.45), inset 0 0 14px rgba(232, 212, 168, 0.2);
}

.cm-app--game .cm-skill .cm-skill__btn {
  display: flex;
  align-items: center;
  gap: var(--cm-gap-xs);
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  font: inherit;
}

.cm-app--game .cm-skill .cm-skill__btn .cm-skill__name {
  flex: 1;
  min-width: 0;
}

.cm-app--game .cm-skill .cm-skill__btn .cm-skill__mana {
  margin-left: auto;
}

.cm-app--game .cm-skill .cm-skill__btn .cm-skill__cooldown {
  margin-left: 6px;
  font-size: 10px;
  color: #ffce8f;
  border: 1px solid rgba(180, 103, 45, 0.7);
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.2;
}

.cm-app--game .cm-skills__divider {
  list-style: none;
  height: 1px;
  margin: 6px 2px;
  background: linear-gradient(90deg, rgba(196, 163, 90, 0), rgba(196, 163, 90, 0.75), rgba(196, 163, 90, 0));
}

.cm-app--game .cm-col--right .cm-panel--skills .cm-skills-viewport {
  max-height: none;
}

.cm-app--game .cm-inv-cell,
.cm-app--game .cm-hot-slot,
.cm-app--game .cm-equip-slot__box {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", var(--font-ui);
}

/* Hover card for inventory items (new UI style). */
.inventory-item-detail-popover {
  position: fixed;
  z-index: 99990;
  left: -9999px;
  top: 0;
  max-width: min(320px, calc(100vw - 24px));
  pointer-events: none;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  opacity: 0.98;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
}

.inventory-item-detail-popover[hidden] {
  display: none !important;
}

.item-detail-card {
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #2d2118 0%, #1e1410 100%);
  border: 1px solid var(--bronze-dark);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(196, 163, 90, 0.15);
  backdrop-filter: blur(1px);
}

.item-detail-rarity-common { border-color: #7a6855; }
.item-detail-rarity-rare { border-color: #00d2ff; }
.item-detail-rarity-unique { border-color: #c445ff; }

.item-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(196, 163, 90, 0.25);
}

.item-detail-rarity,
.item-detail-type,
.item-detail-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-dim);
}

.item-detail-stack-pill {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--bronze-dark);
  border-radius: 999px;
  padding: 2px 7px;
}

.item-detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.skill-detail-topline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.skill-detail-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-left: auto;
}

.skill-detail-badges--item {
  margin-bottom: 8px;
}

.item-detail-section + .item-detail-section {
  margin-top: 8px;
}

.item-detail-icon {
  font-size: 20px;
  width: var(--equip-slot-size);
  height: var(--equip-slot-size);
  min-width: var(--equip-slot-size);
  min-height: var(--equip-slot-size);
  max-width: var(--equip-slot-size);
  max-height: var(--equip-slot-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-detail-icon .cm-sprite-stack {
  width: 100%;
  height: 100%;
}

.item-detail-icon .cm-sprite-stack--item .cm-sprite-stack__frame,
.item-detail-icon .cm-sprite-stack--item .cm-sprite-stack__body {
  width: 100%;
  height: 100%;
}

.item-detail-icon__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.item-detail-name { font-weight: 700; }
.item-detail-list { margin: 0; padding-left: 16px; }
.item-detail-list-plain { list-style: none; padding-left: 0; }
.item-detail-desc { margin: 0; color: var(--text-muted); }
.item-detail-muted { color: var(--text-muted); font-size: 11px; }

/* Rarity visuals for real item cells (Variant 1: Magic Glow). */
.item-rarity-common {
  border-color: #7a6855 !important;
}

.item-rarity-rare {
  border-color: #00d2ff !important;
  box-shadow: 
    inset 0 0 16px rgba(0, 210, 255, 0.35), 
    0 0 10px rgba(0, 210, 255, 0.4), 
    0 0 0 1px rgba(0, 210, 255, 0.5) !important;
}

.item-rarity-unique {
  border-color: #c445ff !important;
  box-shadow: 
    inset 0 0 16px rgba(196, 69, 255, 0.35), 
    0 0 12px rgba(196, 69, 255, 0.45), 
    0 0 0 1px rgba(196, 69, 255, 0.6) !important;
}

/* Ensure absolute item badges are anchored to item cells. */
.cm-equip-slot__box,
.cm-welcome-item {
  position: relative;
}

/* Weapon total damage badge (single number). */
.cm-item-weapon-damage {
  position: absolute;
  right: 3px;
  top: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: var(--gold);
  background: rgba(20, 14, 11, 0.92);
  border: 1px solid var(--bronze-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
  z-index: 2;
}

.cm-stat-value--up,
.cm-item-weapon-damage.cm-stat-value--up {
  color: #92e08d !important;
}

.cm-stat-value--down,
.cm-item-weapon-damage.cm-stat-value--down {
  color: #ff8d8d !important;
}

/* Consumables qty: circle at bottom-left. */
.cm-app--game .cm-panel--consumables .cm-inv-cell__qty {
  left: 3px;
  right: auto;
  bottom: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: var(--gold);
  background: rgba(20, 14, 11, 0.92);
  border: 1px solid var(--bronze-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

.cm-hot-slot__mana {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: #9fd3ff;
  background: rgba(11, 20, 30, 0.92);
  border: 1px solid var(--bronze-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

.cm-hot-slot__cooldown {
  position: absolute;
  right: 3px;
  top: 3px;
  min-width: 18px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  color: #ffce8f;
  background: rgba(38, 18, 12, 0.92);
  border: 1px solid rgba(180, 103, 45, 0.8);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}
