:root {
    --primary-color: #3498db;
    --danger-color: #e74c3c;
    --background-color: #f4f4f4;
    --text-color: #333;
    --card-background: #fff;
    --border-color: #ddd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1, h2 {
    color: var(--primary-color);
}

.main-container {
    display: flex;
    gap: 30px;
}

.side-panels {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.side-panels .panel {
  flex: 1;
  overflow: hidden;
  padding: 10px;
}

.panel {
    background-color: var(--card-background);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    max-height: 50vh;
}

.faction-panel {
    flex: 5; /* This will take up 3 parts of the available space */
}

.rarity-panel {
    flex: 3; /* This will take up 2 parts of the available space */
}

.faction-count, .rarity-count {
    display: flex;
    align-items: center;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 3px;
    margin-bottom: 3px;
    transition: all 0.3s ease;
}

.faction-count:hover, .rarity-count:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.faction-icon, .rarity-icon {
    width: 20px;
    height: 20px;
    margin-right: 5px;
    object-fit: contain;
}

.faction-info, .rarity-info {
    flex-grow: 1;
    font-size: 0.8em; /* Slightly reduce font size */
}

main {
    flex: 1;
}

.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn:hover {
    opacity: 0.9;
}

.troop-counter {
    font-size: 18px;
    font-weight: bold;
}

.grid-container {
    background-color: var(--card-background);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 10px;
}

.cell {
    aspect-ratio: 1;
    background-color: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    overflow: hidden; /* Prevent character from overflowing */
}

.cell .character {
    width: 100%;
    height: 100%;
    padding: 5px;
    font-size: 10px;
}


.cell .character .character-name {
    font-size: 12px;
    margin-bottom: 2px;
    font-weight: bold;
    text-align: center;
    word-wrap: break-word;
    justify-content: center;
    align-items: center;
}

.cell .character .character-info {
    font-size: 8px;
}

.cell:hover {
    border-color: var(--primary-color);
}

.faction-count {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 3px;
    margin-bottom: 3px;
    transition: all 0.3s ease;
}

.faction-count:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.character-panel-container {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.filter-container {
    margin-bottom: 20px;
}

#characterSearch {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
}

.filter-group {
    display: flex;
    gap: 10px;
}

.filter-group select {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    background-color: white;
}

.character-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.character {
    width: 100px;
    height: 150px;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}


.character:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.character-name {
    font-weight: bold;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.character-info {
    font-size: 12px;
    text-align: center;
}

.character::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 15%;
    background-color: var(--faction-color);
}

/* Rarity colors */
.character.legendary { background-color: rgba(255, 211, 0, 0.8); /* Brighter Yellow with 80% opacity */ }
.character.epic { background-color: rgba(155, 48, 255, 0.8); /* Bright Purple with 80% opacity */ }
.character.rare { background-color: rgba(50, 205, 50, 0.8); /* Vibrant Green with 80% opacity */ }
.character.common { background-color: rgba(105, 105, 105, 0.8); /* Subtle Gray with 80% opacity */ }


/* Faction colors */
.character.militia::after { --faction-color: #3333FF; /* Softer Blue */ }
.character.infernal::after { --faction-color: #663399; /* Muted Indigo */ }
.character.divine::after { --faction-color: #D4AF37; /* Softer Gold */ }
.character.wildling::after { --faction-color: #228B22; /* Softer Green */ }
.character.hunter::after { --faction-color: #CC3333; /* Muted Red */ }


#saveContainer {
  width: 1200px; /* Adjust as needed */
  height: 800px; /* Adjust as needed */
  background-color: #fff;
}

.save-layout {
  display: flex;
  height: 100%;
}

.save-grid-container {
  flex: 1;
  padding: 10px;
}

#saveGrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 10px;
  height: 100%;
}

/* Styles for faction and rarity counters */
.save-faction-count, .save-rarity-count {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.save-faction-icon, .save-rarity-icon {
  width: 20px;
  height: 20px;
  margin-right: 5px;
}