html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #f5f6fa;
  color: #222;
  font-family: 'Roboto', Arial, sans-serif;
  min-height: 100vh;
  box-sizing: border-box;
}
body.dark-mode {
  background: #111;
  color: #fff;
}
body.light-mode {
  background: #f5f6fa;
  color: #222;
}
.container {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 24px #0001;
  padding: 36px 32px 32px 32px;
  margin-bottom: 32px;
  max-width: 900px;
  width: 100%;
  border: 1.5px solid #e0e0e0;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
body.dark-mode .container {
  background: #181d2b;
  border: 1.5px solid #232a3a;
}
body.light-mode .container {
  background: #fff;
  border: 1.5px solid #e0e0e0;
}
@media (max-width: 1200px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}
@media (max-width: 700px) {
  .container {
    padding-left: 4px;
    padding-right: 4px;
  }
}
h1 {
  color: #2196f3;
  font-size: 2.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
}
h2 {
  color: #1976d2;
  font-size: 1.35rem;
  margin-top: 32px;
}
.feature {
  margin-bottom: 28px;
}
.feature a {
  color: #2196f3;
  font-weight: 600;
  text-decoration: none;
}
.feature a:hover {
  text-decoration: underline;
}
.example {
  background: #e3eafc;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0 0 0;
  font-family: 'Fira Mono', monospace;
  font-size: 1.01rem;
}
ul {
  margin: 0 0 0 18px;
}

/* Toggle Sidebar Card Search Button */
#toggleSidebarCardSearchBtn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 1200;
  background: #2d8cff;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 28px 14px 20px;
  font-size: 1.13rem;
  font-weight: 600;
  box-shadow: 0 4px 18px #0003;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.18s, box-shadow 0.18s;
}
#toggleSidebarCardSearchBtn:hover { background: #2196f3; box-shadow: 0 6px 24px #2196f355; }
#toggleSidebarCardSearchBtn svg { width: 22px; height: 22px; fill: #fff; display: inline-block; }

/* Sidebar Card Search */
#sidebarCardSearch {
  background: #232a3a;
  border-left: 2px solid #2d8cff;
  box-shadow: -2px 0 12px #0002;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 10px 10px 10px;
  gap: 10px;
  position: fixed;
  top: 70px;
  right: 0;
  width: 320px;
  max-width: 90vw;
  height: calc(100vh - 80px);
  z-index: 1001;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(.4,1.4,.6,1), opacity 0.18s;
}
#sidebarCardSearch.sidebar-visible { transform: translateX(0); opacity: 1; pointer-events: auto; }
.sidebar-search-row { width:100%; display:flex; align-items:center; gap:8px; margin-bottom:8px; }
#sidebarCardSearchInput {
  width: 100%;
  padding: 10px 14px;
  border-radius: 22px;
  border: 1.5px solid #2196f3;
  background: #181b20;
  color: #fff;
  font-size: 1rem;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: border 0.2s;
}
#sidebarCardSearchInput:focus { border: 1.5px solid #4e9cff; }
#sidebarCardSearchResults {
  background: #181b20;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  padding: 8px 0;
  max-height: 70vh;
  overflow-y: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-card-result { display:flex; align-items:center; gap:10px; padding:8px 12px; color:#e0e6ed; border-radius:8px; background:transparent; cursor:pointer; transition: background .15s, color .15s, box-shadow .15s; border:1.5px solid transparent; }
.sidebar-card-result img { width: 38px; height: 56px; border-radius: 4px; object-fit: cover; background:#222; box-shadow:0 2px 8px #0003; }
.sidebar-card-result:hover, .sidebar-card-result.active { background:#2a3140; color:#4e9cff; border:1.5px solid #4e9cff; box-shadow:0 2px 12px #2196f355; }
.sidebar-card-result span { font-size:1.04rem; font-weight:500; flex:1 1 0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Right-side Card Search results (light theme) */
#boardCardSearchResults {
  margin-top: 10px;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  max-height: 420px;
  overflow: auto;
}
#opponentGlobalSearchResults {
  margin-top: 10px;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  max-height: 420px;
  overflow: auto;
}
/* robust empty state control */
#boardCardSearchResults:not([data-has-results="true"]) { display: none; }
/* keep this for browsers that support it */
#boardCardSearchResults:empty { display: none; }

#boardCardSearchResults .panel-card-result,
#opponentGlobalSearchResults .panel-card-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f1f1;
  cursor: grab;
}
#boardCardSearchResults .panel-card-result:last-child,
#opponentGlobalSearchResults .panel-card-result:last-child {
  border-bottom: none;
}
#boardCardSearchResults .panel-card-result:hover,
#opponentGlobalSearchResults .panel-card-result:hover {
  background: #f9fafb;
}
#boardCardSearchResults .panel-card-result:active,
#opponentGlobalSearchResults .panel-card-result:active {
  cursor: grabbing;
}
#boardCardSearchResults .panel-card-result img,
#opponentGlobalSearchResults .panel-card-result img {
  width: 36px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
