:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #232736;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00b894;
  --orange: #fdcb6e;
  --red: #e17055;
  --text: #dfe6e9;
  --text2: #8395a7;
  --border: #2d3142;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header { text-align: center; margin-bottom: 2rem; }
header h1 { font-size: 2rem; color: #fff; letter-spacing: -0.5px; }
.subtitle { color: var(--text2); margin-top: 0.4rem; font-size: 0.95rem; }

.search-box {
  max-width: 500px;
  margin: 0 auto 2rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

#appIdInput {
  flex: 1;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

#appIdInput:focus { border-color: var(--accent); }
#appIdInput::placeholder { color: var(--text2); }

#fetchBtn {
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#fetchBtn:hover { background: var(--accent2); }

.error {
  background: rgba(225, 112, 85, 0.12);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.loading { text-align: center; padding: 3rem; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.game-card {
  display: flex;
  gap: 1.2rem;
  background: var(--bg2);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  align-items: center;
}

.game-card img {
  width: 185px;
  height: 87px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.game-info h2 { color: #fff; font-size: 1.15rem; margin-bottom: 0.3rem; }
.game-info p { color: var(--text2); font-size: 0.85rem; margin-bottom: 0.5rem; }

.game-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-count { background: rgba(0, 184, 148, 0.2); color: var(--green); }
.badge-source { background: rgba(108, 92, 231, 0.2); color: var(--accent2); }

.actions-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-primary {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: #00a884; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.file-section { margin-bottom: 1.5rem; }

.file-section-title {
  color: var(--text2);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.file-badge {
  background: var(--bg3);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
  font-size: 0.7rem;
  margin-left: 0.3rem;
}

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.4rem;
  transition: border-color 0.2s;
}

.file-row:hover { border-color: var(--accent); }
.file-row.file-type-manifest { border-left: 3px solid var(--green); }
.file-row.file-type-lua { border-left: 3px solid var(--orange); }
.file-row.file-type-vdf { border-left: 3px solid var(--accent); }
.file-row.file-type-json { border-left: 3px solid var(--text2); }

.file-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.file-icon { font-size: 1.2rem; flex-shrink: 0; }

.file-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  color: var(--text2);
  font-size: 0.75rem;
}

.file-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.btn-dl, .btn-github {
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-dl {
  background: var(--green);
  color: #fff;
}

.btn-dl:hover { background: #00a884; }

.btn-github {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}

.btn-github:hover { color: #fff; border-color: var(--text2); }

.welcome {
  text-align: center;
  padding: 3rem 1rem;
}

.welcome-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.welcome h2 { color: #fff; font-size: 1.5rem; margin-bottom: 0.5rem; }
.welcome > p { color: var(--text2); font-size: 0.95rem; }
.welcome-sub { margin-top: 0.3rem; font-size: 0.85rem !important; }

.popular {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  align-items: center;
}

.popular-label { color: var(--text2); font-size: 0.85rem; margin-right: 0.3rem; }

.popular-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.popular-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

footer {
  text-align: center;
  padding: 2rem 0 0;
  color: var(--text2);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  .container { padding: 1rem; }
  header h1 { font-size: 1.5rem; }
  .game-card { flex-direction: column; text-align: center; }
  .game-card img { width: 100%; max-width: 300px; height: auto; }
  .search-row { flex-direction: column; }
  .file-row { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .file-actions { width: 100%; justify-content: flex-end; }
}
