/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans SC', 'Outfit', system-ui, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1d6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1a6; }

/* ===== Header ===== */
.header {
  background: #fff;
  border-bottom: 1px solid #e5e5e7;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #1d1d1f;
  letter-spacing: -0.5px;
}

.logo-text span { color: #0071e3; }

.logo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #86868b;
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e5e5e7;
  border-radius: 10px;
  padding: 8px 14px;
  width: 240px;
  transition: border-color 0.2s;
}

.search-bar:focus-within { border-color: #0071e3; }

.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  color: #1d1d1f;
  width: 100%;
}

.search-bar input::placeholder { color: #86868b; }

.game-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #86868b;
  background: #f5f5f7;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ===== Main ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.genre-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.genre-pill {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: #1d1d1f;
  background: #fff;
  border: 1px solid #e5e5e7;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.genre-pill:hover { border-color: #1d1d1f; }

.genre-pill.active {
  font-weight: 600;
  color: #fff;
  background: #1d1d1f;
  border-color: #1d1d1f;
}

.result-count {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px;
  color: #86868b;
}

/* ===== Game Grid ===== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ===== Game Card ===== */
.game-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
}

.card-cover {
  aspect-ratio: 4/3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

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

.card-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.5) 100%);
  z-index: 1;
}

.card-cover-title {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
  text-align: center;
  padding: 0 16px;
  line-height: 1.3;
  position: relative;
  z-index: 2;
}

.card-cover-en {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  letter-spacing: 1px;
  position: relative;
  z-index: 2;
}

.badge-fc {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  color: #fff;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  z-index: 3;
}

.play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 4;
}

.game-card:hover .play-overlay { opacity: 1; }

.play-btn-text {
  background: #fff;
  color: #1d1d1f;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-info {
  padding: 12px 14px;
}

.card-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.card-info-name {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: #1d1d1f;
}

.card-info-year {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #86868b;
}

.card-info-tags {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tag-genre {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px;
  color: #86868b;
  background: #f5f5f7;
  padding: 2px 8px;
  border-radius: 4px;
}

.tag-players {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #86868b;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 0;
  color: #86868b;
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }

.empty-text {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
}

/* ===== Manual Load ===== */
.manual-load {
  text-align: center;
  padding: 30px 0 10px;
  color: #86868b;
  font-size: 13px;
}

.manual-load p { margin-bottom: 10px; }

.file-label {
  position: relative;
  cursor: pointer;
}

.file-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.file-btn {
  display: inline-block;
  padding: 8px 18px;
  background: #fff;
  color: #1d1d1f;
  border: 1px solid #e5e5e7;
  border-radius: 10px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  transition: all 0.2s;
}

.file-btn:hover {
  border-color: #0071e3;
  color: #0071e3;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: #fff;
  border-radius: 20px;
  width: 440px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}

.modal-cover {
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.modal-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-cover-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.5) 100%);
  z-index: 1;
}

.modal-cover-title {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}

.modal-cover-en {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
  letter-spacing: 1px;
  position: relative;
  z-index: 2;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.modal-close:hover { background: rgba(0,0,0,0.5); }

.modal-body { padding: 20px 24px; }

.modal-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.modal-tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
}

.modal-tag.fc {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: #0071e3;
  background: rgba(0,113,227,0.08);
}

.modal-tag.default {
  font-family: 'JetBrains Mono', monospace;
  color: #86868b;
  background: #f5f5f7;
}

.modal-desc {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  color: #6e6e73;
  line-height: 1.7;
  margin-bottom: 20px;
}

.modal-play-btn {
  width: 100%;
  padding: 12px 0;
  background: #0071e3;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modal-play-btn:hover { background: #0077ed; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Game Area ===== */
.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.screen {
  width: 512px;
  height: 480px;
  background: #000;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.screen canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.status-bar {
  width: 512px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 12px;
  color: #86868b;
}

.status-text { color: #0071e3; }

.fps-display {
  font-family: 'JetBrains Mono', monospace;
  color: #86868b;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.control-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #0071e3;
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: #0077ed; }

.btn-secondary {
  background: #fff;
  color: #1d1d1f;
  border: 1px solid #e5e5e7;
}

.btn-secondary:hover:not(:disabled) { border-color: #1d1d1f; }

.btn-back {
  background: #f5f5f7;
  color: #86868b;
}

.btn-back:hover { background: #e5e5e7; color: #1d1d1f; }

/* ===== Keymap ===== */
.keymap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  padding: 16px 20px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 512px;
}

.keymap-title {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 12px;
  text-align: center;
}

.keymap-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: center;
}

.keymap-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #86868b;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  background: #f5f5f7;
  border: 1px solid #e5e5e7;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #1d1d1f;
  min-width: 24px;
  text-align: center;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 16px 0;
  border-top: 1px solid #e5e5e7;
  font-size: 12px;
  color: #86868b;
}

.footer a {
  color: #0071e3;
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  color: #fff;
  font-size: 14px;
  border-radius: 8px;
}

.loading-overlay .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .screen {
    width: 100%;
    height: auto;
    aspect-ratio: 256 / 240;
  }
  .status-bar { width: 100%; }
  .search-bar { width: 160px; }
}
