/* ==========================================================
   CHESS+ ROGUELIKE: FIXED 512x288 PIXEL RETRO STYLE
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --font-pixel: 'Silkscreen', 'Press Start 2P', monospace;
  --font-title: 'Press Start 2P', monospace;

  /* Palette: 16-bit retro arcade */
  --bg-viewport: #07090f;
  --bg-app: #0e111a;
  --bg-panel: #141824;
  --bg-card: #1b2030;
  --border-dark: #22283a;
  --border-light: #3a4460;
  --border-gold: #c89b3c;
  --gold: #f0c242;
  --gold-dim: #9a7620;
  --text-main: #e8ecf4;
  --text-muted: #828c9e;
  --accent-red: #e04848;
  --accent-green: #3ec86a;
  --accent-blue: #3e88e8;

  /* Board geometry */
  --tile-size: 36px;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg-viewport);
  color: var(--text-main);
  font-family: var(--font-pixel);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* ===== BALATRO HYPNOTIC CANVAS & VIEWPORT ===== */
.balatro-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
  background: #080a12;
}

#gameViewport {
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent !important;
  position: relative;
  z-index: 10;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: manipulation;
}

/* ===== RETRO 768x432 PIXEL CANVAS (1:1 PIXEL ACCURACY) ===== */
#app {
  width: var(--app-width, 768px);
  height: 432px;
  min-height: 432px;
  max-height: 432px;
  position: relative;
  background: var(--bg-app);
  border: 2px solid var(--border-dark);
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.92), 0 0 12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: center center;
}

/* ===== HEADER (26px) ===== */
.game-header {
  height: 26px;
  min-height: 26px;
  max-height: 26px;
  padding: 2px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 4px;
}

.logo-poke-ball {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #ffffff 22%, #181818 23%, #181818 32%, transparent 33%),
              linear-gradient(to bottom, #ee2828 0%, #ee2828 45%, #181818 46%, #181818 54%, #ffffff 55%, #ffffff 100%);
  border: 1px solid #000;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 5px rgba(238, 40, 40, 0.85);
}

.logo-poke-badge {
  font-family: var(--font-title);
  font-size: 8.5px;
  color: #ff3838;
  text-shadow: 1px 1px 0 #580000, 0 0 4px rgba(255, 56, 56, 0.5);
  letter-spacing: 0.5px;
}

.logo-text {
  font-family: var(--font-title);
  font-size: 8.5px;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.logo-plus {
  color: var(--accent-red);
}

.rogue-tag {
  font-family: var(--font-pixel);
  font-size: 7px;
  background: var(--gold-dim);
  color: #fff;
  padding: 1px 4px;
  border-radius: 2px;
}

.rogue-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  padding: 2px 6px;
  font-size: 7.5px;
}

.stat-label {
  color: var(--text-muted);
}

.stat-val {
  color: var(--gold);
  font-weight: 700;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Music BGM Controls ---- */
.music-widget {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  height: 20px;
  padding: 0 6px;
  gap: 5px;
  border-radius: 0;
  transition: border-color 0.15s, background 0.15s;
}

.music-widget:hover {
  border-color: var(--border-gold);
}

.btn-music {
  border: none;
  background: transparent;
  padding: 0;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-main);
  font-family: var(--font-pixel);
  font-size: 7.5px;
}

.btn-music:hover {
  background: transparent;
  color: var(--gold);
}

.btn-music.music-muted {
  color: var(--text-muted);
  opacity: 0.6;
}

.music-text {
  letter-spacing: 0.5px;
}

.music-slider-wrap {
  display: flex;
  align-items: center;
  width: 44px;
}

.music-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: #1e2433;
  border: 1px solid var(--border-light);
  border-radius: 0;
  outline: none;
  cursor: pointer;
}

.music-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 7px;
  height: 12px;
  background: var(--gold);
  border: 1px solid #ffffff;
  cursor: pointer;
  border-radius: 0;
}

.music-slider::-moz-range-thumb {
  width: 7px;
  height: 12px;
  background: var(--gold);
  border: 1px solid #ffffff;
  cursor: pointer;
  border-radius: 0;
}

.btn {
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  padding: 2px 7px;
  height: 20px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: #272f44;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-gold {
  border-color: var(--border-gold);
  color: var(--gold);
}

.btn-slot-upgrade {
  background: url('assets/ui/buy_button.png') no-repeat center !important;
  background-size: 100% 100% !important;
  image-rendering: pixelated !important;
  border: none !important;
  color: #fff !important;
  text-shadow: 1px 1px 0 #000;
  padding: 0 5px 2px 5px !important;
}

.btn-slot-upgrade:hover:not(:disabled) {
  filter: brightness(1.25);
  background: url('assets/ui/buy_button.png') no-repeat center !important;
  background-size: 100% 100% !important;
  color: #fff !important;
}

.btn-slot-upgrade:disabled {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.btn-cta-battle {
  background: #245830;
  border-color: var(--accent-green);
  color: #afffa4;
}

.btn-cta-battle:hover:not(:disabled) {
  background: #2d723d;
  color: #fff;
}

/* ===== MAIN GAME LAYOUT (Full remaining height in 432px canvas) ===== */
.game-layout {
  height: calc(432px - 28px);
  min-height: calc(432px - 28px);
  max-height: calc(432px - 28px);
  flex: 1;
  display: flex;
  gap: 6px;
  padding: 4px 6px 6px 6px;
  overflow: hidden;
}

/* Panel Box Common */
.card-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-dark);
  padding: 4px;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 7.5px;
  color: var(--gold);
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  letter-spacing: 0.5px;
}

/* ===== LEFT PANEL: TALISMANS (Fixed column: 175px matching Right Panel) ===== */
.left-panel {
  width: 175px;
  min-width: 175px;
  max-width: 175px;
  flex-shrink: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.talisman-panel {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.talisman-panel-title {
  font-family: var(--font-title);
  font-size: 7.5px;
  color: var(--gold);
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  text-align: center;
  width: 100%;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* Tabs: [BAG] and [SHOP] */
.talisman-tabs {
  display: flex;
  width: 100%;
  gap: 3px;
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.talisman-tab {
  flex: 1;
  height: 20px;
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.talisman-tab:hover {
  color: #fff;
  border-color: var(--border-gold);
}

.talisman-tab.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold);
}

/* Applying Banner */
.talisman-apply-banner {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 3px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.talisman-apply-msg {
  font-size: 6px;
  color: var(--text-normal);
  line-height: 1.1;
  font-family: var(--font-pixel);
}

.btn-cancel-apply {
  font-size: 6px;
  height: 16px;
  padding: 0 4px;
  background: #c0392b;
  border: 1px solid #e74c3c;
  color: #fff;
  cursor: pointer;
}

/* Talisman Content List */
.talisman-content {
  flex: 1 1 0%;
  min-height: 0;
  max-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  cursor: grab;
}

.talisman-content.is-dragging {
  cursor: grabbing;
}

.talisman-content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.talisman-content::-webkit-scrollbar-track,
.talisman-content::-webkit-scrollbar-thumb {
  display: none;
}

/* Individual Talisman Card */
.talisman-card {
  width: 100%;
  min-height: 56px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  padding: 5px 6px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  transition: border-color 0.15s, filter 0.15s;
}

.talisman-card:hover {
  border-color: var(--border-light);
  filter: brightness(1.1);
}

.talisman-card.bag-selected {
  border-color: #ff7675 !important;
  box-shadow: 0 0 5px rgba(231, 76, 60, 0.45);
}

.talisman-card.applying-active {
  border-color: var(--border-light);
  box-shadow: none;
}

.talisman-card-header {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  width: 100%;
}

.talisman-icon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  image-rendering: pixelated;
  flex-shrink: 0;
  display: block;
}

.talisman-card-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.talisman-name {
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  color: #fff;
  white-space: normal;
  line-height: 1.15;
  word-break: break-word;
}

.talisman-uses-badge {
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 1px;
  white-space: nowrap;
  flex-shrink: 0;
  color: #ffa502;
  background: rgba(255, 165, 2, 0.15);
  border: 1px solid rgba(255, 165, 2, 0.3);
  align-self: flex-start;
}

.talisman-spell-badge {
  color: #a29bfe !important;
  background: rgba(108, 92, 231, 0.25) !important;
  border: 1px solid rgba(162, 155, 254, 0.5) !important;
}

.talisman-target-desc,
.talisman-target-badge {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: #70a1ff;
  line-height: 1.15;
  white-space: normal;
  word-break: break-word;
  margin-top: 1px;
}

.talisman-desc {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
  word-break: break-word;
}

.talisman-card-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.btn-sell-talisman-card {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  height: 16px;
  padding: 0 5px;
  background: rgba(192, 57, 43, 0.2);
  border: 1px solid #e74c3c;
  color: #ff7675;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  white-space: nowrap;
}

.btn-sell-talisman-card:hover:not(:disabled) {
  background: #c0392b;
  border-color: #ff7675;
  color: #fff;
}

.btn-sell-talisman-card:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-sell-talisman-card:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--text-muted);
}

.btn-use-talisman {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  height: 16px;
  padding: 0 6px;
  background: #245830;
  border: 1px solid #2ed573;
  color: #afffa4;
  cursor: pointer;
}

.btn-use-talisman:hover {
  background: #2ed573;
  color: #000;
}

.btn-use-talisman.btn-cancel {
  background: #c0392b;
  border-color: #e74c3c;
  color: #fff;
}

.btn-buy-talisman {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  height: 18px;
  padding: 0 6px 2px 6px;
  background: url('assets/ui/buy_button.png') no-repeat center;
  background-size: 100% 100%;
  image-rendering: pixelated;
  border: none;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
}

.btn-buy-talisman:hover:not(:disabled) {
  filter: brightness(1.25);
}

.btn-buy-talisman:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-buy-talisman:disabled {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}


/* Status Badge on Equipped Cards */
.talisman-status-badge {
  font-family: var(--font-pixel);
  font-size: 5px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 1px;
  color: #2ed573;
  background: rgba(46, 213, 115, 0.15);
  border: 1px solid rgba(46, 213, 115, 0.4);
  white-space: nowrap;
  flex-shrink: 0;
}

.talisman-equipped-card {
  border-color: rgba(46, 213, 115, 0.35);
  background: #111b15;
}

.talisman-equipped-card:hover {
  border-color: #2ed573;
}

/* Empty unit message */
.talisman-empty-unit-msg {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 4px;
  width: 100%;
  border: 1px dashed var(--border-dark);
  box-sizing: border-box;
  margin-bottom: 2px;
  flex-shrink: 0;
}

/* Section Divider */
.talisman-section-divider {
  width: 100%;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  padding: 4px 0 2px 0;
  border-top: 1px dashed var(--border-dark);
  margin-top: 2px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ==========================================================
   TFT-STYLE SYNERGY PANEL (COMPACT & CLEAN)
   ========================================================== */
.synergy-card {
  width: 100%;
  background: #151928;
  border: 1px solid var(--border-dark);
  border-left: 3px solid var(--border-light);
  padding: 4px 5px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 3px;
  border-radius: 2px;
}

.synergy-card.synergy-active {
  background: #192036;
  border-color: rgba(255, 255, 255, 0.15);
}

.synergy-card .talisman-card-header {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.synergy-card .talisman-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
}

.synergy-card .talisman-name {
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.1;
}

.synergy-tiers-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 1px;
}

.synergy-tier-pill {
  font-family: var(--font-pixel);
  font-size: 5.5px;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.06);
  color: #718093;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.synergy-tier-pill.reached {
  font-weight: 700;
}

.synergy-tier-badge {
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 1px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.1;
  margin-left: auto;
}

.synergy-tier-badge.tier-active {
  box-shadow: 0 0 4px rgba(255, 215, 0, 0.3);
}

.synergy-tier-badge.tier-inactive {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8395a7;
}

.synergy-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.synergy-tier-line {
  font-family: var(--font-pixel) !important;
  font-size: 6px;
  line-height: 1.35;
  display: flex;
  align-items: flex-start;
  gap: 3px;
  text-transform: none;
}

.synergy-bullet {
  font-family: var(--font-pixel) !important;
  font-size: 6px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1.35;
}

.synergy-tier-text {
  font-family: var(--font-pixel) !important;
  font-size: 6px;
  line-height: 1.35;
  letter-spacing: 0;
  word-break: break-word;
  text-transform: none;
}

.synergy-units-row {
  font-family: var(--font-pixel) !important;
  font-size: 5.5px;
  color: #8395a7;
  line-height: 1.3;
  margin-top: 1px;
  padding-top: 2px;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
  word-break: break-word;
  text-transform: none;
}

.syn-empty-box {
  width: 100%;
  padding: 16px 8px;
  text-align: center;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.syn-empty-icon {
  font-size: 14px;
  opacity: 0.85;
}

.syn-empty-title {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  color: var(--gold);
  letter-spacing: 0.4px;
}

.syn-empty-hint {
  font-family: var(--font-pixel) !important;
  font-size: 6px;
  color: #8395a7;
  line-height: 1.35;
  text-transform: none;
}

/* Footer / Reroll & Sell */
.talisman-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.btn-sell-talisman {
  width: 100%;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(192, 57, 43, 0.2);
  border: 1px solid #e74c3c;
  color: #ff7675;
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
}

.btn-sell-talisman:hover:not(:disabled) {
  background: #c0392b;
  border-color: #ff7675;
  color: #fff;
}

.btn-sell-talisman:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-sell-talisman:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--text-muted);
  background: var(--bg-card);
}

.btn-reroll-talisman {
  width: 100%;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  cursor: pointer;
  box-sizing: border-box;
}

.btn-reroll-talisman:hover:not(:disabled) {
  background: var(--gold);
  color: #000;
}

.btn-reroll-talisman:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--text-muted);
}

/* Talisman Attached Seal Badge on Pieces */
.ui-talisman-mark {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 7px;
  height: 7px;
  image-rendering: pixelated;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 0 1px #000);
}

/* Eligible Target during Talisman / Spell Apply Mode (No yellow border, no glow) */
.talisman-target-eligible {
  box-shadow: none !important;
  outline: none !important;
  cursor: pointer !important;
}

.talisman-target-ineligible {
  opacity: 0.35 !important;
  filter: grayscale(0.8) !important;
  cursor: not-allowed !important;
}

