:root {
  --bg-color: #222;
  --card-list-color: #494949;
  --text-color: white;
  --background-filter: #303030;
  --pokemon-red: #FF0000;
  --pokemon-blue: #0075BE;
  --pokemon-yellow: #FFCC00;
  --pokemon-white: white;
  --pokemon-black: black;
  
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: #333;
  }
  .container {
    max-width: 1400px;
    margin: 95px auto;
    padding: 20px;
  }
  .deck-builder {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-top: 30px;
  }
  .deck-preview .close-deck{
    display: none;
  }
  .card-search {
    background: var(--card-list-color);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  }
  .deck-preview {
    background: var(--card-list-color);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    position: sticky;
    top: 120px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }
  .search-filters {
    background: var(--background-filter);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
  }
  .search-input input,
  .filter-select select {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 15px;
    font-size: 14px;
    transition: all 0.3s ease;
    width: -webkit-fill-available;
  }
  .search-input input:focus,
  .filter-select select:focus {
    border-color: #ee1515;
    outline: none;
    box-shadow: 0 0 0 3px rgba(238,21,21,0.1);
  }
  .filter-buttons {
    margin-top: 15px;
  }
  .filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
  }
  .filter-btn {
    padding: 8px 16px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
  }
  .filter-btn:hover {
    border-color: #ee1515;
    background: #fff5f5;
  }
  .filter-btn.active {
    background: var(--pokemon-yellow);
    color: black;
    border-color: var(--pokemon-yellow);
  }
  .card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    justify-items: center;
  }
  .card {
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    border: none;
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
    cursor: auto;
  }
  .card img {
    border-radius: 15px 15px 0 0;
    width: 100%;
    height: auto;
    aspect-ratio: 2.5/3.5;
    object-fit: cover;
    display: block;
  }
  .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  }
  .card-details {
    padding: 15px;
    display: none;
  }
  .deck-info {
    background: var(--background-filter);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
  }
  .deck-element select,
  .deck-name input,
  .deck-type select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 15px;
    font-size: 14px;
    transition: all 0.3s ease;
  }
  .deck-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 20px 0;
  }
  .stat-box {
    background: #ffffff;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.04);
  }
  .deck-list {
    background: var(--background-filter);
    border-radius: 15px;
    padding: 15px;
    margin-top: 20px;
  }
  .deck-card {
    background: var(--card-list-color);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    justify-content: space-between;
    color: var(--text-color);
  }
  .deck-card img {
    width: 60px;
    height: 84px;
    object-fit: cover;
    margin-right: 10px;
  }
  .count-btn {
    background: #ee1515;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
  }
  .count-btn:hover {
    background: #cc0000;
    transform: scale(1.05);
  }
  .save-deck {
    background: #ee1515;
    color: white;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 25px;
    transition: all 0.3s ease;
  }
  .save-deck:hover {
    background: #cc0000;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(238,21,21,0.2);
  }
  .save-deck:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
  .card-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
  }
  .card-modal.active {
    display: flex;
  }
  .modal-content-card {
    position: relative;
    max-width: 80%;
    max-height: 90vh;
  }
  .modal-content-card img {
    max-height: 90vh;
    width: auto;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
  }
  .close-modal {
    position: absolute;
    top: -40px;
    right: -40px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 10px;
    font-size: xx-large; 
  }
  .close-modal:hover {
    color: #ee1515;
  }
  .card-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #ff4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
  }
  @media (max-width: 768px) {
    .deck-preview {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100vh;
      z-index: 100;
      display: none;
      overflow-y: auto;
      background: #ffffff; /* Ensure background is white */
      margin: 0; /* Remove any margins */
      border-radius: 0; /* Remove border radius when fullscreen */
      padding: 15px;
    }

    .deck-preview.show {
      display: block;
    }

    .deck-info {
      margin-top: 40px; /* Give space for close button */
      margin-bottom: 15px;
    }

    .deck-list {
      max-height: calc(100vh - 350px); /* Adjust based on header height */
      overflow-y: auto;
    }

    .deck-preview .close-deck {
      position: fixed; /* Keep button always visible */
      top: 15px;
      right: 15px;
      background: #ee1515;
      color: white;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      z-index: 101;
      box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
  }
  @media (max-width: 480px) {
    .card-grid {
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 10px;
    }
  }

  @media (max-width: 480px) {
    .deck-stats {
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
    }
    
    .stat-box {
      padding: 10px;
      font-size: 14px;
    }
  }
  @media (max-width: 768px) {
    .modal-content-card {
      max-width: 95%;
    }
    
    .modal-content-card img {
      max-width: 100%;
      height: auto;
    }
    
    .close-modal {
      top: -30px;
      right: 0;
    }
    .deck-builder{
      display: inline;
    }
  }
  @media (max-width: 480px) {
    .deck-card {
      padding: 8px;
    }
    
    .deck-card img {
      width: 45px;
      height: 63px;
    }
    
    .count-btn {
      padding: 6px 10px;
      font-size: 12px;
    }
  }
  @media (max-width: 768px) {
    .container {
      padding: 35px 10px;
    }
    
    .card-search,
    .deck-preview {
      padding: 47px;
    }
  }
  .fab-deck {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ee1515;
    color: white;
    border: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 99;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .fab-deck:hover {
    transform: scale(1.1);
    background: #cc0000;
  }

  @media (max-width: 768px) {
    .fab-deck {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .deck-preview {
      position: fixed;
      top: 80px;
      left: 0;
      width: 100%;
      height: 90vh;
      z-index: 100;
      display: none;
      overflow-y: auto;
      background-color: var(--background-filter);
    }
    
    .deck-preview.show {
      display: block;
      width: -webkit-fill-available;
    }

    .deck-preview .close-deck {
      position: absolute;
      top: 10px;
      right: 10px;
      background: none;
      border: none;
      color: #333;
      font-size: 24px;
      cursor: pointer;
      background-color: #ee1515;
    }
  }

  .card:active {
    transform: scale(0.95); 
  }