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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

header {
  margin-bottom: 24px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.top-bar h1 {
  font-size: 2.2rem;
  color: #e94560;
  margin-bottom: 6px;
}

.top-bar p {
  color: #888;
  font-size: 1rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

#userName {
  color: #aaa;
}

.top-link {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  color: white;
  background: #0f3460;
  transition: background 0.2s;
}

.top-link:hover {
  background: #1a4a80;
}

.logout-btn {
  background: #333;
  color: #ccc;
}

.logout-btn:hover {
  background: #444;
  color: #fff;
}

.controls {
  background: #16213e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.control-group {
  flex: 1;
  min-width: 180px;
}

.control-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  color: #aaa;
}

.control-group select,
.control-group input[type="file"],
.control-group input[type="url"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.source-tabs {
  display: flex;
  gap: 0;
  width: 100%;
  margin-bottom: 4px;
}

.source-tab {
  flex: 1;
  text-align: center;
  padding: 8px 16px;
  background: #0f3460;
  color: #888;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
  user-select: none;
}

.source-tab.active {
  background: #1a1a3e;
  color: #e0e0e0;
  font-weight: 600;
}

.source-tab:hover:not(.active) {
  background: #1a2a50;
}

#source-local,
#source-online {
  min-width: 100%;
}

.control-group input[type="file"]::file-selector-button {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: #e94560;
  color: white;
  cursor: pointer;
  margin-right: 10px;
}

button {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#startBtn {
  background: #e94560;
  color: white;
}

#startBtn:hover {
  background: #d63851;
}

#stopBtn {
  background: #333;
  color: #ccc;
}

#stopBtn:hover {
  background: #444;
}

#emulator-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0a1a;
  border-radius: 12px;
  overflow: hidden;
}

#emulator-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: none;
}

#emulator-frame.active {
  display: block;
}

#emulator-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #555;
  text-align: center;
  padding: 20px;
}

#emulator-placeholder p {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

#emulator-placeholder .sub {
  font-size: 0.9rem;
  color: #444;
  max-width: 400px;
}

.status {
  text-align: center;
  padding: 10px;
  margin-top: 10px;
  border-radius: 8px;
  background: #16213e;
  font-size: 0.9rem;
}

.status.error {
  background: #3d1010;
  color: #ff6b6b;
}

.status.success {
  background: #0d3d1a;
  color: #51cf66;
}

.game-library {
  background: #16213e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.game-library h2 {
  font-size: 1.1rem;
  color: #e94560;
  margin-bottom: 12px;
}

.library-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.library-bar input,
.library-bar select {
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 0.85rem;
}

.library-bar input {
  flex: 1;
  min-width: 0;
}

#searchArchiveBtn {
  padding: 8px 16px;
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #e94560;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.2s;
}

#searchArchiveBtn:hover {
  background: #1a4a80;
}

.library-status {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 8px;
  min-height: 1.2em;
}

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

.game-card {
  background: #0f3460;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  text-align: center;
  border: 1px solid transparent;
}

.game-card:hover {
  background: #1a4a80;
  transform: translateY(-2px);
  border-color: #e94560;
}

.game-card .thumb {
  width: 100%;
  aspect-ratio: 1;
  background: #0a0a1a;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.game-card .name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card .plat {
  font-size: 0.75rem;
  color: #888;
}

.loading-games {
  grid-column: 1 / -1;
  text-align: center;
  color: #666;
  padding: 20px;
}

.info {
  margin-top: 24px;
  background: #16213e;
  border-radius: 12px;
  padding: 20px;
}

.info h3 {
  margin-bottom: 10px;
  color: #e94560;
  font-size: 1rem;
}

.platform-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.platform-list span {
  background: #0f3460;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.controls-list {
  line-height: 1.8;
  font-size: 0.9rem;
}

.warning {
  margin-top: 12px;
  color: #ffd43b;
  font-size: 0.85rem;
}
