:root {
  --bg: #090a10;
  --panel: #12131c;
  --card: #181926;
  --card-hover: #212335;
  --border: #232536;
  --accent: #f5ba42;
  --text: #ffffff;
  --text-muted: #8b8ea4;
  --radius: 12px;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

/* Game Category Tabs */
.game-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.game-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.game-tab:hover {
  color: #fff;
}

.game-tab.active {
  background: var(--accent);
  color: #111;
  font-weight: 700;
}

.char-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--panel);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.header-search input {
  background-color: var(--panel);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 0.92rem;
  padding: 8px 16px;
  border-radius: 10px;
  width: 260px;
  outline: none;
  transition: border-color 0.15s;
}

.header-search input:focus {
  border-color: var(--accent);
}

/* Main Cards Grid */
.main-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px 40px 32px;
  flex: 1;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

/* Card with Gacha art */
.card {
  position: relative;
  aspect-ratio: 1 / 1.25;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid #d4a047;
  background-color: #12131c;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7), 0 0 16px rgba(244, 192, 85, 0.35);
  border-color: #ffda79;
}

.card-img-wrap {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  transition: transform 0.25s ease;
}

.card:hover .card-img {
  transform: scale(1.06);
}

/* Clean SVG Icon placeholder when no image */
.card-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1e202f 0%, #0e0f17 100%);
}

.card-fallback svg {
  width: 44px;
  height: 44px;
  color: #3b3e58;
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.4) 35%, transparent 65%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 10px 8px;
  pointer-events: none;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 95%;
  text-align: center;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.card-id {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(245, 186, 66, 0.4);
}

.card-bodytype {
  font-size: 0.62rem;
  font-weight: 600;
  color: #c0c3d8;
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Footer Disclaimer */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  text-align: center;
  background: #090a10;
}

.footer-disclaimer {
  font-size: 0.74rem;
  color: #5d6175;
  letter-spacing: 0.2px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.88);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 1200px;
  height: 88vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: #151624;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.title-group h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.skin-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.skin-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.skin-btn:hover {
  color: #fff;
}

.skin-btn.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-download-all {
  background: var(--accent);
  color: #111;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-download-all:hover {
  opacity: 0.9;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.btn-close:hover {
  color: #fff;
}

/* Modal Content: Canvas + Sidebar */
.modal-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.canvas-box {
  flex: 1.5;
  background: radial-gradient(circle at center, #1b1c2b 0%, #0d0e15 100%);
  position: relative;
}

.canvas-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  color: #fff;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.canvas-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

.tool-btn {
  background: rgba(24, 25, 38, 0.8);
  border: 1px solid var(--border);
  color: #ddd;
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.tool-btn:hover {
  color: #fff;
  border-color: #444;
}

/* Download Sidebar */
.download-sidebar {
  flex: 0.9;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.download-sidebar h3 {
  font-size: 0.92rem;
  color: #fff;
  font-weight: 700;
}

.files-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.files-group-title .count {
  background: var(--card);
  padding: 2px 6px;
  border-radius: 6px;
}

.file-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.file-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.file-item-dl {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  padding: 4px 8px;
  background: rgba(245, 186, 66, 0.1);
  border-radius: 6px;
  white-space: nowrap;
}

.file-item-dl:hover {
  background: var(--accent);
  color: #111;
}

.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
