/* ===== 基础重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}

/* ===== 容器布局 ===== */
.container {
  max-width: 800px;
  width: 100%;
}

/* ===== 标题 ===== */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 28px;
  color: #e94560;
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.subtitle {
  color: #888;
  font-size: 14px;
  margin-top: 4px;
}

/* ===== 游戏画面 ===== */
.screen-wrapper {
  position: relative;
  background: #000;
  border: 3px solid #333;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 480px;
  margin: 0 auto;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.emulator-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.screen-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  color: #666;
  font-size: 16px;
  transition: opacity 0.3s;
}

.screen-placeholder.hidden {
  opacity: 0;
  pointer-events: none;
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

/* ===== 控制面板 ===== */
.controls {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

/* 文件选择 */
.file-label {
  display: inline-block;
  padding: 8px 16px;
  background: #e94560;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.file-label:hover {
  background: #c73a52;
}

.rom-name {
  font-size: 13px;
  color: #888;
}

/* 按钮 */
.buttons button {
  padding: 8px 14px;
  border: 1px solid #444;
  background: #16213e;
  color: #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.buttons button:hover:not(:disabled) {
  background: #0f3460;
  border-color: #e94560;
}

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

.buttons button.active {
  background: #e94560;
  border-color: #e94560;
}

/* 状态 */
.status {
  justify-content: space-between;
  font-size: 13px;
  color: #888;
}

#fpsDisplay {
  font-family: "Consolas", "Courier New", monospace;
  color: #4ecca3;
}

/* ===== 键位说明 ===== */
.keymap {
  margin-top: 20px;
  background: #16213e;
  border-radius: 8px;
  padding: 16px;
}

.keymap h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #e94560;
}

.keymap-tables {
  display: flex;
  gap: 32px;
  justify-content: center;
}

.keymap-player h4 {
  font-size: 14px;
  color: #4ecca3;
  margin-bottom: 8px;
  text-align: center;
}

.keymap-player table {
  border-collapse: collapse;
  font-size: 13px;
}

.keymap-player td {
  padding: 4px 12px;
  border: 1px solid #333;
}

.keymap-player td:first-child {
  color: #aaa;
  text-align: center;
  min-width: 50px;
}

.keymap-player td:last-child {
  font-family: "Consolas", monospace;
  color: #e0e0e0;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #e94560;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  .header h1 { font-size: 22px; }
  .keymap-tables { flex-direction: column; gap: 16px; align-items: center; }
  .buttons button { padding: 6px 10px; font-size: 12px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ===== 游戏库 ===== */
.game-library {
  margin-bottom: 24px;
}

.section-title {
  font-size: 18px;
  color: #e94560;
  margin-bottom: 14px;
}

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

.game-card {
  background: #16213e;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s;
  border: 2px solid transparent;
  position: relative;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: #e94560;
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.25);
}

.game-card.active {
  border-color: #4ecca3;
  box-shadow: 0 0 16px rgba(78, 204, 163, 0.3);
}

.game-card-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #0a0a1a;
}

.game-card-info {
  padding: 10px 12px;
}

.game-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card-meta {
  font-size: 11px;
  color: #666;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-card-tag {
  background: rgba(233, 69, 96, 0.15);
  color: #e94560;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.game-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #4ecca3;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  display: none;
}

.game-card.active .game-card-badge {
  display: block;
}