.talisman-empty-msg {
  font-size: 6.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 6px;
  line-height: 1.5;
}

/* ===== CENTER ARENA (Responsive centered board view) ===== */
.arena-center {
  flex: 1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.board-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Top Battle Controls Bar (Crimson Battle Banner - 256x24 px) */
.board-top-controls {
  width: 256px;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 1px 8px;
  margin-bottom: 4px;
  background: url('assets/ui/banner_stage.png') no-repeat center top;
  background-size: 256px 24px;
  image-rendering: pixelated;
  border: none;
  box-sizing: border-box;
}

.enemy-status-badge {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.enemy-text {
  font-family: var(--font-title);
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 #2b0404, -1px -1px 0 #2b0404, 1px -1px 0 #2b0404, -1px 1px 0 #2b0404;
  line-height: 23px;
  white-space: nowrap;
}

.phase-buttons {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}

.board-top-controls .btn {
  height: 16px;
  font-size: 6px;
  padding: 0 5px;
  line-height: 16px;
}

/* Bottom Battle Controls Bar (Hidden - Controls moved to top banner) */
.board-bottom-controls {
  display: none !important;
}

.btn-auto-battler,
#btnStartAutoBattle,
#btnToggleAutoBattle {
  display: none !important;
  height: 16px;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  line-height: 16px;
  padding: 0 5px;
  background: #192030;
  border: 1px solid var(--border-light);
  color: #8395a7;
  cursor: pointer;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.btn-auto-battler:hover:not(:disabled) {
  border-color: var(--gold);
  color: #fff;
}

.btn-auto-battler:disabled {
  opacity: 0.65;
  cursor: default;
  border-color: var(--border-dark);
}

.btn-auto-battler.auto-active {
  background: #143d22;
  border-color: #2ed573;
  color: #afffa4;
  box-shadow: 0 0 6px rgba(46, 213, 115, 0.5);
  animation: pulseAuto 1.5s infinite ease-in-out;
}

.btn-auto-battler .auto-bolt {
  color: #f1c40f;
  font-size: 7px;
}

.btn-auto-battler.auto-active .auto-bolt {
  color: #2ed573;
  text-shadow: 0 0 4px #2ed573;
}

.btn-auto-battler .auto-status-text {
  font-weight: 700;
}

.auto-speed-badge {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: var(--gold);
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.btn-cta-battle {
  height: 16px;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  line-height: 16px;
  padding: 0 5px;
  background: #1b4d27;
  border: 1px solid #2ed573;
  color: #afffa4;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  box-shadow: 0 0 5px rgba(46, 213, 115, 0.4);
}

.btn-cta-battle:hover:not(:disabled) {
  background: #256634;
  color: #fff;
  box-shadow: 0 0 8px rgba(46, 213, 115, 0.7);
}

.btn-cta-battle:disabled {
  opacity: 0.5;
  cursor: default;
  border-color: var(--border-dark);
  background: #192030;
  color: #8395a7;
  box-shadow: none;
}

@keyframes pulseAuto {
  0%, 100% {
    box-shadow: 0 0 3px rgba(46, 213, 115, 0.3);
  }
  50% {
    box-shadow: 0 0 8px rgba(46, 213, 115, 0.8);
  }
}

/* ===== CHESSBOARD CONTAINER ===== */
.board-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== TURN ORDER QUEUE STRIP (UNDER CHESSBOARD) ===== */
.turn-order-container {
  width: calc(var(--tile-size) * 8 + 16px);
  max-width: 384px;
  margin-top: 4px;
  background: rgba(12, 16, 26, 0.94);
  border: 1px solid #232936;
  border-radius: 3px;
  padding: 3px 6px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.turn-order-container.hidden {
  display: none !important;
}

.turn-order-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 2px;
  line-height: 1;
}

.turn-queue-title {
  font-family: var(--font-pixel);
  font-size: 5px;
  font-weight: 700;
  color: #718093;
  letter-spacing: 0.5px;
}

.turn-queue-round {
  font-family: var(--font-pixel);
  font-size: 5px;
  font-weight: 700;
  color: var(--gold, #f1c40f);
  letter-spacing: 0.5px;
}

.turn-order-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 1px 3px 1px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.turn-order-strip::-webkit-scrollbar {
  display: none;
}

/* Individual Turn Order Card */
.turn-card {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #181d28;
  border: 1px solid #2f3542;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-pixel);
  font-size: 5.5px;
  white-space: nowrap;
  flex-shrink: 0;
  color: #dcdde1;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  user-select: none;
}

.turn-card:hover {
  filter: brightness(1.15);
}

.turn-card.player-unit {
  border-color: #2980b9;
  background: rgba(41, 128, 185, 0.18);
  color: #dff9fb;
}

.turn-card.enemy-unit {
  border-color: #c0392b;
  background: rgba(192, 57, 43, 0.18);
  color: #ffbe76;
}

.turn-card.active-turn {
  border-color: #f1c40f !important;
  background: rgba(241, 196, 15, 0.35) !important;
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.85);
  transform: translateY(-1px) scale(1.08);
  color: #fff !important;
  font-weight: 700;
  z-index: 5;
  animation: turnCardPulse 1.2s infinite alternate ease-in-out;
}

@keyframes turnCardPulse {
  0% { box-shadow: 0 0 4px rgba(241, 196, 15, 0.5); }
  100% { box-shadow: 0 0 10px rgba(241, 196, 15, 1); }
}

.turn-card.has-acted {
  opacity: 0.45;
  filter: grayscale(0.6);
  transform: scale(0.95);
}

.turn-card.is-defeated {
  opacity: 0.2;
  filter: grayscale(1);
  text-decoration: line-through;
}

.turn-card-icon {
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
  object-fit: contain;
  flex-shrink: 0;
}

.turn-card-name {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.spd-pill {
  font-size: 5px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.45);
  color: #f1c40f;
  margin-left: 2px;
  border: 1px solid rgba(241, 196, 15, 0.3);
}

.spd-pill.strike-first-pill {
  background: linear-gradient(135deg, #e67e22, #f1c40f);
  color: #fff;
  border-color: #ffd32a;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 0 0 5px rgba(241, 196, 15, 0.8);
  animation: strikeFirstGlow 0.8s infinite alternate ease-in-out;
}

@keyframes strikeFirstGlow {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.3); }
}

.turn-card-end {
  background: rgba(47, 53, 66, 0.5) !important;
  border: 1px dashed #747d8c !important;
  color: #a4b0be !important;
  font-size: 5px;
  padding: 2px 6px;
}

.turn-pass-btn {
  font-family: var(--font-pixel);
  font-size: 5px;
  font-weight: 700;
  background: #34495e;
  border: 1px solid #7f8c8d;
  color: #ecf0f1;
  padding: 1px 4px;
  border-radius: 2px;
  cursor: pointer;
  margin-left: 3px;
}
.turn-pass-btn:hover {
  background: #7f8c8d;
  color: #fff;
}

.board-frame {
  background: #181c28;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px;
}

.board-labels-top,
.board-labels-bottom {
  display: grid;
  grid-template-columns: 8px repeat(8, var(--tile-size)) 8px;
  font-size: 5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 8px;
  height: 8px;
}

.board-with-ranks {
  display: flex;
  align-items: center;
}

.board-ranks {
  display: flex;
  flex-direction: column;
  width: 8px;
  height: calc(var(--tile-size) * 8);
  font-size: 5px;
  color: var(--text-muted);
  text-align: center;
}

.board-ranks span {
  height: var(--tile-size);
  line-height: var(--tile-size);
}

.board-container {
  width: calc(var(--tile-size) * 8);
  height: calc(var(--tile-size) * 8);
  position: relative;
  background: #060810;
  overflow: visible;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--tile-size));
  grid-template-rows: repeat(8, var(--tile-size));
  width: calc(var(--tile-size) * 8);
  height: calc(var(--tile-size) * 8);
  gap: 0;
  position: relative;
  z-index: 1;
}

.square {
  width: var(--tile-size);
  height: var(--tile-size);
  position: relative;
  cursor: default;
  overflow: visible;
  padding: 0;
  margin: 0;
}

/* ==========================================================
   Y-SORTING / DEPTH ORDERING PREREQUISITE
   Chess pieces on lower tiles (greater row index / closer to bottom)
   MUST ALWAYS have a higher stacking layer than pieces on tiles above them.
   All floor tiles remain at floor level (z-index: 0..3) so NO FLOOR TILE
   can ever cover any chess piece!
   ========================================================== */

/* Base piece depth order by row: Row 7 > Row 6 > ... > Row 0 */
.square[data-row="0"] .piece, .square:nth-child(-n+8) .piece { z-index: 100 !important; }
.square[data-row="1"] .piece, .square:nth-child(n+9):nth-child(-n+16) .piece { z-index: 200 !important; }
.square[data-row="2"] .piece, .square:nth-child(n+17):nth-child(-n+24) .piece { z-index: 300 !important; }
.square[data-row="3"] .piece, .square:nth-child(n+25):nth-child(-n+32) .piece { z-index: 400 !important; }
.square[data-row="4"] .piece, .square:nth-child(n+33):nth-child(-n+40) .piece { z-index: 500 !important; }
.square[data-row="5"] .piece, .square:nth-child(n+41):nth-child(-n+48) .piece { z-index: 600 !important; }
.square[data-row="6"] .piece, .square:nth-child(n+49):nth-child(-n+56) .piece { z-index: 700 !important; }
.square[data-row="7"] .piece, .square:nth-child(n+57):nth-child(-n+64) .piece { z-index: 800 !important; }

/* Subtle elevation when hovered or selected, strictly kept WITHIN row interval */
.square[data-row="0"].piece-hover .piece, .square:nth-child(-n+8).piece-hover .piece { z-index: 110 !important; }
.square[data-row="1"].piece-hover .piece, .square:nth-child(n+9):nth-child(-n+16).piece-hover .piece { z-index: 210 !important; }
.square[data-row="2"].piece-hover .piece, .square:nth-child(n+17):nth-child(-n+24).piece-hover .piece { z-index: 310 !important; }
.square[data-row="3"].piece-hover .piece, .square:nth-child(n+25):nth-child(-n+32).piece-hover .piece { z-index: 410 !important; }
.square[data-row="4"].piece-hover .piece, .square:nth-child(n+33):nth-child(-n+40).piece-hover .piece { z-index: 510 !important; }
.square[data-row="5"].piece-hover .piece, .square:nth-child(n+41):nth-child(-n+48).piece-hover .piece { z-index: 610 !important; }
.square[data-row="6"].piece-hover .piece, .square:nth-child(n+49):nth-child(-n+56).piece-hover .piece { z-index: 710 !important; }
.square[data-row="7"].piece-hover .piece, .square:nth-child(n+57):nth-child(-n+64).piece-hover .piece { z-index: 810 !important; }

.square[data-row="0"].selected .piece, .square:nth-child(-n+8).selected .piece { z-index: 115 !important; }
.square[data-row="1"].selected .piece, .square:nth-child(n+9):nth-child(-n+16).selected .piece { z-index: 215 !important; }
.square[data-row="2"].selected .piece, .square:nth-child(n+17):nth-child(-n+24).selected .piece { z-index: 315 !important; }
.square[data-row="3"].selected .piece, .square:nth-child(n+25):nth-child(-n+32).selected .piece { z-index: 415 !important; }
.square[data-row="4"].selected .piece, .square:nth-child(n+33):nth-child(-n+40).selected .piece { z-index: 515 !important; }
.square[data-row="5"].selected .piece, .square:nth-child(n+41):nth-child(-n+48).selected .piece { z-index: 615 !important; }
.square[data-row="6"].selected .piece, .square:nth-child(n+49):nth-child(-n+56).selected .piece { z-index: 715 !important; }
.square[data-row="7"].selected .piece, .square:nth-child(n+57):nth-child(-n+64).selected .piece { z-index: 815 !important; }

/* Piece HUD stays with its piece: on top of its own piece, but below any piece in rows below */
.square[data-row="0"] .piece-hud, .square:nth-child(-n+8) .piece-hud { z-index: 120 !important; }
.square[data-row="1"] .piece-hud, .square:nth-child(n+9):nth-child(-n+16) .piece-hud { z-index: 220 !important; }
.square[data-row="2"] .piece-hud, .square:nth-child(n+17):nth-child(-n+24) .piece-hud { z-index: 320 !important; }
.square[data-row="3"] .piece-hud, .square:nth-child(n+25):nth-child(-n+32) .piece-hud { z-index: 420 !important; }
.square[data-row="4"] .piece-hud, .square:nth-child(n+33):nth-child(-n+40) .piece-hud { z-index: 520 !important; }
.square[data-row="5"] .piece-hud, .square:nth-child(n+41):nth-child(-n+48) .piece-hud { z-index: 620 !important; }
.square[data-row="6"] .piece-hud, .square:nth-child(n+49):nth-child(-n+56) .piece-hud { z-index: 720 !important; }
.square[data-row="7"] .piece-hud, .square:nth-child(n+57):nth-child(-n+64) .piece-hud { z-index: 820 !important; }

/* Active airborne leap / strike animation elevation above board during flight */
.square .piece.piece-advance-move,
.square .piece.piece-attacking,
.square .piece.piece-flying-attack-recoil,
.square .piece.piece-capturing,
.square .piece.piece-flying-attack-capture,
.square .piece.piece-setup-hop,
.square .piece.piece-setup-swap-a,
.square .piece.piece-setup-swap-b,
.square .piece.piece-setup-deploy,
.square .piece.piece-setup-recall,
.square .piece.piece-transform-anim,
.square .piece.piece-equip-anim {
  z-index: 950 !important;
}

/* Sudden Death Collapse Animations */
.square.tile-shaking {
  animation: tileEarthquake 0.12s infinite alternate linear !important;
}

@keyframes tileEarthquake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-1.5px, 1px) rotate(-1deg); }
  50% { transform: translate(1px, -1.5px) rotate(1deg); }
  75% { transform: translate(-1px, -1px) rotate(0.5deg); }
  100% { transform: translate(1.5px, 0.5px) rotate(-0.5deg); }
}

.square.tile-shaking::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1.5px solid #ff3333;
  box-shadow: inset 0 0 6px rgba(255, 30, 30, 0.7), 0 0 4px rgba(255, 60, 60, 0.5);
  pointer-events: none;
  animation: tileShakeWarningPulse 0.35s infinite alternate ease-in-out;
  z-index: 9;
}

