html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

.main {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

.controls {
  width: 100%;
  max-width: 960px;
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
  z-index: 100;
  padding: 10px;
  text-align: center;
  background-color: #f0f0f0;
  border-radius: 5px;
}

#rom-select {
  padding: 8px;
  font-size: 16px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #fff;
  min-width: 200px;
}

.controls button {
  margin: 0 5px;
  padding: 8px 15px;
  border: none;
  background: #4a4a4a;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.controls button:hover {
  background: #666;
}

.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  vertical-align: middle;
}

/* 桌面端样式 */
@media screen and (min-width: 927px) {
  .main {
    padding: 20px;
  }

  .screen {
    width: 100%;
    height: calc(100% - 80px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  #emulator {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  canvas.nes-screen {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    max-width: 100%;
    max-height: calc(100vh - 160px);
  }
}

/* 移动端横屏布局 */
@media screen and (max-width: 926px) and (orientation: landscape) {
  .main {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .controls {
    flex: 0 0 auto;
    margin: 0;
    padding: 5px;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
  }

  .screen {
    flex: 1;
    width: 100%;
    height: calc(100vh - 50px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  #emulator {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  canvas.nes-screen {
    max-width: 100% !important;
    max-height: calc(100vh - 50px) !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: 4/3;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
  }

  #rom-select {
    min-width: 150px;
    background: rgba(255, 255, 255, 0.9);
  }

  .controls button {
    background: rgba(74, 74, 74, 0.8);
    padding: 4px 10px;
  }
}