body {
  font-family: Arial, sans-serif;
  background: #f4f4f4;
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
}

h1 {
  text-align: center;
  margin: 0 0 4px;
  font-size: 1em;
}

#app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sticky-header {
  flex-shrink: 0;
  background: #f4f4f4;
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
}

#deck-panel {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-left: 2px solid #ddd;
  padding: 8px;
  overflow-y: auto;
  height: 100vh;
  box-sizing: border-box;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 2px;
  padding: 4px;
  overflow-y: auto;
  flex: 1;
}

/* --------------------------------------------------
   Mobile portrait optimizations
   -------------------------------------------------- */
@media (max-width: 600px) and (orientation: portrait) {
  #app-wrapper {
    flex-direction: column;
  }

  #deck-panel {
    width: 100%;
    height: auto;
    max-height: 35vh;
    border-left: none;
    border-top: 2px solid #ddd;
    order: 2;
    overflow-y: auto;
  }

  #main-panel {
    order: 1;
    flex: 1;
    min-height: 0;
  }

  #sticky-header {
    padding: 4px 6px;
  }

  #filter-row input,
  #filter-row select {
    padding: 3px 5px;
    font-size: 0.78em;
    width: 70px;
  }

  #filter-row select {
    width: auto;
  }

  .filter-toggle {
    padding: 3px 7px;
    font-size: 0.78em;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }

  #deck-panel h2 {
    font-size: 0.95em;
  }

  .deck-entry {
    font-size: 0.75em;
    padding: 2px 4px;
  }

  .deck-entry img {
    width: 30px;
  }
}

.card img {
  width: 100%;
  height: auto;
  display: block;
}

.card h2 {
  margin: 10px 0 5px;
}

.card .set {
  font-size: 0.9em;
  color: #666;
}

.stats, .abilities {
  margin-top: 10px;
  padding: 10px;
  background: #fafafa;
  border-radius: 6px;
  font-size: 0.9em;
}

.card {
  position: relative;
  overflow: visible;
  background: none;
  border-radius: 6px;
  padding: 0;
  box-shadow: none;
  margin: 0;
}

.card img {
  width: 100%;
  height: auto;
  transition: opacity 0.2s ease;
  cursor: pointer;
  position: relative;
  z-index: 1;
  border-radius: 4px;
}

.card img:hover {
  opacity: 0.8;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 5px; /* or even 0 if you want images touching */
}


.card img {
  width: 100%;
  height: auto;
  display: block;
}

.card h2 {
  margin: 10px 0 5px;
}

.card .set {
  font-size: 0.9em;
  color: #666;
}

.stats, .abilities {
  margin-top: 10px;
  padding: 10px;
  background: #fafafa;
  border-radius: 6px;
  font-size: 0.9em;
}
.search-bar {
  display: block;
  width: 60%;
  margin: 0 auto 30px auto;
  padding: 12px 16px;
  font-size: 1.1em;
  border-radius: 8px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.card {
  position: relative;
  overflow: visible;
  background: none;
  border-radius: 10px;
  padding: 0;
  box-shadow: none;
  margin: 0;
}

.card img {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
  position: relative;
  z-index: 1;
  border-radius: 4px;
}

/* Modal background */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  padding-top: 40px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.85);
}

/* Modal image */
.modal-content {
  margin: auto;
  display: block;
  max-width: 80%;
  max-height: 80%;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255,255,255,0.3);
  animation: zoomIn 0.25s ease;
}

/* Close button */
.close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}

/* Zoom animation */
@keyframes zoomIn {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.card img:hover {
  opacity: 0.8;
}

.role-badge {
  font-size: 0.7em;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.role-frontline {
  background: #4a90e2;
  color: #fff;
}

.role-reserve {
  background: #e2a44a;
  color: #fff;
}

#expand-deck {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  padding: 2px 6px;
  color: #666;
  line-height: 1;
}

#expand-deck:hover {
  background: #f0f0f0;
  border-color: #4a90e2;
  color: #4a90e2;
}

#deck-panel.expanded {
  width: 500px;
}

#deck-panel.expanded .deck-entry img {
  width: 60px;
}

#deck-panel.expanded .deck-entry {
  font-size: 1em;
}

#toggle-filters-btn {
  padding: 4px 10px;
  font-size: 0.82em;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

#toggle-filters-btn:hover {
  border-color: #4a90e2;
  color: #4a90e2;
}

#toggle-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.filter-toggle {
  padding: 4px 10px;
  font-size: 0.85em;
  border: 2px solid #aaa;
  border-radius: 20px;
  background: transparent;
  color: #444;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.filter-toggle:hover {
  border-color: #4a90e2;
  color: #4a90e2;
}

.filter-toggle.active {
  background: #4a90e2;
  border-color: #4a90e2;
  color: #fff;
}

#filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

#filter-row input, #filter-row select {
  padding: 4px 6px;
  font-size: 0.82em;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 90px;
}

#filter-row select {
  width: auto;
}

#deck-panel h2 {
  margin: 0 0 10px;
  font-size: 1.1em;
  text-align: center;
}

#clear-deck {
  flex: 1;
  padding: 6px;
  background: #e55;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

#clear-deck:hover {
  background: #c33;
}

#deck-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.8em;
}

.deck-entry img {
  width: 40px;
  height: auto;
  border-radius: 4px;
  flex-shrink: 0;
}

.deck-entry-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-entry-count {
  font-weight: bold;
  color: #444;
  min-width: 20px;
  text-align: center;
}

.deck-entry-remove {
  cursor: pointer;
  color: #e55;
  font-weight: bold;
  font-size: 1em;
  line-height: 1;
  padding: 0 2px;
}

.card.selected img {
  outline: 3px solid #4a90e2;
  border-radius: 4px;
}
#export-deck {
  flex: 1;
  padding: 6px;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

#export-deck:hover {
  background: #357abd;
}

#deck-export-text {
  width: 100%;
  height: 150px;
  margin-top: 8px;
  padding: 6px;
  font-size: 0.8em;
  border: 1px solid #ddd;
  border-radius: 6px;
  resize: vertical;
  box-sizing: border-box;
  background: #f9f9f9;
  color: #333;
}
#copy-deck {
  flex: 1;
  padding: 6px;
  background: #6ab04c;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

#import-deck {
  flex: 1;
  padding: 6px;
  background: #7b68ee;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

#import-deck:hover {
  background: #6a5acd;
}

#deck-import-text {
  width: 100%;
  height: 100px;
  margin-top: 6px;
  padding: 6px;
  font-size: 0.8em;
  border: 1px solid #7b68ee;
  border-radius: 6px;
  resize: vertical;
  box-sizing: border-box;
  background: #f9f9f9;
  color: #333;
  display: none;
}

#import-confirm {
  display: none;
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  background: #6ab04c;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

#import-confirm:hover {
  background: #519a35;
}

#copy-deck:hover {
  background: #519a35;
}