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

body {
  background: #0a0e14;
  color: #c5c8c6;
  font-family: 'IBM Plex Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0, 60, 60, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(0, 40, 70, 0.1) 0%, transparent 60%);
}

#top-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(20, 28, 36, 0.9);
  border-bottom: 1px solid rgba(100, 140, 130, 0.2);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.top-bar-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.top-title {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  color: #7fbfb0;
  letter-spacing: 0.5px;
}

.top-subtitle {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 300;
  font-size: 11px;
  color: #5a7a70;
}

.top-bar-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.top-bar-right button, .top-bar-right select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(40, 55, 55, 0.8);
  color: #9fbfb0;
  border: 1px solid rgba(100, 140, 130, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.top-bar-right button:hover, .top-bar-right select:hover {
  background: rgba(60, 80, 75, 0.9);
  border-color: rgba(127, 191, 176, 0.5);
  color: #c0e0d4;
}

.top-bar-right select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%239fbfb0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.top-bar-right select option {
  background: #1a2a28;
  color: #c0e0d4;
}

#calculator-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  width: 100%;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  cursor: pointer;
}

#status-bar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #5a7a70;
  background: rgba(15, 22, 28, 0.8);
  border-top: 1px solid rgba(100, 140, 130, 0.15);
}

#status-emu {
  color: #e8a040;
}

#status-emu.running {
  color: #60c090;
}

footer {
  padding: 12px;
  text-align: center;
}

footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #3a5a50;
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover {
  color: #7fbfb0;
}

/* Modals */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 8, 12, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none;
}

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

.modal-content {
  background: #141e24;
  border: 1px solid rgba(100, 140, 130, 0.3);
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  color: #7fbfb0;
  margin-bottom: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #5a7a70;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #c0e0d4;
}

#drop-zone {
  border: 2px dashed rgba(100, 140, 130, 0.4);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

#drop-zone:hover, #drop-zone.dragover {
  border-color: #7fbfb0;
  background: rgba(60, 100, 90, 0.1);
}

.drop-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.6;
}

#drop-zone p {
  font-size: 14px;
  color: #9fbfb0;
  margin-bottom: 6px;
}

#drop-zone .drop-sub {
  font-size: 11px;
  color: #5a7a70;
  margin-bottom: 16px;
}

#btn-file-pick {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 8px 24px;
  background: rgba(60, 100, 90, 0.3);
  color: #7fbfb0;
  border: 1px solid rgba(100, 140, 130, 0.4);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

#btn-file-pick:hover {
  background: rgba(80, 130, 110, 0.4);
}

#file-info {
  text-align: center;
  padding: 20px;
}

#file-info p {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: #9fbfb0;
  margin-bottom: 8px;
}

#btn-load-rom {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  padding: 10px 32px;
  background: #2a6a58;
  color: #d0f0e0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin: 12px 6px;
  transition: all 0.15s;
}

#btn-load-rom:hover {
  background: #3a8a6a;
}

#btn-cancel-rom {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 8px 20px;
  background: rgba(60, 50, 50, 0.5);
  color: #a08080;
  border: 1px solid rgba(150, 100, 100, 0.3);
  border-radius: 6px;
  cursor: pointer;
  margin: 12px 6px;
  transition: all 0.15s;
}

.rom-help {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(100, 140, 130, 0.15);
}

.rom-help h3 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: #7fbfb0;
  margin-bottom: 8px;
  font-weight: 600;
}

.rom-help p {
  font-size: 12px;
  color: #5a7a70;
  line-height: 1.6;
  margin-bottom: 8px;
}

.help-content {
  max-width: 520px;
}

.key-map-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: #9fbfb0;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(40, 60, 55, 0.6);
  border: 1px solid rgba(100, 140, 130, 0.3);
  border-radius: 3px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
}

@media (max-width: 600px) {
  #top-bar {
    flex-direction: column;
    gap: 6px;
    padding: 6px 10px;
  }
  .top-bar-right {
    flex-wrap: wrap;
    justify-content: center;
  }
  .top-bar-right button, .top-bar-right select {
    font-size: 11px;
    padding: 3px 8px;
  }
  #status-bar {
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    text-align: center;
  }
  .key-map-grid {
    grid-template-columns: 1fr;
  }
}