@keyframes tileShakeWarningPulse {
  0% { opacity: 0.35; }
  100% { opacity: 1; }
}

.square.tile-falling {
  animation: tileAbyssFall 0.65s cubic-bezier(0.5, 0, 0.75, 0) forwards !important;
  pointer-events: none !important;
  z-index: 4 !important;
}

@keyframes tileAbyssFall {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
  35% {
    transform: translateY(16px) scale(0.9) rotate(3deg);
    opacity: 0.85;
  }
  100% {
    transform: translateY(90px) scale(0.3) rotate(22deg);
    opacity: 0;
  }
}

.square.tile-collapsed {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  cursor: default !important;
}

/* 0. Floor tile */
.square .tile-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 0;
  display: block;
}

/* 1. Yellow deploy zone starting outline: ON THE FLOOR */
.square.deploy-zone::before {
  content: '';
  position: absolute;
  inset: 1px;
  border: 1px dashed var(--gold);
  pointer-events: none;
  z-index: 1;
}

/* 2. Piece shadow on floor (Exact 16x16 native size) */
.square .piece-shadow {
  position: absolute;
  bottom: 4px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 2;
}

/* 3. Ray overlays: ON THE FLOOR under pieces (Exact 16x16 native size) */
.square .ray-overlay {
  position: absolute;
  top: calc(50% - 8px);
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.square.show-ray .ray-overlay {
  opacity: 1;
}

.square:has(.piece-threatened) .ray-overlay {
  opacity: 0 !important;
  display: none !important;
}

/* 10. POKEMON PIECES: TOP LAYER (40x30 px, bottom of sprite aligned at 1/4 from tile bottom) */
.square .piece {
  position: absolute;
  left: calc(50% - 20px);
  bottom: 25%;
  width: 40px;
  height: 30px;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
  z-index: 100;
  --lift-y: 0px;
  transform: translateY(var(--lift-y));
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.4, 1);
}

.square .preview-piece {
  z-index: 850;
}

/* Hover & Selected lift-up: uniform subtle lift (-3px) without altering depth layer */
.square.piece-hover .piece,
.square.selected .piece,
.square.piece-hover.selected .piece {
  --lift-y: -3px;
}

/* Threatened enemy piece: Translucent red tint overlay (retaining all shading & contours), no glow, trembling vibration */
.square .piece.piece-threatened {
  animation: threatTremble 0.22s infinite ease-in-out alternate;
  filter: sepia(0.85) saturate(5.5) hue-rotate(-42deg) brightness(1.1) !important;
}

@keyframes threatTremble {
  0% {
    transform: translateY(var(--lift-y, 0px)) translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translateY(var(--lift-y, 0px)) translate(-1.5px, -1px) rotate(-1.5deg);
  }
  50% {
    transform: translateY(var(--lift-y, 0px)) translate(1.5px, 0.5px) rotate(1deg);
  }
  75% {
    transform: translateY(var(--lift-y, 0px)) translate(-1px, 1px) rotate(-1deg);
  }
  100% {
    transform: translateY(var(--lift-y, 0px)) translate(1px, -1px) rotate(1.5deg);
  }
}

/* Transformation & Promotion Animation: Radiant elevation & golden flash */
.square .piece.piece-transform-anim,
.inv-slot .inv-slot-piece.piece-transform-anim {
  animation: pieceTransformAnim 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  z-index: 950 !important;
}

