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

body {
  background: #0a0a0a;
  color: #33FF33;
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

#app-container {
  max-width: 1100px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* CRT Frame */
#crt-frame {
  position: relative;
  padding: 12px;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border-radius: 24px;
  box-shadow: 
    0 0 0 2px #3a3a3a,
    0 0 30px rgba(51, 255, 51, 0.05),
    inset 0 0 60px rgba(0,0,0,0.5);
}

#crt-bezel {
  position: relative;
  background: #111;
  border-radius: 16px;
  padding: 16px 20px 20px;
  border: 2px solid #222;
}

#screen-label {
  text-align: center;
  font-size: 10px;
  letter-spacing: 4px;
  color: #555;
  margin-bottom: 10px;
  font-weight: 700;
}

#canvas-wrapper {
  position: relative;
  line-height: 0;
  border-radius: 8px;
  overflow: hidden;
}

#canvas {
  display: block;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 4px;
  width: 100%;
  max-width: 960px;
  height: auto;
}

#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  border-radius: 4px;
}

#crt-glow {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, 0.4) 100%
  );
  pointer-events: none;
  border-radius: 4px;
}

/* Controls */
#controls {
  width: 100%;
  max-width: 960px;
}

#control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 700px) {
  #control-panel {
    grid-template-columns: 1fr;
  }
}

.panel-section {
  background: #111;
  border: 1px solid #1a3a1a;
  border-radius: 8px;
  padding: 12px;
}

.section-title {
  font-size: 10px;
  letter-spacing: 3px;
  color: #1a8a1a;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1a2a1a;
  font-weight: 700;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.ctrl-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border: 1px solid #33FF33;
  background: #0a1a0a;
  color: #33FF33;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.ctrl-btn:hover {
  background: #1a3a1a;
  box-shadow: 0 0 8px rgba(51, 255, 51, 0.3);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.run-btn {
  border-color: #33FF33;
  color: #33FF33;
}

.stop-btn {
  border-color: #FF3333;
  color: #FF3333;
  background: #1a0a0a;
}

.stop-btn:hover {
  background: #3a1a1a;
  box-shadow: 0 0 8px rgba(255, 51, 51, 0.3);
}

.speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #888;
}

.speed-row label {
  color: #1a8a1a;
  font-size: 10px;
  letter-spacing: 1px;
}

.speed-row input[type="range"] {
  flex: 1;
  accent-color: #33FF33;
  height: 4px;
}

.speed-row span {
  min-width: 30px;
  text-align: right;
  color: #33FF33;
  font-size: 12px;
}

.load-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.load-row label {
  font-size: 10px;
  color: #1a8a1a;
  letter-spacing: 1px;
}

.load-row input[type="text"] {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 4px 8px;
  background: #080808;
  border: 1px solid #1a3a1a;
  color: #33FF33;
  border-radius: 3px;
  width: 70px;
  text-transform: uppercase;
}

.load-row input[type="text"]:focus {
  outline: none;
  border-color: #33FF33;
  box-shadow: 0 0 6px rgba(51, 255, 51, 0.2);
}

#file-input {
  display: none;
}

.file-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid #1a5a1a;
  background: #0a1a0a;
  color: #33cc33;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.file-label:hover {
  background: #1a3a1a;
  border-color: #33FF33;
}

#file-name {
  font-size: 11px;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.reg-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  margin-bottom: 8px;
}

.reg-display span {
  color: #888;
}

.reg-display b {
  color: #33FF33;
  font-weight: 500;
  margin-left: 2px;
}

.flags-row {
  display: flex;
  gap: 6px;
}

.flags-row span {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  border: 1px solid #1a3a1a;
}

.flag-on {
  background: #1a4a1a;
  color: #33FF33;
  border-color: #33FF33 !important;
  box-shadow: 0 0 4px rgba(51, 255, 51, 0.3);
}

.flag-off {
  background: #0a0a0a;
  color: #333;
}

.disasm-display {
  font-size: 12px;
  color: #33cc33;
  background: #080808;
  padding: 6px 8px;
  border-radius: 3px;
  border: 1px solid #1a2a1a;
  min-height: 24px;
  word-break: break-all;
}

.hex-display {
  font-size: 11px;
  color: #22aa22;
  background: #050505;
  padding: 8px;
  border-radius: 3px;
  border: 1px solid #1a2a1a;
  overflow-x: auto;
  max-height: 200px;
  white-space: pre;
  line-height: 1.5;
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a3a1a;
  color: #33FF33;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
  border: 1px solid #33FF33;
  box-shadow: 0 0 20px rgba(51, 255, 51, 0.2);
  z-index: 1000;
  transition: opacity 0.3s, transform 0.3s;
  letter-spacing: 0.5px;
}

.toast.error {
  background: #3a1a1a;
  color: #FF5555;
  border-color: #FF3333;
  box-shadow: 0 0 20px rgba(255, 51, 51, 0.2);
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

/* Footer */
footer {
  margin-top: 30px;
  padding: 16px;
  text-align: center;
}

footer a {
  color: #1a5a1a;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  transition: color 0.2s;
}

footer a:hover {
  color: #33FF33;
}

/* Responsive */
@media (max-width: 500px) {
  body {
    padding: 10px;
  }
  
  #crt-frame {
    padding: 6px;
    border-radius: 16px;
  }
  
  #crt-bezel {
    padding: 8px 10px 10px;
    border-radius: 10px;
  }
  
  .panel-section {
    padding: 8px;
  }
  
  .button-row {
    flex-wrap: wrap;
  }
  
  .reg-display {
    font-size: 11px;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
  background: #1a3a1a;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #2a5a2a;
}