#boardCardSearchResults .panel-card-result span,
#opponentGlobalSearchResults .panel-card-result span {
  font-size: 13px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Board title */
.board-title { margin-bottom: 18px; }

/* Board grid */
.board {
  display: grid;
  grid-template-columns: repeat(7, 100px);
  grid-template-rows: repeat(7, 140px);
  gap: 7px;
  border: 2.5px solid #2196f3;
  padding: 14px;
  background: #e3eafc;
  border-radius: 10px;
  box-shadow: 0 2px 12px #0001;
  position: relative;
  margin-bottom: 32px;
}
.span-7 { grid-column: 1 / span 7; }

/* Zones */
.zone {
  border: 2px solid #2196f3;
  background: #fff;
  border-radius: 6px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  text-align: center;
  min-height: 130px;
  padding: 2px;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.zone:hover { box-shadow: 0 0 0 3px #2196f355; border-color: #ff9800; cursor: pointer; }
.zone .zone-label { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:13px; color:#555; pointer-events:none; z-index:1; user-select:none; text-align:center; line-height:1.05; padding:2px; white-space:normal; }
.zone .card-stack { position: relative; width:100%; height:100%; min-width:78px; min-height:112px; display:flex; align-items:center; justify-content:center; }
/* Stacking for non-hand zones */
.zone:not([data-label*="Hand"]) .card-stack img { position:absolute; top:0; left:0; margin:0; }
.zone:not([data-label*="Hand"]) .card-stack .card-wrapper { position:absolute; top:50%; transform: translateY(-50%); }
.zone:not([data-label*="Hand"]) .card-stack .card-wrapper img { top:0; left:0; }

.zone img { position: static; width:78px; height:112px; object-fit: cover; border-radius:4px; cursor:pointer; box-shadow:0 2px 8px #0002; border:2px solid #e0e0e0; background:#fff; transition: box-shadow 0.2s, border-color 0.2s; margin-left:0 !important; margin-right:0 !important; box-sizing: border-box; display: block; }

.zone img:hover { box-shadow: 0 0 0 3px #ff980099; border-color: #ff9800; z-index: 100; }

/* Remover button */
.remove-card-btn { position:absolute; top:2px; right:2px; width:20px; height:20px; background: rgba(34,34,34,0.85); color:#fff; border:none; border-radius:50%; font-size:15px; font-weight:bold; line-height:20px; text-align:center; cursor:pointer; opacity:0; transition: opacity .18s; z-index:200; padding:0; display:flex; align-items:center; justify-content:center; pointer-events:auto; }
.zone:hover .remove-card-btn, .zone .remove-card-btn:focus { opacity:1; }

/* Draggable card wrapper styles */
.card-wrapper { position: relative; overflow: visible; }
.card-wrapper[draggable="true"] { cursor: grab; }
.card-wrapper[draggable="true"]:active { cursor: grabbing; }
/* Draw highlight exactly at wrapper edge (matches image outer edge via border-box) */
.card-wrapper[draggable="true"]::after { content:''; position:absolute; inset:0; border:2px solid #ff9800; border-radius:4px; pointer-events:none; box-sizing:border-box; z-index: 150; }
.card-wrapper[draggable="true"]:active::after { border-width:3px; inset:0; z-index: 150; }

/* Search and Save bars */
.search-bar, .save-bar { background:#f5f6fa; border-radius:8px; box-shadow:0 2px 8px #0001; padding:16px 18px; margin-bottom:8px; display:flex; align-items:center; gap:12px; border:1.5px solid #e0e0e0; justify-content:center; }
.search-bar input, .save-bar input { background:#fff; color:#222; border:1.5px solid #2196f3; border-radius:6px; padding:8px 14px; font-size:1rem; outline:none; transition: border-color .2s; width:100%; }
.search-bar input:focus, .save-bar input:focus { border-color:#ff9800; }
/* Updated: solid buttons, no gradients; search = blue, save = green */
.search-bar button { background:#2d8cff; color:#fff; border:none; border-radius:8px; font-size:1rem; font-weight:700; padding:10px 22px; cursor:pointer; box-shadow:0 2px 8px #0001; transition: background .18s, box-shadow .18s, transform .08s; }
.save-bar button   { background:#2ecc40; color:#fff; border:none; border-radius:8px; font-size:1rem; font-weight:700; padding:10px 22px; cursor:pointer; box-shadow:0 2px 8px #0001; transition: background .18s, box-shadow .18s, transform .08s; }
.search-bar button:hover { background:#2196f3; box-shadow:0 4px 16px rgba(33,150,243,.35); }
.save-bar button:hover   { background:#29b34a; box-shadow:0 4px 16px rgba(41,179,74,.35); }
.search-bar button:active, .save-bar button:active { transform: translateY(1px); }
.search-bar button:focus-visible, .save-bar button:focus-visible { outline: 3px solid #ff9800; outline-offset: 2px; }
#searchResults { margin-bottom:28px; text-align:center; color:#2196f3; font-size:1.08rem; }

/* Zones: drag-over feedback */
.zone.drag-over { border-color:#ff9800; box-shadow: 0 0 0 3px rgba(255,152,0,0.35) inset, 0 0 0 3px rgba(255,152,0,0.25); }

/* Flash highlight when focusing a zone from local search */
.zone.zone-flash { box-shadow: 0 0 0 4px rgba(255,152,0,0.45), 0 0 0 8px rgba(255,152,0,0.20); border-color:#ff9800; }

/* Overlays (modals) */
#boardSearchModal, #cardSearchModal, #zoneCardsModal { display:none; position:fixed; z-index:1100; top:0; left:0; width:100vw; height:100vh; background: rgba(0,0,0,0.7); align-items:center; justify-content:center; backdrop-filter: blur(2px); }

/* Modal close button - consistent styling */
.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #0b1220;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  font-size: 20px;
  line-height: 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  transition: background .18s, border-color .18s, box-shadow .18s, transform .08s;
}
.modal-close-btn:hover { background:#0d1526; border-color:#2d8cff; box-shadow:0 6px 18px rgba(45,140,255,.20); }
.modal-close-btn:active { transform: translateY(1px); }
.modal-close-btn:focus-visible { outline: 3px solid #ff9800; outline-offset: 2px; }

/* =============================
   Board Search Modal - Base Styles (restored)
   ============================= */
.board-search-modal-inner {
  background:#111827;
  padding:24px 20px;
  border-radius:14px;
  min-width:360px;
  max-width:640px;
  width:min(640px, 92vw);
  max-height:80vh;
  overflow:hidden; /* header fixed, results scroll */
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  border:1px solid #1f2937;
  box-shadow:0 20px 50px rgba(0,0,0,.45);
}
.board-search-modal-inner .modal-title {
  width:100%; color:#e5e7eb; font-size:1.15rem; font-weight:700; letter-spacing:.3px; margin:2px 0 12px 0; text-align:left;
}
.board-search-modal-inner .modal-hint {
  width:100%; color:#9ca3af; font-size:.9rem; margin:-6px 0 10px 0; text-align:left; border-bottom: 1px solid #1f2937; padding-bottom: 8px;
}
.board-search-modal-inner input {
  box-sizing: border-box;
  width: calc(100% - 28px);
  margin: 0 14px 12px 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  background: #0b1220;
  color: #e5e7eb;
  outline: none;
  box-shadow: 0 0 0 1px #1f2937 inset;
  border: 1.5px solid #2d8cff;
  transition: border-color .2s, box-shadow .2s;
  /* keep the icon from the polish */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; padding-left: 38px;
}
.board-search-modal-inner input:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.25); }
#boardSearchResults {
  width:100%;
  min-height:32px;
  color:#fff;
  display:flex;
  flex-direction:column;
  gap:10px;
  flex:1 1 auto;
  overflow:auto;
  max-height: calc(80vh - 180px);
  padding-right:4px;
  padding-left: 14px;
  padding-right: 14px;
}

/* Result card */
.board-result-card { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:10px 12px; background:#0b1220; border:1px solid #1f2937; border-radius:10px; box-shadow:0 2px 10px rgba(0,0,0,.25); cursor:pointer; transition: border-color .18s, box-shadow .18s, transform .08s, background .18s; }
.board-result-card:hover { border-color:#2d8cff; box-shadow:0 6px 18px rgba(45,140,255,.20); background:#0d1526; }
.board-result-card:active { transform: translateY(1px); }
.board-result-card:focus-visible { outline: 3px solid rgba(255,152,0,.45); outline-offset: 2px; }
.board-result-name { color:#e5e7eb; font-weight:600; font-size:1rem; flex:1 1 auto; text-align:left; }
.board-result-mini { display:grid; grid-template-columns: repeat(7, 10px); grid-template-rows: 10px repeat(5, 10px) 10px; gap:1px; width:77px; height:77px; background:#0f172a; border:1px solid #1f2937; border-radius:4px; overflow:hidden; }
/* individual cells */
.board-mini-cell { width:10px; height:10px; background:#111827; border-radius:2px; overflow:hidden; box-shadow: inset 0 0 0 1px #1f2937; }
/* top/bottom spanning hand rows */
.board-mini-span { background:#111827; border-radius:2px; overflow:hidden; box-shadow: inset 0 0 0 1px #1f2937; }
.board-result-mini img { width:100%; height:100%; object-fit:cover; display:block; border-radius:2px; }
/* Empty text */
#boardSearchResults .empty { color:#aab4c3; font-size:.95rem; padding:8px 2px; }

/* Consolidate mini-board blank + emz styles */
.board-mini-blank { background:#0f172a !important; box-shadow: inset 0 0 0 1px #374151 !important; opacity: 1 !important; }
.board-mini-emz { background: #111827; box-shadow: inset 0 0 0 1px #1f2937; opacity: 1; }
.board-mini-span img { width: 8px !important; height: 10px !important; object-fit: contain !important; display:block; margin: 0 auto; border-radius: 1.5px; }

/* Footer (shared across pages) */
footer { width:100vw; background:#222; color:#b3c7e6; text-align:center; padding:18px 0 10px 0; font-size:1rem; letter-spacing:1px; margin-top:32px; box-shadow:0 -2px 12px #0002; }
.board-container { display:flex; flex-direction:column; align-items:center; }
.zone .zone-label { z-index: 1; }
.zone .card-stack, .zone .card-wrapper, .zone img { z-index: 5; }

/* ============================= */
/* Endboards page: two-column UI */
/* ============================= */
.container.endboards-shell {
  max-width: 1400px; /* keep a sensible cap */
  width: calc(100% - 48px); /* consistent 24px side gutters like other pages */
  margin-left: auto;
  margin-right: auto;
}
.endboards-layout { display:grid; grid-template-columns: max-content 420px; justify-content: center; gap:24px; align-items:start; overflow:visible; }
.board-column { min-width: 0; }
.side-panels { width:100%; max-width:100%; display:flex; flex-direction:column; gap:16px; position:sticky; top:80px; align-self:start; }
.side-panels .panel { background:#fff; border:1px solid #d9e1e8; border-radius:10px; padding:16px; box-shadow:0 2px 4px -2px rgba(31,41,55,.15),0 1px 3px rgba(31,41,55,.08); position:relative; overflow:visible; }
.side-panels .panel h2 { margin:0 0 12px 0; font-size:1.05rem; letter-spacing:.5px; color:#102a43; font-weight:600; }
.side-panels .panel .search-bar, .side-panels .panel .save-bar { margin:0; padding: 12px 14px; border-radius: 8px; }
.side-panels .panel .search-bar input, .side-panels .panel .save-bar input { font-size: 0.98rem; background:#fff; color:#222; border:1.5px solid #2196f3; border-radius:6px; padding:8px 14px; font-size:1rem; outline:none; transition: border-color .2s; width:100%; }
.side-panels #saveStatus { display:block; font-size:.8rem; color:#2f6f3b; margin-top:8px; }

.drag-hint { margin-top: 6px; color: #6b7280; font-size: 12px; }

@media (max-width: 1320px){
  .endboards-layout{ display:flex; flex-direction:column; flex-wrap:nowrap; align-items:stretch; gap:20px; }
  .board-column, .side-panels { max-width:100%; }
  .side-panels { position: static; }
}
@media (max-width: 800px){
  .board { grid-template-columns: repeat(7, minmax(64px, 1fr)); grid-template-rows: repeat(7, minmax(96px, auto)); }
}

/* Align board content left and match header spacing */
.board-container { display:flex; flex-direction:column; align-items:center; }
.board-column .board-container { align-items:flex-start; }
.board-title { margin-bottom:12px; }

/* Mini-board: blank middle-row cells blend with background */
.board-mini-blank { background:#0f172a !important; box-shadow:none !important; opacity: 1 !important; }
/* Mini-board: hand rows show a tiny centered thumbnail, not full-width */
.board-mini-span img { width: 8px !important; height: 10px !important; object-fit: contain !important; display:block; margin: 0 auto; border-radius: 1.5px; }

/* Blank cells in mini-board (represent empty zones on main board) */
.board-mini-blank { background: repeating-linear-gradient(45deg, #0f172a, #0f172a 3px, #111827 3px, #111827 6px); opacity: .6; box-shadow: inset 0 0 0 1px #374151; }

/* Visible EMZ in mini-board */
.board-mini-emz { background: #111827; box-shadow: inset 0 0 0 1px #1f2937; opacity: 1; }

/* =============================
   Card Search Modal (per-zone quick search) - Base Styles
   ============================= */
.card-search-modal-inner {
  background:#111827;
  padding:20px;
  border-radius:14px;
  min-width:360px;
  max-width:720px;
  width:min(680px, 92vw);
  max-height:80vh;
  overflow:hidden; /* header fixed, results scroll */
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  border:1px solid #1f2937;
  box-shadow:0 20px 50px rgba(0,0,0,.45);
}
#cardSearchInput {
  width:100%; padding:10px 12px; margin:0 0 12px 0; border-radius:8px; border:none; font-size:16px; background:#0b1220; color:#e5e7eb; outline:none; box-shadow:0 0 0 1px #1f2937 inset; border:1.5px solid #2d8cff; transition: border-color .2s, box-shadow .2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:10px center; padding-left:38px;
}
#cardSearchInput:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.25); }
#cardSearchResults { flex:1 1 auto; overflow:auto; min-height:140px; padding-right:4px; }
#cardSearchResults::-webkit-scrollbar { width: 10px; height: 10px; }
#cardSearchResults::-webkit-scrollbar-track { background: #0b1220; border-radius: 8px; }
#cardSearchResults::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 8px; border: 2px solid #0b1220; }
#cardSearchResults::-webkit-scrollbar-thumb:hover { background: #2a3446; }

/* =============================
   Zone Cards Modal (view/manage cards in a zone) - Base Styles
   ============================= */
.zone-cards-modal-inner {
  background:#111827;
  padding:16px 16px 12px 16px;
  border-radius:14px;
  min-width:480px;
  max-width:780px;
  width:min(740px, 96vw);
  max-height:84vh;
  overflow:hidden;
  position:relative;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  border:1px solid #1f2937;
  box-shadow:0 20px 50px rgba(0,0,0,.45);
}
.zone-modal-topbar { display:flex; align-items:center; justify-content:space-between; padding:2px 6px 10px 6px; }
.zone-modal-title { color:#e5e7eb; font-size:1.05rem; font-weight:700; letter-spacing:.3px; }

.zone-modal-actions { padding:8px 6px 10px 6px; display:flex; flex-direction:column; gap:8px; border-top:1px solid #1f2937; border-bottom:1px solid #1f2937; }
.zone-modal-search-wrap { display:flex; align-items:center; gap:8px; }
/* Fix: prevent overextension of zone modal search inputs */
.zone-modal-search, .zone-modal-add-search { box-sizing: border-box !important; max-width:100% !important; }
.zone-modal-search {
  width:100%;
  padding:8px 12px;
  border-radius:8px;
  border:none;
  font-size:15px;
  background:#0b1220;
  color:#e5e7eb;
  outline:none;
  box-shadow:0 0 0 1px #1f2937 inset;
  border:1.5px solid #2d8cff;
  transition: border-color .2s, box-shadow .2s;
  /* keep the icon from the polish */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:10px center; padding-left:36px;
}
.zone-modal-search:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.25); }
.zone-modal-add-search {
  flex:1 1 auto; padding:8px 12px; border-radius:8px; border:none; font-size:15px; background:#0b1220; color:#e5e7eb; outline:none; box-shadow:0 0 0 1px #1f2937 inset; border:1.5px solid #2d8cff; transition: border-color .2s, box-shadow .2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23e5e7eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:10px center; padding-left:36px;
}
.zone-modal-add-search:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.25); }
.zone-modal-add-btn { width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center; background:#2d8cff; color:#fff; border:none; border-radius:8px; cursor:pointer; box-shadow:0 2px 8px #0003; transition: background .18s, box-shadow .18s, transform .08s; }
.zone-modal-add-btn:hover { background:#2196f3; box-shadow:0 4px 16px rgba(33,150,243,.35); }
.zone-modal-add-btn:active { transform: translateY(1px); }

#zoneCardsAddResults { display:flex; flex-direction:column; gap:6px; max-height:180px; overflow:auto; padding-right:4px; }
#zoneCardsAddResults::-webkit-scrollbar { width: 10px; height: 10px; }
#zoneCardsAddResults::-webkit-scrollbar-track { background: #0b1220; border-radius: 8px; }
#zoneCardsAddResults::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 8px; border: 2px solid #0b1220; }
#zoneCardsAddResults::-webkit-scrollbar-thumb:hover { background: #2a3446; }

.zone-modal-content { flex:1 1 auto; margin-top:10px; padding:8px 6px; background:#0b1220; border:1px solid #1f2937; border-radius:10px; overflow:auto; white-space: nowrap; min-height:260px; }
.zone-modal-empty { color:#9ca3af; font-size:.95rem; display:block; padding:10px; text-align:center; }

.zone-modal-filter-row { padding:8px 6px 0 6px; }
.zone-modal-search { width:100%; padding:8px 12px; border-radius:8px; border:none; font-size:15px; background:#0b1220; color:#e5e7eb; outline:none; box-shadow:0 0 0 1px #1f2937 inset; border:1.5px solid #2d8cff; transition: border-color .2s, box-shadow .2s; }
.zone-modal-search:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.25); }

/* Ensure zone search results fill the modal width */
#zoneCardsAddResults .card-search-result {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 10px 12px !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}
#zoneCardsAddResults .card-search-result img {
  width: 40px !important;
  height: 58px !important;
  border-radius: 6px !important;
}
#zoneCardsAddResults .card-search-result span {
  flex: 1 1 auto !important;
  color: #e5e7eb !important;
  font-size: 1rem !important;
}

/* Keep some gutter between modal and window edges on small screens */
#boardSearchModal, #cardSearchModal, #zoneCardsModal {
  padding: 16px; /* viewport gutter */
  box-sizing: border-box;
}

/* Board Search: find boards by card names */
.board-search-by-names {
  margin-top: 10px;
  padding: 12px 14px 10px 14px; /* match the 14px input gutter */
  border-top: 1px solid #1c2538; /* softer than dashed */
}
.board-search-by-names .modal-subtitle { color:#c9d1d9; font-size: .95rem; margin: 2px 0 8px 2px; }
.board-search-names-row {
  display:flex;
  gap:8px;
  align-items: center;
  position: relative;
}
/* Align controls in the Board Search names row */
.board-search-names-row { gap: 10px; align-items: center; }
#boardCardNamesInput { height: 40px; }
.board-search-names-row select,
.board-search-names-row button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
}
.board-search-names-row select { border: 1.5px solid #2d8cff; }

#boardCardNamesInput {
  flex:1 1 auto;
  padding:10px 12px;
  border-radius:8px;
  border:none;
  font-size:15px;
  background:#0b1220;
  color:#e7e7eb;
  outline:none;
  box-shadow:0 0 0 1px #1f2937 inset;
  border:1.5px solid #2d8cff;
  transition: border-color .2s, box-shadow .2s;
  height: 40px;
}
#boardCardIdsMatch {
  background:#0b1220;
  color:#e7e7eb;
  border:1px solid #2d8cff;
  border-radius:8px;
  padding:8px 10px;
  height: 40px;
  line-height: 40px;
}
#boardCardNamesSearchBtn {
  background:#2d8cff;
  color:#fff;
  border:none;
  border-radius:8px;
  padding:8px 12px;
  cursor:pointer;
  height: 40px;
  padding: 0 14px;
}

/* Revert: suggestions in normal flow under the input */
.board-search-by-names, .board-search-names-row { position: static; }
.board-name-suggestions { position: static; top:auto; left:auto; right:auto; z-index:auto; margin-top:6px; display:flex; flex-direction:column; gap:6px; max-height:220px; overflow:auto; }
.board-name-suggestions:empty { display:none; }
.board-name-suggestions:not(:empty) {
  background: #0e1424;
  border: 1px solid #202b40;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  border-radius: 10px;
  padding: 4px;
  max-height: 240px;
  overflow: auto;
}
.board-name-suggestions .name-suggestion {
  padding: 6px 10px;
  color: #d7dee7;
  border-radius: 8px;
  cursor: pointer;
  background:#0c1426;
}
.board-name-suggestions .name-suggestion:hover { background:#0f1b33; }
.board-name-suggestions .name-suggestion + .name-suggestion { border-top: 1px solid #162035; }

/* Chips: make selected cards clearly visible */
/* Override dark background for chips list inside Save Board panel to keep it transparent */
.save-meta .chips:not(:empty) { background: transparent !important; }
.chip {
  /* override to improve contrast */
  background: #15233b;
  border: 1px solid #2d8cff;
  color: #eaf1ff;
  font-weight: 500;
  border-radius: 999px;
}
.chip .chip-name { color: inherit; white-space: nowrap; font-size: .98rem; }
.chip .chip-x {
  background: transparent;
  color: #a7b6d0;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}
.chip .chip-x:hover { background: rgba(45,140,255,0.15); color: #fff; }
.chip .chip-x:focus-visible { outline: 2px solid rgba(255,152,0,.6); outline-offset: 2px; }

/* Gutters for suggestions and chips to align with inputs */
.board-name-suggestions,
#boardSelectedCardChips { margin-left: 14px; margin-right: 14px; }

/* Make chips compact tokens, avoid full-width look */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 0; border: none; background: transparent; }
.chip {
  flex: 0 0 auto; /* never stretch */
  width: auto !important;
  max-width: min(360px, 70%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px; /* tighter */
  background: #15233b;
  border: 1px solid #2d8cff;
  border-radius: 999px;
  color: #eaf1ff;
}
.chip .chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 24px);
}

/* Small spacing before results */
#boardSearchResults { margin-top: 8px; }
/* Tabs in board search modal */
.board-search-modal-inner .tabs { display:inline-flex; gap:8px; background:#0e1424; border:1px solid #1f2937; border-radius:10px; padding:4px; }
.board-search-modal-inner .tab-btn { background:transparent; color:#c9d1d9; border:none; padding:6px 12px; border-radius:8px; cursor:pointer; font-weight:600; font-size:.9rem; }
.board-search-modal-inner .tab-btn.active { background:#2d8cff; color:#fff; }

/* Simple styles for the local board search results list */
#boardLocalCardSearchResults .list-item { display:flex; align-items:center; gap:6px; padding:6px 8px; border-radius:8px; cursor:pointer; border:1px solid transparent; }
#boardLocalCardSearchResults .list-item:hover { background:#f9fafb; border-color:#e6e6e6; }
#boardLocalCardSearchResults .list-item .nm { font-weight:600; color:#111827; }
#boardLocalCardSearchResults .list-item .zl { color:#374151; font-size:.92rem; }

/* Match Save Board pickers to the same list look */
#startingHandSuggestions .list-item,
#opponentCardsSuggestions   .list-item { display:flex; align-items:center; gap:6px; padding:6px 8px; border-radius:8px; cursor:pointer; border:1px solid transparent; }
#startingHandSuggestions .list-item:hover,
#opponentCardsSuggestions   .list-item:hover { background:#f9fafb; border-color:#e6e6e6; }
#startingHandSuggestions .list-item .nm,
#opponentCardsSuggestions   .list-item .nm { font-weight:600; color:#111827; }
#startingHandSuggestions .list-item .zl,
#opponentCardsSuggestions   .list-item .zl { color:#374151; font-size:.92rem; }

/* Save Board inputs and pickers */
.side-panels .panel .save-meta { display:flex; flex-direction:column; gap:10px; margin-top:8px; }
.side-panels .panel .save-meta textarea,
.side-panels .panel .save-meta input[type="text"],
.side-panels .panel .save-meta select { width:100%; padding:10px 12px; border-radius:8px; border:1.5px solid #2196f3; background:#fff; color:#111827; font-size:.98rem; outline:none; transition: border-color .2s, box-shadow .2s; box-shadow: 0 1px 2px rgba(0,0,0,0.04); font-family: inherit; }
.side-panels .panel .save-meta textarea:focus,
.side-panels .panel .save-meta input[type="text"]:focus,
.side-panels .panel .save-meta select:focus { border-color:#ff9800; box-shadow:0 0 0 3px rgba(255,152,0,.18); }
.side-panels .panel .save-meta .row { display:flex; gap:10px; align-items:center; }
.side-panels .panel .save-meta .row select { flex: 1 1 auto; }
.side-panels .panel .save-meta .row label.inline { display:inline-flex; align-items:center; gap:8px; color:#374151; font-size:.95rem; }

/* Meta pickers */
.meta-picker { border-top:1px dashed #e6e6e6; padding-top:10px; }
.meta-picker .modal-subtitle { font-weight:600; color:#0f172a; margin-bottom:6px; }
.meta-picker .board-search-names-row { display:flex; gap:8px; align-items:center; }
.meta-picker select { flex:1 1 auto; height:40px; border:1.5px solid #2196f3; border-radius:8px; }
.meta-picker button { height:40px; background:#2d8cff; color:#fff; border:none; border-radius:8px; padding:0 14px; cursor:pointer; box-shadow:0 2px 8px #0001; transition: background .18s, box-shadow .18s; }
.meta-picker button:hover { background:#2196f3; box-shadow:0 4px 16px rgba(33,150,243,.35); }
.meta-picker .meta-hint { color:#6b7280; font-size:.85rem; margin-top:4px; }

/* Chips under save meta pickers */
#startingHandChips, #opponentCardsChips { margin-top:6px; }

/* Suggestions under Save Board pickers */
#startingHandSuggestions, #opponentCardsSuggestions {
  position: static;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#startingHandSuggestions:empty, #opponentCardsSuggestions:empty { display:none; }
#startingHandSuggestions:not(:empty), #opponentCardsSuggestions:not(:empty) {
  background: #0e1424;
  border: 1px solid #202b40;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  border-radius: 10px;
  padding: 4px;
  max-height: 200px;
  overflow: auto;
}
#startingHandSuggestions .name-suggestion, #opponentCardsSuggestions .name-suggestion {
  padding: 6px 10px;
  color: #d7dee7;
  border-radius: 8px;
  cursor: pointer;
  background:#0c1426;
}
#startingHandSuggestions .name-suggestion:hover, #opponentCardsSuggestions .name-suggestion:hover { background:#0f1b33; }

/* Chips look like tokens, not full-width bars */
.chips { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.chip {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:4px 8px;
  border-radius:999px;
  background:#f3f6ff; /* light token background */
  border:1px solid #c9d8ff;
  color:#102a43;
  box-shadow:0 1px 2px rgba(0,0,0,0.04);
}
body.dark-mode .chip { background:#15233b; border-color:#2d8cff; color:#eaf1ff; }
.chip .chip-thumb { width:20px; height:28px; display:inline-flex; align-items:center; justify-content:center; overflow:hidden; border-radius:4px; box-shadow:0 1px 2px rgba(0,0,0,0.2); }
.chip .chip-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.chip .chip-name { font-size:.92rem; max-width:220px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chip .chip-x { background:transparent; color:#374151; border:none; cursor:pointer; font-size:14px; line-height:1; padding:2px 6px; border-radius:6px; }
.chip .chip-x:hover { background:#e8eefb; }
body.dark-mode .chip .chip-x { color:#a7b6d0; }
body.dark-mode .chip .chip-x:hover { background: rgba(45,140,255,0.15); }

/* Inputs row in Save Board pickers */
.meta-picker .board-search-names-row input { flex:1 1 auto; height:40px; border:1.5px solid #2196f3; border-radius:8px; padding:8px 12px; }
.meta-picker .board-search-names-row button { height:40px; background:#2d8cff; color:#fff; border:none; border-radius:8px; padding:0 14px; cursor:pointer; }
.meta-picker .board-search-names-row button:hover { background:#2196f3; }

/* Overrides: Save Board pickers suggestions should match light panel styling */
#startingHandSuggestions:not(:empty),
#opponentCardsSuggestions:not(:empty) {
  background: #fff;
  border: 1px solid #e6e6e6;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
#startingHandSuggestions .list-item .nm,
#opponentCardsSuggestions .list-item .nm { color: #111827; }
#startingHandSuggestions .list-item .zl,
#opponentCardsSuggestions .list-item .zl { color: #374151; }
#startingHandSuggestions .list-item:hover,
#opponentCardsSuggestions .list-item:hover { background: #f9fafb; border-color: #e6e6e6; }

/* Dark mode: keep dark surface and use light text for contrast */
body.dark-mode #startingHandSuggestions:not(:empty),
body.dark-mode #opponentCardsSuggestions:not(:empty) {
  background: #0e1424;
  border: 1px solid #202b40;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
body.dark-mode #startingHandSuggestions .list-item .nm,
body.dark-mode #opponentCardsSuggestions .list-item .nm { color: #e5e7eb; }
body.dark-mode #startingHandSuggestions .list-item .zl,
body.dark-mode #opponentCardsSuggestions .list-item .zl { color: #9ca3af; }
body.dark-mode #startingHandSuggestions .list-item:hover,
body.dark-mode #opponentCardsSuggestions .list-item:hover { background: #0f1b33; border-color: #1f2937; }

/* Prevent inputs from overflowing panel width */
.side-panels .panel input,
.side-panels .panel textarea,
.side-panels .panel select {
  box-sizing: border-box;
  max-width: 100%;
}