/* Ditto Transformed Aura: Signature purple shimmering glow */
.square .piece.ditto-transformed {
  filter: drop-shadow(0 0 3px #ba68c8) drop-shadow(0 0 7px #ab47bc);
  animation: dittoTransformGlow 2.2s ease-in-out infinite alternate;
}

@keyframes dittoTransformGlow {
  0% {
    filter: drop-shadow(0 0 2px #ba68c8) drop-shadow(0 0 5px rgba(171, 71, 188, 0.6));
  }
  100% {
    filter: drop-shadow(0 0 5px #f3e5f5) drop-shadow(0 0 10px #ce93d8) drop-shadow(0 0 14px rgba(186, 104, 200, 0.8));
  }
}

/* =============================================
   POKEMON EVOLUTION ANIMATION ON BOARD
   ============================================= */
.square .piece.piece-evolving,
.inv-slot .inv-slot-piece.piece-evolving {
  animation: pokemonEvolutionAnim 1.35s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  z-index: 980 !important;
}

@keyframes pokemonEvolutionAnim {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
  15% {
    transform: translateY(-3px) scale(1.1) rotate(-2deg);
    filter: brightness(2) drop-shadow(0 0 6px #ffffff) drop-shadow(0 0 10px #64b5f6);
  }
  30% {
    transform: translateY(-7px) scale(0.95) rotate(3deg);
    filter: brightness(3.5) drop-shadow(0 0 10px #ffffff) drop-shadow(0 0 18px #ffd700);
  }
  45% {
    /* Climax: blinding radiant flash and ascension */
    transform: translateY(-13px) scale(1.45) rotate(-3deg);
    filter: brightness(6) contrast(200%) drop-shadow(0 0 16px #ffffff) drop-shadow(0 0 28px #ffea00);
  }
  50% {
    /* Sprite swap point */
    transform: translateY(-14px) scale(1.5) rotate(0deg);
    filter: brightness(5) drop-shadow(0 0 20px #ffffff) drop-shadow(0 0 32px #ffd700);
  }
  65% {
    /* Revealed form descends with golden aura */
    transform: translateY(-10px) scale(1.3) rotate(2deg);
    filter: brightness(2.2) drop-shadow(0 0 12px #ffd700) drop-shadow(0 0 20px rgba(255, 152, 0, 0.8));
  }
  80% {
    transform: translateY(1px) scale(0.96) rotate(0deg);
    filter: brightness(1.3) drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
  }
  90% {
    transform: translateY(-2px) scale(1.04) rotate(0deg);
    filter: brightness(1.1);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

/* Expanding radial evolution shockwave ring */
.evolution-shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 12px #ffd700, inset 0 0 8px #ffffff;
  pointer-events: none;
  z-index: 970;
  animation: evoShockwaveBurst 1.1s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes evoShockwaveBurst {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }
  20% {
    opacity: 1;
    transform: scale(0.8);
    border-color: #ffffff;
    box-shadow: 0 0 20px #ffffff, 0 0 35px #ffd700;
  }
  60% {
    opacity: 0.9;
    transform: scale(2.0);
    border-color: #ffd700;
  }
  100% {
    opacity: 0;
    transform: scale(3.2);
    border-color: #ff9800;
  }
}

@keyframes pieceTransformAnim {
  0% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  30% {
    transform: translateY(-9px) scale(1.35) rotate(-3deg);
    filter: brightness(2.2) drop-shadow(0 0 8px #f1c40f) drop-shadow(0 0 14px rgba(243, 156, 18, 0.9));
  }
  60% {
    transform: translateY(-5px) scale(1.18) rotate(3deg);
    filter: brightness(1.7) drop-shadow(0 0 6px #e67e22);
  }
  85% {
    transform: translateY(1px) scale(0.96) rotate(0deg);
    filter: brightness(1.2);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

/* Talisman Equip Animation: Radiant pulse, emerald-gold socket aura */
.square .piece.piece-equip-anim,
.inv-slot .inv-slot-piece.piece-equip-anim {
  animation: pieceEquipAnim 0.75s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  z-index: 950 !important;
}

@keyframes pieceEquipAnim {
  0% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  30% {
    transform: translateY(-8px) scale(1.25);
    filter: brightness(2.2) drop-shadow(0 0 6px #2ed573) drop-shadow(0 0 12px rgba(46, 213, 115, 0.9));
  }
  65% {
    transform: translateY(-2px) scale(1.1);
    filter: brightness(1.6) drop-shadow(0 0 5px #f1c40f);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

/* Piece HUD (HP fraction without heart icon or black border) */
.piece-hud {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

.hud-heart-icon {
  display: none !important;
}

.hud-hp-num {
  font-family: var(--font-pixel);
  font-size: 5px;
  font-weight: 700;
  color: #ffffff !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.9) !important;
  border: none !important;
  outline: none !important;
  background: none !important;
  box-shadow: none !important;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.piece-acted {
  filter: grayscale(0.65) brightness(0.6) !important;
  opacity: 0.6 !important;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

/* Floating damage numbers (-1, -2 without heart) */
.dmg-popup {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 700;
  color: #ff3e3e;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  pointer-events: none;
  z-index: 900 !important;
  animation: dmgFloat 0.75s ease-out forwards;
}

.dmg-popup.heal-popup {
  color: #2ed573 !important;
}

.dmg-popup.revive-popup {
  color: #f1c40f !important;
  font-size: 7px !important;
}

.dmg-popup.crit-popup,
.dmg-popup.crit-2x,
.dmg-popup.crit-4x {
  color: #ffb703 !important;
  font-size: 7px !important;
  font-weight: 900 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
               0 0 6px #ff5722 !important;
  z-index: 1000 !important;
}

.dmg-popup.resist-popup,
.dmg-popup.resist-2x,
.dmg-popup.resist-4x {
  color: #b0bec5 !important;
  font-size: 6px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000 !important;
  z-index: 950 !important;
}

.dmg-popup.immune-popup,
.dmg-popup.immune {
  color: #cfd8dc !important;
  font-size: 7px !important;
  font-weight: 900 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
               0 0 4px #546e7a !important;
  z-index: 950 !important;
}

/* 16x16 Circular Pixel Element Badges */
.element-badge {
  width: 13px;
  height: 13px;
  image-rendering: pixelated;
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}

.card-type-badge {
  width: 11px;
  height: 11px;
  margin-left: 2px;
}

.slot-type-badge {
  width: 10px;
  height: 10px;
  margin-left: 1px;
}

.hud-type-badge {
  width: 9px;
  height: 9px;
  image-rendering: pixelated;
  margin-left: 2px;
  vertical-align: middle;
}

.dmg-popup.evo-popup {
  color: #fff9c4 !important;
  font-size: 8px !important;
  font-weight: 900 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
               0 0 8px #ffd700, 0 0 16px #ff9800 !important;
  animation: evoPopupFloat 1.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards !important;
  z-index: 1000 !important;
}

.dmg-popup.transform-popup {
  color: #f3e5f5 !important;
  font-size: 8px !important;
  font-weight: 900 !important;
  white-space: nowrap !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
               0 0 8px #ce93d8, 0 0 16px #ab47bc !important;
  animation: evoPopupFloat 1.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards !important;
  z-index: 1000 !important;
}

@keyframes evoPopupFloat {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(4px) scale(0.5);
  }
  25% {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px) scale(1.25);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) translateY(-16px) scale(1.1);
  }
  75% {
    opacity: 0.9;
    transform: translateX(-50%) translateY(-22px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px) scale(0.9);
  }
}

.dmg-popup.equip-popup {
  color: #2ed573 !important;
  font-size: 7px !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 0 0 6px rgba(46, 213, 115, 0.85) !important;
}

.dmg-popup.gold-popup {
  color: #ffd32a !important;
  font-size: 7px !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 0 0 6px rgba(255, 211, 42, 0.9) !important;
}

.dmg-popup.arcane-popup {
  color: #a29bfe !important;
  font-size: 7px !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 0 0 6px rgba(162, 155, 254, 0.9) !important;
}

.dmg-popup.mirror-popup {
  color: #00d2d3 !important;
  font-size: 7px !important;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 0 0 6px rgba(0, 210, 211, 0.9) !important;
}

.popup-pixel-icon {
  width: 8px;
  height: 8px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 3px;
  display: inline-block;
}

/* Stat Pill bounce animation */
.pill-bounce {
  animation: pillBounce 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes pillBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes dmgFloat {
  0% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.2);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -10px) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -16px) scale(0.9);
  }
}

/* ==========================================================
   COMBAT & MOVEMENT ANIMATIONS (Retro Pixel Arcade)
   ========================================================== */

/* 1. Smooth slide move to empty square */
.square .piece.piece-advance-move {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceAdvanceMove 0.22s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pieceAdvanceMove {
  0% {
    transform: translate(0, 0) scale(1);
  }

  45% {
    transform: translate(calc(var(--move-dx, 0px) * 0.5), calc(var(--move-dy, 0px) * 0.5 - 10px)) scale(1.15);
  }

  85% {
    transform: translate(var(--move-dx, 0px), var(--move-dy, 0px)) scale(1.14, 0.88);
  }

  100% {
    transform: translate(var(--move-dx, 0px), var(--move-dy, 0px)) scale(1);
  }
}

/* 2. Attack with recoil (Enemy survives: strike forward, bounce back home) */
.square .piece.piece-attacking,
.square .piece.piece-flying-attack-recoil {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceAttackRecoil 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pieceAttackRecoil {
  0% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(calc(var(--atk-dx, 0px) * 0.4), calc(var(--atk-dy, 0px) * 0.4 - 8px)) scale(1.15);
  }

  50% {
    /* Impact point: strikes forward */
    transform: translate(calc(var(--atk-dx, 0px) * 0.85), calc(var(--atk-dy, 0px) * 0.85 - 2px)) scale(1.2);
  }

  75% {
    transform: translate(calc(var(--atk-dx, 0px) * 0.35), calc(var(--atk-dy, 0px) * 0.35 - 3px)) scale(1.08);
  }

  100% {
    transform: translate(0, 0) scale(1);
  }
}

/* 3. Attack and capture (Enemy dies: charge forward in dynamic arc leap, crush, occupy tile) */
.square .piece.piece-capturing,
.square .piece.piece-flying-attack-capture {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceCaptureMove 0.24s cubic-bezier(0.25, 1, 0.35, 1) forwards;
}

@keyframes pieceCaptureMove {
  0% {
    transform: translate(0, 0) scale(1);
  }

  45% {
    transform: translate(calc(var(--atk-dx, 0px) * 0.5), calc(var(--atk-dy, 0px) * 0.5 - 12px)) scale(1.22);
  }

  85% {
    transform: translate(var(--atk-dx, 0px), var(--atk-dy, 0px)) scale(1.16, 0.85);
  }

  100% {
    transform: translate(var(--atk-dx, 0px), var(--atk-dy, 0px)) scale(1);
  }
}

/* 4. Defender reaction animations */
.square .piece.piece-hit-flash {
  animation: pieceHitFlash 0.22s ease-out forwards;
}

@keyframes pieceHitFlash {
  0% {
    filter: brightness(3.5) contrast(1.4);
    transform: translate(1px, -1px);
  }

  25% {
    filter: brightness(2.5) contrast(1.2);
    transform: translate(-2px, 1px);
  }

  50% {
    filter: brightness(1.8);
    transform: translate(2px, 0);
  }

  75% {
    filter: brightness(1.3);
    transform: translate(-1px, 0);
  }

  100% {
    filter: none;
    transform: translate(0, 0);
  }
}

.square .piece.piece-defeat-fade {
  animation: pieceDefeatFade 0.22s ease-out forwards;
}

@keyframes pieceDefeatFade {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(0.7) translateY(-2px);
  }

  100% {
    opacity: 0;
    transform: scale(0.1) translateY(2px);
  }
}

/* Shock / Electric vibration shake */
.square .piece.piece-shock-shake {
  animation: pieceShockShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes pieceShockShake {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
    filter: brightness(1);
  }
  15% {
    transform: translate(-3px, 1px) rotate(-3deg);
    filter: brightness(2) drop-shadow(0 0 4px #fbc531);
  }
  30% {
    transform: translate(3px, -2px) rotate(3deg);
    filter: brightness(2.5) drop-shadow(0 0 6px #00d2d3);
  }
  45% {
    transform: translate(-2px, 2px) rotate(-2deg);
    filter: brightness(2) drop-shadow(0 0 5px #fbc531);
  }
  60% {
    transform: translate(2px, -1px) rotate(2deg);
    filter: brightness(2.2) drop-shadow(0 0 4px #00d2d3);
  }
  75% {
    transform: translate(-1px, 1px) rotate(-1deg);
    filter: brightness(1.5);
  }
  90% {
    transform: translate(1px, 0) rotate(0deg);
    filter: brightness(1.2);
  }
}

/* Status effect particles (Poison bubbles, Fire embers, Electric sparks, Bleed drops) */
.poison-bubble {
  position: absolute;
  pointer-events: none;
  z-index: 920;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e056fd, #68009c);
  border: 1px solid #be2edd;
  box-shadow: 0 0 4px rgba(190, 46, 221, 0.7);
  animation: poisonBubbleRise 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes poisonBubbleRise {
  0% {
    transform: translate(var(--p-dx, 0px), 0px) scale(0.3);
    opacity: 0.9;
  }
  50% {
    transform: translate(calc(var(--p-dx, 0px) + var(--p-wobble, 2px)), -12px) scale(1.1);
    opacity: 1;
  }
  80% {
    transform: translate(calc(var(--p-dx, 0px) - var(--p-wobble, 2px)), -20px) scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: translate(var(--p-dx, 0px), -24px) scale(1.4);
    opacity: 0;
  }
}

.fire-spark {
  position: absolute;
  pointer-events: none;
  z-index: 920;
  border-radius: 2px;
  background: #ff4757;
  box-shadow: 0 0 4px #ffa502, 0 0 8px #ff4757;
  animation: fireSparkFly 0.55s ease-out forwards;
}

@keyframes fireSparkFly {
  0% {
    transform: translate(var(--f-dx, 0px), 0px) scale(0.6) rotate(0deg);
    opacity: 1;
    background: #ffa502;
  }
  50% {
    transform: translate(calc(var(--f-dx, 0px) * 1.4), -14px) scale(1.2) rotate(45deg);
    opacity: 0.9;
    background: #ff6b81;
  }
  100% {
    transform: translate(calc(var(--f-dx, 0px) * 1.8), -22px) scale(0.2) rotate(90deg);
    opacity: 0;
    background: #ff4757;
  }
}

.electric-spark {
  position: absolute;
  pointer-events: none;
  z-index: 920;
  width: 5px;
  height: 5px;
  background: #fbc531;
  box-shadow: 0 0 4px #00d2d3, 0 0 8px #fbc531;
  clip-path: polygon(40% 0%, 100% 0%, 60% 50%, 90% 50%, 10% 100%, 35% 55%, 10% 55%);
  animation: electricSparkFlash 0.45s steps(2, start) forwards;
}

@keyframes electricSparkFlash {
  0% {
    transform: translate(var(--e-dx, 0px), var(--e-dy, 0px)) scale(0.6) rotate(var(--e-rot, 0deg));
    opacity: 1;
  }
  33% {
    transform: translate(calc(var(--e-dx, 0px) + 2px), calc(var(--e-dy, 0px) - 3px)) scale(1.3) rotate(calc(var(--e-rot, 0deg) + 30deg));
    opacity: 0.9;
    background: #00d2d3;
  }
  66% {
    transform: translate(calc(var(--e-dx, 0px) - 2px), calc(var(--e-dy, 0px) + 2px)) scale(1.1) rotate(calc(var(--e-rot, 0deg) - 20deg));
    opacity: 0.7;
    background: #fff;
  }
  100% {
    transform: translate(var(--e-dx, 0px), var(--e-dy, 0px)) scale(0.2);
    opacity: 0;
  }
}

.bleed-spark {
  position: absolute;
  pointer-events: none;
  z-index: 920;
  width: 3px;
  height: 5px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #c0392b;
  box-shadow: 0 0 3px #e74c3c;
  animation: bleedDropFall 0.5s ease-in forwards;
}

@keyframes bleedDropFall {
  0% {
    transform: translate(var(--b-dx, 0px), -4px) scale(0.8);
    opacity: 1;
  }
  60% {
    transform: translate(var(--b-dx, 0px), 8px) scale(1.1);
    opacity: 0.9;
  }
  100% {
    transform: translate(var(--b-dx, 0px), 14px) scale(0.4);
    opacity: 0;
  }
}

/* Hide piece HUD during flight */
.piece-advance-move~.piece-hud,
.piece-capturing~.piece-hud,
.piece-setup-hop~.piece-hud,
.piece-setup-swap-a~.piece-hud,
.piece-setup-swap-b~.piece-hud,
.piece-setup-deploy~.piece-hud,
.piece-setup-recall~.piece-hud {
  opacity: 0 !important;
}

/* ===== SETUP PHASE ANIMATIONS ===== */

/* 1. Setup Hopping to an empty square */
.square .piece.piece-setup-hop {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceSetupHop 0.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pieceSetupHop {
  0% {
    transform: translate(0, 0) scale(1);
  }
  45% {
    transform: translate(calc(var(--hop-dx, 0px) * 0.5), calc(var(--hop-dy, 0px) * 0.5 - 10px)) scale(1.15);
  }
  85% {
    transform: translate(var(--hop-dx, 0px), var(--hop-dy, 0px)) scale(1.14, 0.88);
  }
  100% {
    transform: translate(var(--hop-dx, 0px), var(--hop-dy, 0px)) scale(1);
  }
}

/* 2. Setup Swap Two Pieces on Board (Reciprocal Arcs) */
.square .piece.piece-setup-swap-a {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceSetupSwapA 0.22s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pieceSetupSwapA {
  0% {
    transform: translate(0, 0) scale(1);
  }
  45% {
    transform: translate(calc(var(--swap-dx, 0px) * 0.5), calc(var(--swap-dy, 0px) * 0.5 - 12px)) scale(1.18);
  }
  85% {
    transform: translate(var(--swap-dx, 0px), var(--swap-dy, 0px)) scale(1.14, 0.88);
  }
  100% {
    transform: translate(var(--swap-dx, 0px), var(--swap-dy, 0px)) scale(1);
  }
}

.square .piece.piece-setup-swap-b {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceSetupSwapB 0.22s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pieceSetupSwapB {
  0% {
    transform: translate(0, 0) scale(1);
  }
  45% {
    transform: translate(calc(var(--swap-dx, 0px) * 0.5), calc(var(--swap-dy, 0px) * 0.5 - 4px)) scale(1.08);
  }
  85% {
    transform: translate(var(--swap-dx, 0px), var(--swap-dy, 0px)) scale(1.12, 0.9);
  }
  100% {
    transform: translate(var(--swap-dx, 0px), var(--swap-dy, 0px)) scale(1);
  }
}

/* 3. Setup Deploy from Bench to Board (Animation Lên Cờ) */
.square .piece.piece-setup-deploy {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceSetupDeploy 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes pieceSetupDeploy {
  0% {
    transform: translate(var(--fly-from-x, 0px), var(--fly-from-y, 0px)) scale(0.65) rotate(-5deg);
    opacity: 0.8;
  }
  50% {
    transform: translate(calc(var(--fly-from-x, 0px) * 0.4), calc(var(--fly-from-y, 0px) * 0.4 - 14px)) scale(1.22) rotate(2deg);
    opacity: 1;
  }
  85% {
    transform: translate(0, 0) scale(1.18, 0.84) rotate(0deg);
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
}

/* 4. Setup Recall / Return to Bench (Animation Đổi Cờ Từ Bàn Ra Bench) */
.square .piece.piece-setup-recall,
.piece.piece-setup-recall {
  z-index: 950 !important;
  transition: none !important;
  animation: pieceSetupRecall 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pieceSetupRecall {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  40% {
    transform: translate(calc(var(--fly-to-x, 0px) * 0.4), calc(var(--fly-to-y, 0px) * 0.4 - 10px)) scale(1.15);
    opacity: 1;
  }
  85% {
    transform: translate(var(--fly-to-x, 0px), var(--fly-to-y, 0px)) scale(0.85);
    opacity: 0.85;
  }
  100% {
    transform: translate(var(--fly-to-x, 0px), var(--fly-to-y, 0px)) scale(0.45);
    opacity: 0;
  }
}

/* 5. Landing Puff Ripple Effect */
.square .land-puff {
  position: absolute;
  inset: -1px;
  pointer-events: none;
  z-index: 35;
  border-radius: 2px;
  animation: landPuffAnim 0.28s ease-out forwards;
}

@keyframes landPuffAnim {
  0% {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 8px rgba(255, 255, 255, 0.5);
    transform: scale(0.75);
    opacity: 1;
  }
  100% {
    box-shadow: inset 0 0 0 0px rgba(255, 255, 255, 0), 0 0 16px rgba(255, 255, 255, 0);
    transform: scale(1.35);
    opacity: 0;
  }
}

/* 6. Landing Squash & Bounce */
.square .piece.piece-land-bounce {
  animation: pieceLandBounce 0.2s ease-out forwards;
}

@keyframes pieceLandBounce {
  0% {
    transform: scale(1.18, 0.84);
  }
  50% {
    transform: scale(0.94, 1.06);
  }
  100% {
    transform: scale(1, 1);
  }
}

/* 7. Bench Slot Bounce */
.inv-slot.inv-slot-bounce {
  animation: invSlotBounce 0.24s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes invSlotBounce {
  0% {
    transform: scale(0.88);
  }
  50% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

/* Piercing line attack beam effect (Arch) */
.square.line-attack-beam::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 68, 68, 0.45);
  box-shadow: inset 0 0 8px #ff2222;
  pointer-events: none;
  z-index: 25;
  animation: lineBeamFlash 0.35s ease-out forwards;
}

@keyframes lineBeamFlash {
  0% {
    opacity: 0;
  }

  25% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ===== RIGHT PANEL: POKEMON (BENCH & RECRUIT TABS) ===== */
.right-panel {
  width: 175px;
  min-width: 175px;
  max-width: 175px;
  flex-shrink: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pokemon-panel {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 3px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.pokemon-panel-title {
  font-family: var(--font-title);
  font-size: 7.5px;
  color: var(--gold);
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  text-align: center;
  width: 100%;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* Pokemon Tabs: [BENCH] and [RECRUIT] (Identical to Talisman Tabs) */
.pokemon-tabs {
  display: flex;
  width: 100%;
  gap: 3px;
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.pokemon-tab {
  flex: 1;
  height: 20px;
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.pokemon-tab:hover {
  color: #fff;
  border-color: var(--border-gold);
}

.pokemon-tab.active {
  background: var(--gold-dim);
  border-color: var(--border-gold);
  color: var(--gold);
}

.pokemon-subtitle {
  font-size: 6.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.pokemon-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 1px 0;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  touch-action: pan-y;
  cursor: grab;
}

.pokemon-content.is-dragging {
  cursor: grabbing;
}

.pokemon-content::-webkit-scrollbar,
.pokemon-cards-list::-webkit-scrollbar,
#pokemonContent::-webkit-scrollbar,
#inventorySlots::-webkit-scrollbar,
#rewardCardsGrid::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.pokemon-content::-webkit-scrollbar-track,
.pokemon-content::-webkit-scrollbar-thumb,
.pokemon-cards-list::-webkit-scrollbar-track,
.pokemon-cards-list::-webkit-scrollbar-thumb,
#pokemonContent::-webkit-scrollbar-track,
#pokemonContent::-webkit-scrollbar-thumb,
#rewardCardsGrid::-webkit-scrollbar-track,
#rewardCardsGrid::-webkit-scrollbar-thumb {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.pokemon-cards-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: 100%;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.pokemon-footer {
  margin-top: auto;
  padding-top: 3px;
  border-top: 1px solid var(--border-dark);
  width: 100%;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.recruit-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.btn-reroll {
  width: 100%;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  cursor: pointer;
  box-sizing: border-box;
}

.btn-reroll:hover:not(:disabled) {
  background: var(--gold);
  color: #000;
}

.btn-reroll:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--text-muted);
}

/* Recruit card slot styled with assets/ui/recruit/recruit_slot.png (156x50 px) */
.reward-card {
  width: 156px !important;
  height: 50px !important;
  min-width: 156px !important;
  max-width: 156px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  background: url('assets/ui/recruit/recruit_slot.png') no-repeat 0 0;
  background-size: 100% 100% !important;
  image-rendering: pixelated;
  border: none;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.reward-card:hover:not(.cant-afford) {
  filter: brightness(1.2);
}

.reward-card:active:not(.cant-afford) {
  transform: translateY(1px);
}

.reward-card.cant-afford {
  opacity: 0.55;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

/* Left side: Pokemon sprite 40x30 px centered vertically in 50px height */
.reward-card-img-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: 42px !important;
  height: 50px !important;
  display: block;
  overflow: visible;
}

.reward-card-img {
  position: absolute;
  left: 1px;
  top: 10px;
  width: 40px !important;
  height: 30px !important;
  image-rendering: pixelated !important;
  object-fit: contain !important;
  display: block;
}

/* Middle: Piece info (name, rarity, stats) */
.reward-card-info {
  position: absolute;
  left: 44px;
  top: 3px;
  bottom: 3px;
  width: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  pointer-events: none;
}

.card-name {
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.card-rarity {
  font-family: var(--font-pixel);
  font-size: 5.5px;
  font-weight: 700;
  line-height: 1;
  text-shadow: none !important;
  display: block;
}

.card-rarity.rarity-common {
  color: #dcdde1;
}

.card-rarity.rarity-rare {
  color: #54a0ff;
}

.card-rarity.rarity-epic {
  color: #a55eea;
}

.card-rarity.rarity-legend,
.card-rarity.rarity-legendary {
  color: #ff9f43;
}

.card-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 1px;
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

/* Right side: Pick / buy button located on ticket stub */
.btn-pick-card {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 6.5px;
  font-weight: 700;
  padding: 0;
  background: url('assets/ui/buy_button.png') no-repeat center;
  background-size: 100% 100%;
  image-rendering: pixelated;
  border: none;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.btn-pick-card:hover:not(:disabled) {
  filter: brightness(1.25);
}

.btn-pick-card:active:not(:disabled) {
  transform: translateY(calc(-50% + 1px));
}

.btn-pick-card.btn-free {
  filter: hue-rotate(90deg);
}

.btn-pick-card.btn-free:hover:not(:disabled) {
  filter: hue-rotate(90deg) brightness(1.25);
}

.btn-pick-card:disabled {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

/* Bench Cards (Kho Pokemon - formatted like recruit cards with bench_slot.png) */
.reward-card.bench-card {
  background: url('assets/ui/bench/bench_slot.png') no-repeat 0 0 !important;
  background-size: 100% 100% !important;
  cursor: pointer;
}

.reward-card.bench-card:hover {
  filter: brightness(1.2);
}

.reward-card.bench-card.selected {
  filter: brightness(1.2) drop-shadow(0 0 3px #2ed573);
}

.reward-card.bench-card.deployed {
  opacity: 0.6;
}

.reward-card.bench-card .reward-card-info {
  width: 104px !important;
}

.card-rarity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  line-height: 1;
}

.stat-evo {
  font-family: var(--font-pixel);
  font-size: 5.5px;
  font-weight: 700;
  line-height: 1;
}

/* ===== PIXEL UI ICONS (Strict 1:1 Native 8x8 Resolution - No scaling/distortion) ===== */
.stat-icon,
.btn-ui-icon,
.ui-icon-coin,
.ui-icon-mini,
.ui-icon-micro,
.modal-coin-icon {
  width: 8px !important;
  height: 8px !important;
  min-width: 8px !important;
  min-height: 8px !important;
  max-width: 8px !important;
  max-height: 8px !important;
  image-rendering: pixelated !important;
  object-fit: none !important;
  flex-shrink: 0 !important;
  display: inline-block;
  vertical-align: middle;
}

.stat-icon {
  margin-right: 2px;
}

.btn-ui-icon {
  margin: 0 1px;
}

.ui-icon-coin {
  margin-left: 2px;
}

.ui-icon-mini {
  margin-right: 1px;
}

.ui-icon-micro {
  margin-right: 1px;
}

.modal-coin-icon {
  margin: 0 2px;
}

.recruit-locked-msg,
.recruit-picked-msg {
  font-size: 5px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 4px;
}

/* ===== BENCH PANEL: VERTICAL COLUMN (Matches 48x48 bench slot) ===== */
.bench-panel {
  width: 58px;
  flex-shrink: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bench-box {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 2px;
  box-sizing: border-box;
  overflow: hidden;
}

.bench-title {
  font-family: var(--font-title);
  font-size: 6px;
  color: var(--gold);
  margin-bottom: 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  text-align: center;
  width: 100%;
  flex-shrink: 0;
}

.bench-count-badge {
  font-size: 5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-dark);
  width: 100%;
  flex-shrink: 0;
}

.inventory-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 0%;
  min-height: 0;
  max-height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
  cursor: grab;
}

.inventory-slots.is-dragging {
  cursor: grabbing;
}

.inventory-slots::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.inventory-slots::-webkit-scrollbar-track,
.inventory-slots::-webkit-scrollbar-thumb {
  display: none;
}

.inventory-slots img,
.talisman-content img {
  -webkit-user-drag: none;
  user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Bench Footer / SALE button (aligns with recruit-footer on same horizontal row) */
.bench-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px solid var(--border-dark);
  flex-shrink: 0;
}

.btn-sell {
  width: 100%;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  font-weight: 700;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(192, 57, 43, 0.2);
  border: 1px solid #e74c3c;
  color: #ff7675;
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
}

.btn-sell:hover:not(:disabled) {
  background: #c0392b;
  border-color: #ff7675;
  color: #fff;
}

.btn-sell:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-sell:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-dark);
  color: var(--text-muted);
  background: var(--bg-card);
}

/* Bench Cards: Full 156x50 px exact size with bench_slot.png */
.reward-card.bench-card,
.reward-card.bench-card.inv-slot {
  width: 156px !important;
  height: 50px !important;
  min-width: 156px !important;
  max-width: 156px !important;
  min-height: 50px !important;
  max-height: 50px !important;
  background: url('assets/ui/bench/bench_slot.png') no-repeat 0 0 !important;
  background-size: 100% 100% !important;
  image-rendering: pixelated;
  border: none !important;
  position: relative !important;
  cursor: pointer !important;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 0;
  overflow: hidden !important;
  display: flex !important;
  align-items: center !important;
}

.reward-card.bench-card:hover {
  filter: brightness(1.2);
}

.reward-card.bench-card.selected {
  filter: brightness(1.15) drop-shadow(0 0 3px #2ed573);
}

.reward-card.bench-card.deployed {
  opacity: 0.55;
}

.reward-card.bench-card .reward-card-img-wrap,
.reward-card.bench-card.inv-slot .inv-slot-img-wrap {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 42px !important;
  height: 50px !important;
  display: block !important;
}

.reward-card.bench-card .reward-card-img,
.reward-card.bench-card.inv-slot .inv-slot-piece {
  position: absolute !important;
  left: 1px !important;
  top: 10px !important;
  width: 40px !important;
  height: 30px !important;
  image-rendering: pixelated !important;
  object-fit: contain !important;
  display: block !important;
}

.reward-card.bench-card .reward-card-info {
  position: absolute !important;
  left: 44px !important;
  top: 3px !important;
  bottom: 3px !important;
  width: 104px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  gap: 2px !important;
  overflow: hidden !important;
  pointer-events: none !important;
}



/* ===== MODALS (PIXEL FRAMED) ===== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

#confirmModal {
  z-index: 3500;
}

.modal-box {
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 240px;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 8px;
  color: var(--gold);
}

.modal-subtitle {
  font-size: 6px;
  color: var(--text-main);
  line-height: 1.3;
}

.reward-pill,
.defeat-stats {
  font-size: 6px;
  color: var(--accent-green);
}

.defeat-stats {
  color: var(--accent-red);
}

.btn-large {
  font-size: 7px;
  height: 20px;
  padding: 2px 8px;
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  color: #fff;
}

.btn-large:hover {
  background: var(--gold);
  color: #000;
}

/* ===== RETRO PIXEL TOAST BANNER ===== */
.retro-toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #141824;
  border: 1.5px solid var(--border-gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.85), inset 0 0 4px rgba(240, 194, 66, 0.25);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 4000;
  max-width: 85%;
  pointer-events: auto;
  cursor: pointer;
  animation: toastSlideDown 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.retro-toast.toast-error {
  border-color: var(--accent-red);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.85), inset 0 0 4px rgba(224, 72, 72, 0.3);
}

.retro-toast.toast-info {
  border-color: var(--accent-blue);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.85), inset 0 0 4px rgba(62, 136, 232, 0.3);
}

.retro-toast.toast-hide {
  animation: toastSlideUp 0.18s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards !important;
}

@keyframes toastSlideDown {
  0% {
    transform: translateX(-50%) translateY(-26px);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes toastSlideUp {
  0% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(-26px);
    opacity: 0;
  }
}

.retro-toast .toast-icon {
  font-size: 8px;
  line-height: 1;
  flex-shrink: 0;
}

.retro-toast .toast-message {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-main);
  line-height: 1.25;
  white-space: normal;
  text-align: center;
}

.confirm-box {
  width: 210px;
  padding: 10px 8px;
}

.confirm-buttons {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.confirm-buttons .btn {
  min-width: 60px;
}

/* Promotion Modal */
.promotion-choices {
  display: flex;
  gap: 4px;
}

.promo-btn {
  width: 24px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-btn:hover {
  border-color: var(--gold);
}

.promo-btn img {
  width: 16px !important;
  height: 32px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  image-rendering: pixelated !important;
  object-fit: none !important;
  flex-shrink: 0 !important;
}

/* ===== MOBILE PORTRAIT ROTATE OVERLAY ===== */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(7, 9, 15, 0.98);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

@media (orientation: portrait) and (max-width: 950px) {
  .rotate-overlay {
    display: flex;
  }
}

.rotate-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 320px;
}

.rotate-icon-wrap {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rotate-phone-icon {
  width: 22px;
  height: 36px;
  border: 3px solid var(--gold);
  border-radius: 4px;
  position: relative;
  animation: phoneRotate 2s ease-in-out infinite;
}

.rotate-phone-icon::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
}

@keyframes phoneRotate {

  0%,
  25% {
    transform: rotate(0deg);
  }

  65%,
  100% {
    transform: rotate(-90deg);
  }
}

.rotate-title {
  font-family: var(--font-title);
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 8px;
  line-height: 1.4;
  text-shadow: 1px 1px 0 #000;
}

.rotate-subtitle {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

.rotate-btn {
  font-size: 7px;
  padding: 6px 12px;
}

/* =============================================
   MAIN MENU & 3-SLOT SAVE/LOAD SYSTEM
   ============================================= */

/* Main Menu Overlay (inside #app) */
.main-menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 2500;
  background: radial-gradient(circle at center, #121726 0%, #070912 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  user-select: none;
}

.main-menu-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.main-menu-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 295px;
  padding: 13px 16px;
  background: #0e121e;
  border: 2px solid var(--border-gold);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.95);
  position: relative;
}

.main-menu-header {
  margin-bottom: 12px;
}

.main-menu-tag {
  font-family: var(--font-pixel);
  font-size: 5.5px;
  letter-spacing: 1.2px;
  color: var(--accent-red);
  font-weight: 700;
  margin-bottom: 4px;
  text-shadow: none;
}

.main-menu-title {
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #1b1102;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-poke-ball {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #ffffff 22%, #1b1b1b 23%, #1b1b1b 32%, transparent 33%),
              linear-gradient(to bottom, #ee2828 0%, #ee2828 45%, #181818 46%, #181818 54%, #ffffff 55%, #ffffff 100%);
  border: 1.5px solid #000;
  display: inline-block;
  margin-right: 5px;
  box-shadow: none;
}

.title-poke {
  color: #ff3b3b;
  text-shadow: 2px 2px 0 #5f0000;
}

.main-menu-subtitle {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-muted);
  letter-spacing: 0.8px;
}

.main-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 200px;
  margin-bottom: 10px;
}

.btn-menu-action {
  width: 100%;
  height: 22px;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 0 6px;
  cursor: pointer;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-main);
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-menu-action:hover:not(:disabled) {
  border-color: var(--gold);
  background: #252d42;
  color: #fff;
  transform: translateY(-1px);
}

.btn-menu-action:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-menu-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-dark);
}

.btn-menu-primary {
  background: #245830;
  border-color: var(--accent-green);
  color: #afffa4;
}

.btn-menu-primary:hover:not(:disabled) {
  background: #2e733e;
  border-color: #64f787;
  color: #fff;
}

.btn-menu-gold {
  border-color: var(--border-gold);
  color: var(--gold);
}

.main-menu-footer {
  font-family: var(--font-pixel);
  font-size: 4px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* In-game Pause Menu Box */
.in-game-menu-box {
  width: 180px;
  padding: 10px;
  text-align: center;
}

.in-game-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
  width: 100%;
}

.in-game-menu-buttons .btn {
  width: 100%;
  height: 20px;
  font-size: 6px;
}

/* Save Slots Vault Modal */
.save-slots-box {
  width: 330px;
  max-width: 95%;
  padding: 8px 10px;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
}

.save-vault-title {
  font-size: 8px;
  color: var(--gold);
  margin-bottom: 2px;
}

.save-vault-subtitle {
  font-size: 5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.save-slots-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin-bottom: 8px;
}

.save-slot-card {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}

.save-slot-card:hover {
  border-color: var(--border-light);
}

.save-slot-card.slot-active {
  border-color: var(--border-gold);
  background: rgba(200, 155, 60, 0.1);
}

.save-slot-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.save-slot-badge-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.save-slot-badge {
  font-family: var(--font-title);
  font-size: 6px;
  color: var(--gold);
}

.save-slot-stage {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: #fff;
  font-weight: 700;
}

.save-slot-stats {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.save-slot-stats strong {
  color: var(--gold);
}

.save-slot-date {
  font-family: var(--font-pixel);
  font-size: 4px;
  color: #657088;
}

.save-slot-empty-text {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: var(--text-muted);
  font-style: italic;
}

.save-slot-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.save-slot-actions .btn {
  height: 16px;
  font-size: 5px;
  padding: 0 4px;
}

.btn-slot-delete {
  background: rgba(192, 57, 43, 0.2);
  border-color: #e74c3c;
  color: #ff7675;
}

.btn-slot-delete:hover:not(:disabled) {
  background: #c0392b;
  color: #fff;
}

.save-vault-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border-top: 1px solid var(--border-dark);
  padding-top: 5px;
  width: 100%;
}

.save-vault-actions .btn {
  height: 16px;
  font-size: 5px;
  padding: 0 6px;
}

/* How to Play Modal Box (Cẩm Nang Huấn Luyện Viên) */
.how-to-play-box {
  width: 380px;
  max-width: 95%;
  max-height: 350px;
  overflow-y: auto;
  padding: 10px 14px;
  text-align: center;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.95), 0 0 10px rgba(240, 194, 66, 0.3);
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold) var(--bg-card);
}

.how-to-play-box::-webkit-scrollbar {
  width: 4px;
}

.how-to-play-box::-webkit-scrollbar-thumb {
  background: var(--border-gold);
  border-radius: 2px;
}

.how-to-play-content {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 6px 0 10px 0;
  text-align: left;
}

.intel-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 6.5px;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-card);
  padding: 6px 8px;
  border: 1px solid var(--border-dark);
  border-radius: 2px;
}

.intel-item span:last-child {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.intel-num {
  font-family: var(--font-title);
  font-size: 7px;
  color: #fff;
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#btnCloseHowToPlay {
  min-width: 80px;
  height: 20px;
  font-size: 6.5px;
}

/* ===== INTERACTIVE STEP-BY-STEP GUIDED TUTORIAL (SQUARE PIXEL) ===== */
.tutorial-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 0 !important;
}

.tutorial-spotlight {
  position: absolute;
  border-radius: 0 !important;
  box-shadow: 0 0 0 9999px rgba(5, 7, 14, 0.84);
  border: 2px solid var(--gold);
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: tutorialSpotlightPulse 1.1s infinite alternate ease-in-out;
}

@keyframes tutorialSpotlightPulse {
  0% {
    box-shadow: 0 0 0 9999px rgba(5, 7, 14, 0.84), 0 0 4px rgba(240, 194, 66, 0.4);
    border-color: var(--gold);
  }
  100% {
    box-shadow: 0 0 0 9999px rgba(5, 7, 14, 0.88), 0 0 12px rgba(240, 194, 66, 0.95);
    border-color: #ffe680;
  }
}

.tutorial-pointer {
  position: absolute;
  pointer-events: none;
  z-index: 1030;
  transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-hand {
  font-size: 22px;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.95));
  animation: tutorialHandBounce 0.65s infinite alternate ease-in-out;
}

@keyframes tutorialHandBounce {
  0% { transform: scale(1); }
  100% { transform: scale(1.25); }
}

.tutorial-card {
  position: absolute;
  z-index: 1020;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  border-radius: 0 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.95), inset 0 0 6px rgba(240, 194, 66, 0.1);
  padding: 8px 10px;
  width: 260px;
  min-width: 240px;
  max-width: 285px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
  transition: all 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tutorial-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 4px;
  gap: 6px;
  border-radius: 0 !important;
}

.tutorial-step-badge {
  font-size: 6px;
  color: var(--gold);
  font-weight: bold;
  background: rgba(240, 194, 66, 0.15);
  padding: 2px 4px;
  border-radius: 0 !important;
  border: 1px solid var(--gold-dim);
  white-space: nowrap;
}

.tutorial-card-title {
  font-size: 6.5px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 0.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tutorial-btn-skip {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 6px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: var(--font-pixel);
  transition: color 0.15s;
  white-space: nowrap;
  border-radius: 0 !important;
}

.tutorial-btn-skip:hover {
  color: var(--accent-red);
}

.tutorial-card-body {
  font-size: 6.5px;
  line-height: 1.45;
  color: var(--text-main);
  padding: 2px 0;
  min-height: 40px;
  word-break: break-word;
}

.tutorial-card-body strong {
  color: var(--gold);
}

.tutorial-card-body em {
  color: #a6bac4;
  font-style: normal;
}

.tutorial-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
  padding-top: 5px;
  border-top: 1px solid var(--border-dark);
}

.tutorial-btn-prev,
.tutorial-btn-next {
  font-size: 6.5px !important;
  padding: 3px 8px !important;
  min-width: 65px;
  height: 20px !important;
  line-height: 18px;
  border-radius: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   POKEMON VISUAL MOVE EDITOR MODAL (FULL SCREEN DEV CONSOLE)
   ========================================================== */
#moveEditorModal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3100;
  padding: 0;
}

#moveEditorModal.hidden {
  display: none !important;
}

.move-editor-box {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  background: var(--bg-panel) !important;
  border: 2px solid var(--border-gold) !important;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.95), inset 0 0 8px rgba(240, 194, 66, 0.15) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 3px !important;
  padding: 4px 8px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  border-radius: 0 !important;
  z-index: 3100 !important;
}

.move-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 2px;
  flex-shrink: 0;
}

.move-editor-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.move-editor-title {
  font-size: 8px !important;
  color: var(--gold) !important;
  letter-spacing: 0.5px;
}

.move-editor-subtitle {
  font-size: 5px;
  color: var(--text-muted);
}

.btn-close-editor {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 7px;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.btn-close-editor:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* Clean Sub-Bar: Pokemon Picker & File Actions */
.move-editor-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #0f1422;
  padding: 4px 8px;
  border: 1px solid var(--border-dark);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.editor-pkm-picker-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-bar-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
}

.editor-file-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-file-badge {
  font-family: monospace;
  font-size: 10px;
  font-weight: 600;
  color: #70a1ff;
  background: #0a0e18;
  border: 1px solid #1e283d;
  padding: 2px 8px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
}

#moveEditorPokemonSelect {
  max-width: 220px;
  min-width: 170px;
}

/* ==========================================================
   DROPDOWN & SELECT STYLES (CLEAN & LEGIBLE FONTS)
   ========================================================== */
select.editor-select, select {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  background: #141824 !important;
  color: var(--gold) !important;
  border: 1px solid var(--border-gold) !important;
  padding: 1px 6px !important;
  height: 20px !important;
  line-height: 20px !important;
  cursor: pointer !important;
  outline: none !important;
  border-radius: 2px !important;
  box-sizing: border-box !important;
}

select.editor-select:focus, select:focus {
  border-color: #ffd700 !important;
  box-shadow: 0 0 5px rgba(240, 194, 66, 0.4) !important;
}

select option, select.editor-select option {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  background: #141824 !important;
  color: #e8ecf4 !important;
  padding: 6px 10px !important;
  line-height: 1.5 !important;
}

/* ==========================================================
   TOM SELECT: RETRO PIXEL DARK THEME FOR POKEMON SELECTORS
   ========================================================== */
.ts-wrapper,
.ts-wrapper.editor-select,
.ts-wrapper.editor-evo-select {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 11px !important;
  position: relative !important;
  display: inline-block !important;
  vertical-align: middle !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  height: auto !important;
  line-height: normal !important;
  box-shadow: none !important;
  outline: none !important;
}

.ts-wrapper.focus,
.ts-wrapper.focus.editor-select {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
}

#moveEditorPokemonSelect + .ts-wrapper {
  width: 200px !important;
  min-width: 170px !important;
}

#editPieceNextEvo + .ts-wrapper {
  width: 175px !important;
  min-width: 150px !important;
}

#selectCloneFromAnyPkm + .ts-wrapper {
  width: 175px !important;
  min-width: 150px !important;
}

#createPkmNextEvo + .ts-wrapper {
  flex: 1 !important;
  min-width: 150px !important;
}

.ts-wrapper.single .ts-control {
  background: #141824 !important;
  border: 1px solid var(--border-gold) !important;
  color: var(--gold) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 0 20px 0 5px !important;
  height: 20px !important;
  min-height: 20px !important;
  border-radius: 2px !important;
  box-shadow: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  line-height: 20px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.ts-wrapper.single .ts-control::after {
  content: '▼' !important;
  position: absolute !important;
  right: 5px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  font-size: 7px !important;
  color: var(--gold) !important;
  pointer-events: none !important;
  border: none !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
}

.ts-wrapper.focus .ts-control {
  border-color: #ffd700 !important;
  box-shadow: 0 0 6px rgba(240, 194, 66, 0.4) !important;
}

.ts-control > input {
  color: #fff !important;
  font-size: 11px !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  background: transparent !important;
  height: 18px !important;
  line-height: 18px !important;
  padding: 0 !important;
  margin: 0 !important;
}

.ts-dropdown {
  position: absolute !important;
  background: #141824 !important;
  border: 1px solid var(--border-gold) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.95), inset 0 0 8px rgba(240, 194, 66, 0.1) !important;
  border-radius: 2px !important;
  z-index: 99999 !important;
  margin-top: 2px !important;
  overflow: hidden !important;
  min-width: 220px !important;
}

.ts-dropdown .ts-dropdown-content {
  max-height: 220px !important;
  overflow-y: auto !important;
  padding: 2px 0 !important;
}

.ts-dropdown .ts-dropdown-content::-webkit-scrollbar {
  width: 5px;
}
.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-track {
  background: #0d111a;
}
.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb {
  background: #3a4460;
  border-radius: 2px;
}
.ts-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.ts-dropdown .option {
  padding: 4px 8px !important;
  font-size: 12px !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  color: #e8ecf4 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
  line-height: 1.4 !important;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
  background: #252f48 !important;
  color: #ffd700 !important;
}

.ts-dropdown .option.selected {
  background: #1c2b3d !important;
  color: #00d2d3 !important;
  font-weight: 700 !important;
}

.ts-pkm-option, .ts-pkm-item {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  overflow: hidden;
}

.ts-pkm-empty {
  color: var(--text-muted);
  font-style: italic;
}

.ts-pkm-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.ts-pkm-id {
  font-size: 10px;
  font-weight: 700;
  color: #828c9e;
  font-family: monospace;
  flex-shrink: 0;
}

.ts-pkm-name {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ts-pkm-elem {
  font-size: 8px;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.ts-pkm-file {
  font-size: 9px;
  color: #70a1ff;
  font-family: monospace;
  opacity: 0.8;
  flex-shrink: 0;
}

.elem-grass { background: #2ed573; color: #000; }
.elem-fire { background: #ff4757; color: #fff; }
.elem-water { background: #1e90ff; color: #fff; }
.elem-electric { background: #ffa502; color: #000; }
.elem-bug { background: #7bed9f; color: #000; }
.elem-normal { background: #a4b0be; color: #000; }
.elem-poison { background: #9b59b6; color: #fff; }
.elem-ground { background: #eccc68; color: #000; }
.elem-rock { background: #d2b48c; color: #000; }
.elem-flying { background: #70a1ff; color: #000; }
.elem-psychic { background: #ff6b81; color: #fff; }
.elem-ice { background: #70d6ff; color: #000; }
.elem-fighting { background: #eb4d4b; color: #fff; }
.elem-ghost { background: #6c5ce7; color: #fff; }
.elem-dragon { background: #4834d4; color: #fff; }
.elem-steel { background: #95afc0; color: #000; }
.elem-fairy { background: #ff9ff3; color: #000; }
.elem-dark { background: #2f3542; color: #fff; }

/* Stats Editor Inputs */
.editor-num-input {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  width: 100% !important;
  height: 22px !important;
  background: #141824 !important;
  color: #fff !important;
  border: 1px solid #28334a !important;
  padding: 0 4px !important;
  text-align: center !important;
  outline: none !important;
  border-radius: 2px !important;
  box-sizing: border-box !important;
}

.editor-num-input:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 5px rgba(240, 194, 66, 0.4) !important;
}

.editor-text-input {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  background: #141824 !important;
  color: #fff !important;
  border: 1px solid #28334a !important;
  padding: 2px 6px !important;
  outline: none !important;
  width: 100% !important;
  height: 22px !important;
  border-radius: 2px !important;
  box-sizing: border-box !important;
}

.editor-text-input:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 5px rgba(240, 194, 66, 0.4) !important;
}

/* Brush Bar */
.editor-brush-bar {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  background: #0f1422 !important;
  padding: 2px 4px !important;
  border: 1px solid var(--border-dark) !important;
  border-radius: 3px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.editor-brush-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 9px !important;
  font-weight: 800 !important;
  color: var(--gold) !important;
  white-space: nowrap !important;
}

.editor-brush-pills {
  display: flex !important;
  gap: 3px !important;
  flex: 1 !important;
}

.btn-brush {
  flex: 1 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  height: 18px !important;
  padding: 0 2px !important;
  background: #141824 !important;
  border: 1px solid #28334a !important;
  color: #8e9bb0 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  border-radius: 2px !important;
  white-space: nowrap !important;
}

.btn-brush:hover {
  border-color: #fff !important;
  color: #fff !important;
}

.btn-brush.active {
  border-color: var(--gold) !important;
  color: #fff !important;
  background: rgba(240, 194, 66, 0.2) !important;
}

.btn-brush[data-brush="all"].active {
  border-color: #00d2d3 !important;
  color: #00d2d3 !important;
  background: rgba(0, 210, 211, 0.2) !important;
}

.btn-brush[data-brush="moveOnly"].active {
  border-color: #feca57 !important;
  color: #feca57 !important;
  background: rgba(254, 202, 87, 0.2) !important;
}

.btn-brush[data-brush="captureOnly"].active {
  border-color: #ff6b6b !important;
  color: #ff6b6b !important;
  background: rgba(255, 107, 107, 0.2) !important;
}

.brush-dot {
  width: 5px !important;
  height: 5px !important;
  display: inline-block !important;
  border-radius: 1px !important;
}

.dot-all { background: #00d2d3 !important; }
.dot-move { background: #feca57 !important; }
.dot-capture { background: #ff6b6b !important; }
.dot-clear { background: #576574 !important; }

/* Main Layout (2 Balanced Columns) */
.move-editor-main {
  display: flex !important;
  gap: 10px !important;
  flex: 1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  padding: 3px 0 !important;
}

/* LEFT COLUMN: Board 7x7 & Tools */
.move-editor-left-col {
  width: 250px !important;
  flex-shrink: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 4px !important;
}

/* 7x7 Board Area */
.editor-board-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 1px !important;
}

.grid-direction-indicator {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 8.5px !important;
  font-weight: 700 !important;
  color: var(--gold) !important;
  letter-spacing: 0.5px !important;
}

.move-editor-grid-wrapper {
  display: flex !important;
  align-items: center !important;
  gap: 2px !important;
}

.grid-direction-side {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  font-size: 8px !important;
  font-weight: 700 !important;
  color: #636e72 !important;
  writing-mode: vertical-rl !important;
  text-orientation: mixed !important;
  transform: rotate(180deg) !important;
}

.grid-direction-side.side-right {
  transform: none !important;
}

.move-editor-grid {
  display: grid !important;
  grid-template-columns: repeat(7, 23px) !important;
  grid-template-rows: repeat(7, 23px) !important;
  gap: 1px !important;
  background: #07090f !important;
  padding: 2px !important;
  border: 1px solid var(--border-gold) !important;
}

.editor-cell {
  width: 23px;
  height: 23px;
  background: #121622;
  border: 1px solid #1f2639;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  user-select: none;
  box-sizing: border-box;
  transition: background 0.1s, border-color 0.1s;
}

.editor-cell:hover:not(.cell-center) {
  border-color: #70a1ff;
  filter: brightness(1.25);
}

.editor-cell.cell-center {
  background: #1e293b;
  border: 1.5px solid var(--gold);
  cursor: default;
  position: relative;
  overflow: visible;
}

.cell-center-icon {
  width: 26px !important;
  height: 22px !important;
  object-fit: contain !important;
  image-rendering: pixelated !important;
  position: absolute;
  top: 0;
  left: -1px;
  pointer-events: none;
}

.cell-center-label {
  position: absolute;
  bottom: 0px;
  right: 1px;
  font-size: 4px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.editor-cell.mode-all {
  background: rgba(0, 210, 211, 0.35);
  border-color: #00d2d3;
}

.editor-cell.mode-moveOnly {
  background: rgba(254, 202, 87, 0.35);
  border-color: #feca57;
}

.editor-cell.mode-captureOnly {
  background: rgba(255, 107, 107, 0.35);
  border-color: #ff6b6b;
}

.editor-cell.mode-slide {
  background: rgba(165, 94, 234, 0.28);
  border-color: #a55eea;
  position: relative;
}

.editor-cell.mode-slide.mode-slide-moveOnly {
  background: rgba(254, 202, 87, 0.28);
  border-color: #feca57;
}

.editor-cell.mode-slide.mode-slide-captureOnly {
  background: rgba(255, 107, 107, 0.28);
  border-color: #ff6b6b;
}

.editor-cell.mode-slide.mode-slide-moveOnly .cell-ray-arrow {
  color: #feca57;
}

.editor-cell.mode-slide.mode-slide-captureOnly .cell-ray-arrow {
  color: #ff6b6b;
}

.cell-ray-step-badge {
  position: absolute;
  bottom: 0px;
  right: 1px;
  font-size: 3.5px;
  font-weight: 700;
  line-height: 1;
  color: #ffd700;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* Candidate cells when a direction is selected */
.editor-cell.cell-ray-candidate {
  border: 1px dashed rgba(255, 215, 0, 0.75) !important;
  background: rgba(255, 215, 0, 0.09) !important;
  cursor: crosshair !important;
  position: relative;
  transition: all 0.12s;
}

.editor-cell.cell-ray-candidate::after {
  content: attr(data-step-label);
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 3.5px;
  color: #ffd700;
  font-weight: bold;
  opacity: 0.95;
  line-height: 1;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.editor-cell.cell-ray-candidate:hover,
.editor-cell.cell-ray-hover-active {
  border: 1px solid #ffd700 !important;
  background: rgba(255, 215, 0, 0.32) !important;
  box-shadow: inset 0 0 8px rgba(255, 215, 0, 0.55);
}

.cell-tag {
  font-size: 4px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 1px 1px 0 #000;
}

.mode-all .cell-tag { color: #00d2d3; }
.mode-moveOnly .cell-tag { color: #feca57; }
.mode-captureOnly .cell-tag { color: #ff6b6b; }

.cell-ray-arrow {
  font-size: 8px;
  color: #a55eea;
  line-height: 1;
  text-shadow: 1px 1px 0 #000;
}

/* Left Column Tools */
.editor-left-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
}

.editor-mini-label {
  font-size: 5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 1px;
}

.btn-mini {
  font-size: 5px !important;
  height: 17px !important;
  padding: 0 4px !important;
  white-space: nowrap;
}

/* Right Column: Clean Card-based Layout */
.move-editor-right-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  min-width: 0;
  padding-right: 2px;
}

.move-editor-right-col::-webkit-scrollbar {
  width: 4px;
}

.move-editor-right-col::-webkit-scrollbar-thumb {
  background: #252e44;
  border-radius: 2px;
}

.editor-card {
  background: #0d111a;
  border: 1px solid #1c2436;
  border-radius: 3px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.editor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1c2436;
  padding-bottom: 3px;
}

.editor-card-title {
  font-size: 6.5px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.3px;
}

.editor-card-count {
  font-size: 5.5px;
  color: #70a1ff;
  background: rgba(112, 161, 255, 0.12);
  padding: 1px 5px;
  border-radius: 2px;
}

.editor-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-field-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.editor-field label {
  font-size: 5px;
  color: #8395a7;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.editor-clone-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-clone-label {
  font-size: 5px;
  color: #8395a7;
  font-weight: 700;
  white-space: nowrap;
}

/* Slide Rays Grid */
.slide-rays-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.btn-slide-ray {
  font-family: var(--font-pixel);
  font-size: 5px;
  height: 19px;
  padding: 0 4px;
  background: #141824;
  border: 1px solid #222a3d;
  color: #a4b0be;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  border-radius: 2px;
  transition: all 0.15s;
}

.btn-slide-ray:hover {
  border-color: #70a1ff;
  color: #fff;
}

.btn-slide-ray.active {
  border-color: #a55eea;
  background: rgba(165, 94, 234, 0.22);
  color: #fff;
}

.btn-slide-ray.active.mode-moveOnly {
  border-color: #feca57;
  background: rgba(254, 202, 87, 0.22);
}

.btn-slide-ray.active.mode-captureOnly {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.22);
}

.slide-status-badge {
  font-size: 4px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 1px;
  background: rgba(0, 0, 0, 0.45);
  color: #576574;
}

.btn-slide-ray.active .slide-status-badge {
  color: #2ed573;
}

.btn-slide-ray.selected-direction {
  border-color: #ffd700 !important;
  background: rgba(255, 215, 0, 0.22) !important;
  color: #ffd700 !important;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.55);
  animation: slideDirPulse 1.5s infinite alternate ease-in-out;
}

.btn-slide-ray.selected-direction .slide-status-badge {
  color: #ffd700 !important;
  background: rgba(0, 0, 0, 0.75) !important;
}

@keyframes slideDirPulse {
  0% { box-shadow: 0 0 3px rgba(255, 215, 0, 0.3); }
  100% { box-shadow: 0 0 9px rgba(255, 215, 0, 0.85); }
}

/* Ray Guide Banner above grid */
.editor-ray-guide-banner {
  background: linear-gradient(90deg, rgba(165, 94, 234, 0.32), rgba(255, 215, 0, 0.22));
  border: 1px solid #a55eea;
  border-radius: 2px;
  padding: 2px 5px;
  margin-bottom: 2px;
  font-size: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f1f2f6;
  box-shadow: 0 0 6px rgba(165, 94, 234, 0.25);
  box-sizing: border-box;
  width: 100%;
}

.editor-ray-guide-banner .btn-banner-close {
  background: #ff4757;
  border: none;
  color: #fff;
  font-size: 4px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 1px;
  cursor: pointer;
  line-height: 1.2;
}

.editor-ray-guide-banner .btn-banner-close:hover {
  background: #ff6b81;
}

/* Slide Ray Inspector */
.slide-ray-inspector {
  margin-top: 4px;
  background: #0f131e;
  border: 1px solid #a55eea;
  border-radius: 2px;
  padding: 4px;
  font-size: 5px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
}

.inspector-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid #1e2638;
}

.inspector-title {
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 3px;
}

.inspector-pulse-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffd700;
  box-shadow: 0 0 5px #ffd700;
  animation: dotPulse 1.2s infinite alternate;
}

@keyframes dotPulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

.btn-inspector-close {
  background: #2f3542;
  border: 1px solid #57606f;
  color: #ced6e0;
  font-size: 4.5px;
  padding: 1px 4px;
  border-radius: 2px;
  cursor: pointer;
}

.btn-inspector-close:hover {
  background: #ff4757;
  color: #fff;
  border-color: #ff4757;
}

.inspector-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.inspector-lbl {
  color: #8395a7;
  font-weight: bold;
  min-width: 46px;
}

.inspector-pills {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.pill-step, .pill-mode {
  background: #192033;
  border: 1px solid #2d3852;
  color: #a4b0be;
  font-family: var(--font-pixel);
  font-size: 4.5px;
  padding: 1px 4px;
  border-radius: 1px;
  cursor: pointer;
  transition: all 0.12s;
}

.pill-step:hover, .pill-mode:hover {
  border-color: #70a1ff;
  color: #fff;
}

.pill-step.active {
  background: #2ed573;
  border-color: #2ed573;
  color: #000;
  font-weight: bold;
}

.pill-mode.active.mode-all {
  background: #a55eea;
  border-color: #a55eea;
  color: #fff;
}

.pill-mode.active.mode-moveOnly {
  background: #feca57;
  border-color: #feca57;
  color: #000;
}

.pill-mode.active.mode-captureOnly {
  background: #ff6b6b;
  border-color: #ff6b6b;
  color: #fff;
}

.inspector-guide {
  color: #70a1ff;
  font-size: 4.5px;
  margin-top: 2px;
  font-style: italic;
}

/* Slide Origin on Grid Cell */
.editor-cell.has-slide-origin {
  box-shadow: inset 0 0 4px rgba(255, 215, 0, 0.4);
}

.editor-cell.has-slide-origin.slide-origin-captureOnly {
  border-color: #ff6b6b !important;
  box-shadow: inset 0 0 5px rgba(255, 107, 107, 0.6);
}

.editor-cell.has-slide-origin.slide-origin-moveOnly {
  border-color: #feca57 !important;
  box-shadow: inset 0 0 5px rgba(254, 202, 87, 0.6);
}

.editor-cell.has-slide-origin.slide-origin-all {
  border-color: #00d2d3 !important;
  box-shadow: inset 0 0 5px rgba(0, 210, 211, 0.6);
}

.slide-origin-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 3.5px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 1px;
  background: rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 2;
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 0.2px;
}

.slide-origin-badge.mode-captureOnly {
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.7);
}

.slide-origin-badge.mode-moveOnly {
  color: #feca57;
  border: 1px solid rgba(254, 202, 87, 0.7);
}

.slide-origin-badge.mode-all {
  color: #00d2d3;
  border: 1px solid rgba(0, 210, 211, 0.7);
}

/* Laser aiming ready cursor */
.editor-cell.cell-slide-aiming-ready {
  cursor: crosshair !important;
}

/* Laser hover beam effect */
.editor-cell.cell-laser-preview {
  transition: none !important;
  z-index: 5;
}

.editor-cell.cell-laser-preview.laser-captureOnly {
  background: rgba(255, 107, 107, 0.45) !important;
  border: 1px dashed #ff4757 !important;
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.8), inset 0 0 6px rgba(255, 71, 87, 0.5) !important;
}

.editor-cell.cell-laser-preview.laser-all {
  background: rgba(0, 210, 211, 0.45) !important;
  border: 1px dashed #00d2d3 !important;
  box-shadow: 0 0 8px rgba(0, 210, 211, 0.8), inset 0 0 6px rgba(0, 210, 211, 0.5) !important;
}

.editor-cell.cell-laser-preview.laser-moveOnly {
  background: rgba(254, 202, 87, 0.45) !important;
  border: 1px dashed #feca57 !important;
  box-shadow: 0 0 8px rgba(254, 202, 87, 0.8), inset 0 0 6px rgba(254, 202, 87, 0.5) !important;
}

.editor-cell.cell-laser-preview.laser-clear {
  background: rgba(255, 71, 87, 0.25) !important;
  border: 1px dotted #ff4757 !important;
}

.editor-cell.cell-laser-preview.laser-origin-preview {
  border-style: solid !important;
  outline: 1px solid #ffd700;
  animation: laserOriginPulse 0.4s infinite alternate;
}

@keyframes laserOriginPulse {
  0% { transform: scale(0.96); }
  100% { transform: scale(1.04); }
}

/* Slide Rays List */
.slide-rays-list-wrap {
  margin-top: 5px;
  background: #0f131e;
  border: 1px solid #1c2436;
  border-radius: 2px;
  padding: 4px;
}

.slide-rays-list-header {
  font-size: 5px;
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid #1e2638;
}

.slide-rays-empty-hint {
  font-size: 4.5px;
  color: #8395a7;
  font-style: italic;
  padding: 4px 2px;
  line-height: 1.4;
}

.slide-rays-list-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 100px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.slide-rays-list-items::-webkit-scrollbar {
  width: 3px;
}

.slide-rays-list-items::-webkit-scrollbar-thumb {
  background: #252e44;
  border-radius: 2px;
}

.slide-ray-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #141824;
  border: 1px solid #222a3d;
  border-radius: 2px;
  padding: 2px 4px;
  font-size: 4.5px;
  gap: 4px;
}

.slide-ray-item.mode-captureOnly {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.08);
}

.slide-ray-item.mode-all {
  border-color: rgba(0, 210, 211, 0.4);
  background: rgba(0, 210, 211, 0.08);
}

.slide-ray-item.mode-moveOnly {
  border-color: rgba(254, 202, 87, 0.4);
  background: rgba(254, 202, 87, 0.08);
}

.slide-ray-item-arrow {
  font-size: 7px;
  font-weight: bold;
  color: #ffd700;
  line-height: 1;
}

.slide-ray-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.slide-ray-item-name {
  color: #fff;
  font-weight: bold;
}

.slide-ray-item-coords {
  color: #8395a7;
  font-size: 4px;
}

.btn-del-slide-ray {
  background: #2f3542;
  border: 1px solid #57606f;
  color: #ff6b81;
  border-radius: 2px;
  cursor: pointer;
  padding: 1px 3px;
  font-size: 4px;
  line-height: 1;
}

.btn-del-slide-ray:hover {
  background: #ff4757;
  color: #fff;
  border-color: #ff4757;
}

/* Action Buttons */
.btn-reload-file {
  background: linear-gradient(180deg, #1e90ff, #0984e3) !important;
  color: #fff !important;
  border: 1px solid #70a1ff !important;
  font-size: 6px !important;
  height: 20px !important;
  padding: 0 6px !important;
  font-weight: bold;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px;
  white-space: nowrap;
}

.btn-reload-file:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 6px rgba(30, 144, 255, 0.6);
}

.btn-new-pokemon {
  background: linear-gradient(180deg, #10ac84, #1dd1a1) !important;
  color: #fff !important;
  border: 1px solid #1dd1a1 !important;
  font-size: 6px !important;
  height: 20px !important;
  padding: 0 6px !important;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-pixel) !important;
  display: inline-flex !important;
  align-items: center !important;
  border-radius: 2px;
}

.btn-new-pokemon:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 6px rgba(29, 209, 161, 0.6);
}

.btn-delete-pokemon {
  background: linear-gradient(180deg, #eb4d4b, #d63031) !important;
  color: #fff !important;
  border: 1px solid #ff7979 !important;
  font-size: 6px !important;
  height: 20px !important;
  padding: 0 6px !important;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-pixel) !important;
  display: inline-flex !important;
  align-items: center !important;
  border-radius: 2px;
}

.btn-delete-pokemon:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 6px rgba(235, 77, 75, 0.7);
}

.btn-delete-pokemon-footer {
  background: linear-gradient(180deg, #eb4d4b, #d63031) !important;
  color: #fff !important;
  border: 1px solid #ff7979 !important;
  font-size: 5.5px !important;
  height: 20px !important;
  padding: 0 6px !important;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-pixel) !important;
  display: inline-flex !important;
  align-items: center !important;
  border-radius: 2px;
}

.btn-delete-pokemon-footer:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 6px rgba(235, 77, 75, 0.7);
}

.btn-copy-prev {
  background: rgba(254, 202, 87, 0.15) !important;
  border: 1px solid #feca57 !important;
  color: #feca57 !important;
  font-size: 5.5px !important;
  height: 20px !important;
  padding: 0 6px !important;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex !important;
  align-items: center !important;
  gap: 3px;
  font-family: var(--font-pixel) !important;
  border-radius: 2px;
}

.btn-copy-prev:hover {
  background: rgba(254, 202, 87, 0.3) !important;
  color: #fff !important;
}

/* Footer Actions */
.move-editor-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 3px;
  border-top: 1px solid #1c2436;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.move-editor-footer button {
  font-size: 5.5px !important;
  height: 20px !important;
  padding: 0 6px !important;
  white-space: nowrap;
}

/* Sub-modal: Tạo mới Pokémon */
.editor-sub-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3500;
}

.editor-sub-overlay.hidden {
  display: none !important;
}

.editor-create-box {
  width: 340px;
  max-width: 90%;
  background: var(--bg-panel);
  border: 2px solid var(--border-gold);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.95);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 4px;
}

.editor-create-title {
  font-size: 8px;
  color: var(--gold);
  font-weight: bold;
}

.editor-create-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.editor-create-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-create-preview-wrap {
  width: 48px;
  height: 48px;
  background: #07090f;
  border: 1px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.editor-create-preview-img {
  width: 32px !important;
  height: 32px !important;
  object-fit: contain !important;
  image-rendering: pixelated !important;
}

.editor-create-preview-id {
  font-size: 5px;
  color: var(--gold);
  position: absolute;
  bottom: 2px;
}

.editor-form-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-form-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.editor-form-field label {
  font-size: 6px;
  color: var(--text-muted);
  font-weight: bold;
  white-space: nowrap;
}

.editor-text-input {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  background: var(--bg-viewport);
  color: #fff;
  border: 1px solid var(--border-light);
  padding: 1px 4px;
  outline: none;
  flex: 1;
  max-width: 140px;
  height: 20px;
  border-radius: 2px;
  box-sizing: border-box;
}

.editor-text-input:focus {
  border-color: var(--gold);
  color: #fff;
}

.editor-create-footer {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-dark);
}

/* =============================================
   MEGA EVOLUTION AURA & EFFECT
   ============================================= */
.piece-mega-aura {
  filter: drop-shadow(0 0 4px #ffd700) drop-shadow(0 0 8px #ff4757);
  animation: megaAuraPulse 2s infinite alternate ease-in-out;
}

@keyframes megaAuraPulse {
  0% {
    filter: drop-shadow(0 0 3px #ffd700) drop-shadow(0 0 6px #ffa502);
  }
  100% {
    filter: drop-shadow(0 0 6px #ff4757) drop-shadow(0 0 10px #70a1ff);
  }
}

/* =============================================
   MAIN MENU BUTTONS: STARTERS & SKILL TREE
   ============================================= */
.btn-menu-cyan {
  border-color: #00d2d3;
  color: #70a1ff;
  background: #112233;
}
.btn-menu-cyan:hover:not(:disabled) {
  border-color: #00f2fe;
  background: #193854;
  color: #fff;
}

.btn-menu-purple {
  border-color: #a29bfe;
  color: #dcdde1;
  background: #231a38;
}
.btn-menu-purple:hover:not(:disabled) {
  border-color: #e056fd;
  background: #39285c;
  color: #fff;
}

/* =============================================
   STARTER SELECTION MODAL
   ============================================= */
.starter-select-box {
  width: 760px;
  max-width: 96vw;
  height: 460px;
  max-height: 95vh;
  padding: 10px 14px;
  background: #0c101d;
  border: 2px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-sizing: border-box;
}

.starter-modal-header {
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 4px;
}

.starter-active-banner {
  background: rgba(16, 23, 38, 0.95);
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.starter-squad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(255, 211, 42, 0.25);
  padding-bottom: 4px;
}

.starter-squad-title {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--gold);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.starter-squad-count {
  background: #2ed573;
  color: #0b1d10;
  font-family: var(--font-pixel);
  font-size: 5px;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.starter-squad-subtitle {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: #8395a7;
}

.starter-slots-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.starter-slot-box {
  background: #111828;
  border: 1px solid #2d3b55;
  border-radius: 3px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  min-height: 48px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.starter-slot-box.is-filled {
  border-color: #ffd32a;
  background: linear-gradient(180deg, #182239 0%, #111828 100%);
  box-shadow: 0 0 6px rgba(255, 211, 42, 0.15);
}

.starter-slot-box.is-empty {
  border: 1px dashed #3a4a68;
  background: rgba(14, 20, 33, 0.6);
  justify-content: center;
  align-items: center;
}

.starter-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.starter-slot-badge {
  font-family: var(--font-pixel);
  font-size: 4.5px;
  background: #ffd32a;
  color: #000;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  letter-spacing: 0.5px;
}

.starter-slot-badge.empty-badge {
  background: #334155;
  color: #94a3b8;
}

.starter-slot-remove-btn {
  background: #ff4757;
  color: #fff;
  border: none;
  border-radius: 2px;
  width: 13px;
  height: 13px;
  font-size: 7px;
  line-height: 13px;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  padding: 0;
  transition: transform 0.1s, background 0.15s;
}

.starter-slot-remove-btn:hover {
  background: #ff6b81;
  transform: scale(1.15);
}

.starter-slot-body {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.starter-slot-icon {
  width: 28px;
  height: 22px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.starter-slot-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.starter-slot-name {
  font-family: var(--font-pixel);
  font-size: 5.5px;
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.starter-slot-types {
  display: flex;
  gap: 2px;
  margin-top: 1px;
}

.starter-slot-empty-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-family: var(--font-pixel);
  padding: 2px 0;
}

.starter-empty-plus {
  font-size: 10px;
  line-height: 10px;
  color: #475569;
}

.starter-empty-label {
  font-size: 4.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.starter-filter-bar {
  display: flex;
  gap: 6px;
  align-items: center;
}

.starter-search-input {
  flex: 1;
  height: 18px;
  background: #161d2d;
  border: 1px solid var(--border-dark);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 5.5px;
  padding: 0 6px;
  border-radius: 2px;
}

.starter-search-input:focus {
  outline: none;
  border-color: var(--gold);
}

.starter-filter-tabs {
  display: flex;
  gap: 4px;
}

.starter-filter-tab {
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-pixel);
  font-size: 5px;
  background: #1a2030;
  border: 1px solid var(--border-dark);
  color: #8395a7;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
}

.starter-filter-tab.active,
.starter-filter-tab:hover {
  background: #252d42;
  color: var(--gold);
  border-color: var(--gold);
}

.starter-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px;
  max-height: 250px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.starter-grid::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.starter-card {
  background: #141b2a;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  min-width: 0;
  box-sizing: border-box;
  transition: transform 0.1s, border-color 0.15s;
}

.starter-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.starter-card.is-active-starter {
  border: 1.5px solid var(--gold);
  background: #1b2238;
}

.starter-card.is-locked {
  opacity: 0.75;
  filter: grayscale(0.25);
}

.starter-card-icon {
  width: 28px;
  height: 22px;
  image-rendering: pixelated;
  margin-bottom: 2px;
}

.starter-card-name {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: #fff;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.starter-card-types {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
}

.starter-prog-wrap {
  width: 100%;
  margin-bottom: 4px;
}

.starter-prog-bar {
  width: 100%;
  height: 4px;
  background: #0a0d14;
  border: 1px solid #1f293d;
  border-radius: 2px;
  overflow: hidden;
}

.starter-prog-fill {
  height: 100%;
  background: linear-gradient(to right, #00d2d3, #2ed573);
  transition: width 0.3s ease;
}

.starter-prog-text {
  font-family: var(--font-pixel);
  font-size: 4px;
  color: #8395a7;
  margin-top: 1px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.starter-card-slot-ribbon {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ffd32a;
  color: #000;
  font-family: var(--font-pixel);
  font-size: 3.5px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 2;
}

.starter-card.is-active-starter {
  border: 1.5px solid #ffd32a;
  background: #1b2640;
  box-shadow: 0 0 8px rgba(255, 211, 42, 0.25);
}

.btn-select-starter {
  width: 100%;
  height: 16px;
  font-family: var(--font-pixel);
  font-size: 4px;
  padding: 0 2px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid #2ed573;
  background: #1b4d27;
  color: #afffa4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.btn-select-starter:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #334155;
  background: #161d2d;
  color: #8395a7;
}

.btn-select-starter.active-selected,
.btn-select-starter.is-active-slot {
  background: #3c3208;
  border-color: #ffd32a;
  color: #ffeaa7;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-select-starter.is-active-slot:hover {
  background: #4a151b;
  border-color: #ff4757;
  color: #ff6b81;
}

.btn-select-starter.btn-add-starter {
  background: #153e20;
  border-color: #2ed573;
  color: #a8ffb2;
}

.btn-select-starter.btn-add-starter:hover {
  background: #1f5a2f;
  color: #ffffff;
}

.btn-select-starter.btn-swap-starter {
  background: #16364a;
  border-color: #00d2d3;
  color: #aff5ff;
}

.btn-select-starter.btn-swap-starter:hover {
  background: #1e4b66;
  color: #ffffff;
}

.starter-modal-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border-dark);
  padding-top: 4px;
}

/* =============================================
   MASSIVE PATH OF EXILE ASTRAL SKILL TREE MODAL
   ============================================= */
.skill-tree-fullscreen {
  position: absolute;
  inset: 6px;
  background: #060913;
  border: 2px solid #303a52;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.95);
}

.skill-tree-hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: rgba(12, 17, 30, 0.95);
  border-bottom: 1px solid #28334e;
  z-index: 10;
}

.skill-tree-title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.skill-tree-main-title {
  font-family: var(--font-title);
  font-size: 8.5px;
  color: #00f2fe;
  letter-spacing: 0.5px;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.4);
}

.skill-tree-subtitle {
  font-family: var(--font-pixel);
  font-size: 4.5px;
  color: #8395a7;
}

.skill-tree-stats-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-pixel);
  font-size: 5px;
}

.hud-pill-points {
  background: rgba(0, 242, 254, 0.15);
  border: 1px solid #00f2fe;
  color: #00f2fe;
}

.hud-pill-alloc {
  background: rgba(255, 184, 108, 0.15);
  border: 1px solid #ffb86c;
  color: #ffb86c;
}

.btn-tree-action {
  height: 18px;
  padding: 0 6px;
  font-family: var(--font-pixel);
  font-size: 4.5px;
  border-radius: 2px;
}

.btn-tree-close {
  height: 18px;
  padding: 0 8px;
  font-family: var(--font-pixel);
  font-size: 5px;
  border-radius: 2px;
}

.skill-tree-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #03050a;
}

#skillTreeCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.skill-tree-tooltip {
  position: absolute;
  bottom: 24px;
  left: 10px;
  width: 220px;
  background: rgba(9, 13, 24, 0.94);
  border: 1.5px solid #4facfe;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
  padding: 8px 10px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 20;
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 3px;
}

.tooltip-title {
  font-family: var(--font-title);
  font-size: 7.5px;
  color: #fff;
  letter-spacing: 0.5px;
}

.node-badge-keystone {
  font-family: var(--font-pixel);
  font-size: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: #ff7675;
  color: #fff;
}

.node-badge-notable {
  font-family: var(--font-pixel);
  font-size: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: #fbc531;
  color: #000;
  font-weight: 700;
}

.node-badge-origin {
  font-family: var(--font-pixel);
  font-size: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: #ffb86c;
  color: #000;
}

.node-badge-minor {
  font-family: var(--font-pixel);
  font-size: 4px;
  padding: 1px 4px;
  border-radius: 2px;
  background: #2f3640;
  color: #8395a7;
}

.tooltip-desc {
  font-family: var(--font-pixel);
  font-size: 5px;
  color: #dcdde1;
  line-height: 1.35;
  margin-bottom: 5px;
}

.tooltip-status {
  font-family: var(--font-pixel);
  font-size: 4.5px;
}

.skill-tree-hint {
  position: absolute;
  bottom: 4px;
  right: 10px;
  font-family: var(--font-pixel);
  font-size: 4.5px;
  color: #636e72;
  pointer-events: none;
  display: flex;
  gap: 6px;
}

.skill-tree-matrix-tabs {
  display: flex;
  gap: 3px;
  padding: 3px 8px;
  background: rgba(6, 10, 20, 0.98);
  border-bottom: 1px solid #1a253c;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  z-index: 10;
}

.skill-tree-matrix-tabs::-webkit-scrollbar {
  display: none;
}

.matrix-tab {
  padding: 2.5px 6px;
  font-family: var(--font-pixel);
  font-size: 4.5px;
  background: #0d1424;
  border: 1px solid #243250;
  border-radius: 2px;
  color: #8395a7;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.matrix-tab:hover {
  border-color: #00f2fe;
  color: #fff;
  background: #15223c;
}

.matrix-tab.active {
  background: rgba(0, 242, 254, 0.2);
  border-color: #00f2fe;
  color: #00f2fe;
  font-weight: 700;
  box-shadow: 0 0 6px rgba(0, 242, 254, 0.35);
}