* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #12131a;
  color: #f0f0f0;
  display: flex;
  justify-content: center;
  padding: 10px;
}

.game-container {
  width: 100%;
  max-width: 1020px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==================== โซนผู้เล่นและ AI (Desktop Base) ==================== */
.side-zone {
  background: #1c1e29;
  border: 1px solid #2e3244;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #94a3b8;
}

.hand-counter-pill {
  background: #141724;
  border: 1px solid #334155;
  color: #38bdf8;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* กล่อง Leader, Deck, Graveyard, มิติมืด */
.info-box {
  width: 90px;
  height: 122px;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4px;
  font-size: 11px;
  transition: transform 0.15s, border-color 0.15s;
}

.leader-box {
  width: 135px;
  background: linear-gradient(135deg, #4b1d3f, #2a1024);
  border: 2px solid #e06c9f;
}

.leader-role-tag {
  font-size: 10px;
  color: #fbcfe8;
  opacity: 0.9;
}

.leader-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.leader-name-text {
  font-weight: bold;
  font-size: 12px;
  line-height: 1.2;
}

.hp-badge {
  background: #d92648;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pile-group {
  display: flex;
  gap: 8px;
}

.deck-box {
  background: #232738;
  border: 2px dashed #5b658a;
}

.grave-box {
  background: #1f1b24;
  border: 2px dashed #7a5c8a;
}

.dark-box {
  background: #131129;
  border: 2px dashed #6366f1;
}

.pile-sub-hint {
  font-size: 10px;
  color: #a5b4fc;
}

/* กระดาน 3 ช่อง */
.board-slots {
  display: flex;
  gap: 14px;
}

.slot {
  width: 96px;
  height: 128px;
  background: #151722;
  border: 2px solid #353b52;
  border-radius: 7px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  color: #64748b;
  font-size: 11px;
}

/* ==================== โซนกลางกระดาน (Control & Battle Log) ==================== */
.middle-hud-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.center-bar {
  background: #26293b;
  padding: 8px 16px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #3d435e;
  flex-wrap: wrap;
  gap: 8px;
}

.turn-phase-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.phase-pill {
  background: #0f172a;
  color: #38bdf8;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid #0284c7;
  font-size: 12px;
}

.quota-badges {
  display: flex;
  gap: 6px;
}

.quota-badges span {
  background: #191b26;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid #454d6b;
  white-space: nowrap;
}

.control-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.btn:hover { background: #2563eb; }
.btn:disabled { background: #4b5563; cursor: not-allowed; opacity: 0.7; }

/* Battle Log Container */
.action-log-container {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.action-log-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.log-latest-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.action-log-latest-text {
  flex: 1;
  font-size: 13px;
  font-weight: bold;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-expand-btn {
  font-size: 11px;
  color: #38bdf8;
  background: #1e293b;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #334155;
  flex-shrink: 0;
}

.action-log-scrollbox {
  max-height: 72px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
  border-top: 1px solid #1f2937;
  padding-top: 4px;
}

.log-item {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.35;
}

.log-item.ai-action {
  color: #f472b6;
}

/* ==================== การ์ดบนมือและบนสนาม ==================== */
.hand-dock {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hand-dock-label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-shuffle-btn {
  font: inherit;
  color: #38bdf8;
  background: #141724;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 1px 10px;
  cursor: pointer;
}
.hand-shuffle-btn:hover:not(:disabled) { border-color: #38bdf8; }
.hand-shuffle-btn:focus-visible { outline: 2px solid #38bdf8; outline-offset: 1px; }
.hand-shuffle-btn:disabled { opacity: .4; cursor: default; }

.hand-row {
  min-height: 134px;
  background: #161822;
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.card {
  width: 96px;
  height: 128px;
  border-radius: 7px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
  font-size: 11px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.card:hover {
  transform: translateY(-4px);
}

.card.Monster { background: #2b261f; border: 2px solid #d97706; }
.card.NormalSpell { background: #172a24; border: 2px solid #10b981; }
.card.ReactionSpell { background: #281a2e; border: 2px solid #a855f7; }
.card.LandSpell { background: #1e1633; border: 2px solid #c084fc; }

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

.card-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  z-index: 0;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.card-header, .card-name, .card-power, .card-desc {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

.card-type {
  font-size: 9px;
  background: rgba(0, 0, 0, 0.65);
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

.card-name {
  font-weight: bold;
  font-size: 12px;
  margin: 2px 0;
  background: rgba(0, 0, 0, 0.72);
  padding: 2px 4px;
  border-radius: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-power {
  background: #b45309;
  text-align: center;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 12px;
}

.card-desc {
  font-size: 10px;
  color: #cbd5e1;
  line-height: 1.2;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 4px;
  border-radius: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.leader-art {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #f472b6;
  margin: 4px 0;
  background: #1e1b2e;
}

.card.Rest {
  transform: rotate(90deg) scale(0.88);
  opacity: 0.8;
}

.card.selected-mulligan {
  outline: 3px solid #ef4444;
  transform: translateY(-6px);
  position: relative;
}

.card.selected-mulligan::after {
  content: "เลือกใบนี้";
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  font-weight: bold;
  font-size: 10px;
  padding: 2px;
  border-radius: 4px;
  z-index: 5;
}

.card.selected-hand {
  outline: 3px solid #38bdf8;
  transform: translateY(-8px);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.7);
}

.slot.valid-target {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.16);
  cursor: pointer;
}

.card.selected-attacker {
  outline: 3px solid #f59e0b;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.85);
}

.attack-target {
  outline: 3px dashed #ef4444 !important;
  cursor: crosshair !important;
  animation: pulseTarget 1s infinite alternate;
}

@keyframes pulseTarget {
  from { box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
  to { box-shadow: 0 0 18px rgba(239, 68, 68, 0.9); }
}

/* ==================== หน้าต่าง Modal & Deck Builder ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-box {
  background: #1e2130;
  border: 2px solid #4f587a;
  border-radius: 12px;
  padding: 20px;
  max-width: 750px;
  width: 95%;
  text-align: center;
}

.mulligan-cards, .intercept-options {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.dice-box {
  background: #1e2130;
  border: 2px solid #a855f7;
  border-radius: 16px;
  padding: 24px;
  width: 320px;
  text-align: center;
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.5);
}

.dice-cube {
  width: 84px;
  height: 84px;
  margin: 16px auto;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  color: #1e1b4b;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 44px;
  font-weight: 900;
  border: 3px solid #94a3b8;
}

.deck-builder-box {
  background: #161824;
  border: 2px solid #4f587a;
  border-radius: 14px;
  padding: 18px;
  max-width: 960px;
  width: 96%;
  max-height: 92vh;
  overflow-y: auto;
  text-align: left;
}

.deck-builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2e3244;
  padding-bottom: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.deck-section-title {
  font-size: 14px;
  font-weight: bold;
  color: #38bdf8;
  margin: 10px 0 8px 0;
}

.card-pool-grid,
#main-pool-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
  gap: 10px;
  background: #0d1022;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(160, 175, 255, 0.16);
  justify-items: stretch;
  align-items: start;
}

.pool-item,
#main-pool-list .pool-item {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 7px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(160, 175, 255, 0.08);
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

#main-pool-list .pool-item:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.06);
  transform: translateY(-2px);
}

#main-pool-list .pool-item.is-restricted .card {
  opacity: 0.7;
  filter: saturate(0.75);
}

#main-pool-list .card {
  width: 104px !important;
  height: 142px !important;
  aspect-ratio: 750 / 1050;
  flex-shrink: 0 !important;
  box-sizing: border-box;
}

.count-badge {
  background: #1e293b;
  color: #f8fafc;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #475569;
  text-align: center;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

.count-badge.maxed {
  background: #065f46;
  border-color: #10b981;
  color: #a7f3d0;
}

.card.selected-leader {
  outline: 3px solid #ec4899;
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.75);
}

/* ==================== DECK BUILDER 2-COLUMN SPLIT LAYOUT ==================== */
.deck-builder-box {
  max-width: 1320px !important;
  width: 98vw !important;
  height: 94vh !important;
  max-height: 94vh !important;
  padding: 14px 18px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  background: linear-gradient(180deg, #151a3c, #0b0e24) !important;
  border: 1px solid rgba(160, 175, 255, 0.28) !important;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.78) !important;
}

/* Mobile-only elements (hidden by default on desktop) */
.deck-mobile-nav-tabs,
.mobile-current-leader-bar,
.deck-mobile-bottom-bar,
.deck-mobile-go-collection-btn {
  display: none;
}

.deck-builder-split-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  margin-top: 10px;
}

/* ==================== LEFT COLUMN: DECK SIDE ==================== */
.deck-builder-left-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.deck-left-panel {
  background: #111420;
  border: 1px solid #232c40;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.deck-current-cards-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.deck-left-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.dlp-title {
  font-size: 13.5px;
  font-weight: bold;
  color: #38bdf8;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dlp-btn {
  font-size: 11px !important;
  padding: 3px 10px !important;
  border-radius: 6px;
  cursor: pointer;
  background: #1e293b;
  color: #93c5fd;
  border: 1px solid #3b82f6;
  font-family: 'Kanit', sans-serif;
  transition: all 0.15s;
}

.dlp-btn:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Active Leader Preview Card */
.active-leader-preview-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(37,99,235,0.18) 0%, rgba(15,23,42,0.8) 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.active-leader-preview-box:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}

.alp-thumb {
  width: 52px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.3);
  box-shadow: 0 3px 8px rgba(0,0,0,0.6);
  flex-shrink: 0;
}

.alp-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.alp-name {
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alp-hp {
  display: inline-flex;
  align-items: center;
  background: #be185d;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 1px 7px;
  border-radius: 10px;
  width: fit-content;
}

.alp-tribe {
  font-size: 11px;
  color: #94a3b8;
}

/* Leader Picker Dropdown */
.leader-picker-dropdown {
  margin-top: 10px;
  background: #090c14;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px;
  max-height: 250px;
  overflow-y: auto;
}

.leader-picker-dropdown .card-pool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
}

.leader-picker-dropdown .card {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 750 / 1050;
}

.leader-picker-dropdown .card .card-name {
  font-size: 8px !important;
}

/* Deck Cards List Container (Left Side) */
.deck-tray-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: #f8fafc;
  flex-wrap: wrap;
}

.deck-tray-count-badge {
  background: #065f46;
  color: #6ee7b7;
  font-size: 11.5px;
  font-weight: bold;
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid #10b981;
}

.deck-tray-count-badge.is-incomplete {
  background: #78350f;
  color: #fcd34d;
  border-color: #f59e0b;
}

.deck-tray-type-breakdown {
  font-size: 11.5px;
  color: #94a3b8;
}

.deck-card-list-hint {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
  font-style: italic;
}

.deck-current-list-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 #0f121d;
}

.deck-current-list-items::-webkit-scrollbar {
  width: 5px;
}
.deck-current-list-items::-webkit-scrollbar-thumb {
  background: #38bdf8;
  border-radius: 3px;
}

.deck-tray-empty-hint {
  width: 100%;
  text-align: center;
  color: #64748b;
  font-size: 12.5px;
  padding: 24px 0;
  font-style: italic;
}

/* Individual Deck Row Card Item (Left Column) */
.deck-list-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #172033;
  border: 1px solid #2d3b55;
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.deck-list-row-item:hover {
  background: #1f2c47;
  border-color: #ef4444;
  transform: translateX(2px);
}

.dlr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.dlr-thumb {
  width: 32px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.dlr-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dlr-name {
  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dlr-type-power {
  font-size: 10px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dlr-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dlr-count-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
}

.dlr-count-badge.maxed {
  background: #10b981;
}

.dlr-remove-icon {
  color: #ef4444;
  font-size: 12px;
  font-weight: bold;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.deck-list-row-item:hover .dlr-remove-icon {
  opacity: 1;
}

/* ==================== RIGHT COLUMN: COLLECTION SIDE ==================== */
.deck-builder-right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.card-pool-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-radius: 12px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 #0f121d;
}

.card-pool-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.card-pool-scroll-area::-webkit-scrollbar-thumb {
  background: #38bdf8;
  border-radius: 3px;
}

/* Filter Panel */
.deck-filter-panel {
  background: #0c0f18;
  border: 1px solid #1e2638;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
}

.deck-filter-themes-row,
.deck-filter-dropdown {
  position: relative;
  z-index: 25;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.deck-filter-panel .fx-select-btn {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12.5px;
  gap: 6px;
}
.deck-filter-panel .fx-select-label {
  font-size: 12px;
}
.deck-filter-themes-row .fx-select-menu {
  width: min(520px, 88vw);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.deck-filter-dropdown .fx-select-menu-sm {
  width: max(180px, 100%);
  grid-template-columns: 1fr;
}
.deck-slot-fx-select {
  position: relative;
  z-index: 40;
  min-width: 0;
}
.deck-slot-fx-select .fx-select-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  max-width: min(360px, 72vw);
}
.deck-slot-fx-select .fx-select-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-slot-fx-select .fx-select-menu-sm {
  width: max(320px, 100%);
  grid-template-columns: 1fr;
}
.deck-slot-fx-select .fx-select-opt {
  padding: 7px 11px;
  font-size: 13px;
  justify-content: flex-start;
  white-space: nowrap;
}
.deck-slot-fx-select .fx-select-opt::before {
  display: none;
}
.deck-slot-fx-select .fx-select-opt.active {
  background: var(--chip-c, #38bdf8);
  border-color: var(--chip-c, #38bdf8);
  color: #0b1120;
  font-weight: 700;
}
.deck-filter-panel .fx-select-opt {
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  justify-content: flex-start;
  width: 100%;
}
.deck-filter-panel .fx-select-opt.active {
  background: var(--chip-c, #38bdf8);
  border-color: var(--chip-c, #38bdf8);
  color: #0b1120;
  font-weight: 700;
}
.deck-filter-panel .fx-select-opt::before {
  display: none;
}

.deck-filter-themes-row::-webkit-scrollbar {
  height: 4px;
}
.deck-filter-themes-row::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

.deck-theme-btn {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 18px;
  border: 1px solid #29354d;
  background: #172033;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.deck-theme-btn:hover {
  background: #1e293b;
  color: #f1f5f9;
  border-color: #475569;
}

.deck-theme-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.45);
  font-weight: bold;
}

.deck-theme-btn.dtb-leader {
  border-color: #eab308;
  color: #fde047;
  background: rgba(234, 179, 8, 0.12);
}

.deck-theme-btn.dtb-leader:hover {
  background: rgba(234, 179, 8, 0.22);
}

.deck-theme-btn.dtb-leader.active {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  border-color: #fcd34d;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.deck-filter-sub-row {
  display: flex;
  flex: 1 1 520px;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #131926;
  padding: 3px 5px;
  border-radius: 16px;
  border: 1px solid #1e293b;
}

.filter-group-label {
  font-size: 11px;
  color: #64748b;
  padding-left: 5px;
}

.deck-sub-pill {
  padding: 2.5px 9px;
  font-size: 11px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Kanit', sans-serif;
  white-space: nowrap;
}

.deck-sub-pill:hover {
  color: #f8fafc;
  background: #1e293b;
}

.deck-sub-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  font-weight: bold;
}

.deck-search-wrap {
  position: relative;
  flex: 1;
  min-width: 140px;
}

.deck-search-input {
  width: 100%;
  background: #111726;
  border: 1px solid #2e3b52;
  border-radius: 16px;
  padding: 4px 28px 4px 10px;
  color: #f8fafc;
  font-size: 12px;
  font-family: 'Kanit', sans-serif;
  outline: none;
  transition: all 0.15s;
}

.deck-search-input:focus {
  border-color: #38bdf8;
  background: #151d30;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.deck-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 11.5px;
  padding: 0 4px;
}

.deck-search-clear:hover {
  color: #f8fafc;
}

.deck-filter-stats {
  font-size: 11.5px;
  color: #94a3b8;
  background: #1e293b;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid #334155;
  white-space: nowrap;
}

.deck-filter-stats b {
  color: #38bdf8;
}

/* Card Pool Visual Enhancements */
.card-pool-empty-state {
  width: 100%;
  padding: 36px 12px;
  text-align: center;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.card-pool-empty-state p {
  margin: 0;
  font-size: 13.5px;
}

.card-pool-empty-state .btn {
  font-size: 12px;
  padding: 5px 14px;
}

.leader-selected-tag {
  background: linear-gradient(135deg, #ec4899, #be185d);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: bold;
  padding: 1px 6px;
  border-radius: 8px;
  margin-top: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.pool-item.is-restricted {
  opacity: 0.5;
  filter: grayscale(45%);
}

.pool-item.is-restricted .card {
  cursor: not-allowed;
}

.restricted-badge {
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #ef4444;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ==================== Card Tooltip (PC) ==================== */
.card-tooltip {
  position: fixed;
  z-index: 9999;
  width: 270px;
  background: rgba(17, 19, 28, 0.96);
  border: 2px solid #38bdf8;
  border-radius: 10px;
  padding: 12px 14px;
  color: #f8fafc;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  display: none;
  backdrop-filter: blur(4px);
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.tooltip-name { font-weight: bold; font-size: 15px; color: #fbbf24; }
.tooltip-type { font-size: 11px; background: #1e293b; padding: 2px 8px; border-radius: 10px; color: #94a3b8; border: 1px solid #475569; }
.tooltip-stats { font-size: 13px; font-weight: bold; color: #4ade80; margin-bottom: 8px; }
.tooltip-desc { font-size: 13px; color: #e2e8f0; line-height: 1.5; white-space: pre-line; }

/* ============================================================================
   📱 MOBILE-FIRST RESPONSIVE UI (360px – 768px)
   จัดหน้าเล่นเกมการ์ดให้อยู่ในหน้าจอเดียว (100dvh) แบ่งเป็น 3 โซนชัดเจน ไม่ต้องไถหน้าเว็บ
   ============================================================================ */
@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    background: #0d0f17;
  }

  /* --- กระดานเล่นเกมหลัก: พอดีความสูงหน้าจอมือถือ 100dvh ไม่ต้องเลื่อนหน้าเว็บ --- */
  .game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) 6px;
    gap: 4px;
    justify-content: space-between;
    overflow: hidden;
  }

  .side-zone {
    padding: 5px 6px;
    gap: 4px;
    border-radius: 8px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;
  }

  .side-header-bar {
    font-size: 11px;
    padding: 0 2px;
    line-height: 1.1;
  }

  .hand-counter-pill {
    font-size: 11px;
    padding: 1px 8px;
  }

  /* จัดเรียง .field-row ให้มี Compact Status Bar อยู่แถวหนึ่ง และช่องการ์ด 3 ช่องอยู่อีกแถวหนึ่ง */
  .field-row {
    flex-wrap: wrap;
    gap: 4px;
    align-items: stretch;
  }

  /* สลับให้ของ Player เอาช่องสนามไว้ด้านบน และแถบข้อมูล Leader/Deck ไว้ด้านล่างใกล้การ์ดบนมือ */
  .player-side-zone .field-row .board-slots { order: 1; }
  .player-side-zone .field-row .leader-box  { order: 2; }
  .player-side-zone .field-row .pile-group  { order: 3; }

  .ai-side-zone .field-row .leader-box  { order: 1; }
  .ai-side-zone .field-row .pile-group  { order: 2; }
  .ai-side-zone .field-row .board-slots { order: 3; }

  /* 1. ย่อส่วน Leader + HP เป็น Compact Pill ด้านซ้าย (กว้าง 47%) */
  .leader-box {
    width: 47% !important;
    height: 42px !important;
    min-height: 42px !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 6px;
    padding: 3px 6px !important;
    text-align: left !important;
    border-radius: 6px;
  }

  .leader-role-tag {
    display: none; /* ซ่อนป้ายข้อความซ้ำซ้อนบนมือถือเพื่อประหยัดที่ */
  }

  .leader-art {
    width: 32px !important;
    height: 32px !important;
    margin: 0 !important;
    border-width: 1.5px;
    flex-shrink: 0;
  }

  .leader-meta {
    flex: 1;
    min-width: 0;
    align-items: flex-start;
    gap: 1px;
  }

  .leader-name-text {
    font-size: 10.5px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    color: #f8fafc;
  }

  .hp-badge {
    margin-top: 0 !important;
    padding: 1px 7px !important;
    font-size: 11px !important;
    border-radius: 10px;
  }

  /* 2. ย่อส่วน Deck, Graveyard, มิติมืด เป็น Compact Pills ด้านขวา (กว้าง 51%) ไม่บีบหรือทับซ้อนกัน */
  .pile-group {
    width: 51% !important;
    display: flex;
    gap: 3px;
    align-items: stretch;
  }

  .pile-group .info-box {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
    height: 42px !important;
    padding: 2px 3px !important;
    border-radius: 6px;
    border-width: 1.5px !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .pile-group .info-box .pile-label,
  .pile-group .info-box > div:first-child {
    font-size: 9.5px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.1;
    color: #cbd5e1;
  }

  .pile-group .info-box h2 {
    font-size: 13px !important;
    font-weight: 800;
    margin: 0 !important;
    line-height: 1.15;
    color: #ffffff;
  }

  .pile-sub-hint {
    display: none !important;
  }

  /* 3. จัดช่องการ์ดบนสนาม 3 ช่องให้สมดุลกับความสูงหน้าจอมือถือ */
  .board-slots {
    width: 100%;
    justify-content: center;
    gap: 6px;
  }

  .slot {
    flex: 1;
    max-width: 98px;
    height: clamp(102px, 16.5dvh, 132px);
    font-size: 11px;
    border-radius: 6px;
  }

  /* ปรับการ์ดบนสนามให้เต็มช่องพอดี */
  .slot .card {
    width: 100% !important;
    height: 100% !important;
    padding: 3px !important;
  }

  .slot .card.Rest {
    transform: rotate(90deg) scale(0.78) !important;
  }

  /* 4. ย่อส่วนกลาง Turn, Phase, Spell Quota และปุ่มกดให้กระชับและกดง่าย */
  .middle-hud-zone {
    gap: 3px;
    flex-shrink: 0;
    z-index: 40;
  }

  .center-bar {
    padding: 4px 6px;
    gap: 4px;
    border-radius: 6px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .turn-phase-group {
    font-size: 11.5px;
    gap: 5px;
  }

  .phase-pill {
    font-size: 10.5px;
    padding: 1px 7px;
  }

  .quota-badges {
    gap: 4px;
    width: auto;
  }

  .quota-badges span {
    font-size: 10px;
    padding: 2px 6px;
    margin: 0;
  }

  .control-btn-group {
    width: 100%;
    display: flex;
    gap: 6px;
  }

  .control-btn-group .btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 5px;
    margin-right: 0 !important;
  }

  #btn-surrender-match {
    flex: 0 0 auto !important;
    padding: 6px 10px !important;
  }

  /* 5. ปรับ Battle Log เป็นแถบ 1 บรรทัด กดเพื่อขยายดูประวัติแบบลอย (Floating Drawer) โดยไม่ดันหน้าจอ */
  .action-log-container {
    padding: 4px 8px;
    border-radius: 6px;
    gap: 0;
  }

  .action-log-latest-text {
    font-size: 11.5px;
  }

  .log-expand-btn {
    font-size: 10px;
    padding: 1px 6px;
  }

  .action-log-scrollbox {
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้นบนมือถือ แสดงเฉพาะบรรทัดล่าสุด */
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 4px);
    background: rgba(15, 23, 42, 0.98);
    border: 2px solid #38bdf8;
    border-radius: 8px;
    padding: 8px 10px;
    max-height: 180px;
    z-index: 120;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.85);
  }

  .action-log-container.expanded .action-log-scrollbox {
    display: flex;
  }

  .log-item {
    font-size: 11.5px;
    padding: 2px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  }

  /* 6. พื้นที่การ์ดในมือผู้เล่นด้านล่าง (เลื่อนดูแนวนอนลื่นไหล) */
  .hand-dock {
    gap: 2px;
    flex-shrink: 0;
  }

  .hand-dock-label {
    font-size: 10.5px;
    padding-left: 2px;
    line-height: 1.1;
  }

  .hand-row {
    min-height: clamp(106px, 16.5dvh, 130px);
    height: clamp(106px, 16.5dvh, 130px);
    padding: 4px 6px;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    border-radius: 6px;
  }

  .hand-row .card {
    flex: 0 0 auto;
    width: clamp(74px, 21vw, 88px) !important;
    height: clamp(98px, 15dvh, 120px) !important;
    padding: 3px !important;
  }

  .card-name {
    font-size: 10px !important;
    padding: 1px 3px !important;
  }

  .card-power {
    font-size: 10.5px !important;
    padding: 1px 2px !important;
  }

  .card-type {
    font-size: 7.5px !important;
  }

  .card-desc {
    display: none;
  }

  /* ปรับขนาดการ์ดในหน้าต่าง Modal (Mulligan / Intercept / Deck Builder) */
  .modal-box .card,
  .deck-builder-box .card {
    width: 92px !important;
    height: 130px !important;
  }

  .modal-box, .deck-builder-box {
    width: 95% !important;
    padding: 12px !important;
    max-height: 88dvh;
    overflow-y: auto;
  }

  .deck-builder-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .deck-builder-header > div:last-child {
    justify-content: center;
    flex-wrap: wrap;
  }

  .card-pool-grid {
    justify-content: center;
    gap: 8px;
    padding: 8px;
  }

  .card-tooltip {
    display: none !important;
  }
}

/* ปรับแต่งรายละเอียดเพิ่มเติมบนจอมือถือ (โมดัล, ทัชทาร์เก็ต, การ์ดรายละเอียด) */
@media (max-width: 768px) {
  input[type="text"], input[type="password"] {
    font-size: 16px !important; /* ป้องกัน iOS ซูมหน้าจอเมื่อแตะช่องกรอก */
  }

  .btn, button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  #dice-modal .dice-box {
    width: min(340px, 92vw);
    padding: 16px;
  }

  #card-detail-view-modal .modal-box {
    width: 95% !important;
    max-height: 88dvh;
    padding: 14px !important;
    gap: 10px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #card-detail-view-modal #detail-card-img {
    width: clamp(120px, 36vw, 160px) !important;
    height: auto !important;
    aspect-ratio: 750 / 1050;
  }

  #card-detail-view-modal #detail-card-name {
    font-size: 16px !important;
  }

  #fx-card-cutin-banner {
    max-width: 92vw !important;
    min-width: 0 !important;
    padding: 10px 14px !important;
    gap: 10px !important;
  }

  #fx-card-cutin-banner img {
    width: 56px !important;
    height: 78px !important;
  }

  .cutin-info-actor {
    font-size: 10.5px !important;
  }

  .cutin-info-title {
    font-size: 15px !important;
  }

  .cutin-info-sub {
    font-size: 11px !important;
  }

  #pvp-room-modal .modal-box {
    width: 95% !important;
    padding: 14px !important;
  }

  #mulligan-modal .modal-box,
  #intercept-modal .modal-box {
    width: 95% !important;
    padding: 14px !important;
  }

  .mulligan-cards, .intercept-options {
    gap: 8px !important;
  }
}

/* รองรับหน้าจอมือถือขนาดเล็กความสูงน้อย (เช่น iPhone SE / จอความสูง < 680px) */
@media (max-width: 768px) and (max-height: 680px) {
  .leader-box, .pile-group .info-box {
    height: 36px !important;
    min-height: 36px !important;
  }
  .leader-art {
    width: 26px !important;
    height: 26px !important;
  }
  .slot {
    height: clamp(88px, 15dvh, 108px);
  }
  .hand-row {
    min-height: 96px;
    height: 96px;
  }
  .hand-row .card {
    width: 70px !important;
    height: 90px !important;
  }
}

/* ==================== แถบเตือนข้อมูลการ์ด ==================== */
#card-warning {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 10000; /* สูงกว่า z-index สูงสุดเดิม (9999 ของ tooltip) */
  background: #facc15; color: #1f1300;
  font: 14px/1.4 sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
#card-warning .card-warning-head {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px; box-sizing: border-box;
}
#card-warning .card-warning-head strong {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#card-warning button {
  flex: none; cursor: pointer; padding: 4px 10px;
  background: #1f1300; color: #facc15; border: 0; border-radius: 4px; font: inherit;
}
#card-warning ul {
  margin: 0; padding: 4px 12px 8px 30px;
  max-height: 40vh; overflow-y: auto; font-size: 12px;
}
#card-warning ul[hidden] { display: none; }
#card-warning li { margin: 2px 0; word-break: break-word; }


/* ==================== 3D DECK BOX & BADGES (สไตล์ Cardfight Vanguard / BOF) ==================== */
.deck-box {
  position: relative;
  background-color: #12141f;
  background-image: url('../images/card-back.png');
  background-size: cover;
  background-position: center;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 7px;
  box-shadow: 
    1px 1px 0 #334155, 
    2px 2px 0 #1e293b, 
    3px 3px 0 #334155, 
    4px 4px 0 #0f172a, 
    0 6px 14px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 4px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.deck-box:hover {
  transform: translateY(-2px);
  box-shadow: 
    1px 1px 0 #38bdf8, 
    2px 2px 0 #0284c7, 
    3px 3px 0 #38bdf8, 
    4px 4px 0 #0f172a, 
    0 8px 18px rgba(56, 189, 248, 0.35);
}

.deck-box .pile-label {
  display: none !important;
}

.deck-count-badge {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #f8fafc;
  font-family: 'Kanit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  z-index: 5;
  margin-bottom: 2px;
  pointer-events: none;
  line-height: 1.3;
}

.deck-count-badge.grave-badge {
  border-color: rgba(168, 85, 247, 0.8);
  color: #e9d5ff;
}

.deck-count-badge.dark-badge {
  border-color: rgba(99, 102, 241, 0.85);
  color: #c7d2fe;
}

.grave-box {
  position: relative;
  background: rgba(26, 20, 32, 0.85);
  border: 1.5px dashed rgba(168, 85, 247, 0.6);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s, border-color 0.15s;
}
.grave-box:hover {
  border-color: #c084fc;
  transform: translateY(-2px);
}

.dark-box {
  position: relative;
  background: rgba(19, 17, 41, 0.85);
  border: 1.5px dashed rgba(99, 102, 241, 0.7);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s, border-color 0.15s;
}
.dark-box:hover {
  border-color: #818cf8;
  transform: translateY(-2px);
}

/* ==================== DECK SHUFFLE ANIMATION (เหมือนในคลิป) ==================== */
.deck-shuffle-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
}

.deck-packet {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  background-image: url('../images/card-back.png');
  background-size: cover;
  background-position: center;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.deck-packet.packet-left {
  animation: shuffle-split-left 1.25s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.deck-packet.packet-right {
  animation: shuffle-split-right 1.25s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes shuffle-split-left {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  30% { transform: translate(-32px, -4px) rotate(-10deg); }
  55% { transform: translate(-22px, 2px) rotate(-6deg); }
  75% { transform: translate(-10px, -2px) rotate(-2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes shuffle-split-right {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  30% { transform: translate(32px, 4px) rotate(10deg); }
  55% { transform: translate(22px, -2px) rotate(6deg); }
  75% { transform: translate(10px, 2px) rotate(2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* ==================== COIN TOSS SYSTEM MODAL ==================== */
.coin-toss-box {
  background: radial-gradient(circle at center, #1e2238 0%, #0f111a 100%);
  border: 2px solid #475569;
  border-radius: 18px;
  padding: 22px 26px;
  text-align: center;
  max-width: 440px;
  width: 92%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(250, 204, 21, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.coin-toss-header {
  color: #fde047;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.coin-scene {
  width: 105px;
  height: 105px;
  perspective: 900px;
  margin: 10px 0;
}

.bof-coin {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.3s cubic-bezier(0.2, 0.85, 0.25, 1);
  border-radius: 50%;
}

.coin-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.5);
}

.coin-heads {
  background: radial-gradient(circle at 35% 35%, #fff 0%, #fde047 30%, #ca8a04 75%, #854d0e 100%);
  border: 4px solid #fef08a;
  transform: rotateY(0deg);
}

.coin-tails {
  background: radial-gradient(circle at 35% 35%, #fff 0%, #fbbf24 30%, #d97706 75%, #92400e 100%);
  border: 4px solid #fed7aa;
  transform: rotateY(180deg);
}

.coin-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.coin-symbol {
  font-size: 36px;
  font-weight: 900;
  color: #451a03;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

.coin-sub {
  font-size: 13px;
  font-weight: 700;
  color: #78350f;
  margin-top: 2px;
}

.bof-coin.flipping-heads {
  animation: coin-toss-flip-heads 1.35s cubic-bezier(0.25, 1, 0.35, 1) forwards;
}

.bof-coin.flipping-tails {
  animation: coin-toss-flip-tails 1.35s cubic-bezier(0.25, 1, 0.35, 1) forwards;
}

@keyframes coin-toss-flip-heads {
  0% { transform: translateY(0) rotateY(0deg) scale(1); }
  45% { transform: translateY(-70px) rotateY(1080deg) scale(1.2); }
  100% { transform: translateY(0) rotateY(2160deg) scale(1); }
}

@keyframes coin-toss-flip-tails {
  0% { transform: translateY(0) rotateY(0deg) scale(1); }
  45% { transform: translateY(-70px) rotateY(1080deg) scale(1.2); }
  100% { transform: translateY(0) rotateY(2340deg) scale(1); }
}

.coin-result-banner {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 8px 16px;
  width: 100%;
}

.coin-result-banner h2 {
  color: #38bdf8;
  font-size: 18px;
  margin: 0 0 3px 0;
}

.coin-result-banner p {
  color: #fde047;
  font-size: 12.5px;
  margin: 0;
  font-weight: 600;
}

.coin-instruction {
  font-size: 12.5px;
  color: #cbd5e1;
  margin: 0;
}

.btn-coin-start {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  font-size: 14.5px;
  padding: 9px 22px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-coin-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.65);
}

/* ==================== SYMMETRICAL BOARD & MULLIGAN ENHANCEMENTS ==================== */
#ai-board {
  align-items: flex-end;
}

#player-board {
  align-items: flex-start;
}

.mulligan-card {
  width: 128px !important;
  height: 174px !important;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mulligan-card .card-header,
.mulligan-card .card-desc {
  display: none !important;
}

.mulligan-card.selected-mulligan {
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.75) !important;
  transform: translateY(-4px);
}

.deck-box {
  cursor: default !important;
}

.deck-box:hover {
  transform: none !important;
  box-shadow: 
    1px 1px 0 #334155, 
    2px 2px 0 #1e293b, 
    3px 3px 0 #334155, 
    4px 4px 0 #0f172a, 
    0 6px 14px rgba(0, 0, 0, 0.7) !important;
}


/* ==================== ARENA MAT LAYOUT (ผังสนามสมมาตรตามภาพ) ==================== */
.game-container {
  width: 100%;
  max-width: 1020px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 16px;
  background-color: #0c0e18;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  transition: background-image 0.3s ease;
  position: relative;
}

.mat-half {
  background: rgba(20, 24, 38, 0.76);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 14px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 13px;
  color: #94a3b8;
}

.hand-counter-pill {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: #f8fafc;
}

.mat-grid-row {
  display: grid;
  grid-template-columns: 100px 1fr 100px;
  gap: 14px;
  align-items: center;
  width: 100%;
}

.mat-side-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.mat-center-field {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.center-leader-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* ลีดเดอร์เป็นการ์ดเต็มใบ พร้อมหลอดเลือด ❤️ อยู่มุมซ้ายบน */
.leader-card-slot {
  position: relative;
  width: 96px;
  height: 128px;
  border-radius: 7px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.leader-card-slot .card {
  width: 100%;
  height: 100%;
  margin: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.leader-card-slot.attack-target {
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.95);
  animation: pulse-border 1.2s infinite;
}

.leader-hp-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 25;
  background: #dc2626;
  border: 1.5px solid #fff;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 10px rgba(239, 68, 68, 0.7);
  pointer-events: none;
  line-height: 1.2;
}

/* เส้นประแบ่งครึ่งสนามและแถบควบคุม */
.mat-divider-zone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  margin: 2px 0;
}

.mat-divider-line {
  border-top: 2px dashed rgba(148, 163, 184, 0.5);
  width: 100%;
}

@media (max-width: 768px) {
  .game-container {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: calc(4px + env(safe-area-inset-top, 0px)) 5px calc(4px + env(safe-area-inset-bottom, 0px)) 5px;
    gap: 3px;
    border-radius: 0;
    justify-content: space-between;
    overflow: hidden;
  }

  .mat-half {
    padding: 5px 6px;
    gap: 3px;
    border-radius: 10px;
    flex: 1 1 auto;
    min-height: 0;
    justify-content: space-between;
  }

  .side-header-bar {
    font-size: 11px;
    padding: 0 2px;
    line-height: 1.1;
  }

  .hand-counter-pill {
    font-size: 10.5px;
    padding: 1px 8px;
  }

  .mat-grid-row {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    gap: 4px;
    align-items: center;
    flex: 1 1 auto;
    min-height: 0;
  }

  .mat-side-col {
    gap: 4px;
    width: 100%;
  }

  .mat-side-col .info-box {
    width: 52px !important;
    height: clamp(66px, 9.4dvh, 80px) !important;
    min-height: 0 !important;
    padding: 3px 2px !important;
    border-radius: 6px !important;
    gap: 2px;
  }

  .mat-side-col .pile-label {
    font-size: 8.5px !important;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
  }

  .deck-count-badge {
    font-size: 8.5px !important;
    padding: 1px 4px !important;
    letter-spacing: 0;
    margin-bottom: 1px;
  }

  .board-slots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 100%;
  }

  #ai-board {
    align-items: flex-end;
  }

  #player-board {
    align-items: flex-start;
  }

  .center-leader-stack {
    gap: 4px;
    flex: 0 0 auto;
  }

  .board-slots .slot,
  .center-leader-stack .slot,
  .leader-card-slot {
    flex: 0 0 auto !important;
    width: clamp(56px, 16.5vw, 66px) !important;
    max-width: clamp(56px, 16.5vw, 66px) !important;
    height: clamp(72px, 10dvh, 84px) !important;
    min-height: clamp(72px, 10dvh, 84px) !important;
    font-size: 9.5px !important;
    border-radius: 6px !important;
  }

  .leader-hp-badge {
    top: 2px;
    left: 2px;
    padding: 1px 5px;
    font-size: 9.5px;
    border-width: 1px;
  }

  .slot .card .card-header,
  .leader-card-slot .card .card-header,
  .hand-row .card .card-header {
    display: none !important;
  }

  .slot .card .card-name,
  .leader-card-slot .card .card-name {
    font-size: 8px !important;
    padding: 1px 2px !important;
    line-height: 1.1;
  }

  .slot .card .card-power,
  .leader-card-slot .card .card-power {
    font-size: 9px !important;
    padding: 1px 2px !important;
    line-height: 1.1;
  }

  .mat-divider-zone {
    gap: 2px;
    margin: 0;
    flex-shrink: 0;
  }

  .mat-divider-line {
    display: none;
  }

  .center-bar {
    padding: 4px 6px !important;
    gap: 4px !important;
    border-radius: 8px !important;
  }

  .control-btn-group {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
  }

  #btn-toggle-sound {
    flex: 0 0 32px !important;
    width: 32px !important;
    height: 30px !important;
    padding: 0 !important;
    font-size: 13px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #btn-open-combat-log {
    flex: 0 0 auto !important;
    height: 30px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    white-space: nowrap;
  }

  #btn-pass-turn-inline {
    flex: 1 1 auto !important;
    height: 30px !important;
    padding: 0 8px !important;
    font-size: 11.5px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #btn-surrender-match {
    flex: 0 0 auto !important;
    height: 30px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    white-space: nowrap;
  }

  .hand-dock {
    gap: 2px;
    margin-top: 1px;
    flex-shrink: 0;
  }

  .hand-dock-label {
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
  }

  .hand-row {
    min-height: clamp(82px, 11.6dvh, 96px) !important;
    height: clamp(82px, 11.6dvh, 96px) !important;
    padding: 3px 4px !important;
    gap: 5px !important;
  }

  .hand-row .card {
    width: clamp(58px, 16.5vw, 68px) !important;
    height: clamp(76px, 10.8dvh, 90px) !important;
    padding: 2px !important;
  }

  .mulligan-card {
    width: 96px !important;
    height: 132px !important;
  }
}

@media (max-width: 768px) and (max-height: 680px) {
  .mat-side-col .info-box,
  .board-slots .slot,
  .center-leader-stack .slot,
  .leader-card-slot {
    height: clamp(60px, 9.2dvh, 70px) !important;
    min-height: clamp(60px, 9.2dvh, 70px) !important;
  }
  .hand-row {
    min-height: 74px !important;
    height: 74px !important;
  }
  .hand-row .card {
    width: 54px !important;
    height: 68px !important;
  }
}


/* ================= Safari & Samsung Browser Fallback for dvh ================= */
@supports not (height: 100dvh) {
  @media (max-width: 767px) {
    #bof-game-arena {
      height: 100vh !important;
      max-height: 100vh !important;
    }
    .board-row-grid .slot,
    .board-row-grid .leader-slot {
      min-height: clamp(82px, 11.6vh, 96px) !important;
      height: clamp(82px, 11.6vh, 96px) !important;
    }
    .hand-card,
    .hand-zone .card.hand-card {
      height: clamp(72px, 10vh, 84px) !important;
      min-height: clamp(72px, 10vh, 84px) !important;
    }
  }
}

/* ============================================================================
   1. AI BATTLE SETUP MODAL (เลือกระดับความยาก & เลือกเด็คให้ AI)
   ============================================================================ */
.ai-setup-box {
  max-width: 940px !important;
  width: 95% !important;
  max-height: 90dvh;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  text-align: left !important;
  padding: 20px 22px !important;
  background: linear-gradient(180deg, #13182b 0%, #0b0e1a 100%) !important;
  border: 1.5px solid rgba(160, 175, 255, 0.28) !important;
  border-radius: 18px !important;
}

.ai-setup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 14px;
}

.ai-setup-header h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  color: #38bdf8;
}

.ai-setup-header p {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
}

.ai-setup-section {
  margin-bottom: 16px;
}

.ai-setup-sec-title {
  font-size: 14px;
  font-weight: 700;
  color: #fde047;
  margin-bottom: 8px;
}

.ai-diff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ai-diff-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  gap: 6px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #161c30;
  border: 1.5px solid #2e3a59;
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ai-diff-card:hover {
  transform: translateY(-2px);
  border-color: #64748b;
}

.ai-diff-card.is-selected {
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.55) 0%, rgba(15, 23, 42, 0.95) 100%);
  border-color: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.5), 0 8px 20px rgba(0, 0, 0, 0.45);
}

.ai-diff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.ai-diff-badge {
  font-size: 13.5px;
  font-weight: 700;
}
.ai-diff-badge.is-easy { color: #4ade80; }
.ai-diff-badge.is-normal { color: #facc15; }
.ai-diff-badge.is-hard { color: #f87171; }

.ai-diff-reward {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #fde047;
  white-space: nowrap;
}

.ai-diff-desc {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.38;
}

.ai-deck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 44vh;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 2px 4px 4px 0;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 #0f121d;
}

.ai-deck-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ai-deck-accent, #38bdf8) 10%, #161c30), #0e1324);
  border: 1.5px solid rgba(160, 175, 255, 0.18);
  color: #f8fafc;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ai-deck-card.is-random-card {
  grid-column: 1 / -1;
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.9), rgba(49, 46, 129, 0.65));
}

@media (max-width: 820px) {
  .ai-deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ai-deck-grid { grid-template-columns: 1fr; }
}

.ai-deck-card:hover {
  transform: translateY(-2px);
  border-color: var(--ai-deck-accent, #38bdf8);
}

.ai-deck-card.is-selected {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.32), rgba(15, 23, 42, 0.95));
  border-color: var(--ai-deck-accent, #38bdf8);
  box-shadow: 0 0 0 1px var(--ai-deck-accent, #38bdf8), 0 8px 18px rgba(0, 0, 0, 0.45);
}

.ai-deck-random-ico {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.ai-deck-thumb {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: 7px;
  border: 1.5px solid var(--ai-deck-accent, #64748b);
  flex-shrink: 0;
}

.ai-deck-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ai-deck-meta strong {
  font-size: 13.5px;
  color: #f8fafc;
}

.ai-deck-meta small {
  font-size: 11px;
  color: #fde047;
  font-weight: 600;
}

.ai-deck-meta span {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.3;
}

.ai-setup-footer {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.ai-start-btn {
  flex: 2;
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: #052e16 !important;
  font-weight: 800 !important;
  font-size: 15px !important;
  padding: 12px !important;
  border-radius: 10px !important;
}

.ai-cancel-btn {
  flex: 1;
  background: #334155 !important;
  padding: 12px !important;
  border-radius: 10px !important;
}

.ai-header-diff-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #475569;
}
.ai-header-diff-pill.is-easy { border-color: #4ade80; color: #86efac; }
.ai-header-diff-pill.is-normal { border-color: #facc15; color: #fde047; }
.ai-header-diff-pill.is-hard { border-color: #f87171; color: #fca5a5; }


/* ============================================================================
   2. MULTIPLE DECK SLOTS (5 สล็อต) & SHARE DECK CODE TOOLBAR
   ============================================================================ */
.deck-slots-toolbar {
  position: relative;
  z-index: 50;
  background: #0c0f18;
  border: 1px solid #1e2638;
  border-radius: 12px;
  padding: 8px 12px;
  margin: 8px 0 2px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deck-slots-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.deck-slot-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: #0d111f;
  border: 1.5px solid #26314f;
  color: #cbd5e1;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  min-width: 0;
}

.deck-slot-tab:hover {
  border-color: #475569;
  background: #171f36;
}

.deck-slot-tab.is-active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(15, 23, 42, 0.95));
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.28);
  color: #fff;
}

.deck-slot-tab img {
  width: 30px;
  height: 40px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.deck-slot-tab-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.deck-slot-tab-meta strong {
  font-size: 12px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-slot-tab-meta span {
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-code-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.deck-name-edit-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(160, 175, 255, 0.2);
  border-radius: 999px;
  padding: 0 12px;
  transition: border-color 0.2s;
}
.deck-name-edit-group:focus-within {
  border-color: #fde047;
}

.deck-name-edit-group label {
  font-size: 12px;
  font-weight: 600;
  color: #fde047;
  white-space: nowrap;
}

.deck-name-edit-group input {
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 13px;
  font-family: inherit;
  width: 140px;
  outline: none;
}

.deck-code-share-group {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.deck-code-share-group input {
  flex: 1;
  min-width: 120px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(160, 175, 255, 0.2);
  border-radius: 999px;
  padding: 0 12px;
  color: #7dd3fc;
  font-family: monospace;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.deck-code-share-group input:focus {
  border-color: #38bdf8;
}

.deck-code-btn {
  min-height: 36px;
  padding: 0 14px !important;
  font-size: 12.5px !important;
  border-radius: 999px !important;
  white-space: nowrap;
}
.deck-code-btn.is-copy { background: #0284c7 !important; }
.deck-code-btn.is-import { background: #7c3aed !important; }

.deck-code-feedback {
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.deck-code-feedback.is-ok {
  background: rgba(22, 163, 74, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.45);
  color: #86efac;
}
.deck-code-feedback.is-error {
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

.deck-slot-choice-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
}

.deck-slot-choice-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}
.deck-slot-switch-modal-btn {
  min-height: 36px;
  border-radius: 999px !important;
  padding: 0 12px !important;
  font-size: 12.5px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(160, 175, 255, 0.22) !important;
}
.deck-slot-switch-modal-btn:hover {
  border-color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.12) !important;
}

.deck-slot-choice-select {
  background: #11182d;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  outline: none;
}

.deck-slot-choice-select:focus {
  border-color: #fde047;
}

.deck-slot-switch-modal-btn {
  padding: 5px 10px !important;
  font-size: 11.5px !important;
  background: #1e293b !important;
  border: 1px solid #475569 !important;
  border-radius: 6px !important;
  white-space: nowrap;
}

/* หน้าต่างเลือกสล็อตเด็ค (แบบ A "ชั้นวาง + รายละเอียด") — ซ้าย: สล็อตย่อ · ขวา: สล็อตที่เลือก
   ui-motion.css ใส่สกิน .modal-box ด้วย !important ไว้ จึงต้องทับด้วย !important เฉพาะกล่อง */
.sp-box {
  --sp-ink: #e8eaf7; --sp-soft: #b9bee0; --sp-mute: #8a90b8; --sp-line: rgba(160, 175, 255, .18);
  --sp-gold-hi: #ffe39a; --sp-gold-lo: #e0a83c;
  width: min(760px, calc(100vw - 24px)) !important; max-width: none !important; max-height: min(92vh, 92dvh);
  overflow-y: auto; padding: 22px !important; text-align: left !important; color: var(--sp-ink);
  background: linear-gradient(180deg, #171c40 0%, #0f1229 70%) !important;
  border: 1px solid rgba(160, 175, 255, .32) !important; border-radius: 20px !important;
}
.sp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sp-head h2 { margin: 0; font: 700 24px/1.2 var(--font-display); color: var(--sp-gold-hi); }
.sp-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--sp-soft); }
.sp-x {
  width: 44px; height: 44px; flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid rgba(160, 175, 255, .32); background: rgba(255, 255, 255, .05); color: var(--sp-ink); cursor: pointer;
}
.sp-x:hover { border-color: #f3c969; }
.sp-x svg, .sp-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sp-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.sp-list { display: flex; flex-direction: column; gap: 6px; }
.sp-row {
  --c: #3ee08f; position: relative; display: grid; grid-template-columns: 22px 36px minmax(0, 1fr); align-items: center; gap: 10px;
  min-height: 58px; padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; background: rgba(255, 255, 255, .03);
  color: var(--sp-ink); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation;
  transition: background-color .25s, border-color .25s;
}
.sp-row:hover { border-color: rgba(160, 175, 255, .32); }
.sp-row[aria-selected="true"] { background: #1c2a3c; background: color-mix(in srgb, var(--c) 14%, #141834); border-color: var(--c); }
.sp-num { font: 700 18px var(--font-display); color: var(--c); text-align: center; }
.sp-row img { width: 36px; aspect-ratio: 750 / 1050; object-fit: cover; border-radius: 4px; }
.sp-row-meta { min-width: 0; }
.sp-row-meta strong { display: block; font: 600 14px/1.3 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row-meta small { font-size: 12px; color: var(--sp-mute); }
.sp-warn { color: #ffb36b !important; }
.sp-detail {
  --c: #3ee08f; position: relative; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; padding: 20px;
  border-radius: 16px; border: 1px solid var(--sp-line); overflow: hidden; background: #141834;
  background: radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--c) 22%, transparent), transparent 60%), #141834;
}
.sp-art { width: 150px; aspect-ratio: 750 / 1050; border-radius: 10px; overflow: hidden; transform: rotate(-3deg); box-shadow: 0 16px 34px rgba(0, 0, 0, .6), 0 0 0 2px var(--c); }
.sp-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-info { display: flex; flex-direction: column; min-width: 0; }
.sp-tag { align-self: flex-start; padding: 2px 10px; border-radius: 99px; background: var(--c); color: #12142a; font: 600 12px var(--font-display); }
.sp-slot-label { font: 600 13px var(--font-display); color: var(--sp-mute); }
.sp-info h3 { margin: 8px 0 0; font: 700 26px/1.15 var(--font-display); color: var(--c); overflow-wrap: anywhere; }
.sp-leader { font-size: 14px; color: var(--sp-soft); }
.sp-count { margin-top: 16px; }
.sp-count > div:first-child { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; color: var(--sp-soft); }
.sp-count b { font: 600 15px var(--font-display); color: var(--sp-ink); }
.sp-meter { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.sp-meter i { display: block; height: 100%; border-radius: inherit; background: var(--c); transform-origin: left; }
.sp-acts { margin-top: auto; padding-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.sp-btn {
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px var(--font-display); cursor: pointer; touch-action: manipulation;
}
.sp-btn-gold { flex: 1 1 160px; background: linear-gradient(135deg, var(--sp-gold-hi), var(--sp-gold-lo)); color: #1a1405; box-shadow: 0 6px 18px rgba(224, 168, 60, .25); }
.sp-btn-ghost { background: rgba(255, 255, 255, .04); border: 1px solid rgba(160, 175, 255, .32); color: var(--sp-ink); }
.sp-btn-ghost:hover:not(:disabled) { border-color: #f3c969; }
.sp-btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 680px) {
  .sp-box { padding: 16px 14px !important; }
  .sp-body { grid-template-columns: 1fr; }
  .sp-list { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; }
  .sp-row { flex: 0 0 72px; grid-template-columns: 1fr; justify-items: center; gap: 4px; scroll-snap-align: start; }
  .sp-row-meta { display: none; }
  .sp-detail { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; padding: 14px; }
  .sp-art { width: 96px; }
  .sp-info h3 { font-size: 20px; }
}
@media (max-width: 400px) {
  .sp-detail { grid-template-columns: 76px minmax(0, 1fr); }
  .sp-art { width: 76px; }
  .sp-acts .sp-btn { flex: 1 1 100%; }
}


/* ============================================================================
   3. BATTLE LOG SPOTLIGHT & LATEST PLAYED CARD WIDGET
   ============================================================================ */
.last-card-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px !important;
  background: rgba(15, 23, 42, 0.92) !important;
  border: 1.5px solid #22c55e !important;
  border-radius: 8px !important;
  height: 30px;
  max-width: 175px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.last-card-pill-img {
  width: 20px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.last-card-pill-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  min-width: 0;
  overflow: hidden;
}

.last-card-pill-side {
  font-size: 9px;
  font-weight: 700;
  color: #86efac;
}

.last-card-pill-name {
  font-size: 11px;
  color: #fde047;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.combat-log-spotlight {
  margin: 10px 0 4px 0;
}

.combat-spot-empty {
  background: rgba(15, 23, 42, 0.65);
  border: 1px dashed #334155;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

.combat-spot-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
  border: 1.5px solid #22c55e;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.combat-spot-card.is-ai {
  border-color: #ef4444;
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.92), rgba(49, 16, 42, 0.88));
}

.combat-spot-art-wrap {
  position: relative;
  width: 74px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid rgba(250, 204, 21, 0.6);
  align-self: flex-start;
}

.combat-spot-art-wrap img {
  width: 100%;
  aspect-ratio: 750 / 1050;
  object-fit: cover;
  display: block;
}

.combat-spot-zoom-hint {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  background: rgba(0, 0, 0, 0.78);
  color: #fde047;
  font-size: 9.5px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
}

.combat-spot-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combat-spot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.combat-spot-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #065f46;
  color: #a7f3d0;
}
.combat-spot-badge.is-ai {
  background: #991b1b;
  color: #fecaca;
}

.combat-spot-stat {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 600;
}

.combat-spot-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.combat-spot-name {
  font-size: 15px;
  color: #fde047;
}

.combat-spot-rarity {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
}

.combat-spot-action-summary {
  font-size: 12px;
  color: #38bdf8;
  font-weight: 600;
}

.combat-spot-skill-highlight {
  margin-top: 2px;
  background: rgba(11, 15, 29, 0.85);
  border-left: 3px solid #facc15;
  border-radius: 6px;
  padding: 6px 9px;
}

.combat-spot-skill-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #fde047;
  margin-bottom: 2px;
}

.combat-spot-skill-text {
  font-size: 11.5px;
  color: #f1f5f9;
  line-height: 1.4;
  white-space: pre-line;
  max-height: 76px;
  overflow-y: auto;
}

.combat-log-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(51, 65, 85, 0.55);
  border-left: 4px solid #10b981;
  text-align: left;
  transition: background 0.15s ease, transform 0.15s ease;
}

.combat-log-row.is-ai {
  background: rgba(30, 27, 75, 0.72);
  border-left-color: #ef4444;
}

.combat-log-row.has-card {
  cursor: pointer;
}

.combat-log-row.has-card:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: #38bdf8;
}

.combat-log-thumb {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.combat-log-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combat-log-row-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.combat-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.combat-chip.is-turn { background: #1e293b; border: 1px solid #475569; color: #e2e8f0; }
.combat-chip.is-side-player { background: #065f46; color: #a7f3d0; }
.combat-chip.is-side-ai { background: #991b1b; color: #fecaca; }
.combat-chip.is-cat-attack { background: #b91c1c; color: #fee2e2; }
.combat-chip.is-cat-spell { background: #7e22ce; color: #f3e8ff; }
.combat-chip.is-cat-summon { background: #0f766e; color: #ccfbf1; }
.combat-chip.is-cat-other { background: #334155; color: #e2e8f0; }
.combat-chip.is-inspect-hint {
  background: rgba(2, 132, 199, 0.22);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
}

.combat-log-time {
  margin-left: auto;
  font-size: 10px;
  color: #64748b;
}

.combat-log-msg {
  font-size: 12.5px;
  color: #f8fafc;
  line-height: 1.38;
}


/* ============================================================================
   4. COSMETICS: CARD BACKS, ARENA MAT THEMES & LEADER FRAMES
   ============================================================================ */
#player-deck-box,
.player-mat-half .deck-packet {
  background-image: var(--bof-card-back-url, url('../images/card-back.png'));
}

html[data-card-back="gold"] #player-deck-box,
html[data-card-back="gold"] .player-mat-half .deck-packet {
  border-color: #facc15;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.55);
}

html[data-card-back="crimson"] #player-deck-box,
html[data-card-back="crimson"] .player-mat-half .deck-packet {
  border-color: #f87171;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.55);
}

html[data-card-back="emerald"] #player-deck-box,
html[data-card-back="emerald"] .player-mat-half .deck-packet {
  border-color: #4ade80;
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.55);
}

html[data-card-back="abyss"] #player-deck-box,
html[data-card-back="abyss"] .player-mat-half .deck-packet {
  border-color: #c084fc;
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.6);
}

html[data-card-back="cosmic"] #player-deck-box,
html[data-card-back="cosmic"] .player-mat-half .deck-packet {
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.55);
}

#pvp-room-modal .modal-box {
  background: linear-gradient(180deg, #151a3c, #0b0e24);
  border: 1.5px solid rgba(160, 175, 255, 0.32);
  border-radius: 20px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.78);
}
#bof-game-arena[data-arena-theme]:not([data-arena-theme="default"]) .player-mat-half .deck-mat-fx {
  display: none;
}
#bof-game-arena[data-arena-theme="crimson"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(16, 5, 7, 0.45), rgba(16, 5, 7, 0.62)), url('../images/mats/mt_crimson.jpg') center / cover no-repeat;
  border-color: rgba(248, 113, 113, 0.48);
}

#bof-game-arena[data-arena-theme="abyss"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(12, 5, 26, 0.45), rgba(12, 5, 26, 0.62)), url('../images/mats/mt_abyss.jpg') center / cover no-repeat;
  border-color: rgba(192, 132, 252, 0.48);
}

#bof-game-arena[data-arena-theme="jungle"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(4, 22, 14, 0.45), rgba(4, 22, 14, 0.62)), url('../images/mats/mt_jungle.jpg') center / cover no-repeat;
  border-color: rgba(52, 211, 153, 0.45);
}

#bof-game-arena[data-arena-theme="sanctuary"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(14, 12, 8, 0.42), rgba(14, 12, 8, 0.58)), url('../images/mats/mt_sanctuary.jpg') center / cover no-repeat;
  border-color: rgba(253, 224, 71, 0.48);
}

#bof-game-arena[data-arena-theme="cyber"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(4, 14, 26, 0.42), rgba(4, 14, 26, 0.6)), url('../images/mats/mt_cyber.jpg') center / cover no-repeat;
  border-color: rgba(34, 211, 238, 0.5);
}

#bof-game-arena[data-arena-theme="sakura"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(24, 6, 18, 0.45), rgba(24, 6, 18, 0.62)), url('../images/mats/mt_sakura.jpg') center / cover no-repeat;
  border-color: rgba(244, 114, 182, 0.48);
}

#bof-game-arena[data-arena-theme="inferno"] .mat-half.player-mat-half {
  background: radial-gradient(ellipse at 50% 50%, rgba(249, 115, 22, 0.28) 0%, transparent 55%), radial-gradient(circle at 50% 50%, #431407 0%, #270a04 65%, #110302 100%);
  border-color: rgba(251, 146, 60, 0.5);
}

#bof-game-arena[data-arena-theme="void"] .mat-half.player-mat-half {
  background: linear-gradient(180deg, rgba(6, 5, 18, 0.42), rgba(6, 5, 18, 0.6)), url('../images/mats/mt_void.jpg') center / cover no-repeat;
  border-color: rgba(165, 180, 252, 0.48);
}

/* Player Leader Frame Cosmetics */
#player-leader-box[data-frame="gold"] {
  border-color: #facc15 !important;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.75) !important;
}
#player-leader-box[data-frame="crimson"] {
  border-color: #ef4444 !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.8) !important;
}
#player-leader-box[data-frame="neon"] {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.85) !important;
}
#player-leader-box[data-frame="abyss"] {
  border-color: #a855f7 !important;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.85) !important;
}
#player-leader-box[data-frame="holo"] {
  border-color: #f472b6 !important;
  box-shadow: 0 0 18px rgba(244, 114, 182, 0.8), 0 0 28px rgba(56, 189, 248, 0.65) !important;
}
#player-leader-box[data-frame="emerald"] {
  border-color: #10b981 !important;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.85) !important;
}
#player-leader-box[data-frame="sakura"] {
  border-color: #f472b6 !important;
  box-shadow: 0 0 18px rgba(244, 114, 182, 0.85) !important;
}
#player-leader-box[data-frame="solar"] {
  border-color: #f97316 !important;
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.85), 0 0 30px rgba(251, 191, 36, 0.5) !important;
}
#player-leader-box[data-frame="amethyst"] {
  border-color: #a855f7 !important;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.85) !important;
}

@media (max-width: 767px) {
  .ai-diff-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .ai-deck-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .ai-deck-card.is-random-card {
    grid-column: span 1;
  }
  .deck-slots-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .deck-slot-choice-group,
  .deck-name-edit-group,
  .deck-code-share-group {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
  }
  .deck-slot-choice-group .deck-slot-choice-select {
    flex: 1;
    min-width: 140px;
  }
  .deck-name-edit-group input {
    flex: 1;
    width: auto;
  }
  .last-card-pill-btn {
    max-width: 118px;
    height: 24px;
    padding: 2px 6px 2px 3px !important;
  }
  .last-card-pill-img {
    width: 15px;
    height: 18px;
  }
  .last-card-pill-side {
    font-size: 7.5px;
  }
  .last-card-pill-name {
    font-size: 9px;
    max-width: 72px;
  }
  .combat-spot-card {
    padding: 8px 10px;
    gap: 9px;
  }
  .combat-spot-art-wrap {
    width: 58px;
  }
}

/* ============================================================================
   5. CARD SKILL SANDBOX & 72-CARD DIAGNOSTIC RUNNER (ห้องทดลองสกิลการ์ด)
   ============================================================================ */
.bof-sandbox-box {
  max-width: 960px !important;
  width: min(960px, 96vw) !important;
  max-height: 92dvh;
  overflow-y: auto;
  text-align: left !important;
  background: linear-gradient(180deg, #13182b 0%, #0b0e1a 100%) !important;
  border: 1.5px solid #a855f7 !important;
  border-radius: 18px !important;
  padding: 18px 20px !important;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.85) !important;
}

.bof-sb-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.bof-sb-diag-btn {
  flex: 1;
  min-width: 240px;
  background: linear-gradient(135deg, #0284c7, #2563eb) !important;
  font-size: 12.5px !important;
  font-weight: 700 !important;
  padding: 9px 14px !important;
  border-radius: 10px !important;
}

.bof-sb-dummy-btn {
  background: #334155 !important;
  border: 1px solid #64748b !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  padding: 9px 14px !important;
  border-radius: 10px !important;
}

.bof-sb-dummy-btn.is-on {
  background: rgba(22, 163, 74, 0.25) !important;
  border-color: #22c55e !important;
  color: #86efac !important;
}

.bof-sandbox-diag-results {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.bof-diag-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.bof-diag-summary.is-pass {
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid rgba(74, 222, 128, 0.45);
  color: #86efac;
}

.bof-diag-summary.is-fail {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

.bof-diag-table-wrap {
  max-height: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.bof-diag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(30, 41, 59, 0.75);
  font-size: 11.5px;
}

.bof-diag-row.is-err {
  background: rgba(127, 29, 29, 0.45);
  border: 1px solid #ef4444;
}

.bof-diag-badge {
  font-weight: 800;
  color: #4ade80;
  white-space: nowrap;
}

.bof-diag-row.is-err .bof-diag-badge {
  color: #f87171;
}

.bof-diag-card-name {
  color: #f8fafc;
  min-width: 170px;
}

.bof-diag-card-type {
  color: #fde047;
  font-size: 10.5px;
  min-width: 82px;
}

.bof-diag-card-note {
  flex: 1;
  color: #94a3b8;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bof-diag-try-btn {
  padding: 3px 9px !important;
  font-size: 10.5px !important;
  background: #7c3aed !important;
  border-radius: 6px !important;
  white-space: nowrap;
}

.bof-sb-filter-section {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid #2b3554;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.bof-sb-deck-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.bof-sb-tab-btn {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  transition: all 0.14s ease;
}

.bof-sb-tab-btn.is-active {
  background: #7c3aed;
  color: #ffffff;
  border-color: #c084fc;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.45);
}

.bof-sb-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bof-sb-cat-select { position: relative; z-index: 30; }
.bof-sb-cat-select .fx-select-btn { min-height: 36px; padding: 0 12px; font-size: 13px; }
.bof-sb-cat-select .fx-select-menu { width: min(480px, 86vw); grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
.bof-sb-cat-select .bof-sb-tab-btn { border-radius: 10px; padding: 6px 10px; font-size: 12.5px; justify-content: flex-start; width: 100%; }
.bof-sb-cat-select .bof-sb-tab-btn::before { display: none; }
.bof-sb-cat-select .bof-sb-tab-btn.is-active { background: #7c3aed; border-color: #c084fc; color: #fff; }
.bof-sb-match-count { font-size: 12px; color: #cbd5e1; background: #1e293b; padding: 5px 10px; border-radius: 999px; border: 1px solid #334155; white-space: nowrap; }

.bof-sb-card-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px 6px;
  margin-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: #a855f7 #0f172a;
}
.bof-sb-card-item {
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  background: #141a2e;
  border: 1.5px solid #2b3554;
  color: #e2e8f0;
  cursor: pointer;
  text-align: center;
  transition: transform 0.14s, border-color 0.14s, background 0.14s;
}
.bof-sb-card-item:hover { transform: translateY(-2px); border-color: #c084fc; }
.bof-sb-card-item.is-active {
  background: rgba(124, 58, 237, 0.28);
  border-color: #fde047;
  box-shadow: 0 0 0 1px #fde047;
}
.bof-sb-card-item img { width: 58px; aspect-ratio: 750 / 1050; object-fit: cover; border-radius: 6px; }
.bof-sb-ci-name { width: 100%; font: 600 11.5px/1.25 'Kanit', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bof-sb-ci-meta { font-size: 10px; color: #94a3b8; white-space: nowrap; }
.bof-sb-empty { width: 100%; padding: 14px; text-align: center; color: #94a3b8; font-size: 13px; }

.bof-sb-search-input {
  flex: 1;
  min-width: 210px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12.5px;
  font-family: 'Kanit', sans-serif;
}

.bof-sb-card-select {
  flex: 1.3;
  min-width: 230px;
  background: #0f172a;
  color: #fde047;
  border: 1.5px solid #a855f7;
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
}

.bof-sb-preview-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.bof-sb-preview-img {
  width: 96px;
  aspect-ratio: 750 / 1050;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid #f3c969;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.bof-sb-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bof-sb-preview-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.bof-sb-id-badge {
  background: #7c3aed;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
}

.bof-sb-title {
  font-size: 16px;
  color: #fde047;
}

.bof-sb-meta-pill {
  font-size: 11.5px;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.9);
  padding: 2px 8px;
  border-radius: 999px;
}

.bof-sb-skill-box {
  font-size: 12px;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.65);
  border-left: 3px solid #38bdf8;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.45;
  white-space: pre-line;
}

.bof-sb-guide-box {
  font-size: 12px;
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.16);
  border-left: 3px solid #22c55e;
  padding: 6px 10px;
  border-radius: 6px;
  line-height: 1.45;
}

.bof-sb-primary-actions {
  margin-bottom: 12px;
}

.bof-sb-scenario-btn {
  width: 100%;
  padding: 12px 16px !important;
  font-size: 14.5px !important;
  font-weight: 800 !important;
  background: linear-gradient(135deg, #16a34a, #059669) !important;
  border: 1.5px solid #4ade80 !important;
  border-radius: 11px !important;
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.45);
}

.bof-sb-zone-bar,
.bof-sb-quick-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid #2b3554;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.bof-sb-bar-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #fde047;
  margin-right: 4px;
}

.bof-sb-zone-btn {
  padding: 5px 10px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  background: #1e293b !important;
  border: 1px solid #38bdf8 !important;
  color: #bae6fd !important;
  border-radius: 7px !important;
}

.bof-sb-zone-btn.is-ai {
  border-color: #f97316 !important;
  color: #fed7aa !important;
}

.bof-sb-tool-btn {
  padding: 5px 10px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  background: #334155 !important;
  border: 1px solid #64748b !important;
  border-radius: 7px !important;
}

.bof-sb-tool-btn.is-attack {
  background: #dc2626 !important;
  border-color: #f87171 !important;
}

@media (max-width: 767px) {
  .bof-sb-preview-card {
    flex-direction: column;
    align-items: center;
  }
  .bof-sb-preview-img {
    width: 82px;
  }
}

/* ============================================================================
   6. HOW-TO-PLAY, 6-DECK COMBO GUIDE & INTERACTIVE TUTORIAL COACH
   ============================================================================ */
#lb-howto-dialog.lb-howto-wide {
  width: min(680px, calc(100vw - 24px)) !important;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 22px !important;
  background: #f5ecd7;
  color: #12142a;
}

/* ปุ่มปิดเดิมเป็นสีอ่อนบนพื้นครีม แทบมองไม่เห็น */
#lb-howto-dialog .bof-auth-close-x {
  min-width: 40px;
  min-height: 40px;
  color: #12142a;
  background: rgba(18, 20, 42, .08);
  border-color: rgba(18, 20, 42, .25);
}

.lb-howto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.lb-howto-header h2 {
  font-size: clamp(20px, 3vw, 25px) !important;
  margin: 0 !important;
}

.lb-howto-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  background: #e2d5b6;
  border-radius: 12px;
}

.lb-howto-tab {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 8px 10px;
  font-family: 'Kanit', sans-serif;
  font-size: 13px;
  font-weight: 700;
  background: transparent;
  color: #334155;
  cursor: pointer;
  transition: all 0.16s ease;
}

.lb-howto-tab.is-active {
  background: #12142a;
  color: #fde047;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.lb-howto-tutorial-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f8fafc;
  border: 1.5px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.lb-howto-tutorial-banner strong {
  display: block;
  font-size: 14px;
  color: #fde047;
  margin-bottom: 2px;
}

.lb-howto-tutorial-banner p {
  font-size: 12px;
  color: #cbd5e1;
  margin: 0;
}

.lb-start-tutorial-btn {
  background: linear-gradient(135deg, #16a34a, #059669) !important;
  color: #fff !important;
  padding: 8px 14px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  border-radius: 9px !important;
  white-space: nowrap;
}

.lb-zones-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lb-zone-guide-card {
  background: #e6dac0;
  border: 1px solid #cbb994;
  border-radius: 11px;
  padding: 11px 13px;
}

.lb-zone-guide-card strong {
  display: block;
  font-size: 13.5px;
  color: #12142a;
  margin-bottom: 4px;
}

.lb-zone-guide-card p {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.45;
  margin: 0;
}

.lb-combo-deck-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.lb-combo-deck-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  border: 1.5px solid #cbb994;
  background: #e6dac0;
  color: #1e293b;
  font-family: 'Kanit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lb-combo-deck-pill img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #12142a;
}

.lb-combo-deck-pill.is-active {
  background: #12142a;
  color: #fde047;
  border-color: #f59e0b;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.lb-combo-content-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52dvh;
  overflow-y: auto;
  padding-right: 4px;
}

.lb-combo-overview {
  background: #12142a;
  color: #f8fafc;
  border-radius: 12px;
  padding: 11px 14px;
  border-left: 4px solid #f59e0b;
}

.lb-combo-overview strong {
  color: #fde047;
  font-size: 14px;
  display: block;
  margin-bottom: 3px;
}

.lb-combo-overview p {
  font-size: 12px;
  color: #cbd5e1;
  margin: 0;
  line-height: 1.45;
}

.lb-combo-card {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.lb-combo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-combo-card-title {
  font-size: 14px;
  font-weight: 800;
  color: #38bdf8;
}

.lb-combo-practice-btn {
  padding: 4px 10px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  background: linear-gradient(135deg, #d97706, #b45309) !important;
  color: #fff !important;
  border-radius: 7px !important;
}

.lb-combo-cards-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px;
}

.lb-combo-mini-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 4px 8px 4px 4px;
  flex-shrink: 0;
  cursor: pointer;
}

.lb-combo-mini-card img {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #f3c969;
}

.lb-combo-mini-meta {
  display: flex;
  flex-direction: column;
}

.lb-combo-mini-meta b {
  font-size: 11.5px;
  color: #fde047;
}

.lb-combo-mini-meta small {
  font-size: 10px;
  color: #94a3b8;
}

.lb-combo-arrow {
  color: #f59e0b;
  font-weight: 900;
  font-size: 14px;
  flex-shrink: 0;
}

.lb-combo-steps-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* แถบโค้ชสอนเล่นบนกระดานจริง (Interactive Tutorial Coach Bar) — ธีม "ตราทอง"
   หลบเป้าหมายอัตโนมัติ: js/tutorial-coach.js ใส่ .is-dock-bottom เมื่อเป้าที่ต้องกดอยู่ครึ่งบนของจอ */
#bof-tutorial-coach-bar {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 240;
  width: min(640px, 95vw);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 214, 120, 0.14), transparent 55%),
    linear-gradient(160deg, rgba(14, 20, 38, 0.97), rgba(8, 12, 24, 0.97));
  border: 1px solid rgba(255, 214, 120, 0.55);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.4) inset, 0 0 22px rgba(255, 196, 80, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f8fafc;
  transition: top .38s cubic-bezier(.2, .8, .2, 1), bottom .38s cubic-bezier(.2, .8, .2, 1), border-color .3s;
}
#bof-tutorial-coach-bar.is-complete { border-color: #4ade80; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7), 0 0 26px rgba(74, 222, 128, 0.35); }

.bof-coach-main { flex: 1; min-width: 0; }
.bof-coach-head { display: flex; align-items: center; gap: 8px; }

.bof-coach-step-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ffe39a, #f5b43c);
  color: #1a1204;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.is-complete .bof-coach-step-badge { background: linear-gradient(135deg, #bbf7d0, #4ade80); }

/* ปุ่มย่อ/ขยาย (PC + มือถือ) — js/tutorial-coach.js สลับ .is-collapsed */
.bof-coach-toggle {
  display: grid; place-items: center;
  margin-left: auto; width: 30px; height: 26px; flex-shrink: 0;
  border: 1px solid rgba(255, 214, 120, .35); border-radius: 8px;
  background: rgba(255, 255, 255, .06); color: #ffe39a; padding: 0; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.bof-coach-toggle:hover { background: rgba(255, 214, 120, .16); border-color: rgba(255, 214, 120, .7); }
.bof-coach-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s; transform: rotate(180deg); }
.is-collapsed .bof-coach-toggle svg { transform: none; }
.is-collapsed .bof-coach-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.is-collapsed .bof-coach-desc,
.is-collapsed .bof-coach-actions { display: none; }

.bof-coach-prog {
  height: 3px;
  margin: 6px 0 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.bof-coach-prog i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f5b43c, #ffe39a);
  box-shadow: 0 0 8px rgba(255, 214, 120, 0.8);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.is-complete .bof-coach-prog i { background: linear-gradient(90deg, #22c55e, #bbf7d0); }

.bof-coach-title {
  font-size: 14px;
  font-weight: 800;
  color: #ffe39a;
  line-height: 1.35;
  margin-bottom: 2px;
}

.bof-coach-desc {
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.45;
}

.bof-coach-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.bof-coach-btn {
  padding: 6px 12px !important;
  font-size: 12px !important;
  border-radius: 9px !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  background: rgba(255, 255, 255, 0.07) !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
  white-space: nowrap;
}
.bof-coach-btn:hover { background: rgba(255, 214, 120, 0.16) !important; border-color: rgba(255, 214, 120, 0.5) !important; }
.bof-coach-btn.is-exit { color: #fca5a5 !important; }

/* ไฮไลต์ชี้เป้าแบบจับมือสอน (Hand-Holding Pointer Highlight) */
@keyframes bofGuidePulse {
  0%, 100% {
    box-shadow: 0 0 0 3px #facc15, 0 0 22px rgba(250, 204, 21, 0.95);
    transform: translateY(-4px) scale(1.03);
  }
  50% {
    box-shadow: 0 0 0 5px #22c55e, 0 0 30px rgba(34, 197, 94, 1);
    transform: translateY(-7px) scale(1.06);
  }
}

.bof-guided-highlight {
  position: relative !important;
  z-index: 65 !important;
  outline: 3px solid #facc15 !important;
  border-radius: 10px !important;
  animation: bofGuidePulse 1.15s infinite ease-in-out !important;
}

.bof-guided-pointer-badge {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #facc15, #f59e0b);
  color: #090d16;
  font-family: 'Kanit', sans-serif;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  z-index: 90;
  border: 1.5px solid #ffffff;
}
/* ไอคอนนิ้วแตะชี้การ์ด/ช่อง/Leader: วงทองกลางเป้า + วงคลื่นกระจาย (ตรงกับประกายที่ยิงจากกลางเป้า) */
.bof-guided-pointer-badge.is-icon {
  top: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fff6d6, #f5b43c 58%, #b7791f);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .65), 0 0 14px rgba(255, 214, 120, .8);
  animation: bofTapBob 1.15s ease-in-out infinite;
}
.bof-guided-pointer-badge.is-icon svg {
  width: 19px; height: 19px;
  fill: none; stroke: #1a1204; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  transform: translate(1px, 1px);
}
.bof-guided-pointer-badge.is-icon::before,
.bof-guided-pointer-badge.is-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #ffe39a;
  animation: bofTapRipple 1.15s ease-out infinite;
  pointer-events: none;
}
.bof-guided-pointer-badge.is-icon::after { animation-delay: .38s; }
@keyframes bofTapBob {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  35% { transform: translate(-50%, calc(-50% + 3px)) scale(.86); }
  55% { transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes bofTapRipple {
  0% { transform: scale(.8); opacity: .95; }
  100% { transform: scale(2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bof-guided-pointer-badge.is-icon, .bof-guided-pointer-badge.is-icon::before, .bof-guided-pointer-badge.is-icon::after { animation: none; }
}
/* ป้ายเกาะขอบบนขวาของปุ่มตัวเลือก: ไม่ทับข้อความในปุ่ม */
.bof-guided-pointer-badge.is-chip {
  top: 0;
  left: auto;
  right: 10px;
  transform: translateY(-60%);
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
  padding: 1px 8px;
}
#choice-modal-buttons button.bof-guided-highlight { overflow: visible !important; animation-name: bofGuidePulseFlat !important; }
#choice-modal-buttons { overflow: visible; padding-top: 6px; }
@keyframes bofGuidePulseFlat {
  0%, 100% { box-shadow: 0 0 0 2px #ffe39a, 0 0 16px rgba(255, 214, 120, 0.7); }
  50% { box-shadow: 0 0 0 3px #4ade80, 0 0 24px rgba(74, 222, 128, 0.85); }
}

@media (max-width: 767px) {
  .lb-zones-guide-grid {
    grid-template-columns: 1fr;
  }
  .lb-howto-tab {
    font-size: 11.5px;
    padding: 7px 6px;
  }
  #bof-tutorial-coach-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 11px;
  }
  .bof-coach-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

/* ไอคอนปุ่มแถบโค้ช (เส้นทอง วาดเองใน game.js COACH_ICONS) + โมชั่นตอนชี้/กด */
.bof-coach-btn { display: inline-flex !important; align-items: center; justify-content: flex-start; gap: 8px; }
.bof-ci {
  width: 18px; height: 18px; flex-shrink: 0; overflow: visible;
  fill: none; stroke: #ffe39a; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bof-ci .ci-dot, .bof-ci .ci-star { fill: #ffe39a; stroke: none; }
.bof-ci .ci-spin, .bof-ci .ci-card, .bof-ci .ci-star, .bof-ci .ci-arrow { transform-box: fill-box; transform-origin: center; transition: transform .45s cubic-bezier(.2, .9, .3, 1.3); }
.bof-ci .ci-back { transform-origin: 50% 100%; }
.bof-ci .ci-front { fill: rgba(14, 20, 38, .95); }
.is-exit .bof-ci { stroke: #fca5a5; }
/* เริ่มใหม่: ลูกศรหมุนย้อนครบรอบ · คอมโบอื่น: การ์ดใบหลังกางออก ดาวหมุน · ออก: ลูกศรพุ่งออกจากประตู */
.bof-coach-btn.is-restart:hover .ci-spin, .bof-coach-btn.is-restart:focus-visible .ci-spin { transform: rotate(-360deg); transition-duration: .6s; }
.bof-coach-btn.is-pick:hover .ci-back, .bof-coach-btn.is-pick:focus-visible .ci-back { transform: rotate(-14deg) translateX(-1px); }
.bof-coach-btn.is-pick:hover .ci-front, .bof-coach-btn.is-pick:focus-visible .ci-front { transform: translateY(-1.5px) rotate(4deg); }
.bof-coach-btn.is-pick:hover .ci-star, .bof-coach-btn.is-pick:focus-visible .ci-star { transform: rotate(72deg) scale(1.25); }
.bof-coach-btn.is-exit:hover .ci-arrow, .bof-coach-btn.is-exit:focus-visible .ci-arrow { transform: translateX(3px); }
.bof-coach-btn:active .bof-ci { transform: scale(.88); }
@media (prefers-reduced-motion: reduce) { .bof-ci * { transition: none !important; } }

/* ============================================================================
   FALLBACK / SAFEGUARD STYLES: Multiplayer Player Banner & Profile View
   ============================================================================ */
#pvp-room-modal .mp-player-banner {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  background: rgba(160, 175, 255, 0.08) !important;
  border: 1px solid rgba(160, 175, 255, 0.2) !important;
  margin-bottom: 12px !important;
}

#pvp-room-modal .mp-banner-left {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
}

#pvp-room-modal img.mp-banner-avatar,
img#mp-banner-avatar,
.mp-banner-avatar {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  object-position: center 18% !important;
  border: 2px solid #38bdf8 !important;
  background: #080a14 !important;
  flex-shrink: 0 !important;
  display: block !important;
}

#pvp-room-modal .mp-banner-text {
  font-size: 13px !important;
  color: #cbd5e1 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#pvp-room-modal .mp-banner-text strong {
  color: #ffe39a !important;
}

#pvp-room-modal .mp-edit-badge {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(160, 175, 255, 0.25) !important;
  border-radius: 20px !important;
  color: #cbd5e1 !important;
  font-size: 11px !important;
  padding: 3px 10px !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Profile Dialog Avatar Picker Fallback */
.bof-avatar-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 8px !important;
  margin-top: 4px !important;
}

.bof-avatar-option {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 8px 4px 6px !important;
  border-radius: 12px !important;
  border: 1.5px solid rgba(160, 175, 255, 0.18) !important;
  background: rgba(11, 13, 26, 0.7) !important;
  cursor: pointer !important;
}

.bof-avatar-option img {
  width: 52px !important;
  height: 52px !important;
  max-width: 52px !important;
  max-height: 52px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  object-position: center 18% !important;
  border: 2px solid rgba(160, 175, 255, 0.25) !important;
  display: block !important;
  margin: 0 auto !important;
}

.bof-avatar-option.is-selected img {
  border-color: #f3c969 !important;
  box-shadow: 0 0 12px rgba(243, 201, 105, 0.65) !important;
  transform: scale(1.06) !important;
}

.bof-backup-box {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.5) 0%, rgba(15, 23, 42, 0.7) 100%) !important;
  border: 1px solid rgba(243, 201, 105, 0.25) !important;
  border-radius: 14px !important;
  padding: 12px 14px !important;
  margin-bottom: 14px !important;
}

.bof-backup-btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #1a1405 !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25) !important;
}

.bof-backup-btn-sub {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(160, 175, 255, 0.25) !important;
  color: #e2e8f0 !important;
}
