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

:root {
  --gold: #d4a843;
  --gold-light: #f0d078;
  --bg-dark: #0a0a12;
  --bg-card: #14141f;
  --bg-card-hover: #1a1a2e;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #2a6aff;
  --border: #2a2a3a;
}

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* Header */
.header {
  text-align: center;
  padding: 48px 20px 32px;
  background: linear-gradient(180deg, #12122a 0%, var(--bg-dark) 100%);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-size: 28px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(212, 168, 67, 0.3);
}

.header p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 8px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* ROM Grid */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px;
}

.rom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.rom-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.rom-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 8px 32px rgba(212, 168, 67, 0.15);
}

.rom-card .cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #1a1a2e;
}

.rom-card .info {
  padding: 14px 16px 16px;
}

.rom-card .title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.rom-card .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.rom-card .version {
  background: rgba(212, 168, 67, 0.15);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 12px;
}

.rom-card .changelog {
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 0 12px;
  min-height: 18px;
}

.btn-download {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--gold) 0%, #b8922e 100%);
  color: #000;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-download:hover { opacity: 0.85; }

.btn-download.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Extra Downloads Section */
.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.btn-alt {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-alt:hover { opacity: 0.85; }

.btn-green {
  background: #2ea043;
}

/* Donate Section */
.donate-qr-row {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.donate-qr-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.donate-qr-item img {
  width: 180px;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.donate-qr-item span {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

/* Emulator Section */
.emu-list {
  list-style: none;
  font-size: 14px;
}

.emu-list li {
  padding: 4px 0;
  color: var(--text-dim);
}

.emu-list li strong {
  color: var(--text);
}

/* Footer */
.footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

.qq-link {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 20px;
  background: rgba(42, 106, 255, 0.1);
  border: 1px solid rgba(42, 106, 255, 0.3);
  border-radius: 8px;
  color: var(--accent);
  font-size: 14px;
  text-decoration: none;
}

/* Version History */
.btn-history {
  display: block;
  width: 100%;
  padding: 6px;
  margin-top: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-history:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.history-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.history-panel.open {
  max-height: 300px;
  overflow-y: auto;
}

.history-list {
  list-style: none;
  margin-top: 8px;
  padding: 0;
}

.history-list li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 42, 58, 0.5);
  font-size: 12px;
  color: var(--text-dim);
}

.history-list li:last-child {
  border-bottom: none;
}

.history-ver {
  color: var(--gold);
  font-weight: 600;
  margin-right: 6px;
}

.history-date {
  color: #666;
  margin-right: 6px;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, #1a1a2e 25%, #222238 50%, #1a1a2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Error toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #c0392b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Mobile */
@media (max-width: 600px) {
  .header { padding: 32px 16px 24px; }
  .header h1 { font-size: 22px; }
  .rom-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .rom-card .info { padding: 10px 12px 14px; }
  .rom-card .title { font-size: 16px; }
  .section { padding: 18px; }
  .donate-qr-row { gap: 20px; }
  .donate-qr-item img { width: 140px; }
}

@media (max-width: 400px) {
  .rom-grid { grid-template-columns: 1fr; max-width: 280px; margin-left: auto; margin-right: auto; }
}
